From ae95abee223261014eb7dc5a672409a01d7815af Mon Sep 17 00:00:00 2001 From: Kirill Stytsenko <kirill@styts.com> Date: Thu, 17 Feb 2022 16:02:05 +0100 Subject: [PATCH] WiP Former-commit-id: f501236a2e9f590f86a52b3fbe91d5c3d5356be1 --- fda-ui/components/TableList.vue | 4 +-- fda-ui/components/dialogs/ColumnUnit.vue | 43 +++++++++++++++++++++--- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/fda-ui/components/TableList.vue b/fda-ui/components/TableList.vue index 8a40ad0ed9..675c7b47b1 100644 --- a/fda-ui/components/TableList.vue +++ b/fda-ui/components/TableList.vue @@ -1,6 +1,6 @@ <template> <div> - <v-progress-linear v-if="loading" :indeterminate="!error" /> + <v-progress-linear v-if="loading" /> <v-card v-if="!loading && tables.length === 0" flat> <v-card-title> (no tables) @@ -115,7 +115,7 @@ {{ col.column_type }} </td> <td> - <DialogsColumnUnit :column="col" /> + <DialogsColumnUnit :column="col" :table-id="tableDetails.id" /> </td> <td> <v-simple-checkbox v-model="col.is_primary_key" disabled aria-readonly="true" /> diff --git a/fda-ui/components/dialogs/ColumnUnit.vue b/fda-ui/components/dialogs/ColumnUnit.vue index 9865f0aa5a..bfa2d725a3 100644 --- a/fda-ui/components/dialogs/ColumnUnit.vue +++ b/fda-ui/components/dialogs/ColumnUnit.vue @@ -83,7 +83,8 @@ <v-btn color="blue darken-1" text - @click="dialog = false"> + :disabled="!model || !uri" + @click="save"> Save </v-btn> </v-card-actions> @@ -94,12 +95,14 @@ <script> export default { props: { - column: { type: Object, default: () => ({}) } + column: { type: Object, default: () => ({}) }, + tableId: { type: Number, default: () => -1 } }, data () { return { dialog: false, isLoading: false, + saved: false, model: null, uri: null, search: null, @@ -108,8 +111,7 @@ export default { }, computed: { name () { - // TODO - return null + return this.saved && this.model && this.model.name }, items () { return this.entries && this.entries.map((entry) => { @@ -121,10 +123,10 @@ export default { }) } }, - watch: { async model (val) { this.uri = null + this.saved = false if (!val) { return } try { const res = await this.$axios.get(`/api/units/uri/${val.name}`) @@ -154,6 +156,37 @@ export default { mounted () { }, methods: { + async save () { + try { + await this.$axios.post('/api/units/saveconcept', { + name: this.model.name, + uri: this.uri + }) + } catch (error) { + const { status } = error.response + if (status !== 201 && status !== 400) { + this.$toast.error('Could not save concept.') + console.log(error) + } + } + console.log(this.$route.params.database_id, this.tableId, this.column) + try { + await this.$axios.post('/api/units/savecolumnsconcept', { + cdbid: Number(this.$route.params.database_id), + cid: this.column.id, + tid: this.tableId, + uri: this.uri + }) + this.dialog = false + this.saved = true + this.$nextTick(() => { + this.$emit('save') + }) + } catch (err) { + this.$toast.error('Could not save column unit.') + console.log(err) + } + } } } </script> -- GitLab