egg-born-module-a-base-sync
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -70,8 +70,6 @@ const require3 = require('require3'); | ||
async create({ atomClass, user }) { | ||
// sequence | ||
const sequence = await this.sequence.next('draft'); | ||
// atomClass | ||
atomClass = await ctx.meta.atomClass.get(atomClass); | ||
// atom | ||
const atom = { atomName: `${ctx.text('Draft')}-${sequence}`, atomFlow: atomClass.flow }; | ||
const atom = { }; | ||
const atomId = await this._add({ | ||
@@ -98,2 +96,9 @@ atomClass, | ||
// save itemId | ||
let atomName = atom.atomName; | ||
if (!atomName) { | ||
// sequence | ||
const sequence = await this.sequence.next('draft'); | ||
atomName = `${ctx.text('Draft')}-${sequence}`; | ||
} | ||
const atomFlow = atom.atomFlow === undefined ? atomClass.flow : atom.atomFlow; | ||
await this._update({ | ||
@@ -103,3 +108,4 @@ atom: { | ||
itemId, | ||
atomFlow: atom.atomFlow, // maybe changed | ||
atomName, | ||
atomFlow, | ||
}, | ||
@@ -189,12 +195,2 @@ user, | ||
const atomClass = await ctx.meta.atomClass.getByAtomId({ atomId: key.atomId }); | ||
if (item && item.atomName !== undefined) { | ||
await this._update({ | ||
atom: { | ||
id: key.atomId, | ||
atomName: item.atomName, | ||
}, | ||
user, | ||
}); | ||
} | ||
// write item | ||
@@ -213,2 +209,15 @@ const moduleInfo = mparse.parseInfo(atomClass.module); | ||
}); | ||
// write atom | ||
if (item) { | ||
const atom = { }; | ||
if (item.atomName !== undefined) atom.atomName = item.atomName; | ||
if (Object.keys(atom).length > 0) { | ||
atom.id = key.atomId; | ||
await this._update({ | ||
atom, | ||
user, | ||
}); | ||
} | ||
} | ||
} | ||
@@ -424,3 +433,3 @@ | ||
async _update({ | ||
atom: { id, atomName, itemId }, | ||
atom: { id, atomName, atomFlow, itemId }, | ||
user, | ||
@@ -430,2 +439,3 @@ }) { | ||
if (atomName !== undefined) params.atomName = atomName; | ||
if (atomFlow !== undefined) params.atomFlow = atomFlow; | ||
if (itemId !== undefined) params.itemId = itemId; | ||
@@ -432,0 +442,0 @@ const res = await this.modelAtom.update(params); |
{ | ||
"name": "egg-born-module-a-base-sync", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"title": "Base", | ||
@@ -5,0 +5,0 @@ "eggBornModule": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
767245
11615