From 3b09cc12406b15304c034b8dca984799988ac8b8 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 24 May 2013 23:38:43 -0700 Subject: [PATCH] Notification Schema in UI --- .../Notifications/AddItemTemplate.html | 1 + UI/Settings/Notifications/AddTemplate.html | 12 ++++++++ UI/Settings/Notifications/AddView.js | 30 +++++++++++++++++++ .../Notifications/CollectionTemplate.html | 4 ++- UI/Settings/Notifications/CollectionView.js | 15 ++++++++-- 5 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 UI/Settings/Notifications/AddItemTemplate.html create mode 100644 UI/Settings/Notifications/AddTemplate.html create mode 100644 UI/Settings/Notifications/AddView.js diff --git a/UI/Settings/Notifications/AddItemTemplate.html b/UI/Settings/Notifications/AddItemTemplate.html new file mode 100644 index 000000000..2097e9a9b --- /dev/null +++ b/UI/Settings/Notifications/AddItemTemplate.html @@ -0,0 +1 @@ +{{name}} \ No newline at end of file diff --git a/UI/Settings/Notifications/AddTemplate.html b/UI/Settings/Notifications/AddTemplate.html new file mode 100644 index 000000000..058598b78 --- /dev/null +++ b/UI/Settings/Notifications/AddTemplate.html @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/UI/Settings/Notifications/AddView.js b/UI/Settings/Notifications/AddView.js new file mode 100644 index 000000000..eae3dd787 --- /dev/null +++ b/UI/Settings/Notifications/AddView.js @@ -0,0 +1,30 @@ +"use strict"; + +define([ + 'app', + 'Settings/Notifications/Model' + +], function () { + + NzbDrone.Settings.Notifications.AddItemView = Backbone.Marionette.ItemView.extend({ + template : 'Settings/Notifications/AddItemTemplate', + tagName : 'button', + className: 'btn', + + events: { + 'click': 'add' + }, + + add: function () { + this.model.set('id', undefined); + var view = new NzbDrone.Settings.Notifications.EditView({ model: this.model}); + NzbDrone.modalRegion.show(view); + } + }); + + NzbDrone.Settings.Notifications.AddView = Backbone.Marionette.CompositeView.extend({ + itemView : NzbDrone.Settings.Notifications.AddItemView, + itemViewContainer : '#notifications-to-add', + template : 'Settings/Notifications/AddTemplate' + }); +}); diff --git a/UI/Settings/Notifications/CollectionTemplate.html b/UI/Settings/Notifications/CollectionTemplate.html index eb08fe772..6d3606041 100644 --- a/UI/Settings/Notifications/CollectionTemplate.html +++ b/UI/Settings/Notifications/CollectionTemplate.html @@ -9,4 +9,6 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/UI/Settings/Notifications/CollectionView.js b/UI/Settings/Notifications/CollectionView.js index 6c8b53a19..c83b4c756 100644 --- a/UI/Settings/Notifications/CollectionView.js +++ b/UI/Settings/Notifications/CollectionView.js @@ -1,8 +1,19 @@ 'use strict'; -define(['app', 'Settings/Notifications/ItemView'], function () { +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' + template : 'Settings/Notifications/CollectionTemplate', + + events: { + 'click .x-add': function () { + var schema = new NzbDrone.Settings.Notifications.Collection(); + schema.url = '/api/notification/schema'; + schema.fetch(); + + var view = new NzbDrone.Settings.Notifications.AddView({ collection: schema}); + NzbDrone.modalRegion.show(view); + } + } }); });