diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 49b1ae49..0332570b 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -456,27 +456,26 @@ export default { refresh() { this.getDataFromApi(); }, - getRowIds() { + getDataTableSourceOptions() { + let vm = this; + //called when parent form needs the selected id's or the list view options needed to rehydrate the entire list of id's in the same order and filter + //i.e. for reporting, bulk operations etc + + let selectedRowIds = []; //get selected row id's if there are selections else get all row id's //called into from parent for things like reporting or bulk ops //selected or records both are arrays with an id property that contains the row id conveniently for this method - if (this.selected.length > 0) { + if (vm.selected.length > 0) { //return row id's of selected items only - return this.selected.map(z => { + selectedRowIds = vm.selected.map(z => { return z.id; }); } - //whups, records is only the visible paged amount, not all, back to the drawing board for this one but the above is fine - if (this.records.length > 0) { - //return row id's of all items - return this.records.map(z => { - return z.id; - }); - } - //no data, just return an empty array - return []; - // console.log("records:", this.records); - // console.log("selected:", this.selected); + return { + selectedRowIds: selectedRowIds, + dataListKey: vm.dataListKey, + listView: untokenizeListView(vm.listView) + }; }, handleSelectChange() { //due to making own template for items need to handle singleselect which only affects if select all checkbox at top is visible when making own item template diff --git a/ayanova/src/components/report-selector-control.vue b/ayanova/src/components/report-selector-control.vue index bbf20f55..6f97da24 100644 --- a/ayanova/src/components/report-selector-control.vue +++ b/ayanova/src/components/report-selector-control.vue @@ -11,7 +11,6 @@ {{ $ay.t("Report") }} - TYPE: {{ ayaType }}, idList:{{ idList }} rights: {{ rights }} @@ -64,7 +63,7 @@ export default { data: () => ({ rights: window.$gz.role.getRights(window.$gz.type.Report), ayaType: null, - idList: [], + sourceData: {}, isVisible: false, resolve: null, reject: null, @@ -76,13 +75,22 @@ export default { selectedReport: null }), methods: { - async open(ayaType, idList) { + async open(ayaType, sourceData) { let vm = this; - if (ayaType == null || idList == null || idList.length == 0) { - throw "report-selector:Open missing type and or idList"; + if (ayaType == null || sourceData == null) { + throw "report-selector:Open missing type and or sourceData"; } this.ayaType = ayaType; - this.idList = idList; + + //source data object + //either need to rehydrate or send as is if not selectedRowIds + // { + // selectedRowIds: selectedRowIds, + // dataListKey: vm.dataListKey, + // listView: untokenizeListView(vm.listView) + // } + + this.sourceData = sourceData; //rights @@ -115,7 +123,11 @@ export default { this.resolve(null); this.$router.push({ name: "ay-report-edit", - params: { recordid: 0, ayaType: this.ayaType, idList: this.idList } + params: { + recordid: 0, + ayaType: this.ayaType, + sourceData: this.sourceData + } }); } } diff --git a/ayanova/src/views/ay-report-edit.vue b/ayanova/src/views/ay-report-edit.vue index da87fc18..67961fc6 100644 --- a/ayanova/src/views/ay-report-edit.vue +++ b/ayanova/src/views/ay-report-edit.vue @@ -156,12 +156,11 @@ export default { vm.formState.readOnly = !vm.rights.change; window.$gz.eventBus.$on("menu-click", clickHandler); - //route params MUST have ID LIST - if (!vm.$route.params.idList) { + //route params MUST have source data + if (!vm.$route.params.sourceData) { + throw "ay-report-edit::created - missing sourceData route parameter"; } - vm.idList = vm.$route.params.idList; - //id 0 means create a new record don't load one if (vm.$route.params.recordid != 0) { //is there already an obj from a prior operation? @@ -767,10 +766,10 @@ async function fetchTranslatedText(vm) { //////////////////// // async function fetchReportData(vm) { - let idList = vm.$route.params.idList; + let sourceData = vm.$route.params.sourceData; vm.obj.objectType = vm.$route.params.ayaType; - if (!idList || idList.length == 0) { - throw "ay-report-edit:fetchReportData - route parameter idList is missing or empty, unable to init report designer"; + if (!sourceData) { + throw "ay-report-edit:fetchReportData - route parameter sourceData is missing or empty, unable to init report designer"; } if (vm.obj.objectType == null) { throw "ay-report-edit:fetchReportData - route parameter ayaType is missing or empty, unable to init report designer"; @@ -782,7 +781,7 @@ async function fetchReportData(vm) { } */ let res = await window.$gz.api.upsert("report/object-report-data", { ObjectType: vm.obj.objectType, - ObjectIdArray: idList + ObjectIdArray: sourceData }); //We never expect there to be no data here if (!res.hasOwnProperty("data")) { diff --git a/ayanova/src/views/widget.vue b/ayanova/src/views/widget.vue index 75fa173a..0bbb8cc1 100644 --- a/ayanova/src/views/widget.vue +++ b/ayanova/src/views/widget.vue @@ -640,7 +640,9 @@ async function clickHandler(menuItem) { let res = await m.vm.$refs.reportSelector.open( window.$gz.type.Widget, - [m.vm.obj.id] + { + selectedRowIds: [m.vm.obj.id] + } ); //if null for no selection diff --git a/ayanova/src/views/widgets.vue b/ayanova/src/views/widgets.vue index dffe439d..26c4f174 100644 --- a/ayanova/src/views/widgets.vue +++ b/ayanova/src/views/widgets.vue @@ -76,13 +76,11 @@ async function clickHandler(menuItem) { params: { recordid: m.id, ayatype: window.$gz.type.Widget } }); } else { - //general report selector chosen - console.log(m.vm.$refs.gzdatatable.getRowIds()); - return; + //general report selector chosen let res = await m.vm.$refs.reportSelector.open( window.$gz.type.Widget, - [m.vm.getSelection()] + m.vm.$refs.gzdatatable.getDataTableSourceOptions() ); //if null for no selection