2
0
Fork 0
tcrud/lib/default/default-tfield.js

33 lines
763 B
JavaScript
Raw Normal View History

2017-06-10 14:53:29 +00:00
module.exports = (function () {
return function DefaultTFieldPlugin() {
this.configPlugin = function (ctx) {
ctx.key = 'defaultTField';
ctx.description = 'Adds the basic data and structure of the tfield.';
ctx.localDir = __dirname;
ctx.localConfigTemplate = 'default-tfield.json';
};
this.fillTField = function(ctx) {
if (ctx.tfield === undefined) {
throw new Error('no tfield');
}
if (ctx.tfield.tid === undefined) {
throw new Error('no tfield.tid');
}
if (ctx.tfield.tid === null) {
throw new Error('null tfield.tid');
}
if (ctx.tfield.tid.length === 0) {
throw new Error('empty tfield.tid');
}
if (ctx.tfield.ttype === null) {
ctx.tfield.ttype = 'text'; // move ?
}
};
};
})();