evado-api-base
Advanced tools
Comparing version 4.5.3 to 4.5.4
@@ -35,3 +35,4 @@ /** | ||
getModelQuery (id) { | ||
return this.meta.view.createQuery(this.getSpawnConfig()).byId(id); | ||
const config = this.getSpawnConfig(); | ||
return this.meta.view.createQuery(config).byId(id); | ||
} | ||
@@ -38,0 +39,0 @@ |
@@ -52,8 +52,9 @@ /** | ||
getPageTitleData ({node, view}) { | ||
getPageTitleData ({node, report, view}) { | ||
if (node.data.label || (node.source && node.label)) { | ||
return node; | ||
} | ||
if (view?.data.label) { | ||
} else if (view?.data.label) { | ||
return view; | ||
} else if (report?.data.label) { | ||
return report; | ||
} | ||
@@ -63,3 +64,3 @@ return node; | ||
getPageDescriptionData ({node, view}) { | ||
getPageDescriptionData ({node, report, view}) { | ||
if (node.options.showDescription) { | ||
@@ -76,4 +77,6 @@ if (node instanceof DynamicNode) { | ||
return node; | ||
} else if (view.description) { | ||
} else if (view?.description) { | ||
return view; | ||
} else if (report?.description) { | ||
return report; | ||
} | ||
@@ -149,4 +152,6 @@ } | ||
for (const attr of view.attrs) { | ||
if (attr.isSortable() && !attr.isReadOnly() && names.includes(attr.name)) { | ||
result.push(attr.name); | ||
if (attr.isSortable() && !attr.isReadOnly()) { | ||
if (names.includes(attr.name)) { | ||
result.push(attr.name); | ||
} | ||
} | ||
@@ -204,3 +209,6 @@ } | ||
isHiddenAttr (attr) { | ||
return attr.isHidden() || (attr.isClassAttr() && attr.isBackRef() && !attr.isEagerLoading()); | ||
if (attr.isHidden()) { | ||
return true; | ||
} | ||
return attr.isClassAttr() && attr.isBackRef() && !attr.isEagerLoading(); | ||
} | ||
@@ -314,3 +322,7 @@ | ||
isStorageThumbnails (view) { | ||
return view.createModel({module: this.module}).createFileBehavior()?.isThumbnails(); | ||
const model = view.createModel({ | ||
module: this.module | ||
}); | ||
const behavior = model.createFileBehavior(); | ||
return behavior?.isThumbnails(); | ||
} | ||
@@ -317,0 +329,0 @@ |
@@ -36,3 +36,4 @@ /** | ||
await this.security.resolveOnList(this.meta.view); | ||
const query = this.meta.view.createQuery(this.getSpawnConfig()); | ||
const config = this.getSpawnConfig(); | ||
const query = this.meta.view.createQuery(config); | ||
const list = this.spawn('component/MetaList', { | ||
@@ -49,3 +50,4 @@ controller: this, | ||
await this.security.resolveAttrsOnList(this.meta.view); | ||
const query = this.meta.view.createQuery(this.getSpawnConfig()).withListData().withTitle(); | ||
const config = this.getSpawnConfig(); | ||
const query = this.meta.view.createQuery(config).withListData().withTitle(); | ||
await this.resolveListFilter(query); | ||
@@ -62,3 +64,4 @@ const list = this.spawn('component/MetaList', { | ||
await this.resolveListParams(); | ||
const query = this.meta.view.createQuery(this.getSpawnConfig()).withTitle(); | ||
const config = this.getSpawnConfig(); | ||
const query = this.meta.view.createQuery(config).withTitle(); | ||
await this.resolveListFilter(query); | ||
@@ -119,3 +122,4 @@ const list = this.spawn('meta/MetaSelect2', { | ||
await this.setMasterMetaParams(request.master); | ||
const model = this.meta.view.createModel(this.getSpawnConfig()); | ||
const config = this.getSpawnConfig(); | ||
const model = this.meta.view.createModel(config); | ||
await model.setDefaultValues(); | ||
@@ -129,3 +133,4 @@ this.setDefaultMasterValue(model); | ||
await security.resolveAttrsOnCreate(model); | ||
this.sendJson(model.output({security})); | ||
const data = model.output({security}); | ||
this.sendJson(data); | ||
} | ||
@@ -141,3 +146,4 @@ | ||
await this.setMasterMetaParams(request.master); | ||
const model = this.meta.view.createModel(this.getSpawnConfig()); | ||
const config = this.getSpawnConfig(); | ||
const model = this.meta.view.createModel(config); | ||
await model.setDefaultValues(); | ||
@@ -316,7 +322,8 @@ this.setDefaultMasterValue(model); | ||
} | ||
const config = this.getSpawnConfig(); | ||
if (!data.id) { | ||
master.model = master.view.createModel(this.getSpawnConfig()); | ||
master.model = master.view.createModel(config); | ||
return master; | ||
} | ||
const query = master.view.createQuery(this.getSpawnConfig()).byId(data.id); | ||
const query = master.view.createQuery(config).byId(data.id); | ||
master.model = await query.one(); | ||
@@ -333,3 +340,4 @@ if (!master.model) { | ||
if (attr?.relation && !model.has(attr)) { | ||
model.set(attr, master.model.get(attr.relation.refAttrName)); | ||
const value = master.model.get(attr.relation.refAttrName); | ||
model.set(attr, value); | ||
master.refAttr = attr; | ||
@@ -354,3 +362,4 @@ } | ||
const errors = model.getFirstErrorMap(); | ||
this.send(this.translateMessageMap(errors), Response.BAD_REQUEST); | ||
const messages = this.translateMessageMap(errors); | ||
this.send(messages, Response.BAD_REQUEST); | ||
} | ||
@@ -357,0 +366,0 @@ |
@@ -20,3 +20,4 @@ /** | ||
this.setMetaParams(); | ||
const model = this.meta.view.createModel(this.getSpawnConfig()); | ||
const config = this.getSpawnConfig(); | ||
const model = this.meta.view.createModel(config); | ||
const behavior = this.createFileBehavior(model); | ||
@@ -50,3 +51,4 @@ const raw = this.spawn(behavior.getRawClass(), { | ||
const name = behavior.getName() || model.getId(); | ||
const headers = storage.getHeaders(name, behavior.getMediaType()); | ||
const type = behavior.getMediaType(); | ||
const headers = storage.getHeaders(name, type); | ||
this.setHttpHeader(headers); | ||
@@ -79,3 +81,4 @@ this.sendFile(file); | ||
} | ||
const headers = storage.getHeaders(name, behavior.getMediaType()); | ||
const type = behavior.getMediaType(); | ||
const headers = storage.getHeaders(name, type); | ||
this.setHttpHeader(headers); | ||
@@ -88,3 +91,4 @@ this.sendFile(file); | ||
this.setMetaParams(); | ||
const model = this.meta.view.createModel(this.getSpawnConfig()); | ||
const config = this.getSpawnConfig(); | ||
const model = this.meta.view.createModel(config); | ||
const behavior = this.createFileBehavior(model); | ||
@@ -91,0 +95,0 @@ const {id} = this.getPostParams(); |
@@ -13,3 +13,4 @@ /** | ||
this.setMetaParams(); | ||
const model = this.meta.view.createModel(this.getSpawnConfig()); | ||
const config = this.getSpawnConfig(); | ||
const model = this.meta.view.createModel(config); | ||
const behavior = this.createFileBehavior(model); | ||
@@ -16,0 +17,0 @@ const raw = this.spawn(behavior.getRawClass(), { |
@@ -29,3 +29,4 @@ /** | ||
if (!await model.save()) { | ||
throw new BadRequest(model.getFirstError().toString()); | ||
const error = model.getFirstError(); | ||
throw new BadRequest(error?.toString()); | ||
} | ||
@@ -43,3 +44,4 @@ this.send('Digital signature created'); | ||
} | ||
if (!await behavior.canCreateSignature(this.createMetaSecurity())) { | ||
const security = this.createMetaSecurity(); | ||
if (!await behavior.canCreateSignature(security)) { | ||
throw new Forbidden('Creating a signature is forbidden'); | ||
@@ -46,0 +48,0 @@ } |
{ | ||
"name": "evado-api-base", | ||
"version": "4.5.3", | ||
"version": "4.5.4", | ||
"description": "Evado Framework data access API module", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -7,3 +7,3 @@ /** | ||
const {expect} = require('chai'); | ||
const MetaSelectHelper = require('../../../component/MetaSelectHelper'); | ||
const Helper = require('../../../component/MetaSelectHelper'); | ||
@@ -17,6 +17,6 @@ describe('MetaSelectHelper', ()=> { | ||
}; | ||
expect(MetaSelectHelper.getLabelText(item)).to.eql('name'); | ||
expect(Helper.getLabelText(item)).to.eql('name'); | ||
item.data.label = 'label'; | ||
expect(MetaSelectHelper.getLabelText(item)).to.eql('label (name)'); | ||
expect(Helper.getLabelText(item)).to.eql('label (name)'); | ||
}); | ||
}); |
64474
1488