This commit is contained in:
2020-09-01 17:22:43 +00:00
parent a592fec7bc
commit 4b3bd3aa07
5 changed files with 44 additions and 34 deletions

View File

@@ -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

View File

@@ -11,7 +11,6 @@
<v-card elevation="24">
<v-card-title class="headline lighten-2" primary-title>
<span> {{ $ay.t("Report") }} </span>
TYPE: {{ ayaType }}, idList:{{ idList }} rights: {{ rights }}
</v-card-title>
<v-card-text style="height: 500px;">
@@ -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
}
});
}
}

View File

@@ -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")) {

View File

@@ -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

View File

@@ -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