2
0
Fork 0
tcrud/lib/default/default-tview.js
2017-06-10 16:53:29 +02:00

39 lines
1 KiB
JavaScript

module.exports = (function () {
var addFilteredFields = function(tview,type,tcrud) {
//debug('addFilterFields of: '+type+' from: '+tview.tid);
result = [];
var keys = Object.keys(tcrud.tmeta.tfields);
var result = [];
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var tfield = tcrud.tmeta.tfields[key];
if (tfield[type]) {
if (!tfield[type].tenable) {
continue;
}
}
result.push(key); // default is true..
}
tview[type].tfields = result;
};
return function DefaultTViewPlugin() {
this.configPlugin = function (ctx) {
ctx.key = 'defaultTView';
ctx.description = 'Add copy template for building the tview from the tentity.';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'default-tview.json';
};
this.fillTView = function(ctx) {
addFilteredFields(ctx.tview,'tlist',ctx.tentity);
addFilteredFields(ctx.tview,'tread',ctx.tentity);
addFilteredFields(ctx.tview,'tedit',ctx.tentity);
addFilteredFields(ctx.tview,'tcreate',ctx.tentity);
};
};
})();