This commit is contained in:
2021-02-27 18:00:04 +00:00
parent 9d4fbb70d7
commit 6beeae8ef4
3 changed files with 25 additions and 73 deletions

View File

@@ -451,10 +451,7 @@ export default {
type: Boolean,
default: false
},
selectReturnColumns: {
type: Array,
default: null
},
reload: {
type: Boolean,
default: false
@@ -659,66 +656,17 @@ export default {
};
},
handleSelectChange() {
if (
this.selectReturnColumns != null &&
this.selectReturnColumns.length > 0
) {
//todo: here need to check if calling form has asked for a template of certain fields instead of row id's
//and emit that as objects instead
//i.e. restock list provides selectReturnTemplate array of field key names:
// ['PartPartNumber','PartWarehouseName','PartWholesalerID','PartAlternativeWholesalerID','PartManufacturerID','PartByWarehouseInventoryReorderQuantity']
//select then saves exactly those columns into the selection instead of id's
//returns the id and name values or basically anything in that column ready for ease of use by extensions like partrestock extension which needs display and id values both
//maybe need to rename selectedRowIds if it can fit within that system too.
console.log("handleselectchange templated", {
selected: this.selected,
headers: this.headers
});
//build a map of column numbers that correspond with template fk names
/*
arrays of objects like this, fk corresponds to field template, value columns.cx equals actual column we need, text may be useful too save a translation to send it maybe?
align: "start"
fk: "PartPartNumber"
flt: true
text: "Part Number"
value: "columns.c0"
*/
//iterate the selected items which are like below, i is id number of record, t is type maybe useful, v is display value, key is only useless thing, maybe just strip the key and send the rest?
/*
c0: {…}
i: 3
key: "0-0"
t: 4
v: "017368"
*/
//return array like this:
/*
todo: work this out, array of arrays I guess??
[
{
fk:"PartPartNumber",
text:"Part number",
i: 3,
t: 4,
v: "01768"
}
*/
} else {
//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
if (this.singleSelect) {
this.selected.splice(0, this.selected.length - 1);
}
//emit event to parent form of selected rows
this.$emit(
"selection-change",
this.selected.map(z => z.id)
);
//SINGLESELECT MODE?
//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
if (this.singleSelect) {
this.selected.splice(0, this.selected.length - 1);
}
//emit event to parent form of selected rows
this.$emit(
"selection-change",
this.selected.map(z => z.id)
);
},
editColumnView() {
this.$router.push({
@@ -902,7 +850,9 @@ function buildHeaders(columnData) {
return ret;
}
/////////////////////////////////////////////////////////////////
//Called by getDataFromApi on retrieval of list with columnData
//
function buildRecords(listData, columndefinitions, ridColumnOpenable) {
//iterate data, build each object keyed with index name and display set to correct translated filter and then return
@@ -926,7 +876,7 @@ function buildRecords(listData, columndefinitions, ridColumnOpenable) {
//iterate row and build object representing row data keyed to index
//container object for row
//id will be set later when code below encounters the id column which could be in any position but is identified by it's rid property
//id will be set later when code below encounters the id column which could be in any position (or not at all) but is identified by it's rid property
let o = { id: undefined, columns: {} };
for (let iColumn = 0; iColumn < row.length; iColumn++) {
@@ -1105,6 +1055,7 @@ function buildRecords(listData, columndefinitions, ridColumnOpenable) {
o.columns["c" + iColumn.toString()] = columnObject;
}
ret.push(o);
}