mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
'use strict';
|
|
define(
|
|
[
|
|
'handlebars'
|
|
], function (Handlebars) {
|
|
|
|
var formBuilder = function (field) {
|
|
if (!field.type) {
|
|
return Handlebars.helpers.partial.apply(field,
|
|
[
|
|
'Form/TextboxTemplate'
|
|
]);
|
|
}
|
|
|
|
if (field.type === 'password') {
|
|
return Handlebars.helpers.partial.apply(field,
|
|
[
|
|
'Form/PasswordTemplate'
|
|
]);
|
|
}
|
|
|
|
if (field.type === 'checkbox') {
|
|
return Handlebars.helpers.partial.apply(field,
|
|
[
|
|
'Form/CheckboxTemplate'
|
|
]);
|
|
}
|
|
|
|
if (field.type === 'select') {
|
|
return Handlebars.helpers.partial.apply(field,
|
|
[
|
|
'Form/SelectTemplate'
|
|
]);
|
|
}
|
|
|
|
return Handlebars.helpers.partial.apply(field,
|
|
[
|
|
'Form/TextboxTemplate'
|
|
]);
|
|
};
|
|
|
|
Handlebars.registerHelper('formBuilder', function () {
|
|
var ret = '';
|
|
_.each(this.fields, function (field) {
|
|
ret += this.FieldBuilder(field);
|
|
});
|
|
|
|
return new Handlebars.SafeString(ret);
|
|
});
|
|
});
|