Optimize manage list
This commit is contained in:
parent
770ab8ea8d
commit
8d8ce63402
|
@ -198,37 +198,25 @@ async function processSelectedDevices() {
|
||||||
* @param {Lot} lot lot id
|
* @param {Lot} lot lot id
|
||||||
* @param {Device[]} deviceList device id
|
* @param {Device[]} deviceList device id
|
||||||
*/
|
*/
|
||||||
manage(event, lot, deviceList) {
|
manage(event, lot, deviceListID) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const lotID = lot.id;
|
const lotID = lot.id;
|
||||||
const srcElement = event.srcElement.parentElement.children[0]
|
const srcElement = event.srcElement.parentElement.children[0]
|
||||||
const {indeterminate} = srcElement;
|
|
||||||
const checked = !srcElement.checked;
|
const checked = !srcElement.checked;
|
||||||
|
|
||||||
const found = this.list.filter(list => list.lotID == lotID)[0];
|
const found = this.list.filter(list => list.lot.id == lotID)[0];
|
||||||
const foundIndex = found != undefined ? this.list.findLastIndex(x => x.lotID == found.lotID) : -1;
|
|
||||||
|
|
||||||
if (checked) {
|
if (checked) {
|
||||||
if (found != undefined && found.type == "Remove") {
|
if (found && found.type == "Remove") {
|
||||||
if (found.isFromIndeterminate == true) {
|
found.type = "Add";
|
||||||
found.type = "Add";
|
|
||||||
this.list[foundIndex] = found;
|
|
||||||
} else {
|
|
||||||
this.list = this.list.filter(list => list.lotID != lotID);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.list.push({ type: "Add", lot, devices: deviceList, isFromIndeterminate: indeterminate });
|
this.list.push({ type: "Add", lot, devices: deviceListID});
|
||||||
}
|
}
|
||||||
} else if (found != undefined && found.type == "Add") {
|
} else if (found && found.type == "Add") {
|
||||||
if (found.isFromIndeterminate == true) {
|
|
||||||
found.type = "Remove";
|
found.type = "Remove";
|
||||||
this.list[foundIndex] = found;
|
|
||||||
} else {
|
} else {
|
||||||
this.list = this.list.filter(list => list.lotID != lotID);
|
this.list.push({ type: "Remove", lot, devices: deviceListID});
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.list.push({ type: "Remove", lot, devices: deviceList, isFromIndeterminate: indeterminate });
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.list.length > 0) {
|
if (this.list.length > 0) {
|
||||||
document.getElementById("ApplyDeviceLots").classList.remove("disabled");
|
document.getElementById("ApplyDeviceLots").classList.remove("disabled");
|
||||||
|
|
Reference in New Issue