diff --git a/zero.Web.UI/App/components/forms/check-list.vue b/zero.Web.UI/App/components/forms/check-list.vue index 112a0fd6..c7c0758f 100644 --- a/zero.Web.UI/App/components/forms/check-list.vue +++ b/zero.Web.UI/App/components/forms/check-list.vue @@ -3,7 +3,7 @@ @@ -32,13 +32,18 @@ type: Boolean, default: false }, - maxItems: { + limit: { type: Number, default: 100 }, - reverse: { - type: Boolean, - default: false + reverse: Boolean, + labelKey: { + type: String, + default: 'value' + }, + idKey: { + type: String, + default: 'key' } }, @@ -81,18 +86,18 @@ isChecked(item) { - let index = this.value.indexOf(item.id); + let index = this.value.indexOf(item[this.idKey]); return (!this.reverse && index > -1) || (this.reverse && index < 0); }, onChange(item) { - let index = this.value.indexOf(item.id); + let index = this.value.indexOf(item[this.idKey]); let value = JSON.parse(JSON.stringify(this.value)); if (index < 0) { - value.push(item.id); + value.push(item[this.idKey]); } else { diff --git a/zero.Web.UI/App/config/router.config.js b/zero.Web.UI/App/config/router.config.js index b3697ca5..260a099a 100644 --- a/zero.Web.UI/App/config/router.config.js +++ b/zero.Web.UI/App/config/router.config.js @@ -67,7 +67,7 @@ export default { base: __zero.path, linkActiveClass: 'is-active', linkExactActiveClass: 'is-active-exact', - beforeEach: beforeEach, + //beforeEach: beforeEach, scrollBehavior(to, from, savedPosition) { return savedPosition ? savedPosition : { x: 0, y: 0 }; diff --git a/zero.Web.UI/App/core/editor-field.js b/zero.Web.UI/App/core/editor-field.js index ec1dc1f8..dcaa06e1 100644 --- a/zero.Web.UI/App/core/editor-field.js +++ b/zero.Web.UI/App/core/editor-field.js @@ -98,6 +98,17 @@ class EditorField } + /** + * Conditionally render this field (this is an alternative method to the field options 'condition') + * @param {function} condition - function which returns a boolean and gets passed the current model + */ + when(condition) + { + this.options.condition = condition; + return this; + } + + /** * Render a custom component * @param {object} component - The custom vue component @@ -220,13 +231,16 @@ class EditorField /** * Renders an input which generates an alias for a given name or an alternative custom alias * @param {EditorSelectItem[]|function} items - Set items to choose from, either via an array or a promise which returns such array - * @param {number} [limit=100] - Maximum items to be checked - * @param {boolean} [reverse] - Reverse the checklist behaviour, so all items are checked by default and unchecking them adds them to the result list + * @param {object} [options] - Custom options + * @param {number} [options.limit=100] - Maximum items to be checked + * @param {boolean} [options.reverse=false] - Reverse the checklist behaviour, so all items are checked by default and unchecking them adds them to the result list + * @param {string} [options.labelKey=value] - Object key to get the label + * @param {string} [options.idKey=key] - Object key to get the id * @returns {EditorField} */ - checkList(items, limit) + checkList(items, options) { - return this._setComponent(Checklist, { items, limit, reverse }); + return this._setComponent(Checklist, { items, ...options }); } diff --git a/zero.Web.UI/App/editor/editor-component.vue b/zero.Web.UI/App/editor/editor-component.vue index a2b3f981..10584376 100644 --- a/zero.Web.UI/App/editor/editor-component.vue +++ b/zero.Web.UI/App/editor/editor-component.vue @@ -1,7 +1,7 @@  diff --git a/zero.Web.UI/App/editor/editor-overlay.vue b/zero.Web.UI/App/editor/editor-overlay.vue index f51f7314..450be617 100644 --- a/zero.Web.UI/App/editor/editor-overlay.vue +++ b/zero.Web.UI/App/editor/editor-overlay.vue @@ -14,7 +14,7 @@
- +
@@ -39,6 +39,7 @@ id: null, loading: true, state: 'default', + editor: null, meta: {}, model: {} }), @@ -50,6 +51,7 @@ { this.isAdd = this.config.create === true; this.model = JSON.parse(JSON.stringify(this.config.model)); + this.editor = this.config.editor; this.loading = false; }, diff --git a/zero.Web.UI/App/editor/editor.vue b/zero.Web.UI/App/editor/editor.vue index 4fa661de..20b5af8d 100644 --- a/zero.Web.UI/App/editor/editor.vue +++ b/zero.Web.UI/App/editor/editor.vue @@ -13,7 +13,6 @@ \ No newline at end of file diff --git a/zero.Web.UI/App/editor/fields/countrypicker.vue b/zero.Web.UI/App/editor/fields/countrypicker.vue index 27a347e0..ce74b036 100644 --- a/zero.Web.UI/App/editor/fields/countrypicker.vue +++ b/zero.Web.UI/App/editor/fields/countrypicker.vue @@ -1,19 +1,17 @@  \ No newline at end of file diff --git a/zero.Web.UI/App/editor/fields/currency.vue b/zero.Web.UI/App/editor/fields/currency.vue index 4de742da..ff54fbd4 100644 --- a/zero.Web.UI/App/editor/fields/currency.vue +++ b/zero.Web.UI/App/editor/fields/currency.vue @@ -1,6 +1,6 @@  @@ -12,18 +12,11 @@ type: Number, default: null }, - config: Object, disabled: { type: Boolean, default: false - } + }, + placeholder: String }, - - computed: { - maxLength() - { - return this.config.maxLength > 0 ? this.config.maxLength : null; - } - } } \ No newline at end of file diff --git a/zero.Web.UI/App/editor/fields/nested.vue b/zero.Web.UI/App/editor/fields/nested.vue index 02996348..693076fc 100644 --- a/zero.Web.UI/App/editor/fields/nested.vue +++ b/zero.Web.UI/App/editor/fields/nested.vue @@ -2,11 +2,11 @@
- +
- +
@@ -14,55 +14,74 @@ import UiEditor from 'zero/editor/editor'; import UiEditorOverlay from 'zero/editor/editor-overlay'; import Overlay from 'zero/services/overlay'; + import Editor from 'zero/core/editor.js'; export default { components: { UiEditor }, props: { - value: { - type: [Array, Object] + value: [Array, Object], + meta: Object, + depth: Number, + disabled: Boolean, + editor: { + type: Editor, + required: true }, - meta: { - type: Object, - default: () => { } - }, - depth: { + limit: { type: Number, - default: 0 + default: 100 }, - disabled: { - type: Boolean, - default: false - }, - config: Object + title: String, + addLabel: String, + itemLabel: Function, + itemDescription: Function, + itemIcon: [String, Function], + template: { + type: Object, + required: true + } + }, + + watch: { + value: { + deep: true, + handler(val) + { + this.setup(); + } + } }, data: () => ({ items: [], - limit: 100, multiple: false }), mounted() { - this.items = JSON.parse(JSON.stringify(this.value)); - this.limit = this.config.limit || this.limit; - this.multiple = this.limit > 1; - if (!this.multiple) - { - this.items = this.items ? [this.items] : []; - } + this.setup(); }, methods: { + setup() + { + this.items = JSON.parse(JSON.stringify(this.value)) || []; + this.multiple = this.limit > 1; + if (!this.multiple) + { + this.items = this.items ? [this.items] : []; + } + }, + getNewItem() { - return JSON.parse(JSON.stringify(this.config.template || {})); + return JSON.parse(JSON.stringify(this.template || {})); }, addItem() @@ -82,8 +101,8 @@ return Overlay.open({ component: UiEditorOverlay, display: 'editor', - renderer: this.config.renderer, - title: this.config.title || '@ui.edit.title', + editor: this.editor, + title: this.title || '@ui.edit.title', model: item, width: 1100, create: isAdd @@ -119,13 +138,19 @@ getName(item) { - return this.config.item && typeof this.config.item.label === 'function' ? this.config.item.label(item) : 'Item'; + return typeof this.itemLabel === 'function' ? this.itemLabel(item) : 'Item'; }, getDescription(item) { - return this.config.item && typeof this.config.item.description === 'function' ? this.config.item.description(item) : ''; + return typeof this.itemDescription === 'function' ? this.itemDescription(item) : ''; + }, + + + getIcon(item) + { + return typeof this.itemIcon === 'function' ? this.itemIcon(item) : this.itemIcon; } } } diff --git a/zero.Web.UI/App/editor/fields/number.vue b/zero.Web.UI/App/editor/fields/number.vue index 231dd9a6..d6da5659 100644 --- a/zero.Web.UI/App/editor/fields/number.vue +++ b/zero.Web.UI/App/editor/fields/number.vue @@ -1,27 +1,15 @@  \ No newline at end of file diff --git a/zero.Web.UI/App/editor/fields/tags.vue b/zero.Web.UI/App/editor/fields/tags.vue index 33fc248e..0949a237 100644 --- a/zero.Web.UI/App/editor/fields/tags.vue +++ b/zero.Web.UI/App/editor/fields/tags.vue @@ -1,5 +1,5 @@  \ No newline at end of file diff --git a/zero.Web.UI/App/editor/fields/toggle.vue b/zero.Web.UI/App/editor/fields/toggle.vue index e01d4796..bee45576 100644 --- a/zero.Web.UI/App/editor/fields/toggle.vue +++ b/zero.Web.UI/App/editor/fields/toggle.vue @@ -6,18 +6,9 @@ \ No newline at end of file diff --git a/zero.Web.UI/App/pages/notfound.vue b/zero.Web.UI/App/pages/notfound.vue index 4f3c3472..318ec634 100644 --- a/zero.Web.UI/App/pages/notfound.vue +++ b/zero.Web.UI/App/pages/notfound.vue @@ -60,6 +60,8 @@ this.path = this.$router.options.base + this.$route.path.substring(1); this.routes = []; + console.info(this.$router.options.routes); + this.$router.options.routes.forEach(route => { this.routes.push({