mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
FormBuilder split out
This commit is contained in:
parent
f1d2e0e6df
commit
34e35bd00b
@ -1,10 +1,16 @@
|
||||
"use strict";
|
||||
define(['app', 'AddSeries/AddSeriesLayout',
|
||||
define(['app',
|
||||
'Form/FormBuilder',
|
||||
'AddSeries/AddSeriesLayout',
|
||||
'Series/Index/SeriesIndexLayout',
|
||||
'Calendar/CalendarCollectionView', 'Shared/NotificationView',
|
||||
'Shared/NotFoundView', 'MainMenuView',
|
||||
'Series/Details/SeriesDetailsView', 'Series/EpisodeCollection',
|
||||
'Settings/SettingsLayout', 'Missing/MissingLayout',
|
||||
'Calendar/CalendarCollectionView',
|
||||
'Shared/NotificationView',
|
||||
'Shared/NotFoundView',
|
||||
'MainMenuView',
|
||||
'Series/Details/SeriesDetailsView',
|
||||
'Series/EpisodeCollection',
|
||||
'Settings/SettingsLayout',
|
||||
'Missing/MissingLayout',
|
||||
'History/HistoryLayout'],
|
||||
function () {
|
||||
var controller = Backbone.Marionette.Controller.extend({
|
||||
|
27
UI/Form/FormBuilder.js
Normal file
27
UI/Form/FormBuilder.js
Normal file
@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
define(['app'], function () {
|
||||
Handlebars.registerHelper('formBuilder', function (){
|
||||
var ret = "";
|
||||
_.each(this.fields, function(field){
|
||||
ret += NzbDrone.Form.FieldBuilder(field);
|
||||
});
|
||||
|
||||
return new Handlebars.SafeString(ret);
|
||||
});
|
||||
|
||||
NzbDrone.Form.FieldBuilder = 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']);
|
||||
}
|
||||
|
||||
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
|
||||
};
|
||||
});
|
@ -7,22 +7,6 @@ Handlebars.registerHelper('partial', function (templateName) {
|
||||
return new Handlebars.SafeString(templateFunction(this));
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('formField', function () {
|
||||
if (!this.type) {
|
||||
return Handlebars.helpers.partial.apply(this, ['Form/TextboxTemplate']);
|
||||
}
|
||||
|
||||
if (this.type === 'password') {
|
||||
return Handlebars.helpers.partial.apply(this, ['Form/PasswordTemplate']);
|
||||
}
|
||||
|
||||
if (this.type === 'checkbox') {
|
||||
return Handlebars.helpers.partial.apply(this, ['Form/CheckboxTemplate']);
|
||||
}
|
||||
|
||||
return Handlebars.helpers.partial.apply(this, ['Form/TextboxTemplate']);
|
||||
});
|
||||
|
||||
Handlebars.registerHelper("debug", function(optionalValue) {
|
||||
console.log("Current Context");
|
||||
console.log("====================");
|
||||
|
@ -52,9 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#each fields}}
|
||||
{{formField}}
|
||||
{{/each}}
|
||||
{{formBuilder}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
Loading…
Reference in New Issue
Block a user