-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1600 from pkuehnel/fix/decimalNumbericInput
fix(GenericInput): use decimal for numeric values
- Loading branch information
Showing
6 changed files
with
410 additions
and
111 deletions.
There are no files selected for viewing
424 changes: 313 additions & 111 deletions
424
TeslaSolarCharger/Client/Components/GenericInput.razor
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
TeslaSolarCharger/Client/Helper/Contracts/IJavaScriptWrapper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Lysando.LabStorageV2.UiHelper.Wrapper.Contracts; | ||
|
||
public interface IJavaScriptWrapper | ||
{ | ||
Task<bool> SetFocusToElementById(string elementId); | ||
Task<bool> RemoveFocusFromElementById(string elementId); | ||
Task OpenUrlInNewTab(string url); | ||
Task<bool> IsIosDevice(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Lysando.LabStorageV2.UiHelper.Wrapper.Contracts; | ||
using Microsoft.JSInterop; | ||
|
||
namespace Lysando.LabStorageV2.UiHelper.Wrapper; | ||
|
||
public class JavaScriptWrapper(IJSRuntime jsRuntime) : IJavaScriptWrapper | ||
{ | ||
/// <summary> | ||
/// Sets the focus to an element with a specific ID | ||
/// </summary> | ||
/// <param name="elementId">ID to set the focus on</param> | ||
/// <returns>Was the ID set successfully</returns> | ||
public async Task<bool> SetFocusToElementById(string elementId) | ||
{ | ||
try | ||
{ | ||
return await jsRuntime.InvokeAsync<bool>("setFocus", elementId); | ||
} | ||
catch (Exception) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public async Task<bool> RemoveFocusFromElementById(string elementId) | ||
{ | ||
try | ||
{ | ||
return await jsRuntime.InvokeAsync<bool>("removeFocus", elementId); | ||
} | ||
catch (Exception) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public async Task OpenUrlInNewTab(string url) | ||
{ | ||
await jsRuntime.InvokeVoidAsync("openInNewTab", url); | ||
} | ||
|
||
public async Task<bool> IsIosDevice() | ||
{ | ||
try | ||
{ | ||
var device = await jsRuntime.InvokeAsync<string>("detectDevice"); | ||
return device == "iOS"; | ||
} | ||
catch (Exception) | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
TeslaSolarCharger/Client/wwwroot/js/javaScriptWrapperFunctions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function setFocus(elementId) { | ||
const element = document.getElementById(elementId); | ||
if (element) { | ||
element.focus(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function removeFocus(elementId) { | ||
const element = document.getElementById(elementId); | ||
if (element) { | ||
element.blur(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function openInNewTab(url) { | ||
window.open(url, '_blank'); | ||
} | ||
|
||
function detectDevice() { | ||
var ua = navigator.userAgent || navigator.vendor || window.opera; | ||
// iOS detection | ||
if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) { | ||
return "iOS"; | ||
} | ||
return "Other"; | ||
} |