fix multi-check
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2022-04-13 08:15:47 +02:00
parent 8e87ab62a8
commit f2ee987dec
5 changed files with 34 additions and 27 deletions

View File

@ -5,19 +5,19 @@
</vn-check>
<vn-icon-button
class="vn-pl-none"
ng-if="$ctrl.checked && $ctrl.checkDummy"
ng-if="$ctrl.checked && $ctrl.checkDummyEnabled"
icon="expand_more"
vn-popover="menu"
ng-click="$ctrl.countRows()">
</vn-icon-button>
<vn-menu vn-id="menu">
<vn-list ng-click="$ctrl.checkDummy()">
<vn-list>
<span translate>All</span>
<span class="bold">
{{$ctrl.rows}}
</span>
<span translate>row(s) have been selected.</span>
<span class="bold link">
<span class="bold link" ng-click="$ctrl.checkDummy()">
{{$ctrl.AllRowsCount}}
</span>
</vn-list>

View File

@ -106,6 +106,9 @@ export default class MultiCheck extends FormInput {
this.toggle();
this.emit('change', value);
if (!value)
this.checkedDummyCount = null;
}
/**
@ -156,7 +159,13 @@ export default class MultiCheck extends FormInput {
});
});
this.rows = data.length;
this.checkedDummy = data.length;
}
checkDummy() {
if (this.checkedDummyCount)
return this.checkedDummyCount = null;
this.checkedDummyCount = 15; // console.log
}
/**
@ -180,8 +189,8 @@ ngModule.vnComponent('vnMultiCheck', {
checkAll: '=?',
checked: '=?',
disabled: '<?',
checkDummy: '<?',
checkedDummy: '=?'
checkDummyEnabled: '<?',
checkedDummyCount: '=?'
}
});

View File

@ -22,7 +22,7 @@ module.exports = Self => {
},
{
arg: 'filter',
type: ['object'],
type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
}],
returns: {
@ -37,7 +37,7 @@ module.exports = Self => {
Self.editLatestBuys = async(field, newValue, lines, filter, options) => {
let tx;
console.log(filter);
console.log('filter', filter);
const myOptions = {};
if (typeof options == 'object')
@ -72,22 +72,22 @@ module.exports = Self => {
const model = models[modelName];
try {
let result;
console.log(filter);
const promises = [];
const value = {};
value[field] = newValue;
if (filter) {
result = await model.upsertWithWhere(filter, value, myOptions);
promises.push(model.upsertWithWhere(filter, value, myOptions));
result = await Promise.all(promises);
if (tx) await tx.commit();
return result;
}
const promises = [];
const targets = lines.map(line => {
return line[identifier];
});
const value = {};
value[field] = newValue;
for (let target of targets)
promises.push(model.upsertWithWhere({id: target}, value, myOptions));

View File

@ -32,8 +32,8 @@
checked="$ctrl.checkAll"
model="model"
check-field="$checked"
check-dummy="$ctrl.checkDummy"
checked-dummy="$ctrl.checkedDummy">
check-dummy-enabled="true"
checked-dummy-count="$ctrl.checkedDummyCount">
</vn-multi-check>
</th>
<th translate>Picture</th>

View File

@ -89,13 +89,11 @@ export default class Controller extends Section {
get checked() {
const buys = this.$.model.data || [];
let checkedBuys = [];
const checkedBuys = [];
for (let buy of buys) {
if (buy.$checked)
checkedBuys.push(buy);
}
if (this.checkedDummy)
checkedBuys = this.checkedDummy;
return checkedBuys;
}
@ -144,6 +142,9 @@ export default class Controller extends Section {
}
get totalChecked() {
if (this.checkedDummyCount)
return this.checkedDummyCount;
return this.checked.length;
}
@ -151,25 +152,22 @@ export default class Controller extends Section {
const rowsToEdit = [];
for (let row of this.checked)
rowsToEdit.push({id: row.id, itemFk: row.itemFk});
console.log(this.editFilter);
const data = {
field: this.editedColumn.field,
newValue: this.editedColumn.newValue,
lines: rowsToEdit,
filter: this.editFilter
lines: rowsToEdit
};
if (this.checkedDummyCount && this.checkedDummyCount > 0)
data.filter = this.$.model.userParams;
return this.$http.post('Buys/editLatestBuys', data)
.then(() => {
this.uncheck();
this.$.model.refresh();
});
}
checkDummy() {
console.log('editFilter', this.model.userParams);
this.editFilter = this.model.userParams;
}
}
ngModule.component('vnEntryLatestBuys', {