mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-23 22:25:14 -04:00
UI Cleanup - Updated Settings subtree.
This commit is contained in:
@@ -3,7 +3,7 @@ var ThingyHeaderGroupView = require('../../ThingyHeaderGroupView');
|
||||
var AddItemView = require('./IndexerAddItemView');
|
||||
|
||||
module.exports = ThingyAddCollectionView.extend({
|
||||
itemView : ThingyHeaderGroupView.extend({itemView : AddItemView}),
|
||||
itemView : ThingyHeaderGroupView.extend({ itemView : AddItemView }),
|
||||
itemViewContainer : '.add-indexer .items',
|
||||
template : 'Settings/Indexers/Add/IndexerAddCollectionViewTemplate'
|
||||
});
|
||||
@@ -1,34 +1,41 @@
|
||||
var _ = require('underscore');
|
||||
var _ = require('underscore');
|
||||
var $ = require('jquery');
|
||||
var AppLayout = require('../../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var EditView = require('../Edit/IndexerEditView');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
|
||||
tagName : 'li',
|
||||
className : 'add-thingy-item',
|
||||
template : 'Settings/Indexers/Add/IndexerAddItemViewTemplate',
|
||||
tagName : 'li',
|
||||
className : 'add-thingy-item',
|
||||
|
||||
events : {
|
||||
events : {
|
||||
'click .x-preset' : '_addPreset',
|
||||
'click' : '_add'
|
||||
},
|
||||
initialize : function(options){
|
||||
|
||||
initialize : function(options) {
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
_addPreset : function(e){
|
||||
|
||||
_addPreset : function(e) {
|
||||
var presetName = $(e.target).closest('.x-preset').attr('data-id');
|
||||
var presetData = _.where(this.model.get('presets'), {name : presetName})[0];
|
||||
var presetData = _.where(this.model.get('presets'), { name : presetName })[0];
|
||||
|
||||
this.model.set(presetData);
|
||||
|
||||
this._openEdit();
|
||||
},
|
||||
_add : function(e){
|
||||
if($(e.target).closest('.btn,.btn-group').length !== 0) {
|
||||
|
||||
_add : function(e) {
|
||||
if ($(e.target).closest('.btn,.btn-group').length !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._openEdit();
|
||||
},
|
||||
_openEdit : function(){
|
||||
|
||||
_openEdit : function() {
|
||||
this.model.set({
|
||||
id : undefined,
|
||||
enableRss : this.model.get('supportsRss'),
|
||||
@@ -39,6 +46,7 @@ module.exports = Marionette.ItemView.extend({
|
||||
model : this.model,
|
||||
targetCollection : this.targetCollection
|
||||
});
|
||||
|
||||
AppLayout.modalRegion.show(editView);
|
||||
}
|
||||
});
|
||||
@@ -5,29 +5,35 @@ var SchemaCollection = require('../IndexerCollection');
|
||||
var AddCollectionView = require('./IndexerAddCollectionView');
|
||||
|
||||
module.exports = {
|
||||
open : function(collection){
|
||||
open : function(collection) {
|
||||
var schemaCollection = new SchemaCollection();
|
||||
var originalUrl = schemaCollection.url;
|
||||
schemaCollection.url = schemaCollection.url + '/schema';
|
||||
schemaCollection.fetch();
|
||||
schemaCollection.url = originalUrl;
|
||||
|
||||
var groupedSchemaCollection = new Backbone.Collection();
|
||||
schemaCollection.on('sync', function(){
|
||||
var groups = schemaCollection.groupBy(function(model, iterator){
|
||||
|
||||
schemaCollection.on('sync', function() {
|
||||
|
||||
var groups = schemaCollection.groupBy(function(model, iterator) {
|
||||
return model.get('protocol');
|
||||
});
|
||||
var modelCollection = _.map(groups, function(values, key, list){
|
||||
var modelCollection = _.map(groups, function(values, key, list) {
|
||||
return {
|
||||
"header" : key,
|
||||
collection : values
|
||||
};
|
||||
});
|
||||
|
||||
groupedSchemaCollection.reset(modelCollection);
|
||||
});
|
||||
|
||||
var view = new AddCollectionView({
|
||||
collection : groupedSchemaCollection,
|
||||
targetCollection : collection
|
||||
});
|
||||
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
};
|
||||
@@ -3,11 +3,15 @@ var Marionette = require('marionette');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Delete/IndexerDeleteViewTemplate',
|
||||
events : {"click .x-confirm-delete" : '_delete'},
|
||||
_delete : function(){
|
||||
|
||||
events : {
|
||||
'click .x-confirm-delete' : '_delete'
|
||||
},
|
||||
|
||||
_delete : function() {
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success : function(){
|
||||
success : function() {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var vent = require('vent');
|
||||
var vent = require('vent');
|
||||
var Marionette = require('marionette');
|
||||
var DeleteView = require('../Delete/IndexerDeleteView');
|
||||
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
|
||||
@@ -8,33 +8,41 @@ require('../../../Form/FormBuilder');
|
||||
require('../../../Mixins/AutoComplete');
|
||||
require('bootstrap');
|
||||
|
||||
module.exports = (function(){
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Edit/IndexerEditViewTemplate',
|
||||
events : {
|
||||
'click .x-back' : '_back'
|
||||
},
|
||||
_deleteView : DeleteView,
|
||||
initialize : function(options){
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
_onAfterSave : function(){
|
||||
this.targetCollection.add(this.model, {merge : true});
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
},
|
||||
_onAfterSaveAndAdd : function(){
|
||||
this.targetCollection.add(this.model, {merge : true});
|
||||
require('../Add/IndexerSchemaModal').open(this.targetCollection);
|
||||
},
|
||||
_back : function(){
|
||||
if(this.model.isNew()) {
|
||||
this.model.destroy();
|
||||
}
|
||||
require('../Add/IndexerSchemaModal').open(this.targetCollection);
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Edit/IndexerEditViewTemplate',
|
||||
|
||||
events : {
|
||||
'click .x-back' : '_back'
|
||||
},
|
||||
|
||||
_deleteView : DeleteView,
|
||||
|
||||
initialize : function(options) {
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
|
||||
_onAfterSave : function() {
|
||||
this.targetCollection.add(this.model, { merge : true });
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
},
|
||||
|
||||
_onAfterSaveAndAdd : function() {
|
||||
this.targetCollection.add(this.model, { merge : true });
|
||||
|
||||
require('../Add/IndexerSchemaModal').open(this.targetCollection);
|
||||
},
|
||||
|
||||
_back : function() {
|
||||
if (this.model.isNew()) {
|
||||
this.model.destroy();
|
||||
}
|
||||
});
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
AsEditModalView.call(view);
|
||||
return view;
|
||||
}).call(this);
|
||||
|
||||
require('../Add/IndexerSchemaModal').open(this.targetCollection);
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
AsEditModalView.call(view);
|
||||
|
||||
module.exports = view;
|
||||
@@ -2,19 +2,24 @@ var Backbone = require('backbone');
|
||||
var IndexerModel = require('./IndexerModel');
|
||||
|
||||
module.exports = Backbone.Collection.extend({
|
||||
model : IndexerModel,
|
||||
url : window.NzbDrone.ApiRoot + '/indexer',
|
||||
comparator : function(left, right, collection){
|
||||
model : IndexerModel,
|
||||
url : window.NzbDrone.ApiRoot + '/indexer',
|
||||
|
||||
comparator : function(left, right, collection) {
|
||||
var result = 0;
|
||||
if(left.get('protocol')) {
|
||||
|
||||
if (left.get('protocol')) {
|
||||
result = -left.get('protocol').localeCompare(right.get('protocol'));
|
||||
}
|
||||
if(result === 0 && left.get('name')) {
|
||||
|
||||
if (result === 0 && left.get('name')) {
|
||||
result = left.get('name').localeCompare(right.get('name'));
|
||||
}
|
||||
if(result === 0) {
|
||||
|
||||
if (result === 0) {
|
||||
result = left.get('implementation').localeCompare(right.get('implementation'));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
});
|
||||
@@ -6,12 +6,20 @@ module.exports = Marionette.CompositeView.extend({
|
||||
itemView : ItemView,
|
||||
itemViewContainer : '.indexer-list',
|
||||
template : 'Settings/Indexers/IndexerCollectionViewTemplate',
|
||||
ui : {"addCard" : '.x-add-card'},
|
||||
events : {"click .x-add-card" : '_openSchemaModal'},
|
||||
appendHtml : function(collectionView, itemView, index){
|
||||
|
||||
ui : {
|
||||
'addCard' : '.x-add-card'
|
||||
},
|
||||
|
||||
events : {
|
||||
'click .x-add-card' : '_openSchemaModal'
|
||||
},
|
||||
|
||||
appendHtml : function(collectionView, itemView, index) {
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
_openSchemaModal : function(){
|
||||
|
||||
_openSchemaModal : function() {
|
||||
SchemaModal.open(this.collection);
|
||||
}
|
||||
});
|
||||
@@ -3,13 +3,18 @@ var Marionette = require('marionette');
|
||||
var EditView = require('./Edit/IndexerEditView');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/IndexerItemViewTemplate',
|
||||
tagName : 'li',
|
||||
events : {"click" : '_edit'},
|
||||
initialize : function(){
|
||||
template : 'Settings/Indexers/IndexerItemViewTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
events : {
|
||||
'click' : '_edit'
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
_edit : function(){
|
||||
|
||||
_edit : function() {
|
||||
var view = new EditView({
|
||||
model : this.model,
|
||||
targetCollection : this.model.collection
|
||||
|
||||
@@ -6,21 +6,25 @@ var RestrictionCollection = require('./Restriction/RestrictionCollection');
|
||||
var RestrictionCollectionView = require('./Restriction/RestrictionCollectionView');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Settings/Indexers/IndexerLayoutTemplate',
|
||||
regions : {
|
||||
template : 'Settings/Indexers/IndexerLayoutTemplate',
|
||||
|
||||
regions : {
|
||||
indexers : '#x-indexers-region',
|
||||
indexerOptions : '#x-indexer-options-region',
|
||||
restriction : '#x-restriction-region'
|
||||
},
|
||||
initialize : function(){
|
||||
|
||||
initialize : function() {
|
||||
this.indexersCollection = new IndexerCollection();
|
||||
this.indexersCollection.fetch();
|
||||
|
||||
this.restrictionCollection = new RestrictionCollection();
|
||||
this.restrictionCollection.fetch();
|
||||
},
|
||||
onShow : function(){
|
||||
this.indexers.show(new CollectionView({collection : this.indexersCollection}));
|
||||
this.indexerOptions.show(new OptionsView({model : this.model}));
|
||||
this.restriction.show(new RestrictionCollectionView({collection : this.restrictionCollection}));
|
||||
|
||||
onShow : function() {
|
||||
this.indexers.show(new CollectionView({ collection : this.indexersCollection }));
|
||||
this.indexerOptions.show(new OptionsView({ model : this.model }));
|
||||
this.restriction.show(new RestrictionCollectionView({ collection : this.restrictionCollection }));
|
||||
}
|
||||
});
|
||||
@@ -2,9 +2,11 @@ var Marionette = require('marionette');
|
||||
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
|
||||
var AsValidatedView = require('../../../Mixins/AsValidatedView');
|
||||
|
||||
module.exports = (function(){
|
||||
var view = Marionette.ItemView.extend({template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'});
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
return view;
|
||||
}).call(this);
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Options/IndexerOptionsViewTemplate'
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
|
||||
module.exports = view;
|
||||
@@ -9,13 +9,18 @@ module.exports = Marionette.CompositeView.extend({
|
||||
template : 'Settings/Indexers/Restriction/RestrictionCollectionViewTemplate',
|
||||
itemViewContainer : '.x-rows',
|
||||
itemView : RestrictionItemView,
|
||||
events : {"click .x-add" : '_addMapping'},
|
||||
_addMapping : function(){
|
||||
var model = this.collection.create({tags : []});
|
||||
|
||||
events : {
|
||||
'click .x-add' : '_addMapping'
|
||||
},
|
||||
|
||||
_addMapping : function() {
|
||||
var model = this.collection.create({ tags : [] });
|
||||
var view = new EditView({
|
||||
model : model,
|
||||
targetCollection : this.collection
|
||||
});
|
||||
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
@@ -3,11 +3,15 @@ var Marionette = require('marionette');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Restriction/RestrictionDeleteViewTemplate',
|
||||
events : {'click .x-confirm-delete' : '_delete'},
|
||||
_delete : function(){
|
||||
|
||||
events : {
|
||||
'click .x-confirm-delete' : '_delete'
|
||||
},
|
||||
|
||||
_delete : function() {
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success : function(){
|
||||
success : function() {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,39 +11,45 @@ require('../../../Mixins/TagInput');
|
||||
require('bootstrap');
|
||||
require('bootstrap.tagsinput');
|
||||
|
||||
module.exports = (function(){
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
|
||||
ui : {
|
||||
required : '.x-required',
|
||||
ignored : '.x-ignored',
|
||||
tags : '.x-tags'
|
||||
},
|
||||
_deleteView : DeleteView,
|
||||
initialize : function(options){
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
onRender : function(){
|
||||
this.ui.required.tagsinput({
|
||||
trimValue : true,
|
||||
tagClass : 'label label-success'
|
||||
});
|
||||
this.ui.ignored.tagsinput({
|
||||
trimValue : true,
|
||||
tagClass : 'label label-danger'
|
||||
});
|
||||
this.ui.tags.tagInput({
|
||||
model : this.model,
|
||||
property : 'tags'
|
||||
});
|
||||
},
|
||||
_onAfterSave : function(){
|
||||
this.targetCollection.add(this.model, {merge : true});
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
AsEditModalView.call(view);
|
||||
return view;
|
||||
}).call(this);
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Restriction/RestrictionEditViewTemplate',
|
||||
|
||||
ui : {
|
||||
required : '.x-required',
|
||||
ignored : '.x-ignored',
|
||||
tags : '.x-tags'
|
||||
},
|
||||
|
||||
_deleteView : DeleteView,
|
||||
|
||||
initialize : function(options) {
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
|
||||
onRender : function() {
|
||||
this.ui.required.tagsinput({
|
||||
trimValue : true,
|
||||
tagClass : 'label label-success'
|
||||
});
|
||||
|
||||
this.ui.ignored.tagsinput({
|
||||
trimValue : true,
|
||||
tagClass : 'label label-danger'
|
||||
});
|
||||
|
||||
this.ui.tags.tagInput({
|
||||
model : this.model,
|
||||
property : 'tags'
|
||||
});
|
||||
},
|
||||
|
||||
_onAfterSave : function() {
|
||||
this.targetCollection.add(this.model, { merge : true });
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
AsEditModalView.call(view);
|
||||
module.exports = view;
|
||||
@@ -3,14 +3,22 @@ var Marionette = require('marionette');
|
||||
var EditView = require('./RestrictionEditView');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate',
|
||||
className : 'row',
|
||||
ui : {tags : '.x-tags'},
|
||||
events : {"click .x-edit" : '_edit'},
|
||||
initialize : function(){
|
||||
template : 'Settings/Indexers/Restriction/RestrictionItemViewTemplate',
|
||||
className : 'row',
|
||||
|
||||
ui : {
|
||||
tags : '.x-tags'
|
||||
},
|
||||
|
||||
events : {
|
||||
'click .x-edit' : '_edit'
|
||||
},
|
||||
|
||||
initialize : function() {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
_edit : function(){
|
||||
|
||||
_edit : function() {
|
||||
var view = new EditView({
|
||||
model : this.model,
|
||||
targetCollection : this.model.collection
|
||||
|
||||
Reference in New Issue
Block a user