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";
|
"use strict";
|
||||||
define(['app', 'AddSeries/AddSeriesLayout',
|
define(['app',
|
||||||
|
'Form/FormBuilder',
|
||||||
|
'AddSeries/AddSeriesLayout',
|
||||||
'Series/Index/SeriesIndexLayout',
|
'Series/Index/SeriesIndexLayout',
|
||||||
'Calendar/CalendarCollectionView', 'Shared/NotificationView',
|
'Calendar/CalendarCollectionView',
|
||||||
'Shared/NotFoundView', 'MainMenuView',
|
'Shared/NotificationView',
|
||||||
'Series/Details/SeriesDetailsView', 'Series/EpisodeCollection',
|
'Shared/NotFoundView',
|
||||||
'Settings/SettingsLayout', 'Missing/MissingLayout',
|
'MainMenuView',
|
||||||
|
'Series/Details/SeriesDetailsView',
|
||||||
|
'Series/EpisodeCollection',
|
||||||
|
'Settings/SettingsLayout',
|
||||||
|
'Missing/MissingLayout',
|
||||||
'History/HistoryLayout'],
|
'History/HistoryLayout'],
|
||||||
function () {
|
function () {
|
||||||
var controller = Backbone.Marionette.Controller.extend({
|
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));
|
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) {
|
Handlebars.registerHelper("debug", function(optionalValue) {
|
||||||
console.log("Current Context");
|
console.log("Current Context");
|
||||||
console.log("====================");
|
console.log("====================");
|
||||||
|
@ -52,9 +52,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#each fields}}
|
{{formBuilder}}
|
||||||
{{formField}}
|
|
||||||
{{/each}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -30,6 +30,7 @@ define('app', ['shared/modal/region'], function (ModalRegion) {
|
|||||||
|
|
||||||
window.NzbDrone = new Backbone.Marionette.Application();
|
window.NzbDrone = new Backbone.Marionette.Application();
|
||||||
window.NzbDrone.Config = {};
|
window.NzbDrone.Config = {};
|
||||||
|
window.NzbDrone.Form = {};
|
||||||
|
|
||||||
window.NzbDrone.Series = {
|
window.NzbDrone.Series = {
|
||||||
Index : {
|
Index : {
|
||||||
|
Loading…
Reference in New Issue
Block a user