requested changes
gitea/salix/2076-item_tags_refactor There was a failure building this commit
Details
gitea/salix/2076-item_tags_refactor There was a failure building this commit
Details
This commit is contained in:
parent
f53217bc71
commit
b77f32a733
|
@ -184,9 +184,7 @@ export default class CrudModel extends ModelProxy {
|
||||||
let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`;
|
let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`;
|
||||||
return this.$http.post(url, changes)
|
return this.$http.post(url, changes)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const newData = res.data;
|
const created = res.data;
|
||||||
const created = newData.created;
|
|
||||||
const updated = newData.updated;
|
|
||||||
|
|
||||||
// Apply new data to created instances
|
// Apply new data to created instances
|
||||||
for (let i = 0; i < orgCreates.length; i++) {
|
for (let i = 0; i < orgCreates.length; i++) {
|
||||||
|
@ -199,15 +197,6 @@ export default class CrudModel extends ModelProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply new data to updated instances
|
|
||||||
for (let i = 0; i < orgUpdates.length; i++) {
|
|
||||||
const row = orgUpdates[i];
|
|
||||||
for (let prop in row) {
|
|
||||||
if (prop.charAt(0) !== '$')
|
|
||||||
row[prop] = updated[i][prop];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.applyChanges();
|
this.applyChanges();
|
||||||
super.save();
|
super.save();
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,20 +64,16 @@ module.exports = function(Self) {
|
||||||
try {
|
try {
|
||||||
let options = {transaction: tx};
|
let options = {transaction: tx};
|
||||||
|
|
||||||
let deleted;
|
|
||||||
if (deletes) {
|
if (deletes) {
|
||||||
let promises = [];
|
let promises = [];
|
||||||
for (let id of deletes)
|
for (let id of deletes)
|
||||||
promises.push(this.destroyById(id, options));
|
promises.push(this.destroyById(id, options));
|
||||||
deleted = await Promise.all(promises);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let updated;
|
|
||||||
if (updates) {
|
if (updates) {
|
||||||
let promises = [];
|
let promises = [];
|
||||||
for (let update of updates)
|
for (let update of updates)
|
||||||
promises.push(this.upsertWithWhere(update.where, update.data, options));
|
promises.push(this.upsertWithWhere(update.where, update.data, options));
|
||||||
updated = await Promise.all(promises);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let created;
|
let created;
|
||||||
|
@ -91,7 +87,7 @@ module.exports = function(Self) {
|
||||||
|
|
||||||
await tx.commit();
|
await tx.commit();
|
||||||
|
|
||||||
return {deleted, created, updated};
|
return created;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
throw error;
|
throw error;
|
||||||
|
|
Loading…
Reference in New Issue