settings is fully moved to required.

This commit is contained in:
Keivan Beigi
2013-06-18 18:02:23 -07:00
parent 73f3459264
commit 6f8c73771d
54 changed files with 533 additions and 439 deletions
+27
View File
@@ -0,0 +1,27 @@
"use strict";
define([
'app',
'marionette',
'Settings/Notifications/EditView'
], function (App, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/AddItemTemplate',
tagName : 'li',
events: {
'click': 'addNotification'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
addNotification: function () {
this.model.set('id', undefined);
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });
App.modalRegion.show(editView);
}
});
});
+7 -27
View File
@@ -1,34 +1,14 @@
"use strict";
define([
'app',
'Settings/Notifications/Model'
'marionette',
'Settings/Notifications/AddItemView'
], function (Marionette, AddItemView) {
], function () {
NzbDrone.Settings.Notifications.AddItemView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/AddItemTemplate',
tagName : 'li',
events: {
'click': 'addNotification'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
addNotification: function () {
this.model.set('id', undefined);
var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model, notificationCollection: this.notificationCollection });
NzbDrone.modalRegion.show(view);
}
});
NzbDrone.Settings.Notifications.AddView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Notifications.AddItemView,
itemViewContainer : '.notifications .items',
template : 'Settings/Notifications/AddTemplate',
return Marionette.CompositeView.extend({
itemView : AddItemView,
itemViewContainer: '.notifications .items',
template : 'Settings/Notifications/AddTemplate',
itemViewOptions: function () {
return {
+4 -4
View File
@@ -1,7 +1,7 @@
"use strict";
define(['app', 'Settings/Notifications/Model'], function () {
NzbDrone.Settings.Notifications.Collection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/notification',
model: NzbDrone.Settings.Notifications.Model
define(['app', 'Settings/Notifications/Model'], function (App, NotificationModel) {
return Backbone.Collection.extend({
url : App.Constants.ApiRoot + '/notification',
model: NotificationModel
});
});
+14 -8
View File
@@ -1,22 +1,28 @@
'use strict';
define(['app', 'Settings/Notifications/ItemView', 'Settings/Notifications/AddView'], function () {
NzbDrone.Settings.Notifications.CollectionView = Backbone.Marionette.CompositeView.extend({
itemView : NzbDrone.Settings.Notifications.ItemView,
itemViewContainer : 'tbody',
template : 'Settings/Notifications/CollectionTemplate',
define([
'app',
'marionette',
'Settings/Notifications/Collection',
'Settings/Notifications/ItemView',
'Settings/Notifications/AddView'
], function (App, Marionette, NotificationCollection, NotificationItemView, AddSelectionNotificationView) {
return Marionette.CompositeView.extend({
itemView : NotificationItemView,
itemViewContainer: 'tbody',
template : 'Settings/Notifications/CollectionTemplate',
events: {
'click .x-add': 'openSchemaModal'
},
openSchemaModal: function () {
var schemaCollection = new NzbDrone.Settings.Notifications.Collection();
var schemaCollection = new NotificationCollection();
schemaCollection.url = '/api/notification/schema';
schemaCollection.fetch();
schemaCollection.url = '/api/notification';
var view = new NzbDrone.Settings.Notifications.AddView({ collection: schemaCollection, notificationCollection: this.collection});
NzbDrone.modalRegion.show(view);
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: this.collection});
App.modalRegion.show(view);
}
});
});
+4 -7
View File
@@ -1,7 +1,6 @@
'use strict';
define(['app', 'Settings/Notifications/Model'], function () {
NzbDrone.Settings.Notifications.DeleteView = Backbone.Marionette.ItemView.extend({
define(['app', 'marionette'], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/DeleteTemplate',
events: {
@@ -9,12 +8,10 @@ define(['app', 'Settings/Notifications/Model'], function () {
},
removeNotification: function () {
var self = this;
this.model.destroy({
wait : true,
success: function (model) {
NzbDrone.modalRegion.closeModal();
success: function () {
App.modalRegion.closeModal();
}
});
}
+25 -19
View File
@@ -2,23 +2,27 @@
define([
'app',
'marionette',
'Settings/Notifications/Model',
'Settings/Notifications/DeleteView'
'Settings/Notifications/DeleteView',
'Settings/SyncNotification',
'Shared/Messenger',
'Mixins/AsModelBoundView'
], function () {
], function (App, Marionette, NotificationModel, DeleteView, SyncNotification, Messenger, AsModelBoundView) {
NzbDrone.Settings.Notifications.EditView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/EditTemplate',
var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/EditTemplate',
events: {
'click .x-save' : '_saveNotification',
'click .x-remove' : '_deleteNotification',
'click .x-test' : '_test'
'click .x-save' : '_saveNotification',
'click .x-remove': '_deleteNotification',
'click .x-test' : '_test'
},
ui: {
testButton : '.x-test',
testIcon : '.x-test-icon'
testButton: '.x-test',
testIcon : '.x-test-icon'
},
initialize: function (options) {
@@ -30,22 +34,22 @@ define([
var success = 'Notification Saved: ' + name;
var fail = 'Failed to save notification: ' + name;
this.model.save(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
successMessage: success,
errorMessage: fail,
this.model.save(undefined, SyncNotification.callback({
successMessage : success,
errorMessage : fail,
successCallback: this._saveSuccess,
context: this
context : this
}));
},
_deleteNotification: function () {
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model });
NzbDrone.modalRegion.show(view);
var view = new DeleteView({ model: this.model });
App.modalRegion.show(view);
},
_saveSuccess: function () {
this.notificationCollection.add(this.model, { merge: true });
NzbDrone.modalRegion.closeModal();
App.modalRegion.closeModal();
},
_test: function () {
@@ -62,9 +66,9 @@ define([
});
var self = this;
var commandPromise = NzbDrone.Commands.Execute(testCommand, properties);
var commandPromise = App.Commands.Execute(testCommand, properties);
commandPromise.done(function () {
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: 'Notification settings tested successfully'
});
});
@@ -74,7 +78,7 @@ define([
return;
}
NzbDrone.Shared.Messenger.show({
Messenger.show({
message: 'Failed to test notification settings',
type : 'error'
});
@@ -90,4 +94,6 @@ define([
}
}
});
return AsModelBoundView.call(model);
});
+9 -9
View File
@@ -2,15 +2,15 @@
define([
'app',
'Settings/Notifications/Collection',
'marionette',
'Settings/Notifications/EditView',
'Settings/Notifications/DeleteView'
], function () {
], function (App, Marionette, EditView, DeleteView) {
NzbDrone.Settings.Notifications.ItemView = Backbone.Marionette.ItemView.extend({
template : 'Settings/Notifications/ItemTemplate',
tagName: 'tr',
return Marionette.ItemView.extend({
template: 'Settings/Notifications/ItemTemplate',
tagName : 'tr',
events: {
'click .x-edit' : 'edit',
@@ -18,13 +18,13 @@ define([
},
edit: function () {
var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model, notificationCollection: this.model.collection});
NzbDrone.modalRegion.show(view);
var view = new EditView({ model: this.model, notificationCollection: this.model.collection});
App.modalRegion.show(view);
},
deleteNotification: function () {
var view = new NzbDrone.Settings.Notifications.DeleteView({ model: this.model});
NzbDrone.modalRegion.show(view);
var view = new DeleteView({ model: this.model});
App.modalRegion.show(view);
}
});
});
+1 -1
View File
@@ -1,5 +1,5 @@
"use strict";
define(['app', 'backbone.deepmodel'], function (App, DeepModel) {
NzbDrone.Settings.Notifications.Model = DeepModel.DeepModel.extend({
return DeepModel.DeepModel.extend({
});
});