Merge pull request #119 from tiqi-group/fix/component_display

Fix/component display
This commit is contained in:
Mose Müller 2024-04-17 09:28:32 +02:00 committed by GitHub
commit 81c05d2e14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 25 additions and 13 deletions

View File

@ -40,7 +40,13 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
}, [props.value]);
const setChecked = (checked: boolean) => {
changeCallback(checked);
changeCallback({
type: 'bool',
value: checked,
full_access_path: fullAccessPath,
readonly: readOnly,
doc: docString
});
};
return (

View File

@ -69,7 +69,12 @@ export const EnumComponent = React.memo((props: EnumComponentProps) => {
{readOnly ? (
// Display the Form.Control when readOnly is true
<Form.Control
value={enumDict[enumValue]}
style={
attribute.type == 'ColouredEnum'
? { backgroundColor: enumDict[enumValue] }
: {}
}
value={attribute.type == 'ColouredEnum' ? enumValue : enumDict[enumValue]}
name={fullAccessPath}
disabled={true}
/>

View File

@ -174,7 +174,6 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
// Create a state for the input string
const [inputString, setInputString] = useState(value.toString());
const renderCount = useRef(0);
const name = fullAccessPath.split('.').at(-1);
const handleKeyDown = (event) => {
const { key, target } = event;
@ -329,7 +328,9 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
useEffect(() => {
// Set the cursor position after the component re-renders
const inputElement = document.getElementsByName(name)[0] as HTMLInputElement;
const inputElement = document.getElementsByName(
fullAccessPath
)[0] as HTMLInputElement;
if (inputElement && cursorPosition !== null) {
inputElement.setSelectionRange(cursorPosition, cursorPosition);
}
@ -351,7 +352,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
type="text"
value={inputString}
disabled={readOnly}
name={name}
name={fullAccessPath}
onKeyDown={handleKeyDown}
onBlur={handleBlur}
className={isInstantUpdate && !readOnly ? 'instantUpdate' : ''}

View File

@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.7ef670d5.css",
"main.js": "/static/js/main.9c35da6c.js",
"main.js": "/static/js/main.27a065cb.js",
"index.html": "/index.html",
"main.7ef670d5.css.map": "/static/css/main.7ef670d5.css.map",
"main.9c35da6c.js.map": "/static/js/main.9c35da6c.js.map"
"main.27a065cb.js.map": "/static/js/main.27a065cb.js.map"
},
"entrypoints": [
"static/css/main.7ef670d5.css",
"static/js/main.9c35da6c.js"
"static/js/main.27a065cb.js"
]
}

View File

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site displaying a pydase UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pydase App</title><script defer="defer" src="/static/js/main.9c35da6c.js"></script><link href="/static/css/main.7ef670d5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site displaying a pydase UI."/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>pydase App</title><script defer="defer" src="/static/js/main.27a065cb.js"></script><link href="/static/css/main.7ef670d5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long