Delete added to indexers

This commit is contained in:
Mark McDowall 2013-06-27 00:37:39 -07:00
parent 1e61f501dc
commit 0ffb72bca1
7 changed files with 62 additions and 7 deletions

View File

@ -19,6 +19,7 @@ namespace NzbDrone.Api.Indexers
GetResourceAll = GetAll; GetResourceAll = GetAll;
CreateResource = CreateIndexer; CreateResource = CreateIndexer;
UpdateResource = UpdateIndexer; UpdateResource = UpdateIndexer;
DeleteResource = DeleteIndexer;
} }
private List<IndexerResource> GetAll() private List<IndexerResource> GetAll()
@ -80,5 +81,10 @@ namespace NzbDrone.Api.Indexers
return indexer; return indexer;
} }
private void DeleteIndexer(int id)
{
_indexerService.Delete(id);
}
} }
} }

View File

@ -29,6 +29,7 @@ namespace NzbDrone.Core.Indexers
List<Indexer> Schema(); List<Indexer> Schema();
Indexer Create(Indexer indexer); Indexer Create(Indexer indexer);
Indexer Update(Indexer indexer); Indexer Update(Indexer indexer);
void Delete(int id);
} }
public class IndexerService : IIndexerService, IHandle<ApplicationStartedEvent> public class IndexerService : IIndexerService, IHandle<ApplicationStartedEvent>
@ -81,7 +82,6 @@ namespace NzbDrone.Core.Indexers
return indexers; return indexers;
} }
public Indexer Create(Indexer indexer) public Indexer Create(Indexer indexer)
{ {
var definition = new IndexerDefinition var definition = new IndexerDefinition
@ -108,6 +108,11 @@ namespace NzbDrone.Core.Indexers
return indexer; return indexer;
} }
public void Delete(int id)
{
_indexerRepository.Delete(id);
}
private Indexer ToIndexer(IndexerDefinition definition) private Indexer ToIndexer(IndexerDefinition definition)
{ {
var indexer = new Indexer(); var indexer = new Indexer();

View File

@ -0,0 +1,11 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Delete Indexer</h3>
</div>
<div class="modal-body">
<p>Are you sure you want to delete '{{name}}'?</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-danger x-confirm-delete">delete</button>
</div>

View File

@ -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();
}
});
}
});
});

View File

@ -1,10 +1,24 @@
'use strict'; '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({ var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate', 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); return AsModelBoundView.call(view);

View File

@ -1,9 +1,9 @@
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Remove: {{name}}</h3> <h3>Delete Notification</h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>Are you sure you want to remove '{{name}}'?</p> <p>Are you sure you want to delete '{{name}}'?</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn" data-dismiss="modal">cancel</button> <button class="btn" data-dismiss="modal">cancel</button>

View File

@ -4,10 +4,10 @@ define(['app', 'marionette'], function (App, Marionette) {
template: 'Settings/Notifications/DeleteTemplate', template: 'Settings/Notifications/DeleteTemplate',
events: { events: {
'click .x-confirm-delete': 'removeNotification' 'click .x-confirm-delete': '_removeNotification'
}, },
removeNotification: function () { _removeNotification: function () {
this.model.destroy({ this.model.destroy({
wait : true, wait : true,
success: function () { success: function () {