FormBuilder split out

pull/3113/head
Mark McDowall 12 years ago
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({

@ -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">

@ -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 : {

Loading…
Cancel
Save