From 3215c5c786a11077ad83670379400833b139c51c Mon Sep 17 00:00:00 2001 From: Dmitriy Ovcharenko Date: Tue, 17 Dec 2024 16:05:51 +1000 Subject: [PATCH] Fix(frontend): Objects list error displaying. --- frontend_src/vstutils/fields/base/BaseFieldMixin.vue | 1 + frontend_src/vstutils/fields/base/props.ts | 1 + .../fields/nested-object/NestedObjectArrayFieldEdit.vue | 6 +++++- vstutils/__init__.py | 2 +- vstutils/utils.py | 2 +- vstutils/utils.pyi | 3 ++- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend_src/vstutils/fields/base/BaseFieldMixin.vue b/frontend_src/vstutils/fields/base/BaseFieldMixin.vue index 8d3a515c..093d260f 100644 --- a/frontend_src/vstutils/fields/base/BaseFieldMixin.vue +++ b/frontend_src/vstutils/fields/base/BaseFieldMixin.vue @@ -34,6 +34,7 @@ :value="value" :data="data" :hideable="hideable" + :error="error" @hide-field="$emit('hide-field', field)" @set-value="setValue" @clear="clearValue" diff --git a/frontend_src/vstutils/fields/base/props.ts b/frontend_src/vstutils/fields/base/props.ts index 44b24620..b82cf8fa 100644 --- a/frontend_src/vstutils/fields/base/props.ts +++ b/frontend_src/vstutils/fields/base/props.ts @@ -60,6 +60,7 @@ export const FieldEditPropsDef = { data: { type: Object as PropType, required: true as const }, value: {}, hideable: { type: Boolean, default: false }, + error: { type: [String, Object, Array], default: null }, }; export type FieldEditPropsDefType = Omit & { diff --git a/frontend_src/vstutils/fields/nested-object/NestedObjectArrayFieldEdit.vue b/frontend_src/vstutils/fields/nested-object/NestedObjectArrayFieldEdit.vue index 6b6120f5..94d1df8b 100644 --- a/frontend_src/vstutils/fields/nested-object/NestedObjectArrayFieldEdit.vue +++ b/frontend_src/vstutils/fields/nested-object/NestedObjectArrayFieldEdit.vue @@ -23,6 +23,7 @@ { + return Array.isArray(props.error) ? props.error : []; + }); const modelClass = props.field.itemField!.nestedModel!; @@ -100,7 +104,7 @@ function setValue(options: SetFieldValueOptions) { if (options.field) { - set(newItemData, options.field, options.value); + set(newItemData.value, options.field, options.value); } } diff --git a/vstutils/__init__.py b/vstutils/__init__.py index f8bed54f..1de4de7f 100644 --- a/vstutils/__init__.py +++ b/vstutils/__init__.py @@ -1,2 +1,2 @@ # pylint: disable=django-not-available -__version__: str = '5.11.19' +__version__: str = '5.11.20' diff --git a/vstutils/utils.py b/vstutils/utils.py index 811d82c6..4b7f4523 100644 --- a/vstutils/utils.py +++ b/vstutils/utils.py @@ -1505,7 +1505,7 @@ def get_session_store() -> 'SessionBase': return engine.SessionStore -def add_in_vary(headers: dict, value: str): +def add_in_vary(headers, value): """ Adds provided value to Vary header if not added already """ diff --git a/vstutils/utils.pyi b/vstutils/utils.pyi index 8d1a9526..c6d4fbbb 100644 --- a/vstutils/utils.pyi +++ b/vstutils/utils.pyi @@ -2,6 +2,7 @@ import asyncio import logging import subprocess import typing as tp +from collections.abc import MutableMapping from .tools import multikeysort as multikeysort from collections.abc import Generator from django.http.response import HttpResponse @@ -531,7 +532,7 @@ class BaseEnum(str, VstEnum): def get_session_store(): ... -def add_in_vary(headers: dict, value: str): +def add_in_vary(headers: MutableMapping[str, str], value: str): ... def check_request_etag(