Lidarr/UI/Settings/Indexers/EditView.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-05-28 00:19:07 +00:00
"use strict";
define([
'app',
2013-06-19 01:02:23 +00:00
'marionette',
'Shared/Messenger',
'Mixins/AsModelBoundView'
2013-05-28 00:19:07 +00:00
2013-06-19 01:02:23 +00:00
], function (App, Marionette, Messenger, AsModelBoundView) {
2013-05-28 00:19:07 +00:00
2013-06-19 01:02:23 +00:00
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
2013-05-28 00:19:07 +00:00
events: {
'click .x-save': 'save'
},
2013-05-29 00:44:29 +00:00
initialize: function (options) {
this.indexerCollection = options.indexerCollection;
2013-05-28 00:19:07 +00:00
},
2013-05-29 00:44:29 +00:00
save: function () {
this.model.save(undefined, this.syncNotification("Indexer Saved", "Couldn't Save Indexer", this));
},
2013-05-28 00:19:07 +00:00
2013-05-29 00:44:29 +00:00
syncNotification: function (success, error, context) {
2013-05-28 00:19:07 +00:00
return {
success: function () {
2013-06-19 01:02:23 +00:00
Messenger.show({
2013-05-29 00:44:29 +00:00
message: success
});
context.indexerCollection.add(context.model);
2013-06-19 01:02:23 +00:00
App.modalRegion.closeModal();
2013-05-28 00:19:07 +00:00
},
error: function () {
window.alert(error);
}
};
}
});
2013-06-19 01:02:23 +00:00
return AsModelBoundView.call(view);
2013-05-28 00:19:07 +00:00
});