#1073 item.tags no busca tags cuando se añade una linea nueva
This commit is contained in:
parent
f6f1dba1d9
commit
94f19c2cb5
|
@ -145,8 +145,9 @@ export default class ModelProxy extends DataModel {
|
|||
});
|
||||
return new Proxy(obj, {
|
||||
set: (obj, prop, value) => {
|
||||
let changed = prop.charAt(0) !== '$' && value !== obj[prop] && !obj.$isNew;
|
||||
if (changed) {
|
||||
let changed = prop.charAt(0) !== '$' && value !== obj[prop];
|
||||
|
||||
if (changed && !obj.$isNew) {
|
||||
if (!obj.$oldData)
|
||||
obj.$oldData = {};
|
||||
if (!obj.$oldData[prop])
|
||||
|
@ -159,7 +160,8 @@ export default class ModelProxy extends DataModel {
|
|||
if (changed) {
|
||||
this.emit('rowChange', {obj, prop, value});
|
||||
this.emit('dataUpdate');
|
||||
if (this.autoSave)
|
||||
|
||||
if (!obj.$isNew && this.autoSave)
|
||||
this.save();
|
||||
}
|
||||
|
||||
|
@ -173,9 +175,10 @@ export default class ModelProxy extends DataModel {
|
|||
this.isChanged = false;
|
||||
|
||||
let data = this.proxiedData;
|
||||
if (data)
|
||||
if (data) {
|
||||
for (let row of data)
|
||||
row.$oldData = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,18 +189,21 @@ export default class ModelProxy extends DataModel {
|
|||
let orgData = this.orgData;
|
||||
if (!data) return;
|
||||
|
||||
for (let row of data)
|
||||
for (let row of data) {
|
||||
if (row.$isNew) {
|
||||
let orgRow = {};
|
||||
for (let prop in row)
|
||||
for (let prop in row) {
|
||||
if (prop.charAt(0) !== '$')
|
||||
orgRow[prop] = row[prop];
|
||||
}
|
||||
row.$orgIndex = orgData.push(orgRow) - 1;
|
||||
row.$orgRow = orgRow;
|
||||
row.$isNew = false;
|
||||
} else if (row.$oldData)
|
||||
} else if (row.$oldData) {
|
||||
for (let prop in row.$oldData)
|
||||
row.$orgRow[prop] = row[prop];
|
||||
}
|
||||
}
|
||||
|
||||
let removed = this.removed;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
link="{itemFk: $ctrl.$stateParams.id}"
|
||||
include="$ctrl.include"
|
||||
order="priority ASC"
|
||||
on-row-change="$ctrl.getSourceTable(obj)"
|
||||
data="$ctrl.itemTags"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
|
@ -31,6 +30,7 @@
|
|||
initial-data="itemTag.tag"
|
||||
field="itemTag.tagFk"
|
||||
data="tags"
|
||||
on-change="$ctrl.getSourceTable(tag)"
|
||||
show-field="name"
|
||||
vn-acl="buyer"
|
||||
vn-focus>
|
||||
|
|
|
@ -30,7 +30,7 @@ class Controller {
|
|||
getSourceTable(obj) {
|
||||
let sourceTable;
|
||||
this.sourceTables[obj.id] = {};
|
||||
let tag = obj.tag;
|
||||
let tag = obj.tag || obj.selection;
|
||||
|
||||
if (!tag || !tag.sourceTable && (tag.isFree === true || tag.isFree === undefined))
|
||||
sourceTable = null;
|
||||
|
|
Loading…
Reference in New Issue