Merge and cleanup of PR #564

The namespace filter in campaigns was dropped (i.e. "Work with campaign's namespace"). Instead, we need a universal solution. For instance a namespace slector somewhere in the top-right corner, which should apply to everything (not just campaigns).

Nevertheless, I kept the ...-by-namespace rest endpoints and related functions in models because they will be useful for implementing the universal namespace selection feature.
This commit is contained in:
Tomas Bures 2019-03-27 00:41:18 +01:00
parent dcb7168322
commit 2fe7f82be3
18 changed files with 1104 additions and 1143 deletions

View file

@ -36,24 +36,28 @@ async function getById(context, id, withPermissions = true) {
});
}
async function listDTAjax(context, params) {
async function _listDTAjax(context, namespaceId, params) {
return await dtHelpers.ajaxListWithPermissions(
context,
[{ entityTypeId: 'template', requiredOperations: ['view'] }],
params,
builder => builder.from('templates').innerJoin('namespaces', 'namespaces.id', 'templates.namespace'),
builder => {
builder = builder.from('templates').innerJoin('namespaces', 'namespaces.id', 'templates.namespace');
if (namespaceId) {
builder = builder.where('namespaces.id', namespaceId);
}
return builder;
},
[ 'templates.id', 'templates.name', 'templates.description', 'templates.type', 'templates.created', 'namespaces.name' ]
);
}
async function listByNamespaceDTAjax(context, params, namespaceId) {
return await dtHelpers.ajaxListWithPermissions(
context,
[{ entityTypeId: 'template', requiredOperations: ['view'] }],
params,
builder => builder.from('templates').innerJoin('namespaces', 'namespaces.id', 'templates.namespace').where('namespaces.id', namespaceId),
[ 'templates.id', 'templates.name', 'templates.description', 'templates.type', 'templates.created', 'namespaces.name' ]
);
async function listDTAjax(context, params) {
return await _listDTAjax(context, undefined, params);
}
async function listByNamespaceDTAjax(context, namespaceId, params) {
return await _listDTAjax(context, namespaceId, params);
}
async function _validateAndPreprocess(tx, entity) {