module.exports = (function () { var autoFieldEnable = function(tfield,type) { if (type === undefined) { throw new Error('no type'); } if (tfield[type] === undefined) { tfield[type] = {}; // todo rm this } if (tfield[type].tenable !== null) { return; } var fieldKey = tfield.tid; var result = true; if ('tlist' === type) { var name = fieldKey.toLowerCase(); if (fieldKey.indexOf('description') >= 0) { result = false; } else if (fieldKey.indexOf('comment') >= 0) { result = false; } } tfield[type].tenable = result; } return function AutoTEnablePlugin() { this.configPlugin = function (ctx) { ctx.key='autoTEnable'; ctx.description='Auto enables to true if undefined.'; }; this.fillTEntity = function(ctx) { if (ctx.tentity.tenable === null || ctx.tentity.tenable === undefined) { ctx.tentity.tenable = true; } autoFieldEnable(ctx.tentity,'tlist'); autoFieldEnable(ctx.tentity,'tread'); autoFieldEnable(ctx.tentity,'tedit'); autoFieldEnable(ctx.tentity,'tcreate'); autoFieldEnable(ctx.tentity,'tdelete'); autoFieldEnable(ctx.tentity,'tcount'); autoFieldEnable(ctx.tentity,'tverify'); } this.fillTField = function(ctx) { autoFieldEnable(ctx.tfield,'tlist'); autoFieldEnable(ctx.tfield,'tread'); autoFieldEnable(ctx.tfield,'tedit'); autoFieldEnable(ctx.tfield,'tcreate'); } }; })();