From 0ffb72bca17b1a52b7a35116a03c56a829a20f4a Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 27 Jun 2013 00:37:39 -0700 Subject: [PATCH] Delete added to indexers --- NzbDrone.Api/Indexers/IndexerModule.cs | 6 ++++++ NzbDrone.Core/Indexers/IndexerService.cs | 7 ++++++- UI/Settings/Indexers/DeleteTemplate.html | 11 +++++++++++ UI/Settings/Indexers/DeleteView.js | 19 +++++++++++++++++++ UI/Settings/Indexers/ItemView.js | 18 ++++++++++++++++-- UI/Settings/Notifications/DeleteTemplate.html | 4 ++-- UI/Settings/Notifications/DeleteView.js | 4 ++-- 7 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 UI/Settings/Indexers/DeleteTemplate.html create mode 100644 UI/Settings/Indexers/DeleteView.js diff --git a/NzbDrone.Api/Indexers/IndexerModule.cs b/NzbDrone.Api/Indexers/IndexerModule.cs index ba626948f..99e81fc64 100644 --- a/NzbDrone.Api/Indexers/IndexerModule.cs +++ b/NzbDrone.Api/Indexers/IndexerModule.cs @@ -19,6 +19,7 @@ public IndexerModule(IIndexerService indexerService) GetResourceAll = GetAll; CreateResource = CreateIndexer; UpdateResource = UpdateIndexer; + DeleteResource = DeleteIndexer; } private List GetAll() @@ -80,5 +81,10 @@ private Indexer GetIndexer(IndexerResource indexerResource) return indexer; } + + private void DeleteIndexer(int id) + { + _indexerService.Delete(id); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Indexers/IndexerService.cs b/NzbDrone.Core/Indexers/IndexerService.cs index 55aa89672..b65e21dcb 100644 --- a/NzbDrone.Core/Indexers/IndexerService.cs +++ b/NzbDrone.Core/Indexers/IndexerService.cs @@ -29,6 +29,7 @@ public interface IIndexerService List Schema(); Indexer Create(Indexer indexer); Indexer Update(Indexer indexer); + void Delete(int id); } public class IndexerService : IIndexerService, IHandle @@ -81,7 +82,6 @@ public List Schema() return indexers; } - public Indexer Create(Indexer indexer) { var definition = new IndexerDefinition @@ -108,6 +108,11 @@ public Indexer Update(Indexer indexer) return indexer; } + public void Delete(int id) + { + _indexerRepository.Delete(id); + } + private Indexer ToIndexer(IndexerDefinition definition) { var indexer = new Indexer(); diff --git a/UI/Settings/Indexers/DeleteTemplate.html b/UI/Settings/Indexers/DeleteTemplate.html new file mode 100644 index 000000000..b152b9708 --- /dev/null +++ b/UI/Settings/Indexers/DeleteTemplate.html @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/UI/Settings/Indexers/DeleteView.js b/UI/Settings/Indexers/DeleteView.js new file mode 100644 index 000000000..3230c2fb0 --- /dev/null +++ b/UI/Settings/Indexers/DeleteView.js @@ -0,0 +1,19 @@ +'use strict'; +define(['app', 'marionette'], function (App, Marionette) { + return Marionette.ItemView.extend({ + template: 'Settings/Notifications/DeleteTemplate', + + events: { + 'click .x-confirm-delete': '_removeIndexer' + }, + + _removeIndexer: function () { + this.model.destroy({ + wait : true, + success: function () { + App.modalRegion.closeModal(); + } + }); + } + }); +}); diff --git a/UI/Settings/Indexers/ItemView.js b/UI/Settings/Indexers/ItemView.js index 2531eeeb9..38135e746 100644 --- a/UI/Settings/Indexers/ItemView.js +++ b/UI/Settings/Indexers/ItemView.js @@ -1,10 +1,24 @@ 'use strict'; -define(['marionette', 'Mixins/AsModelBoundView'], function (Marionette, AsModelBoundView) { +define([ + 'app', + 'marionette', + 'Settings/Notifications/DeleteView', + 'Mixins/AsModelBoundView'], + function (App, Marionette, DeleteView, AsModelBoundView) { var view = Marionette.ItemView.extend({ template: 'Settings/Indexers/ItemTemplate', - tagName : 'li' + tagName : 'li', + + events: { + 'click .x-delete': '_deleteIndexer' + }, + + _deleteIndexer: function () { + var view = new DeleteView({ model: this.model}); + App.modalRegion.show(view); + } }); return AsModelBoundView.call(view); diff --git a/UI/Settings/Notifications/DeleteTemplate.html b/UI/Settings/Notifications/DeleteTemplate.html index ce1352f09..82f71cbb8 100644 --- a/UI/Settings/Notifications/DeleteTemplate.html +++ b/UI/Settings/Notifications/DeleteTemplate.html @@ -1,9 +1,9 @@