33 lines
763 B
JavaScript
33 lines
763 B
JavaScript
|
|
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 ?
|
|
}
|
|
};
|
|
};
|
|
})();
|
|
|