From e7ada02e1d467df86eaa008931bb6985a4527721 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Tue, 14 Dec 2021 14:21:48 +0100 Subject: [PATCH] first draft of ui-editor --- zero.Backoffice.UI/app/components/ui-tab.vue | 6 ++- .../app/components/ui-table.vue | 1 - zero.Backoffice.UI/app/core/zeroRuntime.ts | 2 + .../app/editor/editor-component.vue | 30 ++++++----- zero.Backoffice.UI/app/editor/editor.vue | 23 ++++---- .../app/editor/fields/toggle.vue | 4 +- zero.Backoffice.UI/app/editor/index.ts | 5 ++ zero.Backoffice.UI/app/editor/register.ts | 12 +++++ .../app/forms/components/ui-toggle.vue | 16 +++--- .../app/forms/ui-form-header.vue | 17 +++--- zero.Backoffice.UI/app/forms/ui-form.vue | 53 +++++-------------- .../app/modules/countries/_page.vue | 2 +- .../app/modules/countries/country.vue | 20 +++---- .../app/modules/countries/plugin.ts | 3 +- zero.Backoffice.UI/package.json | 7 +-- zero.Backoffice.UI/vite.config.js | 19 ++++--- 16 files changed, 111 insertions(+), 109 deletions(-) create mode 100644 zero.Backoffice.UI/app/editor/index.ts create mode 100644 zero.Backoffice.UI/app/editor/register.ts diff --git a/zero.Backoffice.UI/app/components/ui-tab.vue b/zero.Backoffice.UI/app/components/ui-tab.vue index da671a7a..09e6d724 100644 --- a/zero.Backoffice.UI/app/components/ui-tab.vue +++ b/zero.Backoffice.UI/app/components/ui-tab.vue @@ -1,5 +1,5 @@  @@ -22,6 +22,10 @@ disabled: { type: Boolean, default: false + }, + hidden: { + type: Boolean, + default: false } }, diff --git a/zero.Backoffice.UI/app/components/ui-table.vue b/zero.Backoffice.UI/app/components/ui-table.vue index 363ba0bd..50264f64 100644 --- a/zero.Backoffice.UI/app/components/ui-table.vue +++ b/zero.Backoffice.UI/app/components/ui-table.vue @@ -232,7 +232,6 @@ getLink(item) { - return '/'; // TODO if (!this.listConfig.link) { return null; diff --git a/zero.Backoffice.UI/app/core/zeroRuntime.ts b/zero.Backoffice.UI/app/core/zeroRuntime.ts index 5e83e218..566ebb0d 100644 --- a/zero.Backoffice.UI/app/core/zeroRuntime.ts +++ b/zero.Backoffice.UI/app/core/zeroRuntime.ts @@ -7,6 +7,7 @@ import { createRouter, RouteRecordRaw, RouterOptions } from 'vue-router'; import registerDirectives from '../directives/register'; import registerComponents from '../components/register'; import registerFormComponents from '../forms/register'; +import registerEditorComponents from '../editor/register'; import { getRouterConfig, appendRouterGuards } from './router/routerConfig'; import { countryPlugin, applicationPlugin, settingsPlugin } from '../modules'; import { ZeroSchema } from 'zero/schemas'; @@ -52,6 +53,7 @@ export class ZeroRuntime implements Zero registerDirectives(app); registerComponents(app); registerFormComponents(app); + registerEditorComponents(app); } diff --git a/zero.Backoffice.UI/app/editor/editor-component.vue b/zero.Backoffice.UI/app/editor/editor-component.vue index eff02f75..38133c41 100644 --- a/zero.Backoffice.UI/app/editor/editor-component.vue +++ b/zero.Backoffice.UI/app/editor/editor-component.vue @@ -12,7 +12,7 @@ :can-unlock="canUnlock || false" @unlock="unlock" @lock="lock"> - +

@@ -38,7 +38,7 @@ type: Object, required: true }, - modelValue: { + value: { type: Object, required: true }, @@ -49,7 +49,7 @@ }, watch: { - modelValue: { + value: { deep: true, handler: function () { @@ -74,15 +74,15 @@ computed: { isHidden() { - return this.loaded && typeof this.config.options.condition === 'function' && !this.config.options.condition(this.modelValue, this); + return this.loaded && typeof this.config.options.condition === 'function' && !this.config.options.condition(this.value, this); }, isRequired() { - return typeof this.config.isRequired === 'function' ? this.config.isRequired(this.modelValue) : this.config.isRequired; + return typeof this.config.isRequired === 'function' ? this.config.isRequired(this.value) : this.config.isRequired; }, isDisabled() { - return this.manualDisabled || this.disabled || (typeof this.config.options.disabled === 'boolean' && this.config.options.disabled) || (typeof this.config.options.disabled === 'function' && this.config.options.disabled(this.modelValue, this.model)); + return this.manualDisabled || this.disabled || (typeof this.config.options.disabled === 'boolean' && this.config.options.disabled) || (typeof this.config.options.disabled === 'function' && this.config.options.disabled(this.value, this.model)); }, label() { @@ -94,11 +94,11 @@ }, isLocked() { - return !this.editor.blueprint.unlocked(this.modelValue, this.config); + return this.editor.blueprint && !this.editor.blueprint.unlocked(this.value, this.config); }, canUnlock() { - return this.editor.blueprint.canUnlock(this.modelValue, this.config); + return this.editor.blueprint && this.editor.blueprint.canUnlock(this.value, this.config); } }, @@ -107,7 +107,7 @@ rebuildModel() { this.selector = selectorToArray(this.config.path); - let currentValue = this.modelValue; + let currentValue = this.value; let found = false; if (!this.selector || !this.selector.length || !currentValue) @@ -132,6 +132,8 @@ this.model = found ? currentValue : null; } + + //console.info(this.config.path + ' => ' + this.model); }, @@ -141,19 +143,19 @@ if (typeof value === 'function') { - value(this.modelValue); + value(this.value); } else { - setObjectValue(this.modelValue, this.selector, value); + setObjectValue(this.value, this.selector, value); } - this.$emit('input', this.modelValue); + this.$emit('input', this.value); if (typeof this.config.options.onChange === 'function') { this.config.options.onChange(value, { oldValue, - model: this.modelValue, + model: this.value, component: this }); } @@ -181,7 +183,7 @@ async lock() { - let originalValue = await this.editor.blueprint.lock(this.modelValue, this.config); + let originalValue = await this.editor.blueprint.lock(this.value, this.config); this.onChange(originalValue); } } diff --git a/zero.Backoffice.UI/app/editor/editor.vue b/zero.Backoffice.UI/app/editor/editor.vue index 0963a1d9..f247d9ed 100644 --- a/zero.Backoffice.UI/app/editor/editor.vue +++ b/zero.Backoffice.UI/app/editor/editor.vue @@ -5,17 +5,17 @@
- +

- +
-
- +