2013-06-25 04:43:16 +00:00
|
|
|
|
'use strict';
|
2013-06-24 23:41:59 +00:00
|
|
|
|
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'app',
|
|
|
|
|
'marionette',
|
|
|
|
|
'Settings/Quality/Profile/EditQualityProfileView',
|
|
|
|
|
'Settings/Quality/Profile/DeleteView',
|
2013-07-06 00:29:29 +00:00
|
|
|
|
'Series/SeriesCollection',
|
2013-06-25 00:41:32 +00:00
|
|
|
|
'Mixins/AsModelBoundView',
|
2013-07-06 00:29:29 +00:00
|
|
|
|
'Settings/Quality/Profile/AllowedLabeler',
|
|
|
|
|
'bootstrap',
|
2013-06-24 23:41:59 +00:00
|
|
|
|
|
2013-07-06 00:29:29 +00:00
|
|
|
|
], function (App, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
|
2013-06-24 23:41:59 +00:00
|
|
|
|
|
|
|
|
|
var view = Marionette.ItemView.extend({
|
|
|
|
|
template: 'Settings/Quality/Profile/QualityProfileTemplate',
|
2013-06-25 00:41:32 +00:00
|
|
|
|
tagName : 'li',
|
2013-06-24 23:41:59 +00:00
|
|
|
|
|
|
|
|
|
ui: {
|
2013-07-06 00:29:29 +00:00
|
|
|
|
'progressbar' : '.progress .bar',
|
|
|
|
|
'deleteButton': '.x-delete'
|
2013-06-24 23:41:59 +00:00
|
|
|
|
},
|
2013-06-24 04:48:47 +00:00
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
|
events: {
|
2013-06-25 00:41:32 +00:00
|
|
|
|
'click .x-edit' : '_editProfile',
|
|
|
|
|
'click .x-delete': '_deleteProfile'
|
2013-06-24 23:41:59 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-06-25 07:21:10 +00:00
|
|
|
|
initialize: function () {
|
|
|
|
|
this.listenTo(this.model, 'sync', this.render);
|
2013-07-06 00:29:29 +00:00
|
|
|
|
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus)
|
2013-06-25 07:21:10 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-06-25 00:41:32 +00:00
|
|
|
|
_editProfile: function () {
|
2013-06-25 07:21:10 +00:00
|
|
|
|
var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection });
|
2013-06-24 23:41:59 +00:00
|
|
|
|
App.modalRegion.show(view);
|
|
|
|
|
},
|
|
|
|
|
|
2013-06-25 00:41:32 +00:00
|
|
|
|
_deleteProfile: function () {
|
2013-07-06 00:29:29 +00:00
|
|
|
|
if (this._isQualityInUse()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
|
var view = new DeleteProfileView({ model: this.model });
|
|
|
|
|
App.modalRegion.show(view);
|
2013-07-06 00:29:29 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
this._updateDisableStatus();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_updateDisableStatus: function () {
|
|
|
|
|
if (this._isQualityInUse()) {
|
|
|
|
|
this.ui.deleteButton.addClass('disabled');
|
|
|
|
|
this.ui.deleteButton.attr('title', 'Can\'t delete quality profiles attached to a series.');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.ui.deleteButton.removeClass('disabled');
|
|
|
|
|
this.ui.deleteButton.attr('title', 'Delete Quality Profile');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_isQualityInUse: function () {
|
|
|
|
|
return SeriesCollection.where({'qualityProfileId': this.model.id}).length !== 0;
|
|
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return AsModelBoundView.call(view);
|
|
|
|
|
});
|