From 346a2c5896e5dadd098d7173ce32ab805b8e22e2 Mon Sep 17 00:00:00 2001 From: Mark van Driel Date: Wed, 29 Mar 2017 21:07:59 +0200 Subject: [PATCH 01/16] Improved selects for foreign keys in edit form --- ui.html | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/ui.html b/ui.html index 44b19e3..59d755b 100644 --- a/ui.html +++ b/ui.html @@ -128,7 +128,7 @@

{{ subject }}: edit

@@ -384,28 +384,8 @@

{{ subject }}: delete #{{ id }}

this.id = this.$route.params.id; this.subject = this.$route.params.subject; this.record = null; - this.options = {}; var self = this; - for (var i = 0; i < this.references.length; i++) { - if (this.references[i] !== false) { - var props = this.getProperties('list', this.references[i][0], this.paths); - var columns = []; - for (key in props) { - columns.push(key); - } - var displayColumn = this.getDisplayColumn(columns); - if (displayColumn) { - displayColumn = columns[displayColumn]; - } else { - displayColumn = this.references[i][0]; - } - api.get('/' + this.references[i][0] + '?columns=' + this.references[i][1] + ',' + displayColumn).then(function (i, response) { - self.options[self.references[i][0]] = response.data[self.references[i][0]].records; - }.bind(null, i)).catch(function (error) { - console.log(error); - }); - } - } + this.populateOptions(); api.get('/' + this.subject + '/' + this.id).then(function (response) { self.record = response.data; }).catch(function (error) { @@ -419,6 +399,31 @@

{{ subject }}: delete #{{ id }}

console.log(error); }); router.push({name: 'List', params: {subject: this.subject}}); + }, + populateOptions: function() { + this.options = {}; + var self = this; + for (var i = 0; i < this.references.length; i++) { + if (this.references[i] !== false) { + var columns = Object.keys(this.getProperties('list', this.references[i][0], this.paths)); + var displayColumn = this.getDisplayColumn(columns); + if (displayColumn) { + displayColumn = columns[displayColumn]; + } else { + displayColumn = this.references[i][1]; + } + api.get('/' + this.references[i][0] + '?columns=' + this.references[i][1] + ',' + displayColumn).then(function (i, displayColumn, response) { + var subject = Object.keys(response.data)[0]; + var keyIndex = response.data[subject].columns.indexOf(self.references[i][1]); + var valueIndex = response.data[subject].columns.indexOf(displayColumn); + self.options[subject] = response.data[subject].records.map(function (record) { + return {key: record[keyIndex], value: record[valueIndex]}; + }); + }.bind(null, i, displayColumn)).catch(function (error) { + console.log(error); + }); + } + } } } }); From 60b095d368086d1d3a8e7cb7fdcf3bcc0add5ad3 Mon Sep 17 00:00:00 2001 From: Maurits van der Schee Date: Mon, 1 Apr 2019 01:53:29 +0200 Subject: [PATCH 02/16] initial v2 --- ui.html | 149 +++++++++++++++++++++++--------------------------------- 1 file changed, 62 insertions(+), 87 deletions(-) diff --git a/ui.html b/ui.html index 59d755b..2da8d58 100644 --- a/ui.html +++ b/ui.html @@ -5,11 +5,11 @@ VUE-CRUD-UI - - - - - + + + + + @@ -25,7 +25,7 @@

VUE-CRUD-UI

- +
@@ -57,23 +57,23 @@

{{ subject }}: list

- + - + - @@ -88,9 +88,9 @@

{{ subject }}: list

-
{{ value }}{{ value }} related actions
+