feat(entry_latest-buys): add multi-check-dummy
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
73ee790f8d
commit
8e87ab62a8
|
@ -0,0 +1 @@
|
|||
SelectAllRows: Select the {{rows}} row(s)
|
|
@ -0,0 +1,3 @@
|
|||
SelectAllRows: Seleccionar las {{rows}} fila(s)
|
||||
All: Se han seleccionado
|
||||
row(s) have been selected.: fila(s).
|
|
@ -3,3 +3,22 @@
|
|||
indeterminate="$ctrl.isIndeterminate"
|
||||
translate-attr="{title: 'Check all'}">
|
||||
</vn-check>
|
||||
<vn-icon-button
|
||||
class="vn-pl-none"
|
||||
ng-if="$ctrl.checked && $ctrl.checkDummy"
|
||||
icon="expand_more"
|
||||
vn-popover="menu"
|
||||
ng-click="$ctrl.countRows()">
|
||||
</vn-icon-button>
|
||||
<vn-menu vn-id="menu">
|
||||
<vn-list ng-click="$ctrl.checkDummy()">
|
||||
<span translate>All</span>
|
||||
<span class="bold">
|
||||
{{$ctrl.rows}}
|
||||
</span>
|
||||
<span translate>row(s) have been selected.</span>
|
||||
<span class="bold link">
|
||||
{{$ctrl.AllRowsCount}}
|
||||
</span>
|
||||
</vn-list>
|
||||
</vn-menu>
|
|
@ -138,6 +138,27 @@ export default class MultiCheck extends FormInput {
|
|||
});
|
||||
}
|
||||
|
||||
countRows() {
|
||||
if (!this.model || !this.model.data) return;
|
||||
const data = this.model.data;
|
||||
const params = {
|
||||
filter: {
|
||||
where: this.model.userParams,
|
||||
limit: null
|
||||
}
|
||||
};
|
||||
|
||||
this.$http.get(this.model.url, {params})
|
||||
.then(res => {
|
||||
this.AllRows = res.data;
|
||||
this.AllRowsCount = this.$t('SelectAllRows', {
|
||||
rows: res.data.length
|
||||
});
|
||||
});
|
||||
this.rows = data.length;
|
||||
this.checkedDummy = data.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles checked property on
|
||||
* all instances
|
||||
|
@ -158,7 +179,9 @@ ngModule.vnComponent('vnMultiCheck', {
|
|||
checkField: '@?',
|
||||
checkAll: '=?',
|
||||
checked: '=?',
|
||||
disabled: '<?'
|
||||
disabled: '<?',
|
||||
checkDummy: '<?',
|
||||
checkedDummy: '=?'
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,17 @@
|
|||
@import "variables";
|
||||
vn-multi-check {
|
||||
.vn-check {
|
||||
margin-bottom: 12px
|
||||
}
|
||||
|
||||
vn-list{
|
||||
padding: 50px;
|
||||
}
|
||||
vn-menu{
|
||||
padding: 50px;
|
||||
}
|
||||
|
||||
}
|
||||
.bold{
|
||||
font-weight: bold;
|
||||
}
|
|
@ -19,6 +19,11 @@ module.exports = Self => {
|
|||
type: ['Object'],
|
||||
required: true,
|
||||
description: `the buys which will be modified`
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: ['object'],
|
||||
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string'
|
||||
}],
|
||||
returns: {
|
||||
type: 'Object',
|
||||
|
@ -30,8 +35,9 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.editLatestBuys = async(field, newValue, lines, options) => {
|
||||
Self.editLatestBuys = async(field, newValue, lines, filter, options) => {
|
||||
let tx;
|
||||
console.log(filter);
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
@ -64,8 +70,16 @@ module.exports = Self => {
|
|||
|
||||
const models = Self.app.models;
|
||||
const model = models[modelName];
|
||||
|
||||
try {
|
||||
let result;
|
||||
console.log(filter);
|
||||
|
||||
if (filter) {
|
||||
result = await model.upsertWithWhere(filter, value, myOptions);
|
||||
if (tx) await tx.commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
const promises = [];
|
||||
|
||||
const targets = lines.map(line => {
|
||||
|
@ -74,11 +88,10 @@ module.exports = Self => {
|
|||
|
||||
const value = {};
|
||||
value[field] = newValue;
|
||||
|
||||
for (let target of targets)
|
||||
promises.push(model.upsertWithWhere({id: target}, value, myOptions));
|
||||
|
||||
const result = await Promise.all(promises);
|
||||
result = await Promise.all(promises);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@
|
|||
<vn-multi-check
|
||||
checked="$ctrl.checkAll"
|
||||
model="model"
|
||||
check-field="$checked">
|
||||
check-field="$checked"
|
||||
check-dummy="$ctrl.checkDummy"
|
||||
checked-dummy="$ctrl.checkedDummy">
|
||||
</vn-multi-check>
|
||||
</th>
|
||||
<th translate>Picture</th>
|
||||
|
|
|
@ -89,11 +89,13 @@ export default class Controller extends Section {
|
|||
|
||||
get checked() {
|
||||
const buys = this.$.model.data || [];
|
||||
const checkedBuys = [];
|
||||
let checkedBuys = [];
|
||||
for (let buy of buys) {
|
||||
if (buy.$checked)
|
||||
checkedBuys.push(buy);
|
||||
}
|
||||
if (this.checkedDummy)
|
||||
checkedBuys = this.checkedDummy;
|
||||
|
||||
return checkedBuys;
|
||||
}
|
||||
|
@ -149,11 +151,12 @@ 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
|
||||
lines: rowsToEdit,
|
||||
filter: this.editFilter
|
||||
};
|
||||
|
||||
return this.$http.post('Buys/editLatestBuys', data)
|
||||
|
@ -162,6 +165,11 @@ export default class Controller extends Section {
|
|||
this.$.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
checkDummy() {
|
||||
console.log('editFilter', this.model.userParams);
|
||||
this.editFilter = this.model.userParams;
|
||||
}
|
||||
}
|
||||
|
||||
ngModule.component('vnEntryLatestBuys', {
|
||||
|
|
Loading…
Reference in New Issue