From 00196ad0b1406c3bb181c1d8b466f1579736e2ac Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Mon, 19 Oct 2020 14:48:21 +0200 Subject: [PATCH] lists + editors work now in a raw state --- zero.Debug/appsettings.Development.json | 2 +- .../App/components/buttons/add-button.vue | 2 +- .../components/tables/table-filter-old.vue | 238 +++++++ .../App/components/tables/table-filter.vue | 328 ++++----- .../App/components/tables/table-old.vue | 623 ++++++++++++++++++ .../App/components/tables/table-value.js | 104 +-- zero.Web.UI/App/components/tables/table.vue | 292 +++----- zero.Web.UI/App/core/editor-field.js | 2 +- zero.Web.UI/App/core/editor.js | 8 +- zero.Web.UI/App/core/list-column.js | 202 ++++++ zero.Web.UI/App/core/list.js | 110 ++++ zero.Web.UI/App/core/plugin.js | 24 + zero.Web.UI/App/core/plugin.zero.js | 6 +- zero.Web.UI/App/core/zero.js | 24 +- zero.Web.UI/App/editor/editor-component.vue | 2 +- zero.Web.UI/App/editor/editor.vue | 38 +- zero.Web.UI/App/editors/all.js | 18 - zero.Web.UI/App/editors/country.js | 77 --- zero.Web.UI/App/editors/language.js | 70 -- zero.Web.UI/App/editors/media.js | 36 - zero.Web.UI/App/editors/translation.js | 29 - zero.Web.UI/App/editors/user.js | 108 --- zero.Web.UI/App/editors/userRole.js | 58 -- .../App/pages/settings/application.vue | 6 +- zero.Web.UI/App/pages/settings/countries.vue | 16 +- zero.Web.UI/App/pages/settings/country.vue | 8 +- zero.Web.UI/App/pages/settings/languages.vue | 16 +- zero.Web.UI/App/pages/settings/role.vue | 8 +- .../App/pages/settings/translations.vue | 16 +- zero.Web.UI/App/pages/settings/user.vue | 8 +- zero.Web.UI/App/pages/settings/users.vue | 29 +- zero.Web.UI/App/renderers/editors/all.js | 18 + .../{ => renderers}/editors/application.js | 12 +- zero.Web.UI/App/renderers/editors/country.js | 11 + .../App/renderers/editors/customers-filter.js | 43 ++ zero.Web.UI/App/renderers/editors/language.js | 12 + zero.Web.UI/App/renderers/editors/media.js | 12 + zero.Web.UI/App/renderers/editors/user.js | 22 + zero.Web.UI/App/renderers/editors/userRole.js | 22 + zero.Web.UI/App/renderers/lists/all.js | 12 + zero.Web.UI/App/renderers/lists/countries.js | 19 + zero.Web.UI/App/renderers/lists/languages.js | 17 + .../App/renderers/lists/translations.js | 16 + zero.Web.UI/App/renderers/lists/users.js | 18 + zero.Web.UI/Sass/Settings/_shadows.scss | 1 + 45 files changed, 1810 insertions(+), 933 deletions(-) create mode 100644 zero.Web.UI/App/components/tables/table-filter-old.vue create mode 100644 zero.Web.UI/App/components/tables/table-old.vue create mode 100644 zero.Web.UI/App/core/list-column.js create mode 100644 zero.Web.UI/App/core/list.js delete mode 100644 zero.Web.UI/App/editors/all.js delete mode 100644 zero.Web.UI/App/editors/country.js delete mode 100644 zero.Web.UI/App/editors/language.js delete mode 100644 zero.Web.UI/App/editors/media.js delete mode 100644 zero.Web.UI/App/editors/translation.js delete mode 100644 zero.Web.UI/App/editors/user.js delete mode 100644 zero.Web.UI/App/editors/userRole.js create mode 100644 zero.Web.UI/App/renderers/editors/all.js rename zero.Web.UI/App/{ => renderers}/editors/application.js (56%) create mode 100644 zero.Web.UI/App/renderers/editors/country.js create mode 100644 zero.Web.UI/App/renderers/editors/customers-filter.js create mode 100644 zero.Web.UI/App/renderers/editors/language.js create mode 100644 zero.Web.UI/App/renderers/editors/media.js create mode 100644 zero.Web.UI/App/renderers/editors/user.js create mode 100644 zero.Web.UI/App/renderers/editors/userRole.js create mode 100644 zero.Web.UI/App/renderers/lists/all.js create mode 100644 zero.Web.UI/App/renderers/lists/countries.js create mode 100644 zero.Web.UI/App/renderers/lists/languages.js create mode 100644 zero.Web.UI/App/renderers/lists/translations.js create mode 100644 zero.Web.UI/App/renderers/lists/users.js diff --git a/zero.Debug/appsettings.Development.json b/zero.Debug/appsettings.Development.json index 91818a4b..9afd4250 100644 --- a/zero.Debug/appsettings.Development.json +++ b/zero.Debug/appsettings.Development.json @@ -2,7 +2,7 @@ "Zero": { "Raven": { "Url": "http://127.0.0.1:9800", - "Database": "zero" + "Database": "laolazero" } }, "Logging": { diff --git a/zero.Web.UI/App/components/buttons/add-button.vue b/zero.Web.UI/App/components/buttons/add-button.vue index e06b4eaf..1f55c143 100644 --- a/zero.Web.UI/App/components/buttons/add-button.vue +++ b/zero.Web.UI/App/components/buttons/add-button.vue @@ -60,7 +60,7 @@ }, hasDropdown() { - return this.decision && zero.apps.shared; + return this.decision && true; // TODO zero.apps.shared; moved to zero instance afaik } }, diff --git a/zero.Web.UI/App/components/tables/table-filter-old.vue b/zero.Web.UI/App/components/tables/table-filter-old.vue new file mode 100644 index 00000000..1deaa6fe --- /dev/null +++ b/zero.Web.UI/App/components/tables/table-filter-old.vue @@ -0,0 +1,238 @@ + + + + + + \ No newline at end of file diff --git a/zero.Web.UI/App/components/tables/table-filter.vue b/zero.Web.UI/App/components/tables/table-filter.vue index 1deaa6fe..9a22a0aa 100644 --- a/zero.Web.UI/App/components/tables/table-filter.vue +++ b/zero.Web.UI/App/components/tables/table-filter.vue @@ -1,7 +1,7 @@  @@ -38,188 +38,190 @@ name: 'uiTableFilter', props: { - value: { - type: Object, - required: true, - default: () => - { - return { - filter: {}, - actions: [], - selectable: false, - search: null - } - } - }, - selection: { - type: Array, - default: () => [] - }, - alias: { - type: String, - default: null + attach: [Object, undefined], + hideSearch: { + type: Boolean, + default: false } }, watch: { - value: function (value) + attach: function (value) { - this.reload(); + this.setup(); } }, data: () => ({ - hideFilter: true, - hideSearch: true, - hideSelection: true, - filters: [], - filter: null + loaded: false + //hideFilter: true, + //hideSelection: true, + //filters: [], + //filter: null }), created() { - this.reload(); + //this.reload(); }, - computed: { - selectedText() - { - return this.selection.length + ' selected'; - }, - storageKey() - { - return 'zero.ui-table-filter.' + this.alias; - }, - filterLabel() - { - return this.filter ? 'Filter: ' + this.filter.name + "" : 'Filter'; - } + mounted() + { + this.setup(); }, methods: { - reload() + setup() { - this.hideFilter = typeof this.value.filter !== 'object'; - this.hideSearch = typeof this.value.search === false; - this.hideSelection = this.value.selectable !== true; - this.filters = JSON.parse(localStorage.getItem(this.storageKey) || "[]"); - }, - - onActionClicked(action, opts) - { - action.action(opts); - }, - - onFilterClear() - { - this.updateFilter(null); - }, - - onFiltered(value) - { - this.updateFilter(value); - }, - - openFilter(id) - { - let model = { - name: null, - filter: this.value.filter.model - }; - - if (id) + if (!this.attach) { - model = this.filters.find(x => x.id === id); + return; } - return Overlay.open({ - component: FilterOverlay, - display: 'editor', - title: 'Filter', - defaults: this.value.filter.model, - model: model, - fields: this.value.filter.fields, - canSave: !!this.alias, - isCreate: !id - }).then(value => - { - if (value.remove && id) - { - this.removeFilter(id); - return; - } - - if (!!value.filterName) - { - id = this.saveFilter(value.filterName, value.model, id); - } - - this.updateFilter({ - id: id, - name: value.filterName, - filter: value.model - }); - }); - }, - - - saveFilter(name, filter, id) - { - id = id || Strings.guid(); - - let savedFilter = this.filters.find(x => x.id === id); - let index = this.filters.indexOf(savedFilter); - - let model = { - id: id, - name: name, - filter: filter - }; - - if (index > -1) - { - this.filters.splice(index, 1, model); - } - else - { - this.filters.push(model); - } - - localStorage.setItem(this.storageKey, JSON.stringify(this.filters)); - - return id; - }, - - - removeFilter(id) - { - let savedFilter = this.filters.find(x => x.id === id); - let index = this.filters.indexOf(savedFilter); - this.filters.splice(index, 1); - localStorage.setItem(this.storageKey, JSON.stringify(this.filters)); - - if (this.filter && this.filter.id === id) - { - this.updateFilter(null); - } - }, - - - updateFilter(value) - { - if (!value) - { - this.filter = null; - this.$emit('filter', null); - } - else - { - this.filter = JSON.parse(JSON.stringify(value)); - this.$emit('filter', this.filter.filter); - } + this.loaded = true; + console.info(this.attach); } } + + //computed: { + // selectedText() + // { + // return this.selection.length + ' selected'; + // }, + // storageKey() + // { + // return 'zero.ui-table-filter.' + this.alias; + // }, + // filterLabel() + // { + // return this.filter ? 'Filter: ' + this.filter.name + "" : 'Filter'; + // } + //}, + + //methods: { + + // reload() + // { + // this.hideFilter = typeof this.value.filter !== 'object'; + // this.hideSelection = this.value.selectable !== true; + // this.filters = JSON.parse(localStorage.getItem(this.storageKey) || "[]"); + // }, + + // onActionClicked(action, opts) + // { + // action.action(opts); + // }, + + // onFilterClear() + // { + // this.updateFilter(null); + // }, + + // onFiltered(value) + // { + // this.updateFilter(value); + // }, + + // openFilter(id) + // { + // let model = { + // name: null, + // filter: this.value.filter.model + // }; + + // if (id) + // { + // model = this.filters.find(x => x.id === id); + // } + + // return Overlay.open({ + // component: FilterOverlay, + // display: 'editor', + // title: 'Filter', + // defaults: this.value.filter.model, + // model: model, + // fields: this.value.filter.fields, + // canSave: !!this.alias, + // isCreate: !id + // }).then(value => + // { + // if (value.remove && id) + // { + // this.removeFilter(id); + // return; + // } + + // if (!!value.filterName) + // { + // id = this.saveFilter(value.filterName, value.model, id); + // } + + // this.updateFilter({ + // id: id, + // name: value.filterName, + // filter: value.model + // }); + // }); + // }, + + + // saveFilter(name, filter, id) + // { + // id = id || Strings.guid(); + + // let savedFilter = this.filters.find(x => x.id === id); + // let index = this.filters.indexOf(savedFilter); + + // let model = { + // id: id, + // name: name, + // filter: filter + // }; + + // if (index > -1) + // { + // this.filters.splice(index, 1, model); + // } + // else + // { + // this.filters.push(model); + // } + + // localStorage.setItem(this.storageKey, JSON.stringify(this.filters)); + + // return id; + // }, + + + // removeFilter(id) + // { + // let savedFilter = this.filters.find(x => x.id === id); + // let index = this.filters.indexOf(savedFilter); + // this.filters.splice(index, 1); + // localStorage.setItem(this.storageKey, JSON.stringify(this.filters)); + + // if (this.filter && this.filter.id === id) + // { + // this.updateFilter(null); + // } + // }, + + + // updateFilter(value) + // { + // if (!value) + // { + // this.filter = null; + // this.$emit('filter', null); + // } + // else + // { + // this.filter = JSON.parse(JSON.stringify(value)); + // this.$emit('filter', this.filter.filter); + // } + // } + //} } diff --git a/zero.Web.UI/App/components/tables/table-old.vue b/zero.Web.UI/App/components/tables/table-old.vue new file mode 100644 index 00000000..8c82d5fc --- /dev/null +++ b/zero.Web.UI/App/components/tables/table-old.vue @@ -0,0 +1,623 @@ + + + + + + \ No newline at end of file diff --git a/zero.Web.UI/App/components/tables/table-value.js b/zero.Web.UI/App/components/tables/table-value.js index 5e77702c..d5384919 100644 --- a/zero.Web.UI/App/components/tables/table-value.js +++ b/zero.Web.UI/App/components/tables/table-value.js @@ -1,96 +1,34 @@ import { warn } from 'zero/services/debug'; import MediaApi from 'zero/resources/media'; -import Strings from 'zero/services/strings'; -import Localization from 'zero/services/localization'; export default function (el, binding) { const item = binding.value.item; - const column = binding.value.column; - const value = item[column.field]; - const isEmpty = typeof value === 'undefined' || value === null; + const column = binding.value.column.column; + const value = item[column.path]; - let render = (value, asHtml) => + if (column.isHtml) { - if (asHtml) - { - el.innerHTML = value; - } - else - { - el.innerText = value; - } - }; - - // set multiline for cell - el.classList.toggle('is-multiline', column.multiline === true); - el.classList.toggle('is-bold', column.bold === true); - - - // render empty - //if (isEmpty) - //{ - // render(column.default || value); - //} - // output text string or HTML - if (!column.as || column.as === 'text' || column.as === 'html') - { - const hasFunc = typeof column.render === 'function'; - const hasSharedIndicator = column.shared === true && item.blueprint != null; //item.appId === zero.sharedAppId; - - let html = hasFunc ? column.render(item, column) : value; - let isHtml = column.as === 'html' || hasSharedIndicator; - - if (column.localize === true) - { - html = Localization.localize(html, column.tokens || {}); - } - - if (hasSharedIndicator) - { - //html = html + ' '; - html = html + ' SYNCED'; - } - - render(html, isHtml); - } - // formatted date - else if (column.as === 'date') - { - render(Strings.date(value, 'short')); - } - // formatted date with time - else if (column.as === 'datetime') - { - render(Strings.date(value, 'short') + ' ' + Strings.date(value, 'time') + '', true); - } - // render formatted price - else if (column.as === 'price') - { - let price = isNaN(value) ? 0 : value; - let hasDecimals = ~~price !== price; - - price = hasDecimals ? (price / 1).toFixed(2) : ~~price; - - render(price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ") + " €", true); - } - // render checkbox - else if (column.as === 'bool') - { - render('', true); - } - // render an image - else if (column.as === 'image') - { - render(value ? `` : '', true); - } - // render global flag - else if (column.as === 'shared') - { - render(item.appId === zero.sharedAppId ? '' : '', true); + el.innerHTML = column.render(value, item); } else { - warn(`ui-table: Column display type ("${column.as}") is not supported`, this); + el.innerText = column.render(value, item); } + + //let render = (value, asHtml) => + //{ + // if (asHtml) + // { + // el.innerHTML = value; + // } + // else + // { + // el.innerText = value; + // } + //}; + + // set multiline for cell + //el.classList.toggle('is-multiline', column.multiline === true); + //el.classList.toggle('is-bold', column.bold === true); } \ No newline at end of file diff --git a/zero.Web.UI/App/components/tables/table.vue b/zero.Web.UI/App/components/tables/table.vue index 8c82d5fc..86598871 100644 --- a/zero.Web.UI/App/components/tables/table.vue +++ b/zero.Web.UI/App/components/tables/table.vue @@ -2,24 +2,23 @@
-
+
{{ column.label | localize }} -
-
-
- -
@@ -40,170 +39,97 @@ \ No newline at end of file diff --git a/zero.Web.UI/App/pages/settings/country.vue b/zero.Web.UI/App/pages/settings/country.vue index 84549bab..a50c23d4 100644 --- a/zero.Web.UI/App/pages/settings/country.vue +++ b/zero.Web.UI/App/pages/settings/country.vue @@ -1,6 +1,6 @@  @@ -11,8 +11,6 @@ import UiEditor from 'zero/editor/editor'; export default { - props: ['id'], - components: { UiEditor }, data: () => ({ @@ -26,7 +24,7 @@ onLoad(form) { - form.load(!this.id ? CountriesApi.getEmpty() : CountriesApi.getById(this.id)).then(response => + form.load(!this.$route.params.id ? CountriesApi.getEmpty() : CountriesApi.getById(this.$route.params.id)).then(response => { this.disabled = !response.meta.canEdit; this.meta = response.meta; @@ -44,7 +42,7 @@ onDelete(item, opts) { opts.hide(); - this.$refs.form.onDelete(CountriesApi.delete.bind(this, this.id)); + this.$refs.form.onDelete(CountriesApi.delete.bind(this, this.$route.params.id)); } } } diff --git a/zero.Web.UI/App/pages/settings/languages.vue b/zero.Web.UI/App/pages/settings/languages.vue index ed49504a..4681b837 100644 --- a/zero.Web.UI/App/pages/settings/languages.vue +++ b/zero.Web.UI/App/pages/settings/languages.vue @@ -1,29 +1,21 @@  \ No newline at end of file diff --git a/zero.Web.UI/App/pages/settings/role.vue b/zero.Web.UI/App/pages/settings/role.vue index 84b47d1f..b3dd1e6c 100644 --- a/zero.Web.UI/App/pages/settings/role.vue +++ b/zero.Web.UI/App/pages/settings/role.vue @@ -1,6 +1,6 @@  @@ -12,8 +12,6 @@ import UiEditor from 'zero/editor/editor'; export default { - props: ['id'], - components: { UiEditor }, data: () => ({ @@ -27,7 +25,7 @@ onLoad(form) { - form.load(!this.id ? UserRolesApi.getEmpty() : UserRolesApi.getById(this.id)).then(response => + form.load(!this.$route.params.id ? UserRolesApi.getEmpty() : UserRolesApi.getById(this.$route.params.id)).then(response => { this.disabled = !response.meta.canEdit; this.meta = response.meta; @@ -45,7 +43,7 @@ onDelete(item, opts) { opts.hide(); - this.$refs.form.onDelete(UserRolesApi.delete.bind(this, this.id)); + this.$refs.form.onDelete(UserRolesApi.delete.bind(this, this.$route.params.id)); } } } diff --git a/zero.Web.UI/App/pages/settings/translations.vue b/zero.Web.UI/App/pages/settings/translations.vue index 3e837896..e042f928 100644 --- a/zero.Web.UI/App/pages/settings/translations.vue +++ b/zero.Web.UI/App/pages/settings/translations.vue @@ -1,30 +1,26 @@