From 0c3d85271e715c1498da5a1281c8714730f4f0f4 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 30 Jun 2020 20:21:03 +0000 Subject: [PATCH] --- ayanova/src/components/gz-data-table.vue | 3 - ayanova/src/views/adm-attachments.vue | 138 ++++++++++++++++++----- 2 files changed, 110 insertions(+), 31 deletions(-) diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index f89175a6..92b8f5de 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -429,10 +429,7 @@ export default { this.selected.splice(0, this.selected.length - 1); } //emit event to parent form of selected rows - //this.$emit("update:selected", this.selected); //Note vm this bubbles up all the columns of all the selected rows - console.log("gzdatatable:handleSelectChange emitting ", this.selected); - //so, to be more efficient for now will just send the ID's until I see a need for other shit this.$emit("selection-change", window.$gz._.map(this.selected, "id")); }, diff --git a/ayanova/src/views/adm-attachments.vue b/ayanova/src/views/adm-attachments.vue index 61dfa324..2819e4c7 100644 --- a/ayanova/src/views/adm-attachments.vue +++ b/ayanova/src/views/adm-attachments.vue @@ -1,25 +1,55 @@ @@ -31,6 +61,7 @@ export default { window.$gz.eventBus.$on("menu-click", clickHandler); //await fetchTranslatedText(this); generateMenu(this); + this.handleSelected([]); //start out read only no selection state for bulk ops options }, beforeDestroy() { window.$gz.eventBus.$off("menu-click", clickHandler); @@ -39,12 +70,23 @@ export default { return { jobActive: false, reload: false, + moveDialog: false, selectedItems: [], currentListViewId: 1, dataListKey: "AttachmentDataList", dataListFilter: "", dataListSort: "", - rights: window.$gz.role.defaultRightsObject() + rights: window.$gz.role.defaultRightsObject(), + formState: { + ready: true, + dirty: false, + valid: true, + readOnly: false, + loading: false, + errorBoxMessage: null, + appError: null, + serverError: {} + } }; }, methods: { @@ -59,11 +101,48 @@ export default { this.selectedItems = selected; if (this.canBulkOp()) { - window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":duplicate"); - window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new"); + window.$gz.eventBus.$emit( + "menu-enable-item", + FORM_KEY + ":DELETE_SELECTED" + ); + window.$gz.eventBus.$emit( + "menu-enable-item", + FORM_KEY + ":MOVE_SELECTED" + ); } else { - window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":duplicate"); - window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new"); + window.$gz.eventBus.$emit( + "menu-disable-item", + FORM_KEY + ":DELETE_SELECTED" + ); + window.$gz.eventBus.$emit( + "menu-disable-item", + FORM_KEY + ":MOVE_SELECTED" + ); + } + }, + async moveSelected(ayType, ayId) { + let vm = this; + try { + //called from move dialog, already selected + vm.moveDialog=false; + + + + let dialogResult = await window.$gz.dialog.confirmDelete(); + if (dialogResult != true) { + return; + } + //TODO: Gather the ID and type here + + window.$gz.form.deleteAllErrorBoxErrors(vm); + let res = await window.$gz.api.remove(url); + if (res.error) { + vm.formState.serverError = res.error; + window.$gz.form.setErrorBoxErrors(vm); + } + this.reload = !this.reload; + } catch (ex) { + window.$gz.errorHandler.handleFormError(ex, vm); } }, async deleteSelected() { @@ -74,14 +153,16 @@ export default { return; } - let url = API_BASE_URL + vm.$route.params.recordid; - window.$gz.form.deleteAllErrorBoxErrors(vm); - let res = await window.$gz.api.remove(url); + let res = await window.$gz.api.upsert( + "attachment/bulk-delete", + this.selectedItems + ); if (res.error) { vm.formState.serverError = res.error; window.$gz.form.setErrorBoxErrors(vm); } + this.reload = !this.reload; } catch (ex) { window.$gz.errorHandler.handleFormError(ex, vm); } @@ -165,7 +246,8 @@ function clickHandler(menuItem) { m.vm.startMaintenanceJob(); break; case "MOVE_SELECTED": - m.vm.moveSelected(); + m.vm.moveDialog = true; + break; case "DELETE_SELECTED": m.vm.deleteSelected();