mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
rjs -> webpack
This commit is contained in:
@@ -1,24 +1,20 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'handlebars',
|
||||
'underscore'
|
||||
], function (Handlebars, _) {
|
||||
Handlebars.registerHelper('allowedLabeler', function () {
|
||||
var ret = '';
|
||||
var cutoff = this.cutoff;
|
||||
var Handlebars = require('handlebars');
|
||||
var _ = require('underscore');
|
||||
|
||||
_.each(this.items, function (item) {
|
||||
if (item.allowed) {
|
||||
if (item.quality.id === cutoff.id) {
|
||||
ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>';
|
||||
}
|
||||
else {
|
||||
ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
|
||||
}
|
||||
module.exports = (function(){
|
||||
Handlebars.registerHelper('allowedLabeler', function(){
|
||||
var ret = '';
|
||||
var cutoff = this.cutoff;
|
||||
_.each(this.items, function(item){
|
||||
if(item.allowed) {
|
||||
if(item.quality.id === cutoff.id) {
|
||||
ret += '<li><span class="label label-info" title="Cutoff">' + item.quality.name + '</span></li>';
|
||||
}
|
||||
});
|
||||
|
||||
return new Handlebars.SafeString(ret);
|
||||
else {
|
||||
ret += '<li><span class="label label-default">' + item.quality.name + '</span></li>';
|
||||
}
|
||||
}
|
||||
});
|
||||
return new Handlebars.SafeString(ret);
|
||||
});
|
||||
}).call(this);
|
@@ -1,12 +1,7 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Settings/Profile/Delay/DelayProfileModel'
|
||||
], function (Backbone, DelayProfileModel) {
|
||||
var Backbone = require('backbone');
|
||||
var DelayProfileModel = require('./DelayProfileModel');
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: DelayProfileModel,
|
||||
url : window.NzbDrone.ApiRoot + '/delayprofile'
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Collection.extend({
|
||||
model : DelayProfileModel,
|
||||
url : window.NzbDrone.ApiRoot + '/delayprofile'
|
||||
});
|
@@ -1,17 +1,12 @@
|
||||
'use strict';
|
||||
define([
|
||||
'backbone.collectionview',
|
||||
'Settings/Profile/Delay/DelayProfileItemView'
|
||||
], function (BackboneSortableCollectionView, DelayProfileItemView) {
|
||||
var BackboneSortableCollectionView = require('backbone.collectionview');
|
||||
var DelayProfileItemView = require('./DelayProfileItemView');
|
||||
|
||||
return BackboneSortableCollectionView.extend({
|
||||
className : 'delay-profiles',
|
||||
modelView : DelayProfileItemView,
|
||||
|
||||
events: {
|
||||
'click li, td' : '_listItem_onMousedown',
|
||||
'dblclick li, td' : '_listItem_onDoubleClick',
|
||||
'keydown' : '_onKeydown'
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = BackboneSortableCollectionView.extend({
|
||||
className : 'delay-profiles',
|
||||
modelView : DelayProfileItemView,
|
||||
events : {
|
||||
"click li, td" : '_listItem_onMousedown',
|
||||
"dblclick li, td" : '_listItem_onDoubleClick',
|
||||
"keydown" : '_onKeydown'
|
||||
}
|
||||
});
|
@@ -1,27 +1,20 @@
|
||||
'use strict';
|
||||
var $ = require('jquery');
|
||||
var AppLayout = require('../../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var EditView = require('./Edit/DelayProfileEditView');
|
||||
|
||||
define([
|
||||
'jquery',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/Profile/Delay/Edit/DelayProfileEditView'
|
||||
], function ($, AppLayout, Marionette, EditView) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate',
|
||||
className : 'row',
|
||||
|
||||
events: {
|
||||
'click .x-edit' : '_edit'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
|
||||
_edit: function() {
|
||||
var view = new EditView({ model: this.model, targetCollection: this.model.collection});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/Delay/DelayProfileItemViewTemplate',
|
||||
className : 'row',
|
||||
events : {"click .x-edit" : '_edit'},
|
||||
initialize : function(){
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
_edit : function(){
|
||||
var view = new EditView({
|
||||
model : this.model,
|
||||
targetCollection : this.model.collection
|
||||
});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
@@ -1,111 +1,75 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'underscore',
|
||||
'vent',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'backbone',
|
||||
'Settings/Profile/Delay/DelayProfileCollectionView',
|
||||
'Settings/Profile/Delay/Edit/DelayProfileEditView',
|
||||
'Settings/Profile/Delay/DelayProfileModel'
|
||||
], function ($,
|
||||
_,
|
||||
vent,
|
||||
AppLayout,
|
||||
Marionette,
|
||||
Backbone,
|
||||
DelayProfileCollectionView,
|
||||
EditView,
|
||||
Model) {
|
||||
var $ = require('jquery');
|
||||
var _ = require('underscore');
|
||||
var vent = require('../../../vent');
|
||||
var AppLayout = require('../../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var Backbone = require('backbone');
|
||||
var DelayProfileCollectionView = require('./DelayProfileCollectionView');
|
||||
var EditView = require('./Edit/DelayProfileEditView');
|
||||
var Model = require('./DelayProfileModel');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
delayProfiles : '.x-rows'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-add' : '_add'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.collection = options.collection;
|
||||
|
||||
this._updateOrderedCollection();
|
||||
|
||||
this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
|
||||
this.listenTo(this.collection, 'add', this._updateOrderedCollection);
|
||||
this.listenTo(this.collection, 'remove', function () {
|
||||
this.collection.fetch();
|
||||
});
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
|
||||
this.sortableListView = new DelayProfileCollectionView({
|
||||
sortable : true,
|
||||
collection : this.orderedCollection,
|
||||
|
||||
sortableOptions : {
|
||||
handle: '.x-drag-handle'
|
||||
},
|
||||
|
||||
sortableModelsFilter : function( model ) {
|
||||
return model.get('id') !== 1;
|
||||
}
|
||||
});
|
||||
|
||||
this.delayProfiles.show(this.sortableListView);
|
||||
|
||||
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
|
||||
},
|
||||
|
||||
_updateOrder: function() {
|
||||
var self = this;
|
||||
|
||||
this.collection.forEach(function (model) {
|
||||
if (model.get('id') === 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var orderedModel = self.orderedCollection.get(model);
|
||||
var order = self.orderedCollection.indexOf(orderedModel) + 1;
|
||||
|
||||
if (model.get('order') !== order) {
|
||||
model.set('order', order);
|
||||
model.save();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_add: function() {
|
||||
var model = new Model({
|
||||
enableUsenet : true,
|
||||
enableTorrent : true,
|
||||
preferredProtocol : 'usenet',
|
||||
usenetDelay : 0,
|
||||
torrentDelay : 0,
|
||||
order : this.collection.length,
|
||||
tags : []
|
||||
});
|
||||
|
||||
model.collection = this.collection;
|
||||
|
||||
var view = new EditView({ model: model, targetCollection: this.collection});
|
||||
AppLayout.modalRegion.show(view);
|
||||
},
|
||||
|
||||
_updateOrderedCollection: function () {
|
||||
if (!this.orderedCollection) {
|
||||
this.orderedCollection = new Backbone.Collection();
|
||||
}
|
||||
|
||||
this.orderedCollection.reset(_.sortBy(this.collection.models, function (model) {
|
||||
return model.get('order');
|
||||
}));
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Settings/Profile/Delay/DelayProfileLayoutTemplate',
|
||||
regions : {delayProfiles : '.x-rows'},
|
||||
events : {"click .x-add" : '_add'},
|
||||
initialize : function(options){
|
||||
this.collection = options.collection;
|
||||
this._updateOrderedCollection();
|
||||
this.listenTo(this.collection, 'sync', this._updateOrderedCollection);
|
||||
this.listenTo(this.collection, 'add', this._updateOrderedCollection);
|
||||
this.listenTo(this.collection, 'remove', function(){
|
||||
this.collection.fetch();
|
||||
});
|
||||
},
|
||||
onRender : function(){
|
||||
this.sortableListView = new DelayProfileCollectionView({
|
||||
sortable : true,
|
||||
collection : this.orderedCollection,
|
||||
sortableOptions : {handle : '.x-drag-handle'},
|
||||
sortableModelsFilter : function(model){
|
||||
return model.get('id') !== 1;
|
||||
}
|
||||
});
|
||||
});
|
||||
this.delayProfiles.show(this.sortableListView);
|
||||
this.listenTo(this.sortableListView, 'sortStop', this._updateOrder);
|
||||
},
|
||||
_updateOrder : function(){
|
||||
var self = this;
|
||||
this.collection.forEach(function(model){
|
||||
if(model.get('id') === 1) {
|
||||
return;
|
||||
}
|
||||
var orderedModel = self.orderedCollection.get(model);
|
||||
var order = self.orderedCollection.indexOf(orderedModel) + 1;
|
||||
if(model.get('order') !== order) {
|
||||
model.set('order', order);
|
||||
model.save();
|
||||
}
|
||||
});
|
||||
},
|
||||
_add : function(){
|
||||
var model = new Model({
|
||||
enableUsenet : true,
|
||||
enableTorrent : true,
|
||||
preferredProtocol : 'usenet',
|
||||
usenetDelay : 0,
|
||||
torrentDelay : 0,
|
||||
order : this.collection.length,
|
||||
tags : []
|
||||
});
|
||||
model.collection = this.collection;
|
||||
var view = new EditView({
|
||||
model : model,
|
||||
targetCollection : this.collection
|
||||
});
|
||||
AppLayout.modalRegion.show(view);
|
||||
},
|
||||
_updateOrderedCollection : function(){
|
||||
if(!this.orderedCollection) {
|
||||
this.orderedCollection = new Backbone.Collection();
|
||||
}
|
||||
this.orderedCollection.reset(_.sortBy(this.collection.models, function(model){
|
||||
return model.get('order');
|
||||
}));
|
||||
}
|
||||
});
|
@@ -1,8 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({});
|
@@ -1,25 +1,16 @@
|
||||
'use strict';
|
||||
var vent = require('../../../../vent');
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define([
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-confirm-delete': '_delete'
|
||||
},
|
||||
|
||||
_delete: function () {
|
||||
var collection = this.model.collection;
|
||||
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success: function () {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/Delay/Delete/DelayProfileDeleteViewTemplate',
|
||||
events : {"click .x-confirm-delete" : '_delete'},
|
||||
_delete : function(){
|
||||
var collection = this.model.collection;
|
||||
this.model.destroy({
|
||||
wait : true,
|
||||
success : function(){
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@@ -1,127 +1,100 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'vent',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/Profile/Delay/Delete/DelayProfileDeleteView',
|
||||
'Mixins/AsModelBoundView',
|
||||
'Mixins/AsValidatedView',
|
||||
'Mixins/AsEditModalView',
|
||||
'Mixins/TagInput',
|
||||
'bootstrap'
|
||||
], function (vent, AppLayout, Marionette, DeleteView, AsModelBoundView, AsValidatedView, AsEditModalView) {
|
||||
var vent = require('../../../../vent');
|
||||
var AppLayout = require('../../../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var DeleteView = require('../Delete/DelayProfileDeleteView');
|
||||
var AsModelBoundView = require('../../../../Mixins/AsModelBoundView');
|
||||
var AsValidatedView = require('../../../../Mixins/AsValidatedView');
|
||||
var AsEditModalView = require('../../../../Mixins/AsEditModalView');
|
||||
require('../../../../Mixins/TagInput');
|
||||
require('bootstrap');
|
||||
|
||||
module.exports = (function(){
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
|
||||
|
||||
_deleteView: DeleteView,
|
||||
|
||||
ui: {
|
||||
template : 'Settings/Profile/Delay/Edit/DelayProfileEditViewTemplate',
|
||||
_deleteView : DeleteView,
|
||||
ui : {
|
||||
tags : '.x-tags',
|
||||
usenetDelay : '.x-usenet-delay',
|
||||
torrentDelay : '.x-torrent-delay',
|
||||
protocol : '.x-protocol'
|
||||
},
|
||||
|
||||
events: {
|
||||
'change .x-protocol' : '_updateModel'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
events : {"change .x-protocol" : '_updateModel'},
|
||||
initialize : function(options){
|
||||
this.targetCollection = options.targetCollection;
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
if (this.model.id !== 1) {
|
||||
onRender : function(){
|
||||
if(this.model.id !== 1) {
|
||||
this.ui.tags.tagInput({
|
||||
model : this.model,
|
||||
property : 'tags'
|
||||
});
|
||||
}
|
||||
|
||||
this._toggleControls();
|
||||
},
|
||||
|
||||
_onAfterSave: function () {
|
||||
this.targetCollection.add(this.model, { merge: true });
|
||||
_onAfterSave : function(){
|
||||
this.targetCollection.add(this.model, {merge : true});
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
},
|
||||
|
||||
_updateModel: function () {
|
||||
_updateModel : function(){
|
||||
var protocol = this.ui.protocol.val();
|
||||
|
||||
if (protocol === 'preferUsenet') {
|
||||
if(protocol === 'preferUsenet') {
|
||||
this.model.set({
|
||||
enableUsenet : true,
|
||||
enableTorrent : true,
|
||||
enableUsenet : true,
|
||||
enableTorrent : true,
|
||||
preferredProtocol : 'usenet'
|
||||
});
|
||||
}
|
||||
|
||||
if (protocol === 'preferTorrent') {
|
||||
if(protocol === 'preferTorrent') {
|
||||
this.model.set({
|
||||
enableUsenet : true,
|
||||
enableTorrent : true,
|
||||
preferredProtocol : 'torrent'
|
||||
});
|
||||
}
|
||||
|
||||
if (protocol === 'onlyUsenet') {
|
||||
if(protocol === 'onlyUsenet') {
|
||||
this.model.set({
|
||||
enableUsenet : true,
|
||||
enableTorrent : false,
|
||||
enableUsenet : true,
|
||||
enableTorrent : false,
|
||||
preferredProtocol : 'usenet'
|
||||
});
|
||||
}
|
||||
|
||||
if (protocol === 'onlyTorrent') {
|
||||
if(protocol === 'onlyTorrent') {
|
||||
this.model.set({
|
||||
enableUsenet : false,
|
||||
enableTorrent : true,
|
||||
preferredProtocol : 'torrent'
|
||||
});
|
||||
}
|
||||
|
||||
this._toggleControls();
|
||||
},
|
||||
|
||||
_toggleControls: function () {
|
||||
_toggleControls : function(){
|
||||
var enableUsenet = this.model.get('enableUsenet');
|
||||
var enableTorrent = this.model.get('enableTorrent');
|
||||
var preferred = this.model.get('preferredProtocol');
|
||||
|
||||
if (preferred === 'usenet') {
|
||||
if(preferred === 'usenet') {
|
||||
this.ui.protocol.val('preferUsenet');
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.protocol.val('preferTorrent');
|
||||
}
|
||||
|
||||
if (enableUsenet) {
|
||||
if(enableUsenet) {
|
||||
this.ui.usenetDelay.show();
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.protocol.val('onlyTorrent');
|
||||
this.ui.usenetDelay.hide();
|
||||
}
|
||||
|
||||
if (enableTorrent) {
|
||||
if(enableTorrent) {
|
||||
this.ui.torrentDelay.show();
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.protocol.val('onlyUsenet');
|
||||
this.ui.torrentDelay.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AsModelBoundView.call(view);
|
||||
AsValidatedView.call(view);
|
||||
AsEditModalView.call(view);
|
||||
|
||||
return view;
|
||||
});
|
||||
}).call(this);
|
@@ -1,24 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
var vent = require('../../vent');
|
||||
var Marionette = require('marionette');
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'Settings/Profile/DeleteProfileViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-confirm-delete': '_removeProfile'
|
||||
},
|
||||
|
||||
_removeProfile: function () {
|
||||
|
||||
this.model.destroy({
|
||||
wait: true
|
||||
}).done(function () {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
});
|
||||
}
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/DeleteProfileViewTemplate',
|
||||
events : {"click .x-confirm-delete" : '_removeProfile'},
|
||||
_removeProfile : function(){
|
||||
this.model.destroy({wait : true}).done(function(){
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@@ -1,9 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'
|
||||
});
|
||||
});
|
||||
var Marionette = require('marionette');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({template : 'Settings/Profile/Edit/EditProfileItemViewTemplate'});
|
@@ -1,130 +1,95 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'vent',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'backbone',
|
||||
'Settings/Profile/Edit/EditProfileItemView',
|
||||
'Settings/Profile/Edit/QualitySortableCollectionView',
|
||||
'Settings/Profile/Edit/EditProfileView',
|
||||
'Settings/Profile/DeleteProfileView',
|
||||
'Series/SeriesCollection',
|
||||
'Config',
|
||||
'Mixins/AsEditModalView'
|
||||
], function (_,
|
||||
vent,
|
||||
AppLayout,
|
||||
Marionette,
|
||||
Backbone,
|
||||
EditProfileItemView,
|
||||
QualitySortableCollectionView,
|
||||
EditProfileView,
|
||||
DeleteView,
|
||||
SeriesCollection,
|
||||
Config,
|
||||
AsEditModalView) {
|
||||
var _ = require('underscore');
|
||||
var vent = require('../../../vent');
|
||||
var AppLayout = require('../../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var Backbone = require('backbone');
|
||||
var EditProfileItemView = require('./EditProfileItemView');
|
||||
var QualitySortableCollectionView = require('./QualitySortableCollectionView');
|
||||
var EditProfileView = require('./EditProfileView');
|
||||
var DeleteView = require('../DeleteProfileView');
|
||||
var SeriesCollection = require('../../../Series/SeriesCollection');
|
||||
var Config = require('../../../Config');
|
||||
var AsEditModalView = require('../../../Mixins/AsEditModalView');
|
||||
|
||||
var view = Marionette.Layout.extend({
|
||||
template: 'Settings/Profile/Edit/EditProfileLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
fields : '#x-fields',
|
||||
qualities: '#x-qualities'
|
||||
},
|
||||
|
||||
ui: {
|
||||
deleteButton: '.x-delete'
|
||||
},
|
||||
|
||||
_deleteView: DeleteView,
|
||||
|
||||
initialize: function (options) {
|
||||
this.profileCollection = options.profileCollection;
|
||||
this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
|
||||
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this._updateDisableStatus();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.fieldsView = new EditProfileView({ model: this.model });
|
||||
this._showFieldsView();
|
||||
var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false);
|
||||
|
||||
this.sortableListView = new QualitySortableCollectionView({
|
||||
selectable : true,
|
||||
selectMultiple : true,
|
||||
clickToSelect : true,
|
||||
clickToToggle : true,
|
||||
sortable : advancedShown,
|
||||
|
||||
sortableOptions : {
|
||||
handle: '.x-drag-handle'
|
||||
},
|
||||
|
||||
visibleModelsFilter : function (model) {
|
||||
return model.get('quality').id !== 0 || advancedShown;
|
||||
},
|
||||
|
||||
collection: this.itemsCollection,
|
||||
model : this.model
|
||||
});
|
||||
|
||||
this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item) { return item.get('allowed') === true; }));
|
||||
this.qualities.show(this.sortableListView);
|
||||
|
||||
this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged);
|
||||
this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
|
||||
},
|
||||
|
||||
_onBeforeSave: function () {
|
||||
var cutoff = this.fieldsView.getCutoff();
|
||||
this.model.set('cutoff', cutoff);
|
||||
},
|
||||
|
||||
_onAfterSave: function () {
|
||||
this.profileCollection.add(this.model, { merge: true });
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
},
|
||||
|
||||
_selectionChanged: function(newSelectedModels, oldSelectedModels) {
|
||||
var addedModels = _.difference(newSelectedModels, oldSelectedModels);
|
||||
var removeModels = _.difference(oldSelectedModels, newSelectedModels);
|
||||
|
||||
_.each(removeModels, function(item) { item.set('allowed', false); });
|
||||
_.each(addedModels, function(item) { item.set('allowed', true); });
|
||||
|
||||
this._updateModel();
|
||||
},
|
||||
|
||||
_updateModel: function() {
|
||||
this.model.set('items', this.itemsCollection.toJSON().reverse());
|
||||
|
||||
this._showFieldsView();
|
||||
},
|
||||
|
||||
_showFieldsView: function () {
|
||||
this.fields.show(this.fieldsView);
|
||||
},
|
||||
|
||||
_updateDisableStatus: function () {
|
||||
if (this._isQualityInUse()) {
|
||||
this.ui.deleteButton.addClass('disabled');
|
||||
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
|
||||
}
|
||||
else {
|
||||
this.ui.deleteButton.removeClass('disabled');
|
||||
}
|
||||
},
|
||||
|
||||
_isQualityInUse: function () {
|
||||
return SeriesCollection.where({'profileId': this.model.id}).length !== 0;
|
||||
module.exports = (function(){
|
||||
var view = Marionette.Layout.extend({
|
||||
template : 'Settings/Profile/Edit/EditProfileLayoutTemplate',
|
||||
regions : {
|
||||
fields : '#x-fields',
|
||||
qualities : '#x-qualities'
|
||||
},
|
||||
ui : {deleteButton : '.x-delete'},
|
||||
_deleteView : DeleteView,
|
||||
initialize : function(options){
|
||||
this.profileCollection = options.profileCollection;
|
||||
this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse());
|
||||
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
|
||||
},
|
||||
onRender : function(){
|
||||
this._updateDisableStatus();
|
||||
},
|
||||
onShow : function(){
|
||||
this.fieldsView = new EditProfileView({model : this.model});
|
||||
this._showFieldsView();
|
||||
var advancedShown = Config.getValueBoolean(Config.Keys.AdvancedSettings, false);
|
||||
this.sortableListView = new QualitySortableCollectionView({
|
||||
selectable : true,
|
||||
selectMultiple : true,
|
||||
clickToSelect : true,
|
||||
clickToToggle : true,
|
||||
sortable : advancedShown,
|
||||
sortableOptions : {handle : '.x-drag-handle'},
|
||||
visibleModelsFilter : function(model){
|
||||
return model.get('quality').id !== 0 || advancedShown;
|
||||
},
|
||||
collection : this.itemsCollection,
|
||||
model : this.model
|
||||
});
|
||||
this.sortableListView.setSelectedModels(this.itemsCollection.filter(function(item){
|
||||
return item.get('allowed') === true;
|
||||
}));
|
||||
this.qualities.show(this.sortableListView);
|
||||
this.listenTo(this.sortableListView, 'selectionChanged', this._selectionChanged);
|
||||
this.listenTo(this.sortableListView, 'sortStop', this._updateModel);
|
||||
},
|
||||
_onBeforeSave : function(){
|
||||
var cutoff = this.fieldsView.getCutoff();
|
||||
this.model.set('cutoff', cutoff);
|
||||
},
|
||||
_onAfterSave : function(){
|
||||
this.profileCollection.add(this.model, {merge : true});
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
},
|
||||
_selectionChanged : function(newSelectedModels, oldSelectedModels){
|
||||
var addedModels = _.difference(newSelectedModels, oldSelectedModels);
|
||||
var removeModels = _.difference(oldSelectedModels, newSelectedModels);
|
||||
_.each(removeModels, function(item){
|
||||
item.set('allowed', false);
|
||||
});
|
||||
_.each(addedModels, function(item){
|
||||
item.set('allowed', true);
|
||||
});
|
||||
this._updateModel();
|
||||
},
|
||||
_updateModel : function(){
|
||||
this.model.set('items', this.itemsCollection.toJSON().reverse());
|
||||
this._showFieldsView();
|
||||
},
|
||||
_showFieldsView : function(){
|
||||
this.fields.show(this.fieldsView);
|
||||
},
|
||||
_updateDisableStatus : function(){
|
||||
if(this._isQualityInUse()) {
|
||||
this.ui.deleteButton.addClass('disabled');
|
||||
this.ui.deleteButton.attr('title', 'Can\'t delete a profile that is attached to a series.');
|
||||
}
|
||||
});
|
||||
|
||||
return AsEditModalView.call(view);
|
||||
else {
|
||||
this.ui.deleteButton.removeClass('disabled');
|
||||
}
|
||||
},
|
||||
_isQualityInUse : function(){
|
||||
return SeriesCollection.where({"profileId" : this.model.id}).length !== 0;
|
||||
}
|
||||
});
|
||||
return AsEditModalView.call(view);
|
||||
}).call(this);
|
@@ -1,34 +1,22 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'marionette',
|
||||
'Settings/Profile/Language/LanguageCollection',
|
||||
'Config',
|
||||
'Mixins/AsModelBoundView',
|
||||
'Mixins/AsValidatedView'
|
||||
], function (_, Marionette, LanguageCollection, Config, AsModelBoundView, AsValidatedView) {
|
||||
var _ = require('underscore');
|
||||
var Marionette = require('marionette');
|
||||
var LanguageCollection = require('../Language/LanguageCollection');
|
||||
var Config = require('../../../Config');
|
||||
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
|
||||
var AsValidatedView = require('../../../Mixins/AsValidatedView');
|
||||
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/Profile/Edit/EditProfileViewTemplate',
|
||||
|
||||
ui: {
|
||||
cutoff : '.x-cutoff'
|
||||
},
|
||||
|
||||
templateHelpers: function () {
|
||||
return {
|
||||
languages : LanguageCollection.toJSON()
|
||||
};
|
||||
},
|
||||
|
||||
getCutoff: function () {
|
||||
var self = this;
|
||||
|
||||
return _.findWhere(_.pluck(this.model.get('items'), 'quality'), { id: parseInt(self.ui.cutoff.val(), 10)});
|
||||
}
|
||||
});
|
||||
|
||||
AsValidatedView.call(view);
|
||||
return AsModelBoundView.call(view);
|
||||
module.exports = (function(){
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/Edit/EditProfileViewTemplate',
|
||||
ui : {cutoff : '.x-cutoff'},
|
||||
templateHelpers : function(){
|
||||
return {languages : LanguageCollection.toJSON()};
|
||||
},
|
||||
getCutoff : function(){
|
||||
var self = this;
|
||||
return _.findWhere(_.pluck(this.model.get('items'), 'quality'), {id : parseInt(self.ui.cutoff.val(), 10)});
|
||||
}
|
||||
});
|
||||
AsValidatedView.call(view);
|
||||
return AsModelBoundView.call(view);
|
||||
}).call(this);
|
@@ -1,22 +1,13 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone.collectionview',
|
||||
'Settings/Profile/Edit/EditProfileItemView'
|
||||
], function (BackboneSortableCollectionView, EditProfileItemView) {
|
||||
return BackboneSortableCollectionView.extend({
|
||||
var BackboneSortableCollectionView = require('backbone.collectionview');
|
||||
var EditProfileItemView = require('./EditProfileItemView');
|
||||
|
||||
className: 'qualities',
|
||||
modelView: EditProfileItemView,
|
||||
|
||||
attributes: {
|
||||
'validation-name': 'items'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click li, td' : '_listItem_onMousedown',
|
||||
'dblclick li, td' : '_listItem_onDoubleClick',
|
||||
'keydown' : '_onKeydown'
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = BackboneSortableCollectionView.extend({
|
||||
className : 'qualities',
|
||||
modelView : EditProfileItemView,
|
||||
attributes : {"validation-name" : 'items'},
|
||||
events : {
|
||||
"click li, td" : '_listItem_onMousedown',
|
||||
"dblclick li, td" : '_listItem_onDoubleClick',
|
||||
"keydown" : '_onKeydown'
|
||||
}
|
||||
});
|
@@ -1,18 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Settings/Profile/Language/LanguageModel'
|
||||
], function (Backbone, LanguageModel) {
|
||||
var Backbone = require('backbone');
|
||||
var LanguageModel = require('./LanguageModel');
|
||||
|
||||
var LanuageCollection = Backbone.Collection.extend({
|
||||
model: LanguageModel,
|
||||
url : window.NzbDrone.ApiRoot + '/language'
|
||||
});
|
||||
|
||||
var languages = new LanuageCollection();
|
||||
|
||||
languages.fetch();
|
||||
|
||||
return languages;
|
||||
module.exports = (function(){
|
||||
var LanuageCollection = Backbone.Collection.extend({
|
||||
model : LanguageModel,
|
||||
url : window.NzbDrone.ApiRoot + '/language'
|
||||
});
|
||||
var languages = new LanuageCollection();
|
||||
languages.fetch();
|
||||
return languages;
|
||||
}).call(this);
|
@@ -1,10 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({});
|
@@ -1,20 +1,14 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'handlebars',
|
||||
'Settings/Profile/Language/LanguageCollection'
|
||||
], function (_, Handlebars, LanguageCollection) {
|
||||
Handlebars.registerHelper('languageLabel', function () {
|
||||
var _ = require('underscore');
|
||||
var Handlebars = require('handlebars');
|
||||
var LanguageCollection = require('./Language/LanguageCollection');
|
||||
|
||||
var wantedLanguage = this.language;
|
||||
|
||||
var language = LanguageCollection.find(function (lang) {
|
||||
return lang.get('nameLower') === wantedLanguage;
|
||||
});
|
||||
|
||||
var result = '<span class="label label-primary">' + language.get('name') + '</span>';
|
||||
|
||||
return new Handlebars.SafeString(result);
|
||||
module.exports = (function(){
|
||||
Handlebars.registerHelper('languageLabel', function(){
|
||||
var wantedLanguage = this.language;
|
||||
var language = LanguageCollection.find(function(lang){
|
||||
return lang.get('nameLower') === wantedLanguage;
|
||||
});
|
||||
var result = '<span class="label label-primary">' + language.get('name') + '</span>';
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
}).call(this);
|
@@ -1,44 +1,34 @@
|
||||
'use strict';
|
||||
var AppLayout = require('../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var ProfileView = require('./ProfileView');
|
||||
var EditProfileView = require('./Edit/EditProfileLayout');
|
||||
var ProfileCollection = require('./ProfileSchemaCollection');
|
||||
var _ = require('underscore');
|
||||
|
||||
define(['AppLayout',
|
||||
'marionette',
|
||||
'Settings/Profile/ProfileView',
|
||||
'Settings/Profile/Edit/EditProfileLayout',
|
||||
'Settings/Profile/ProfileSchemaCollection',
|
||||
'underscore'
|
||||
], function (AppLayout, Marionette, ProfileView, EditProfileView, ProfileCollection, _) {
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
itemView : ProfileView,
|
||||
itemViewContainer: '.profiles',
|
||||
template : 'Settings/Profile/ProfileCollectionTemplate',
|
||||
|
||||
ui: {
|
||||
'addCard': '.x-add-card'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-add-card': '_addProfile'
|
||||
},
|
||||
|
||||
appendHtml: function(collectionView, itemView, index){
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
|
||||
_addProfile: function () {
|
||||
var self = this;
|
||||
var schemaCollection = new ProfileCollection();
|
||||
schemaCollection.fetch({
|
||||
success: function (collection) {
|
||||
var model = _.first(collection.models);
|
||||
model.set('id', undefined);
|
||||
model.set('name', '');
|
||||
model.collection = self.collection;
|
||||
|
||||
var view = new EditProfileView({ model: model, profileCollection: self.collection});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
itemView : ProfileView,
|
||||
itemViewContainer : '.profiles',
|
||||
template : 'Settings/Profile/ProfileCollectionTemplate',
|
||||
ui : {"addCard" : '.x-add-card'},
|
||||
events : {"click .x-add-card" : '_addProfile'},
|
||||
appendHtml : function(collectionView, itemView, index){
|
||||
collectionView.ui.addCard.parent('li').before(itemView.el);
|
||||
},
|
||||
_addProfile : function(){
|
||||
var self = this;
|
||||
var schemaCollection = new ProfileCollection();
|
||||
schemaCollection.fetch({
|
||||
success : function(collection){
|
||||
var model = _.first(collection.models);
|
||||
model.set('id', undefined);
|
||||
model.set('name', '');
|
||||
model.collection = self.collection;
|
||||
var view = new EditProfileView({
|
||||
model : model,
|
||||
profileCollection : self.collection
|
||||
});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@@ -1,34 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Profile/ProfileCollection',
|
||||
'Settings/Profile/ProfileCollectionView',
|
||||
'Settings/Profile/Delay/DelayProfileLayout',
|
||||
'Settings/Profile/Delay/DelayProfileCollection',
|
||||
'Settings/Profile/Language/LanguageCollection'
|
||||
], function (Marionette, ProfileCollection, ProfileCollectionView, DelayProfileLayout, DelayProfileCollection, LanguageCollection) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'Settings/Profile/ProfileLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
profile : '#profile',
|
||||
delayProfile : '#delay-profile'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.settings = options.settings;
|
||||
ProfileCollection.fetch();
|
||||
|
||||
this.delayProfileCollection = new DelayProfileCollection();
|
||||
this.delayProfileCollection.fetch();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.profile.show(new ProfileCollectionView({collection: ProfileCollection}));
|
||||
this.delayProfile.show(new DelayProfileLayout({collection: this.delayProfileCollection}));
|
||||
}
|
||||
});
|
||||
});
|
||||
var Marionette = require('marionette');
|
||||
var ProfileCollection = require('../../Profile/ProfileCollection');
|
||||
var ProfileCollectionView = require('./ProfileCollectionView');
|
||||
var DelayProfileLayout = require('./Delay/DelayProfileLayout');
|
||||
var DelayProfileCollection = require('./Delay/DelayProfileCollection');
|
||||
var LanguageCollection = require('./Language/LanguageCollection');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'Settings/Profile/ProfileLayoutTemplate',
|
||||
regions : {
|
||||
profile : '#profile',
|
||||
delayProfile : '#delay-profile'
|
||||
},
|
||||
initialize : function(options){
|
||||
this.settings = options.settings;
|
||||
ProfileCollection.fetch();
|
||||
this.delayProfileCollection = new DelayProfileCollection();
|
||||
this.delayProfileCollection.fetch();
|
||||
},
|
||||
onShow : function(){
|
||||
this.profile.show(new ProfileCollectionView({collection : ProfileCollection}));
|
||||
this.delayProfile.show(new DelayProfileLayout({collection : this.delayProfileCollection}));
|
||||
}
|
||||
});
|
@@ -1,13 +1,7 @@
|
||||
'use strict';
|
||||
var Backbone = require('backbone');
|
||||
var ProfileModel = require('../../Profile/ProfileModel');
|
||||
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Profile/ProfileModel'
|
||||
], function (Backbone, ProfileModel) {
|
||||
|
||||
return Backbone.Collection.extend({
|
||||
model: ProfileModel,
|
||||
url : window.NzbDrone.ApiRoot + '/profile/schema'
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Collection.extend({
|
||||
model : ProfileModel,
|
||||
url : window.NzbDrone.ApiRoot + '/profile/schema'
|
||||
});
|
@@ -1,38 +1,30 @@
|
||||
'use strict';
|
||||
var AppLayout = require('../../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var EditProfileView = require('./Edit/EditProfileLayout');
|
||||
var AsModelBoundView = require('../../Mixins/AsModelBoundView');
|
||||
require('./AllowedLabeler');
|
||||
require('./LanguageLabel');
|
||||
require('bootstrap');
|
||||
|
||||
define(
|
||||
[
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'Settings/Profile/Edit/EditProfileLayout',
|
||||
'Mixins/AsModelBoundView',
|
||||
'Settings/Profile/AllowedLabeler',
|
||||
'Settings/Profile/LanguageLabel',
|
||||
'bootstrap'
|
||||
], function (AppLayout, Marionette, EditProfileView, AsModelBoundView) {
|
||||
|
||||
var view = Marionette.ItemView.extend({
|
||||
template: 'Settings/Profile/ProfileViewTemplate',
|
||||
tagName : 'li',
|
||||
|
||||
ui: {
|
||||
'progressbar' : '.progress .bar',
|
||||
'deleteButton': '.x-delete'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click' : '_editProfile'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
|
||||
_editProfile: function () {
|
||||
var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection });
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
|
||||
return AsModelBoundView.call(view);
|
||||
module.exports = (function(){
|
||||
var view = Marionette.ItemView.extend({
|
||||
template : 'Settings/Profile/ProfileViewTemplate',
|
||||
tagName : 'li',
|
||||
ui : {
|
||||
"progressbar" : '.progress .bar',
|
||||
"deleteButton" : '.x-delete'
|
||||
},
|
||||
events : {"click" : '_editProfile'},
|
||||
initialize : function(){
|
||||
this.listenTo(this.model, 'sync', this.render);
|
||||
},
|
||||
_editProfile : function(){
|
||||
var view = new EditProfileView({
|
||||
model : this.model,
|
||||
profileCollection : this.model.collection
|
||||
});
|
||||
AppLayout.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
return AsModelBoundView.call(view);
|
||||
}).call(this);
|
Reference in New Issue
Block a user