Socket
Socket
Sign inDemoInstall

egg-born-module-a-base-sync

Package Overview
Dependencies
Maintainers
1
Versions
354
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-born-module-a-base-sync - npm Package Compare versions

Comparing version 4.8.43 to 4.8.44

backend/src/bean/bean.atom/bean.atom_checkRightAction.js

1

backend/src/bean/atom.resource.js

@@ -39,3 +39,2 @@ module.exports = app => {

const data = await this.ctx.model.resource.prepareData(item);
data.id = key.itemId;
await this.ctx.model.resource.update(data);

@@ -42,0 +41,0 @@ }

@@ -98,3 +98,2 @@ module.exports = app => {

const data = await this.ctx.model.role.prepareData(item);
data.id = key.itemId;
if (item.atomName) data.roleName = item.atomName;

@@ -101,0 +100,0 @@ await this.ctx.model.role.update(data);

@@ -71,3 +71,2 @@ module.exports = app => {

const data = await this.ctx.model.user.prepareData(item);
data.id = key.itemId;
if (item.atomName) data.userName = item.atomName;

@@ -74,0 +73,0 @@ await this.ctx.model.user.update(data);

@@ -6,5 +6,25 @@ const atom_0 = require('./bean.atom/bean.atom_0.js');

const atom_areaScope = require('./bean.atom/bean.atom_areaScope.js');
const atom_draft = require('./bean.atom/bean.atom_draft.js');
const atom_formal = require('./bean.atom/bean.atom_formal.js');
const atom_simple = require('./bean.atom/bean.atom_simple.js');
const atom_submit = require('./bean.atom/bean.atom_submit.js');
const atom_checkRightAction = require('./bean.atom/bean.atom_checkRightAction.js');
module.exports = ctx => {
return ctx.app.meta.util.mixinClasses(atom_0, [atom_1, atom_right, atom_starLabel, atom_areaScope], ctx);
return ctx.app.meta.util.mixinClasses(
atom_0,
[
//
atom_1,
atom_right,
atom_starLabel,
atom_areaScope,
atom_draft,
atom_formal,
atom_simple,
atom_submit,
atom_checkRightAction,
],
ctx
);
};

@@ -51,4 +51,7 @@ const require3 = require('require3');

// create
async create({ atomClass, atomStage, roleIdOwner, item, options, user }) {
async create({ atomClass, atomStage, roleIdOwner, item, options, createOptions, user }) {
options = options || {};
if (createOptions) {
options.createOptions = createOptions;
}
// atomClass

@@ -215,3 +218,4 @@ atomClass = await ctx.bean.atomClass.get(atomClass);

const _atomBasic = await this.modelAtom.get({ id: key.atomId });
if (_atomBasic.atomStage !== _atomBasic.atomSimple) ctx.throw(403);
// support formal flow
// if (_atomBasic.atomStage !== _atomBasic.atomSimple) ctx.throw(403);
if (_atomBasic.atomSimple) {

@@ -235,3 +239,3 @@ if (_atomClass.history !== false) {

atomSimple: _atomBasic.atomSimple,
atomStage: _atomBasic.atomSimple ? 1 : 0,
atomStage: _atomBasic.atomSimple ? 1 : _atomBasic.atomStage,
});

@@ -328,109 +332,2 @@ await ctx.meta.util.executeBean({

async submit({ key, options, user }) {
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId: key.atomId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
if (!key.itemId) key.itemId = atomClass.itemId;
// atom
const _atom = await this.modelAtom.get({ id: key.atomId });
if (_atom.atomSimple === 1 && _atom.atomStage === 1) {
// if simple, just return formal, so as for compatible with not simple
return { formal: { key } };
}
// atom bean
const _moduleInfo = mparse.parseInfo(atomClass.module);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
const beanFullName = `${_moduleInfo.relativeName}.atom.${_atomClass.bean}`;
return await ctx.meta.util.executeBean({
beanModule: _moduleInfo.relativeName,
beanFullName,
context: { atomClass, key, options, user },
fn: 'submit',
});
}
async closeDraft({ key }) {
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId: key.atomId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
if (!key.itemId) key.itemId = atomClass.itemId;
// atom bean
const _moduleInfo = mparse.parseInfo(atomClass.module);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
const beanFullName = `${_moduleInfo.relativeName}.atom.${_atomClass.bean}`;
// draft
const atomIdDraft = key.atomId;
const atomDraft = await this.modelAtom.get({ id: atomIdDraft });
const user = { id: atomDraft.userIdUpdated };
// ** update draft from formal
if (atomDraft.atomIdFormal) {
await this._copy({
target: 'draft',
srcKey: { atomId: atomDraft.atomIdFormal },
srcItem: null,
destKey: key,
user,
});
// update atomClosed
await this.modelAtom.update({
id: atomIdDraft,
atomClosed: 1,
});
} else {
// not delete draft if atomFlowId>0
if (atomDraft.atomFlowId > 0) {
// update atomClosed
await this.modelAtom.update({
id: atomIdDraft,
atomClosed: 1,
atomRevision: atomDraft.atomRevision - 1,
});
} else {
// delete
await ctx.meta.util.executeBean({
beanModule: _moduleInfo.relativeName,
beanFullName,
context: { atomClass, key, user },
fn: 'delete',
});
}
}
// notify
this._notifyDraftsDrafting(user, atomClass);
this._notifyDraftsFlowing(user, atomClass);
}
async openDraft({ key, user }) {
// atomClass
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId: key.atomId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
// atom
let atom = await this.modelAtom.get({ id: key.atomId });
if (!atom) ctx.throw.module(moduleInfo.relativeName, 1002);
// check simple switch
atom = await this._checkSimpleSwitch({ atomClass, _atomClass, atom, user });
// open draft
let res;
if (atom.atomSimple) {
// simple
res = await this._openDraft_asSimple({ atomClass, _atomClass, atom, user });
} else {
// not simple
res = await this._openDraft_asSimpleZero({ atomClass, _atomClass, atom, user });
}
// ok
// get atom
const resData = res.draft || res.formal;
const keyDraft = resData.key;
atom = await this.modelAtom.get({ id: keyDraft.atomId });
atom.atomId = atom.id;
atom.module = atomClass.module;
atom.atomClassName = atomClass.atomClassName;
if (res.draft) {
res.draft.atom = atom;
} else {
res.formal.atom = atom;
}
return res;
}
async enable({ key, user }) {

@@ -589,2 +486,9 @@ // atomClass

async atomState({ key, atom: { atomState } }) {
await this.modelAtom.update({
id: key.atomId,
atomState,
});
}
async readCount({ key, atom: { readCount = 1 }, user }) {

@@ -591,0 +495,0 @@ await this.modelAtom.query('update aAtom set readCount = readCount + ? where iid=? and id=?', [

@@ -22,297 +22,3 @@ const require3 = require('require3');

async _submitDirect({ key, item, options, user }) {
// atomClass
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId: key.atomId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
// formal -> history
if (item.atomIdFormal) {
if (_atomClass.history !== false) {
await this._copy({
target: 'history',
srcKey: { atomId: item.atomIdFormal },
srcItem: null,
destKey: null,
options,
user,
});
}
}
// draft -> formal
const keyFormal = await this._copy({
target: 'formal',
srcKey: { atomId: item.atomId },
srcItem: item,
destKey: item.atomIdFormal ? { atomId: item.atomIdFormal } : null,
options,
user,
});
// update draft
await this.modelAtom.update({
id: item.atomId,
atomClosed: 1,
atomIdFormal: keyFormal.atomId,
});
// notify
this._notifyDraftsDrafting(user, atomClass);
if (item.atomFlowId > 0) {
this._notifyDraftsFlowing(user, atomClass);
}
// get formal atom
const atomFormal = await this.modelAtom.get({ id: keyFormal.atomId });
atomFormal.atomId = atomFormal.id;
atomFormal.module = atomClass.module;
atomFormal.atomClassName = atomClass.atomClassName;
// return keyFormal
return { formal: { key: keyFormal, atom: atomFormal } };
}
async _switchToSimple({ atomClass, _atomClass, atom, user }) {
let atomIdDraft;
let atomIdFormal;
if (atom.atomStage === 0) {
// is draft
atomIdDraft = atom.id;
atomIdFormal = atom.atomIdFormal;
if (!atomIdFormal) {
// formal/history not exists, so copy it
// create formal
const srcItem = await ctx.bean.atom.read({ key: { atomId: atomIdDraft }, user });
srcItem.atomSimple = 1; // important
const keyFormal = await this._copy({
target: 'formal',
srcKey: { atomId: atomIdDraft },
srcItem,
destKey: null,
options: null,
user,
});
atomIdFormal = keyFormal.atomId;
}
} else {
// is formal/history
atomIdDraft = atom.atomIdDraft;
atomIdFormal = atom.atomStage === 1 ? atom.id : atom.atomIdFormal;
}
// update history
await ctx.model.query(
`
update aAtom set atomSimple=1, atomIdDraft=0
where iid=? and deleted=0 and atomStage=2 and atomIdFormal=?
`,
[ctx.instance.id, atomIdFormal]
);
// update formal
await this.modelAtom.update({
id: atomIdFormal,
atomSimple: 1,
atomIdDraft: 0,
});
// delete draft
if (atomIdDraft) {
const atomDraft = atom.atomStage === 0 ? atom : await this.modelAtom.get({ id: atomIdDraft });
const keyDraft = { atomId: atomDraft.id, itemId: atomDraft.itemId };
const _moduleInfo = mparse.parseInfo(atomClass.module);
const beanFullName = `${_moduleInfo.relativeName}.atom.${_atomClass.bean}`;
await ctx.meta.util.executeBean({
beanModule: _moduleInfo.relativeName,
beanFullName,
context: { atomClass, key: keyDraft, user },
fn: 'delete',
});
// notify to change draft stats
this._notifyDraftsDrafting(null, atomClass);
}
// ok
if (atom.atomStage === 0) {
// fetch formal
return await this.modelAtom.get({ id: atomIdFormal });
}
atom.atomSimple = 1;
return atom;
}
async _switchToSimpleZero({ /* atomClass, _atomClass,*/ atom, user }) {
const atomIdFormal = atom.atomStage === 1 ? atom.id : atom.atomIdFormal;
// update history's atomSimple
await ctx.model.query(
`
update aAtom set atomSimple=0
where iid=? and deleted=0 and atomStage=2 and atomIdFormal=?
`,
[ctx.instance.id, atomIdFormal]
);
// update formal's atomSimple
await this.modelAtom.update({
id: atomIdFormal,
atomSimple: 0,
});
// ** create draft from formal
const keyDraft = await this._createDraftFromFormal({ atomIdFormal, user });
// update draft's atomClosed
await this.modelAtom.update({
id: keyDraft.atomId,
atomClosed: 1,
});
// ok
atom.atomSimple = 0;
return atom;
}
async _checkSimpleSwitch({ atomClass, _atomClass, atom, user }) {
// the same mode
if (Boolean(atom.atomSimple) === Boolean(_atomClass.simple)) return atom;
// -> simple
if (_atomClass.simple) {
return await this._switchToSimple({ atomClass, _atomClass, atom, user });
}
// -> not simple
return await this._switchToSimpleZero({ atomClass, _atomClass, atom, user });
}
async _createDraftFromFormal({ atomIdFormal, user }) {
// ** create draft from formal
const keyDraft = await this._copy({
target: 'draft',
srcKey: { atomId: atomIdFormal },
srcItem: null,
destKey: null,
user,
});
// update history
await ctx.model.query(
`
update aAtom set atomIdDraft=?
where iid=? and deleted=0 and atomStage=2 and atomIdFormal=?
`,
[keyDraft.atomId, ctx.instance.id, atomIdFormal]
);
// update formal
await this.modelAtom.update({
id: atomIdFormal,
atomIdDraft: keyDraft.atomId,
});
// ok
return keyDraft;
}
async _openDraft_asSimple({ atom, user }) {
let keyFormal;
let changed = true;
// formal
if (atom.atomStage === 1) {
keyFormal = { atomId: atom.id, itemId: atom.itemId };
changed = false;
}
// history
if (atom.atomStage === 2) {
const atomIdFormal = atom.atomIdFormal;
keyFormal = { atomId: atomIdFormal };
// ** create formal from history
keyFormal = await this._copy({
target: 'formal',
srcKey: { atomId: atom.id },
srcItem: null,
destKey: keyFormal,
user,
});
// update formal
await this.modelAtom.update({
id: atomIdFormal,
userIdUpdated: user.id,
});
}
// ok
return { formal: { key: keyFormal }, changed };
}
async _openDraft_asSimpleZero({ /* atomClass, _atomClass,*/ atom, user }) {
let keyDraft;
let changed = true;
// draft
if (atom.atomStage === 0) {
keyDraft = { atomId: atom.id, itemId: atom.itemId };
if (atom.atomClosed === 1) {
// open
await this._openDraft_update({
atomId: atom.id,
atomRevision: atom.atomRevision + 1,
user,
});
} else {
changed = false;
}
}
// formal
if (atom.atomStage === 1) {
if (atom.atomIdDraft > 0) {
keyDraft = { atomId: atom.atomIdDraft };
} else {
// ** create draft from formal
keyDraft = await this._createDraftFromFormal({ atomIdFormal: atom.id, user });
}
// open
await this._openDraft_update({
atomId: keyDraft.atomId,
atomRevision: atom.atomRevision + 1,
user,
});
}
// history
if (atom.atomStage === 2) {
if (atom.atomIdDraft > 0) {
keyDraft = { atomId: atom.atomIdDraft };
} else {
// ** create draft from formal
keyDraft = await this._createDraftFromFormal({ atomIdFormal: atom.atomIdFormal, user });
}
// hold atomRevision
const atomDraft = await this.modelAtom.get({ id: keyDraft.atomId });
const atomRevision = atomDraft.atomRevision;
// ** create draft from history
keyDraft = await this._copy({
target: 'draft',
srcKey: { atomId: atom.id },
srcItem: null,
destKey: keyDraft,
user,
});
// open
await this._openDraft_update({
atomId: keyDraft.atomId,
atomRevision: atomRevision + 1,
user,
});
}
// ok
return { draft: { key: keyDraft }, changed };
}
async _openDraft_update({ atomId, atomRevision, user }) {
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId });
await this.modelAtom.update({
id: atomId,
atomFlowId: 0,
atomClosed: 0,
atomRevision,
userIdUpdated: user.id,
});
// notify
this._notifyDraftsDrafting(null, atomClass);
}
// target: draft/formal/history/clone
async _copy({ target, srcKey, srcItem, destKey, options, user }) {
// atomClass
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId: srcKey.atomId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
if (!srcKey.itemId) srcKey.itemId = atomClass.itemId;
// atom bean
const _moduleInfo = mparse.parseInfo(atomClass.module);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
const beanFullName = `${_moduleInfo.relativeName}.atom.${_atomClass.bean}`;
// srcItem
if (!srcItem) {
srcItem = await ctx.bean.atom.read({ key: { atomId: srcKey.atomId }, user });
}
_copy_prepareDestItem({ target, srcItem, user }) {
// atomSimple

@@ -323,3 +29,3 @@ const atomSimple = srcItem.atomSimple;

if (atomStage === undefined) {
atomStage = atomSimple; // support simple
atomStage = atomSimple; // support simple when target='clone'
}

@@ -329,10 +35,2 @@ // if (target === 'clone') {

// }
// destKey
if (!destKey) {
destKey = await this.create({ atomClass, atomStage, roleIdOwner: srcItem.roleIdOwner, item: null, user });
}
if (!destKey.itemId) {
const _item = await this.modelAtom.get({ id: destKey.atomId });
destKey.itemId = _item.itemId;
}
// atomClosed

@@ -357,3 +55,3 @@ const atomClosed = 0;

userIdUpdated = user.id;
atomFlowId = 0;
atomFlowId = 0; // will start a new flow instance
// formal->draft: = srcItem.atomRevision

@@ -396,4 +94,4 @@ if (srcItem.atomStage === 2) {

const destItem = Object.assign({}, srcItem, {
atomId: destKey.atomId,
itemId: destKey.itemId,
// atomId: destKey.atomId,
// itemId: destKey.itemId,
userIdCreated,

@@ -419,4 +117,41 @@ userIdUpdated,

});
return destItem;
}
// target: draft/formal/history/clone
async _copy({ target, srcKey, srcItem, destKey, options, user }) {
// atomClass
const atomClass = await ctx.bean.atomClass.getByAtomId({ atomId: srcKey.atomId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
if (!srcKey.itemId) srcKey.itemId = atomClass.itemId;
// atom bean
const _moduleInfo = mparse.parseInfo(atomClass.module);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
const beanFullName = `${_moduleInfo.relativeName}.atom.${_atomClass.bean}`;
// srcItem
if (!srcItem) {
srcItem = await ctx.bean.atom.read({ key: { atomId: srcKey.atomId }, user: null });
}
// destItem
const destItem = this._copy_prepareDestItem({ target, srcItem, user });
// destKey
if (!destKey) {
destKey = await this.create({
atomClass,
atomStage: destItem.atomStage,
roleIdOwner: srcItem.roleIdOwner,
item: null,
createOptions: { target, srcItem, destItem },
user,
});
}
if (!destKey.itemId) {
const _item = await this.modelAtom.get({ id: destKey.atomId });
destKey.itemId = _item.itemId;
}
// append destKey
destItem.atomId = destKey.atomId;
destItem.itemId = destKey.itemId;
// update fields
await this.modelAtom.update({
const data = {
id: destItem.atomId,

@@ -436,5 +171,5 @@ userIdCreated: destItem.userIdCreated,

atomStage: destItem.atomStage,
atomFlowId: destItem.atomFlowId,
// atomFlowId: destItem.atomFlowId,
attachmentCount: destItem.attachmentCount,
atomClosed: destItem.atomClosed,
// atomClosed: destItem.atomClosed,
atomIdDraft: destItem.atomIdDraft,

@@ -444,3 +179,8 @@ atomIdFormal: destItem.atomIdFormal,

updatedAt: destItem.updatedAt,
});
};
if (target === 'draft' || target === 'clone') {
data.atomClosed = destItem.atomClosed;
data.atomFlowId = destItem.atomFlowId;
}
await this.modelAtom.update(data);
// bean write

@@ -687,98 +427,2 @@ await ctx.meta.util.executeBean({

async _checkRightAction({ atom, action, stage, user, checkFlow }) {
const _atom = atom;
if (!_atom) ctx.throw.module(moduleInfo.relativeName, 1002);
// adjust for simple
if (stage === 'draft' && _atom.atomSimple === 1) stage = 'formal';
if (
(stage === 'draft' && _atom.atomStage > 0) ||
((stage === 'formal' || stage === 'history') && _atom.atomStage === 0)
) {
return null;
}
// action.stage
const atomClass = await ctx.bean.atomClass.get({ id: _atom.atomClassId });
const actionBase = ctx.bean.base.action({
module: atomClass.module,
atomClassName: atomClass.atomClassName,
code: action,
});
// if (!actionBase) throw new Error(`action not found: ${atomClass.module}:${atomClass.atomClassName}:${action}`);
if (!actionBase) {
await ctx.bean.atomAction.model.delete({ atomClassId: atomClass.id, code: action });
return null;
}
if (actionBase.stage) {
const stages = actionBase.stage.split(',');
if (!stages.some(item => ctx.constant.module(moduleInfo.relativeName).atom.stage[item] === _atom.atomStage)) {
return null;
}
}
// actionBase.enableOnStatic
if (_atom.atomStatic === 1 && !actionBase.enableOnStatic) {
return null;
}
// draft
if (_atom.atomStage === 0) {
// self
const bSelf = _atom.userIdUpdated === user.id;
// checkFlow
if (_atom.atomFlowId > 0 && checkFlow) {
const flow = await ctx.bean.flow.get({ flowId: _atom.atomFlowId, history: true, user });
if (!flow) return null;
return _atom;
}
// 1. closed
if (_atom.atomClosed) {
// enable on 'self and write', not including 'delete'
if (bSelf && action === 3) {
// return _atom;
if (_atom.atomIdFormal) {
const _atomFormal = await this.modelAtom.get({ id: _atom.atomIdFormal });
return await this._checkRightAction({ atom: _atomFormal, action, stage: 'formal', user, checkFlow });
}
}
return null;
}
// 2. flow
if (_atom.atomFlowId > 0) return null;
// 3. self
if (bSelf) return _atom;
// others
return null;
}
// draft: must closed
let _atomDraft;
if (_atom.atomIdDraft) {
_atomDraft = await this.modelAtom.get({ id: _atom.atomIdDraft });
}
// check draft for ( action 3 + atomStage 1)
// not handle for history
if (
action === 3 &&
_atom.atomStage === 1 &&
_atomDraft &&
!_atomDraft.atomClosed &&
_atomDraft.userIdUpdated === user.id
) {
return await this._checkRightAction({ atom: _atomDraft, action, stage: 'draft', user, checkFlow });
}
// check enableOnOpened
if (_atomDraft && !_atomDraft.atomClosed && !actionBase.enableOnOpened) return null;
// enable/disable
if (action === 6 && _atom.atomDisabled === 0) return null;
if (action === 7 && _atom.atomDisabled === 1) return null;
// forAtomUser
const forAtomUser = this._checkForAtomUser(atomClass);
// check formal/history
const sql = this.sqlProcedure.checkRightAction({
iid: ctx.instance.id,
userIdWho: user.id,
atomId: atom.id,
action,
forAtomUser,
});
return await ctx.model.queryOne(sql);
}
async __checkRightActionBulk({ actionRes, stage /* user*/ }) {

@@ -794,3 +438,5 @@ // not care about stage

if (!actionBase) {
await ctx.bean.atomAction.model.delete({ atomClassId: actionRes.atomClassId, code: actionRes.code });
if (actionRes.code < 10000) {
await ctx.bean.atomAction.delete({ atomClassId: actionRes.atomClassId, code: actionRes.code });
}
return null;

@@ -797,0 +443,0 @@ }

@@ -1,4 +0,1 @@

const require3 = require('require3');
const mparse = require3('egg-born-mparse').default;
module.exports = ctx => {

@@ -83,39 +80,2 @@ const moduleInfo = ctx.app.meta.mockUtil.parseInfoFromPackage(__dirname);

async checkRightAction({ atom: { id }, action, stage, user, checkFlow, disableAuthOpenCheck }) {
const _atom = await this.modelAtom.get({ id });
if (!_atom) ctx.throw.module(moduleInfo.relativeName, 1002);
// atomClass
const atomClass = await ctx.bean.atomClass.get({ id: _atom.atomClassId });
if (!atomClass) ctx.throw.module(moduleInfo.relativeName, 1002);
// normal check
const res = await this._checkRightAction_normal({ _atom, atomClass, action, stage, user, checkFlow });
if (!res) return res;
// auth open check
if (!disableAuthOpenCheck) {
const resAuthOpenCheck = await ctx.bean.authOpen.checkRightAtomAction({ atomClass, action });
if (!resAuthOpenCheck) return null;
}
// ok
return res;
}
async _checkRightAction_normal({ _atom, atomClass, action, stage, user, checkFlow }) {
// atom bean
const _moduleInfo = mparse.parseInfo(atomClass.module);
const _atomClass = await ctx.bean.atomClass.atomClass(atomClass);
// parse action code
action = ctx.bean.atomAction.parseActionCode({
action,
atomClass,
});
// check right
const beanFullName = `${_moduleInfo.relativeName}.atom.${_atomClass.bean}`;
return await ctx.meta.util.executeBean({
beanModule: _moduleInfo.relativeName,
beanFullName,
context: { atom: _atom, atomClass, action, stage, user, checkFlow },
fn: 'checkRightAction',
});
}
// atomClass: { id, module, atomClassName, atomClassIdParent = 0 }

@@ -197,3 +157,8 @@ async checkRightActionBulk({ atomClass, action, stage, user }) {

const res = await this.checkRightAction({ atom: { id: key.atomId }, action: action.code, user });
if (res) actionsRes.push(action);
if (res) {
if (res.__task) {
action.__task = res.__task;
}
actionsRes.push(action);
}
}

@@ -200,0 +165,0 @@ return actionsRes;

@@ -0,69 +1,12 @@

const atomAction_base = require('./bean.atomAction/bean.atomAction_base.js');
const atomAction_flow = require('./bean.atomAction/bean.atomAction_flow.js');
module.exports = ctx => {
const moduleInfo = ctx.app.meta.mockUtil.parseInfoFromPackage(__dirname);
class AtomAction extends ctx.app.meta.BeanModuleBase {
constructor(moduleName) {
super(ctx, 'atomAction');
this.moduleName = moduleName || ctx.module.info.relativeName;
}
get model() {
return ctx.model.module(moduleInfo.relativeName).atomAction;
}
async get({ id, atomClassId, code }) {
const data = id ? { id } : { atomClassId, code };
const res = await this.model.get(data);
if (res) return res;
// lock
return await ctx.meta.util.lock({
resource: `${moduleInfo.relativeName}.atomAction.register`,
fn: async () => {
return await ctx.meta.util.executeBeanIsolate({
beanModule: moduleInfo.relativeName,
beanFullName: 'atomAction',
context: { atomClassId, code },
fn: '_registerLock',
});
},
});
}
parseActionCode({ action, atomClass }) {
// is number
if (!isNaN(action)) return parseInt(action);
// add role right
const actionCode = ctx.constant.module('a-base').atom.action[action];
if (actionCode) return actionCode;
// atomClass
if (!atomClass) throw new Error(`should specify the atomClass of action: ${action}`);
const actions = ctx.bean.base.actions();
const _action = actions[atomClass.module][atomClass.atomClassName][action];
if (!_action) throw new Error(`atom action not found: ${atomClass.module}:${atomClass.atomClassName}.${action}`);
return _action.code;
}
async _registerLock({ atomClassId, code }) {
return await this._registerLock_inner({ atomClassId, code });
}
async _registerLock_inner({ atomClassId, code }) {
// get
const res = await this.model.get({ atomClassId, code });
if (res) return res;
const atomClass = await ctx.bean.atomClass.get({ id: atomClassId });
const action = ctx.bean.base.action({ module: atomClass.module, atomClassName: atomClass.atomClassName, code });
const data = {
atomClassId,
code,
name: action.name,
bulk: action.bulk || 0,
};
// insert
const res2 = await this.model.insert(data);
data.id = res2.insertId;
return data;
}
}
return AtomAction;
return ctx.app.meta.util.mixinClasses(
atomAction_base,
[
atomAction_flow, //
],
ctx
);
};
const atomBase_0 = require('./bean.atomBase/bean.atomBase_0.js');
const atomBase_1 = require('./bean.atomBase/bean.atomBase_1.js');
const atomBase_read = require('./bean.atomBase/bean.atomBase_read.js');
const atomBase_write = require('./bean.atomBase/bean.atomBase_write.js');
module.exports = app => {
return app.meta.util.mixinClasses(atomBase_0, atomBase_1, app);
return app.meta.util.mixinClasses(
atomBase_0,
[
//
atomBase_1,
atomBase_read,
atomBase_write,
],
app
);
};

@@ -9,3 +9,3 @@ const require3 = require('require3');

// atomClass
const _atomClass = await this.ctx.bean.atomClass.atomClass(atomClass);
const atomClassBase = await this.ctx.bean.atomClass.atomClass(atomClass);
// atomName

@@ -27,3 +27,3 @@ if (!item.atomName) {

// atomSimple
if (_atomClass.simple) {
if (atomClassBase.simple) {
item.atomSimple = 1;

@@ -67,26 +67,2 @@ item.atomStage = 1;

async read({ atomClass, options, key, user }) {
// get
const item = await this.ctx.bean.atom._get({ atomClass, options, key, mode: 'full', user });
if (!item) return item;
// atomClass
const _atomClass = await this.ctx.bean.atomClass.atomClass(atomClass);
// dict translate
await this._dictTranslate({ item, _atomClass });
// revision
this._appendRevisionToHistory({ item });
// flow
if (item.flowNodeNameCurrent) {
item.flowNodeNameCurrentLocale = this.ctx.text(item.flowNodeNameCurrent);
}
// atomLanguage
if (item.atomLanguage) {
item.atomLanguageLocale = this.ctx.text(item.atomLanguage);
}
// atomDisabled
await this._atomDisabledTranslate({ atomClass, item });
// ok
return item;
}
async selectBefore(/* { atomClass, options, user }*/) {

@@ -99,7 +75,7 @@ // donothing

// atomClass
const _atomClass = atomClass ? await this.ctx.bean.atomClass.atomClass(atomClass) : null;
const atomClassBase = atomClass ? await this.ctx.bean.atomClass.atomClass(atomClass) : null;
// dict translate
if (_atomClass) {
if (atomClassBase) {
for (const item of items) {
await this._dictTranslate({ item, _atomClass });
await this._dictTranslate({ item, atomClassBase });
}

@@ -128,2 +104,13 @@ }

}
// atomState
for (const item of items) {
const atomState = item.atomState;
if (atomState !== undefined && atomState !== null) {
await this._atomStateTranslate({ item });
}
}
// userIds
if (atomClassBase) {
await this._userIdsTranslate({ items, atomClassBase });
}
}

@@ -133,4 +120,4 @@

// atomClass
const _atomClass = await this.ctx.bean.atomClass.atomClass(atomClass);
if (_atomClass.tag) {
const atomClassBase = await this.ctx.bean.atomClass.atomClass(atomClass);
if (atomClassBase.tag) {
const _atomOld = await this.ctx.bean.atom.modelAtom.get({ id: key.atomId });

@@ -154,71 +141,6 @@ if (_atomOld.atomTags) {

async write({ atomClass, target, key, item, options, user }) {
if (!item) return;
// force delete atomDisabled
delete item.atomDisabled;
// simple/stage
const atomSimple = item.atomSimple;
const atomStage = item.atomStage;
// atomClass
const _atomClass = await this.ctx.bean.atomClass.atomClass(atomClass);
let _atomOld;
if (_atomClass.tag && item.atomTags !== undefined && atomStage === 1) {
_atomOld = await this.ctx.bean.atom.modelAtom.get({ id: key.atomId });
}
// validate
const ignoreValidate = options && options.ignoreValidate;
if (
((atomSimple === 0 && atomStage === 0) || (atomSimple === 1 && atomStage === 1)) &&
!target &&
!ignoreValidate
) {
this.ctx.bean.util.setProperty(this.ctx, 'meta.validateHost', {
atomClass,
key,
options,
user,
});
await this.ctx.bean.validation._validate({ atomClass, data: item, options, filterOptions: true });
this.ctx.bean.util.setProperty(this.ctx, 'meta.validateHost', null);
}
// --- item is filtered by validation
// write atom
await this._writeAtom({ key, item, user, atomSimple, atomStage });
// tag
if (_atomClass.tag && item.atomTags !== undefined) {
await this.ctx.bean.tag.updateTagRefs({ atomId: key.atomId, atomTags: item.atomTags });
if (atomStage === 1) {
await this.ctx.bean.tag.setTagAtomCount({ tagsNew: item.atomTags, tagsOld: _atomOld.atomTags });
}
}
// handle resource
await this._writeHandleResource({ _atomClass, key, item });
// remove fields.custom
const fieldsCustom = _atomClass.fields && _atomClass.fields.custom;
if (fieldsCustom) {
for (const field of fieldsCustom) {
delete item[field];
}
}
async submit({ atomClass, key, options, user }) {
return await this.ctx.bean.atom._submitBase({ atomClass, key, options, user });
}
async submit({ /* atomClass,*/ key, options, user }) {
const ignoreFlow = options && options.ignoreFlow;
const _atom = await this.ctx.bean.atom.read({ key, user });
if (_atom.atomStage > 0) this.ctx.throw(403);
// check atom flow
if (!ignoreFlow) {
const _nodeBaseBean = this.ctx.bean._newBean('a-flowtask.flow.node.startEventAtom');
const flowInstance = await _nodeBaseBean._match({ atom: _atom, userId: _atom.userIdUpdated });
if (flowInstance) {
// set atom flow
const atomFlowId = flowInstance.context._flowId;
await this.ctx.bean.atom.flow({ key, atom: { atomFlowId } });
// ok
return { flow: { id: atomFlowId } };
}
}
return await this.ctx.bean.atom._submitDirect({ key, item: _atom, options, user });
}
async enable({ /* atomClass,*/ key /* , user*/ }) {

@@ -225,0 +147,0 @@ await this.ctx.bean.atom.modelAtom.update({

@@ -1,13 +0,1 @@

// maybe modified by user
const __atomBasicFields = [
'atomName', //
'atomLanguage',
'atomCategoryId',
'atomTags',
'allowComment',
// 'atomStatic',
// 'atomStaticKey',
// 'atomRevision',
];
module.exports = app => {

@@ -20,19 +8,2 @@ const moduleInfo = app.meta.mockUtil.parseInfoFromPackage(__dirname);

async _writeAtom({ key, item, user, atomSimple, atomStage }) {
// write atom
const atom = {};
for (const field of __atomBasicFields) {
if (item[field] !== undefined) atom[field] = item[field];
}
if ((atomSimple === 0 && atomStage === 0) || (atomSimple === 1 && atomStage === 1)) {
atom.updatedAt = new Date();
}
if (atom.atomName) {
atom.atomName = atom.atomName.trim();
}
// update
atom.id = key.atomId;
await this.ctx.bean.atom._update({ atom, user });
}
_ensureItemMeta(item) {

@@ -52,4 +23,29 @@ if (!item) return null;

async _dictTranslate({ item, _atomClass }) {
const fields = _atomClass.dict && _atomClass.dict.fields;
async _atomStateTranslate({ item }) {
// atomState
const atomState = item.atomState;
if (atomState === undefined || atomState === null) return;
// atomClass
const atomClassBase = this.ctx.bean.base.atomClass({
module: item.module,
atomClassName: item.atomClassName,
});
// dictKey
const atomStage = item.atomStage === 0 ? 'draft' : item.atomStage === 1 ? 'formal' : null;
if (!atomStage) return;
const dictKey = this.ctx.bean.util.getProperty(atomClassBase, `dict.states.${atomStage}.dictKey`);
if (!dictKey) return;
// dictItem
const dictItem = await this.ctx.bean.dict.findItem({
dictKey,
code: atomState,
});
if (!dictItem) return;
// res
item._atomStateTitle = dictItem.titleFull;
item._atomStateTitleLocale = dictItem.titleLocaleFull;
}
async _dictTranslate({ item, atomClassBase }) {
const fields = atomClassBase.dict && atomClassBase.dict.fields;
for (const fieldName in fields) {

@@ -89,30 +85,2 @@ const field = fields[fieldName];

async _writeHandleResource({ _atomClass, key, item }) {
// atomId/stage
const atomId = key.atomId;
const atomStage = item.atomStage;
if (_atomClass.resource && atomStage === 1) {
// update locales
if (item.atomName) {
await this.ctx.bean.resource.setLocales({
atomId,
atomName: item.atomName,
});
}
// role
// check if any role exists
const right = await this.modelResourceRole.get({
atomId,
});
if (!right) {
// always add role of template.system when no records
const roleSystem = await this.ctx.bean.role.parseRoleName({ roleName: 'template.system' });
await this.ctx.bean.resource.addResourceRole({
atomId,
roleId: roleSystem.id,
});
}
}
}
async _atomDisabledTranslate({ atomClass, item }) {

@@ -135,2 +103,44 @@ //

}
async _userIdsTranslate({ items, item, atomClassBase }) {
// userIds
if (!atomClassBase.userIds) return;
let userIdsKey = atomClassBase.userIds;
if (!Array.isArray(userIdsKey)) {
userIdsKey = userIdsKey.split(',');
}
// items
if (item) {
items = [item];
}
// userIdsWant
const userIdsWantMap = {};
for (item of items) {
for (const userIdKey of userIdsKey) {
const userId = item[userIdKey];
if (userId) {
userIdsWantMap[userId] = true;
}
}
}
const userIdsWant = Object.keys(userIdsWantMap).map(userId => parseInt(userId));
if (userIdsWant.length === 0) return;
// select
const users = await this.ctx.bean.user.model.select({
where: {
id: userIdsWant,
},
});
// set
for (item of items) {
for (const userIdKey of userIdsKey) {
const userId = item[userIdKey];
if (!userId) continue;
const user = users.find(item => item.id === userId);
if (!user) continue;
item[`_${userIdKey}Name`] = user.userName;
item[`_${userIdKey}Avatar`] = user.avatar;
}
}
}
}

@@ -137,0 +147,0 @@

@@ -156,7 +156,12 @@ module.exports = ctx => {

`
select distinct a.action from aViewUserRightAtomClass a
where a.iid=? and a.atomClassId=? and a.userIdWho=?
`,
select distinct a.atomClassId,a.action,b.id as actionId,b.name,b.bulk,b.actionMode,c.atomName as flowDefName from aViewUserRightAtomClass a
inner join aAtomAction b on a.atomClassId=b.atomClassId and a.action=b.code
left join aAtom c on b.flowKey=c.atomStaticKey and c.atomStage=1
where a.iid=? and a.atomClassId=? and a.userIdWho=?
`,
[ctx.instance.id, atomClassId, user.id]
);
// locale
await ctx.bean.role._adjustFlowActionsLocale({ items, actionNameKey: 'name' });
// ok
return items;

@@ -163,0 +168,0 @@ }

@@ -8,2 +8,3 @@ const role_base = require('./bean.role/bean.role_base.js');

const role_users = require('./bean.role/bean.role_users.js');
const role_flow = require('./bean.role/bean.role_flow.js');

@@ -20,2 +21,3 @@ module.exports = ctx => {

role_users,
role_flow,
],

@@ -22,0 +24,0 @@ ctx

@@ -16,3 +16,3 @@ module.exports = ctx => {

roleId = _role.id;
// scope
// scope: allowed []
if (scope) {

@@ -79,2 +79,7 @@ if (typeof scope === 'string') {

async deleteRoleRightByAction({ atomClassId, action }) {
await this.modelRoleRight.delete({ atomClassId, action });
await this.modelRoleRightRef.delete({ atomClassId, action });
}
// const roleRights = [

@@ -104,21 +109,3 @@ // { roleName: 'cms-writer', action: 'create' },

// scope
let scope;
if (!roleRight.scopeNames) {
scope = 0;
} else {
scope = [];
const scopeNames = Array.isArray(roleRight.scopeNames)
? roleRight.scopeNames
: roleRight.scopeNames.split(',');
for (const scopeName of scopeNames) {
let roleScopeId;
if (typeof scopeName === 'number') {
roleScopeId = scopeName;
} else {
const roleScope = await this.parseRoleName({ roleName: scopeName, force: false });
roleScopeId = roleScope.id;
}
scope.push(roleScopeId);
}
}
const scope = await this._parseScopeNames({ scopeNames: roleRight.scopeNames });
// add role right

@@ -143,2 +130,23 @@ const actionCode = ctx.bean.atomAction.parseActionCode({

async _parseScopeNames({ scopeNames }) {
let scope;
if (!scopeNames) {
scope = 0;
} else {
scope = [];
const _scopeNames = Array.isArray(scopeNames) ? scopeNames : scopeNames.split(',');
for (const scopeName of _scopeNames) {
let roleScopeId;
if (typeof scopeName === 'number') {
roleScopeId = scopeName;
} else {
const roleScope = await this.parseRoleName({ roleName: scopeName, force: false });
roleScopeId = roleScope.id;
}
scope.push(roleScopeId);
}
}
return scope;
}
// role rights

@@ -151,5 +159,6 @@ async roleRights({ roleAtomId, roleId, page }) {

`
select a.*,b.module,b.atomClassName,c.name as actionName,c.bulk as actionBulk from aRoleRight a
left join aAtomClass b on a.atomClassId=b.id
left join aAtomAction c on a.atomClassId=c.atomClassId and a.action=c.code
select a.*,b.module,b.atomClassName,c.name as actionName,c.bulk as actionBulk,c.actionMode,d.atomName as flowDefName from aRoleRight a
inner join aAtomClass b on a.atomClassId=b.id
inner join aAtomAction c on a.atomClassId=c.atomClassId and a.action=c.code
left join aAtom d on c.flowKey=d.atomStaticKey and d.atomStage=1
where a.iid=? and a.roleId=?

@@ -165,2 +174,4 @@ order by b.module,a.atomClassId,a.action

await this._translateAreaScopeValue({ items });
// actionFlows
await this._adjustFlowActionsLocale({ items, actionNameKey: 'actionName' });
// ok

@@ -177,7 +188,8 @@ return items;

`
select d.*,d.id as roleExpandId,a.id as roleRightId,a.scope,a.areaKey,a.areaScope,b.module,b.atomClassName,c.code as actionCode,c.name as actionName,c.bulk as actionBulk,e.roleName as roleNameBase from aRoleRight a
left join aAtomClass b on a.atomClassId=b.id
left join aAtomAction c on a.atomClassId=c.atomClassId and a.action=c.code
left join aRoleExpand d on a.roleId=d.roleIdBase
left join aRole e on d.roleIdBase=e.id
select d.*,d.id as roleExpandId,a.id as roleRightId,a.scope,a.areaKey,a.areaScope,b.module,b.atomClassName,c.code as actionCode,c.name as actionName,c.bulk as actionBulk,c.actionMode,e.roleName as roleNameBase,f.atomName as flowDefName from aRoleRight a
inner join aAtomClass b on a.atomClassId=b.id
inner join aAtomAction c on a.atomClassId=c.atomClassId and a.action=c.code
inner join aRoleExpand d on a.roleId=d.roleIdBase
inner join aRole e on d.roleIdBase=e.id
left join aAtom f on c.flowKey=f.atomStaticKey and f.atomStage=1
where d.iid=? and d.roleId=?

@@ -195,2 +207,4 @@ order by b.module,a.atomClassId,a.action

await this._adjustAtomRightsLocale({ items });
// actionFlows
await this._adjustFlowActionsLocale({ items, actionNameKey: 'actionName' });
// ok

@@ -207,6 +221,7 @@ return items;

`
select a.*,b.module,b.atomClassName,c.code as actionCode,c.name as actionName,c.bulk as actionBulk,e.roleName as roleNameBase from aViewUserRightAtomClass a
left join aAtomClass b on a.atomClassId=b.id
left join aAtomAction c on a.atomClassId=c.atomClassId and a.action=c.code
left join aRole e on a.roleIdBase=e.id
select a.*,b.module,b.atomClassName,c.code as actionCode,c.name as actionName,c.bulk as actionBulk,c.actionMode,e.roleName as roleNameBase,f.atomName as flowDefName from aViewUserRightAtomClass a
inner join aAtomClass b on a.atomClassId=b.id
inner join aAtomAction c on a.atomClassId=c.atomClassId and a.action=c.code
inner join aRole e on a.roleIdBase=e.id
left join aAtom f on c.flowKey=f.atomStaticKey and f.atomStage=1
where a.iid=? and a.userIdWho=?

@@ -224,2 +239,4 @@ order by b.module,a.atomClassId,a.action

await this._adjustAtomRightsLocale({ items });
// actionFlows
await this._adjustFlowActionsLocale({ items, actionNameKey: 'actionName' });
// ok

@@ -277,2 +294,12 @@ return items;

}
// actionFlows
async _adjustFlowActionsLocale({ items, actionNameKey }) {
for (const item of items) {
if (item.actionMode === 1) {
item[`${actionNameKey}Locale`] = ctx.text(item[actionNameKey] || 'Unnamed');
item.flowDefNameLocale = ctx.text(item.flowDefName);
}
}
}
}

@@ -279,0 +306,0 @@

@@ -119,3 +119,3 @@ module.exports = ctx => {

_resourceField = ',m.atomNameLocale';
_resourceJoin = ' left join aResourceLocale m on m.atomId=a.id';
_resourceJoin = ' inner join aResourceLocale m on m.atomId=a.id';
_resourceWhere = ctx.model.format(' and a.atomDisabled=0 and m.locale=?', resourceLocale);

@@ -159,6 +159,6 @@ } else {

} else {
_selectFields = `${_itemField}
_selectFields = `${_itemField} ${_cmsField}
a.id as atomId,a.itemId,a.atomStage,a.atomFlowId,a.atomClosed,a.atomIdDraft,a.atomIdFormal,a.roleIdOwner,a.atomClassId,a.atomName,
a.atomStatic,a.atomStaticKey,a.atomRevision,a.atomLanguage,a.atomCategoryId,j.categoryName as atomCategoryName,a.atomTags,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,a.atomState,
a.allowComment,a.starCount,a.commentCount,a.attachmentCount,a.readCount,a.userIdCreated,a.userIdUpdated,a.createdAt as atomCreatedAt,a.updatedAt as atomUpdatedAt,

@@ -168,3 +168,3 @@ b.module,b.atomClassName,b.atomClassIdParent,

g2.userName as userNameUpdated,g2.avatar as avatarUpdated
${_commentField} ${_fileField} ${_resourceField} ${_cmsField}`;
${_commentField} ${_fileField} ${_resourceField}`;
}

@@ -171,0 +171,0 @@

@@ -165,6 +165,6 @@ module.exports = ctx => {

} else {
_selectFields = `${_itemField}
_selectFields = `${_itemField} ${_cmsField}
a.id as atomId,a.itemId,a.atomStage,a.atomFlowId,a.atomClosed,a.atomIdDraft,a.atomIdFormal,a.roleIdOwner,a.atomClassId,a.atomName,
a.atomStatic,a.atomStaticKey,a.atomRevision,a.atomLanguage,a.atomCategoryId,j.categoryName as atomCategoryName,a.atomTags,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,a.atomState,
a.allowComment,a.starCount,a.commentCount,a.attachmentCount,a.readCount,a.userIdCreated,a.userIdUpdated,a.createdAt as atomCreatedAt,a.updatedAt as atomUpdatedAt,

@@ -176,3 +176,2 @@ b.module,b.atomClassName,b.atomClassIdParent,

${_fileField} ${_flowField}
${_cmsField}
`;

@@ -179,0 +178,0 @@ }

@@ -150,3 +150,3 @@ module.exports = ctx => {

_resourceField = ',m.atomNameLocale';
_resourceJoin = ' left join aResourceLocale m on m.atomId=a.id';
_resourceJoin = ' inner join aResourceLocale m on m.atomId=a.id';
_resourceWhere = ctx.model.format(' and a.atomDisabled=0 and m.locale=?', resourceLocale);

@@ -198,6 +198,6 @@ } else {

} else {
_selectFields = `${_itemField}
_selectFields = `${_itemField} ${_cmsField}
a.id as atomId,a.itemId,a.atomStage,a.atomFlowId,a.atomClosed,a.atomIdDraft,a.atomIdFormal,a.roleIdOwner,a.atomClassId,a.atomName,
a.atomStatic,a.atomStaticKey,a.atomRevision,a.atomLanguage,a.atomCategoryId,j.categoryName as atomCategoryName,a.atomTags,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,a.atomState,
a.allowComment,a.starCount,a.commentCount,a.attachmentCount,a.readCount,a.userIdCreated,a.userIdUpdated,a.createdAt as atomCreatedAt,a.updatedAt as atomUpdatedAt,

@@ -207,3 +207,3 @@ b.module,b.atomClassName,b.atomClassIdParent,

g2.userName as userNameUpdated,g2.avatar as avatarUpdated
${_starField} ${_labelField} ${_commentField} ${_fileField} ${_resourceField} ${_cmsField}`;
${_starField} ${_labelField} ${_commentField} ${_fileField} ${_resourceField}`;
}

@@ -210,0 +210,0 @@

@@ -51,3 +51,3 @@ module.exports = ctx => {

_resourceField = ',m.atomNameLocale';
_resourceJoin = ' left join aResourceLocale m on m.atomId=a.id';
_resourceJoin = ' inner join aResourceLocale m on m.atomId=a.id';
// not check atomDisabled

@@ -88,6 +88,6 @@ _resourceWhere = ctx.model.format(' and m.locale=?', resourceLocale);

// sql
const _sql = `select ${_itemField}
const _sql = `select ${_itemField} ${_cmsField}
a.id as atomId,a.itemId,a.atomStage,a.atomFlowId,a.atomClosed,a.atomIdDraft,a.atomIdFormal,a.roleIdOwner,a.atomClassId,a.atomName,
a.atomStatic,a.atomStaticKey,a.atomRevision,a.atomLanguage,a.atomCategoryId,j.categoryName as atomCategoryName,a.atomTags,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,
a.atomSimple,a.atomDisabled,a.atomAreaKey,a.atomAreaValue,a.atomState,
a.allowComment,a.starCount,a.commentCount,a.attachmentCount,a.readCount,a.userIdCreated,a.userIdUpdated,a.createdAt as atomCreatedAt,a.updatedAt as atomUpdatedAt,

@@ -101,3 +101,2 @@ b.module,b.atomClassName,b.atomClassIdParent,

${_flowField}
${_cmsField}
from aAtom a

@@ -104,0 +103,0 @@

@@ -119,5 +119,5 @@ module.exports = ctx => {

if (cms) {
_cmsField = `,${
_cmsField = `${
tableName ? '' : 'p.createdAt,p.updatedAt,'
}p.sticky,p.keywords,p.description,p.summary,p.url,p.editMode,p.slug,p.sorting,p.flag,p.extra,p.imageCover,p.imageFirst,p.audioFirst,p.audioCoverFirst,p.uuid,p.renderAt`;
}p.sticky,p.keywords,p.description,p.summary,p.url,p.editMode,p.slug,p.sorting,p.flag,p.extra,p.imageCover,p.imageFirst,p.audioFirst,p.audioCoverFirst,p.uuid,p.renderAt,`;
_cmsJoin = ' inner join aCmsArticle p on p.atomId=a.id';

@@ -127,3 +127,3 @@ _cmsWhere = ` and p.iid=${iid} and p.deleted=0`;

// full/search/others
_cmsField += ',q.content,q.html';
_cmsField += 'q.content,q.html,';
_cmsJoin += ' inner join aCmsContent q on q.atomId=a.id';

@@ -130,0 +130,0 @@ _cmsWhere += ` and q.iid=${iid} and q.deleted=0`;

@@ -18,2 +18,3 @@ const VersionUpdate1Fn = require('./version/update1.js');

const VersionUpdate20Fn = require('./version/update20.js');
const VersionUpdate21Fn = require('./version/update21.js');
const VersionInit2Fn = require('./version/init2.js');

@@ -31,2 +32,6 @@ const VersionInit4Fn = require('./version/init4.js');

async update(options) {
if (options.version === 21) {
const versionUpdate21 = new (VersionUpdate21Fn(this.ctx))();
await versionUpdate21.run();
}
if (options.version === 20) {

@@ -33,0 +38,0 @@ const versionUpdate20 = new (VersionUpdate20Fn(this.ctx))();

@@ -33,3 +33,4 @@ module.exports = app => {

layout: 15,
// report: 16,
workflowFormal: 16,
// report: 17,

@@ -73,2 +74,3 @@ authorize: 25,

enableOnOpened: true,
enableOnFlowing: true,
icon: { f7: '::visibility' },

@@ -82,2 +84,5 @@ },

enableOnOpened: false,
enableOnFlowing: false,
directShowOnSwipeout: true,
directShowOnList: true,
icon: { f7: '::edit' },

@@ -91,2 +96,5 @@ },

enableOnOpened: false,
enableOnFlowing: false,
directShowOnSwipeout: true,
directShowOnList: true,
icon: { f7: '::delete' },

@@ -100,2 +108,3 @@ },

enableOnOpened: true,
enableOnFlowing: true,
icon: { f7: ':outline:copy-outline' },

@@ -109,2 +118,4 @@ },

enableOnOpened: true,
enableOnFlowing: true,
directShowOnList: true,
stage: 'formal',

@@ -119,2 +130,4 @@ icon: { f7: '::play-arrow' },

enableOnOpened: true,
enableOnFlowing: true,
directShowOnList: true,
stage: 'formal',

@@ -129,5 +142,17 @@ icon: { f7: '::stop' },

enableOnOpened: true,
disableInList: true,
enableOnFlowing: true,
disableOnList: true,
icon: { f7: '::view-list' },
},
workflowFormal: {
title: 'WorkFlow',
actionModule: moduleInfo.relativeName,
actionComponent: 'action',
enableOnStatic: true,
enableOnOpened: true,
enableOnFlowing: true,
directShowOnList: true,
stage: 'formal',
icon: { f7: '::flow-chart' },
},
authorize: {

@@ -139,2 +164,4 @@ title: 'Authorize',

enableOnOpened: true,
enableOnFlowing: true,
directShowOnList: true,
stage: 'formal',

@@ -144,3 +171,3 @@ icon: { f7: '::groups' },

deleteBulk: {
title: 'Delete',
title: 'BatchDelete',
actionModule: moduleInfo.relativeName,

@@ -147,0 +174,0 @@ actionComponent: 'actionBulk',

@@ -26,2 +26,3 @@ module.exports = {

NotImplemented: 'Not Implemented',
BatchDelete: 'Batch Delete',
'Only Valid for Formal Atom': 'Only Valid for Formal Data',

@@ -28,0 +29,0 @@ 'Atom Flag': 'Data Flag',

@@ -152,2 +152,4 @@ module.exports = {

NotImplemented: '未实现',
Unnamed: '未命名',
BatchDelete: '批量删除',
// role name

@@ -154,0 +156,0 @@ root: '根',

@@ -49,3 +49,3 @@ module.exports = app => {

atomStaticKey: 'listComment',
atomRevision: 3,
atomRevision: -1,
atomCategoryId: 'a-base:menu.Tools',

@@ -52,0 +52,0 @@ resourceType: 'a-base:menu',

@@ -94,2 +94,3 @@ module.exports = app => {

saveDraftOnly,
ignoreNotEmpty: saveDraftOnly,
};

@@ -96,0 +97,0 @@ await this.ctx.service.atom.write({

@@ -63,5 +63,2 @@ module.exports = app => {

attachment: false,
fields: {
custom: ['catalog', 'system', 'roleIdParent'],
},
dict: {

@@ -169,5 +166,5 @@ fields: {

attachment: false,
fields: {
custom: ['disabled', 'anonymous', 'activated', 'emailConfirmed', 'mobileVerified'],
},
// fields: {
// custom: ['disabled', 'anonymous', 'activated', 'emailConfirmed', 'mobileVerified'],
// },
layout: {

@@ -249,2 +246,9 @@ config: {

},
flowAction: {
bean: {
module: 'a-sequence',
name: 'simple',
},
start: 10000,
},
},

@@ -251,0 +255,0 @@ },

@@ -74,2 +74,5 @@ export default {

},
data_findItem(key) {
return this.data_callMethod('findItem', key);
},
data_getLoading() {

@@ -76,0 +79,0 @@ return this.data_callMethod('getLoading');

@@ -17,2 +17,3 @@ import ActionBase from '../../common/actionBase.js';

import ActionWorkflow from './action/actionWorkflow.js';
import ActionWorkflowFormal from './action/actionWorkflowFormal.js';
import ActionLayout from './action/actionLayout.js';

@@ -41,2 +42,3 @@

ActionWorkflow,
ActionWorkflowFormal,
ActionLayout,

@@ -77,2 +79,4 @@ ],

return await this._onActionWorkflow();
} else if (action.name === 'workflowFormal') {
return await this._onActionWorkflowFormal();
} else if (action.name === 'layout') {

@@ -79,0 +83,0 @@ return await this._onActionLayout();

@@ -13,3 +13,3 @@ export default {

for (const layout of layouts) {
const icon = layoutCurrent === layout.name ? iconDone : '<i class="icon"></i>';
const icon = layoutCurrent === layout.name ? iconDone : ctx.$meta.util.emptyIcon;
buttons.push({

@@ -16,0 +16,0 @@ icon,

@@ -30,3 +30,3 @@ export default {

for (const locale of locales) {
const icon = locale.value === current.value ? iconDone : '<i class="icon"></i>';
const icon = locale.value === current.value ? iconDone : this.$meta.util.emptyIcon;
buttons.push({

@@ -33,0 +33,0 @@ icon,

@@ -43,5 +43,9 @@ export default {

// back
ctx.page_setDirty(false); // should before navigate
ctx.$f7router.back();
} else {
if (!data.flow) {
ctx.page_setDirty(false); // should before navigate
ctx.$f7router.back();
}
}
// check if flow
if (data.flow) {
// flow

@@ -48,0 +52,0 @@ const flow = data.flow;

@@ -13,3 +13,3 @@ export default {

for (const layout of layouts) {
const icon = layoutCurrent === layout.name ? iconDone : '<i class="icon"></i>';
const icon = layoutCurrent === layout.name ? iconDone : ctx.$meta.util.emptyIcon;
buttons.push({

@@ -16,0 +16,0 @@ icon,

@@ -6,4 +6,6 @@ export default {

UserStar: 'User Star',
UserStarShort: 'Star',
UserLabel: 'User Label',
UserLabels: 'User Labels',
UserLabelsShort: 'Labels',
HeartForAtom: 'Heart',

@@ -41,2 +43,4 @@ KeyForAtom: 'Key',

SubTitle: 'Sub Title',
AtomState: 'Data State',
BatchDelete: 'Batch Delete',
'Atom Flag': 'Data Flag',

@@ -47,3 +51,4 @@ 'Atom Name': 'Title',

'Atom Class': 'Data Class',
'Atom Stage': 'Data Stage',
'My Atoms': 'My Data',
};

@@ -69,2 +69,3 @@ export default {

Selected: '已选择',
Deselect: '取消选择',
Remove: '移除',

@@ -121,4 +122,6 @@ HeartForAtom: '点赞',

UserStar: '用户星标',
UserStarShort: '星标',
UserLabel: '用户标签',
UserLabels: '用户标签',
UserLabelsShort: '标签',
Mine: '我的',

@@ -197,2 +200,8 @@ Resource: '资源',

SubTitle: '副标题',
Stage: '阶段',
AtomState: '数据状态',
More: '更多',
State: '状态',
All: '所有',
BatchDelete: '批量删除',
'Role Name': '角色名称',

@@ -220,2 +229,3 @@ 'Role Type': '角色类型',

'Atom Class': '数据类型',
'Atom Stage': '数据阶段',
'Allow Comment': '允许评论',

@@ -222,0 +232,0 @@ 'Attachment List': '附件列表',

{
"name": "egg-born-module-a-base-sync",
"version": "4.8.43",
"version": "4.8.44",
"title": "Base",
"eggBornModule": {
"fileVersion": 20,
"fileVersion": 21,
"dependencies": {

@@ -8,0 +8,0 @@ "a-instance": "4.0.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc