From 4e0e140b4daa68d0695f9f4d77d010074ded724f Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Fri, 20 Dec 2024 11:43:50 +0100 Subject: [PATCH 1/6] fix(proxy-list): Fix invalid last added proxy --- vue2-components/src/widgets/TextField/script.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vue2-components/src/widgets/TextField/script.js b/vue2-components/src/widgets/TextField/script.js index 4825cf9..08d374b 100644 --- a/vue2-components/src/widgets/TextField/script.js +++ b/vue2-components/src/widgets/TextField/script.js @@ -146,8 +146,6 @@ export default { if (!this.model) { this.model = []; } - this.dynamicSize = this.model.length + 1; - this.model.length = this.dynamicSize; if (this.type == 'proxy') { this.getSimput() .wsClient.getConnection() @@ -158,16 +156,19 @@ export default { ]) .then((proxy_id) => { if (proxy_id != undefined) { - this.model[this.dynamicSize - 1] = proxy_id; - this.validate(this.dynamicSize); + this.model.push(proxy_id); + this.dirty(this.name); } + this.dynamicSize = this.model.length; + this.validate(this.dynamicSize); }); } else { if (this.newValue === 'null') { - this.model[this.dynamicSize - 1] = null; + this.model.push(null); } else if (this.newValue === 'same') { - this.model[this.dynamicSize - 1] = this.model[this.dynamicSize - 2]; + this.model.push(this.model[this.model.length - 2]); } + this.dynamicSize = this.model.length; this.validate(this.dynamicSize); } }, From 9e7bd278fe5406dd3c4e94a023c8a29311d53b3b Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Fri, 20 Dec 2024 15:16:23 +0100 Subject: [PATCH 2/6] fix(vuetify): Set proxyType as explicit property --- docs/definitions.md | 1 + trame_simput/core/ui/resolvers/vuetify.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/definitions.md b/docs/definitions.md index 2d2cdca..3aeca4f 100644 --- a/docs/definitions.md +++ b/docs/definitions.md @@ -74,6 +74,7 @@ The __YAML__ structure follow the given hierarchy: 1. type: Name of the domain class 2. name: (optional) identifier when we don't want to use its `type` as identifier. 3. **: additional parameters specific to domain type expectation. + 2. proxyType: Name of proxy used in proxy lists # Domain definitions diff --git a/trame_simput/core/ui/resolvers/vuetify.py b/trame_simput/core/ui/resolvers/vuetify.py index 6678fe0..36f8f9a 100644 --- a/trame_simput/core/ui/resolvers/vuetify.py +++ b/trame_simput/core/ui/resolvers/vuetify.py @@ -39,7 +39,7 @@ def __init__(self): def get_widget(self, elem): model = self._model.get(elem.get("name"), {}) - attributes = {key: model[key] for key in model if not key.startswith("_")} + attributes = {} if elem.tag in VUETIFY_MAP: return VUETIFY_MAP[elem.tag], attributes elif elem.tag == "input": @@ -80,6 +80,10 @@ def get_widget(self, elem): if self._model.get(elem.get("name"), {}).get("type", "string") == "bool": widget = "sw-switch" + proxy_type = model.get("proxyType", None) + if proxy_type is not None: + attributes["proxyType"] = proxy_type + return widget, attributes elif elem.tag == "proxy": return "sw-proxy", attributes From 897fb6a8b58f90d8f67c4be587c350b55b49b7b4 Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Mon, 23 Dec 2024 08:02:05 +0100 Subject: [PATCH 3/6] fix(pypi): Rename package to trame_simput --- setup.cfg | 2 +- trame_simput/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 24428d7..be49d40 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [metadata] -name = trame-simput +name = trame_simput version = 2.5.0 description = Simput implementation for trame long_description = file: README.rst diff --git a/trame_simput/__init__.py b/trame_simput/__init__.py index 8cf4890..37bba74 100644 --- a/trame_simput/__init__.py +++ b/trame_simput/__init__.py @@ -2,7 +2,7 @@ from .core import get_simput_manager -__version__ = get_version("trame-simput") +__version__ = get_version("trame_simput") __all__ = [ "__version__", From 5c0e26d65ec13c4821131e65ca73482e6bd86b8f Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Thu, 9 Jan 2025 09:08:59 +0100 Subject: [PATCH 4/6] fix(proxy-list): Initialize empty proxy lists --- trame_simput/core/proxy.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/trame_simput/core/proxy.py b/trame_simput/core/proxy.py index c34ddfd..9140a74 100644 --- a/trame_simput/core/proxy.py +++ b/trame_simput/core/proxy.py @@ -95,11 +95,20 @@ def __init__( if _prop_name.startswith("_"): continue + _size = _prop_def.get("size", None) + _positive_size = _size is not None and isinstance(_size, int) and _size > 0 _init_def = _prop_def.get("initial", None) + _is_proxy = _prop_def.get("type", None) == "proxy" + _proxy_type = _prop_def.get("proxyType", None) if _prop_name in kwargs: self.set_property(_prop_name, kwargs[_prop_name]) elif isinstance(_init_def, dict): logger.error("Don't know how to deal with domain yet: %s", _init_def) + elif _positive_size and _is_proxy and _proxy_type is not None: + _init_def = [ + self._proxy_manager.create(_proxy_type).id for _ in range(_size) + ] + self.set_property(_prop_name, _init_def) else: self.set_property(_prop_name, _init_def) From ef89aba38e64c896a99b54613f376cfb1fea312a Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Thu, 9 Jan 2025 09:09:18 +0100 Subject: [PATCH 5/6] fix(proxy): Clean dirty proxy domains before deletion --- trame_simput/core/proxy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/trame_simput/core/proxy.py b/trame_simput/core/proxy.py index 9140a74..67d975d 100644 --- a/trame_simput/core/proxy.py +++ b/trame_simput/core/proxy.py @@ -714,6 +714,7 @@ def delete(self, proxy_id, trigger_modified=True): before_delete = set(self._id_map.keys()) # Delete ourself proxy_to_delete: Proxy = self._id_map[proxy_id] + self.clean_proxy_domains(proxy_to_delete.id) del self._id_map[proxy_id] for tag in proxy_to_delete.tags: From b307fc4678325770619d13baf04c37256f0dc18b Mon Sep 17 00:00:00 2001 From: Jo-Byr Date: Thu, 9 Jan 2025 09:09:51 +0100 Subject: [PATCH 6/6] fix(proxy-list): Limit minimum proxy list size Prevent deletion of element of proxy list below default size --- vue2-components/src/widgets/Proxy/script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vue2-components/src/widgets/Proxy/script.js b/vue2-components/src/widgets/Proxy/script.js index 8f821ae..1e8e7c9 100644 --- a/vue2-components/src/widgets/Proxy/script.js +++ b/vue2-components/src/widgets/Proxy/script.js @@ -76,8 +76,10 @@ export default { return getComponentProps(this.computedLayout, index); }, deleteEntry(index) { - this.model.splice(index, 1); - this.dirty(this.name); + if (this.computedSize > Number(this.size)) { + this.model.splice(index, 1); + this.dirty(this.name); + } }, }, inject: ['data', 'properties', 'domains', 'dirty'],