1
0
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:
Mark McDowall 2013-05-21 20:33:35 -07:00
parent f1d2e0e6df
commit 34e35bd00b
5 changed files with 40 additions and 24 deletions

View File

@ -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
View 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']);
};
});

View File

@ -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("====================");

View File

@ -52,9 +52,7 @@
</div>
</div>
{{#each fields}}
{{formField}}
{{/each}}
{{formBuilder}}
</div>
</div>
<div class="modal-footer">

View File

@ -30,6 +30,7 @@ define('app', ['shared/modal/region'], function (ModalRegion) {
window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Config = {};
window.NzbDrone.Form = {};
window.NzbDrone.Series = {
Index : {