disable delete profile button, show tooltip if profile is in use.
This commit is contained in:
parent
32d6909045
commit
1be62b374a
|
@ -6,17 +6,20 @@ define(
|
||||||
'marionette',
|
'marionette',
|
||||||
'Settings/Quality/Profile/EditQualityProfileView',
|
'Settings/Quality/Profile/EditQualityProfileView',
|
||||||
'Settings/Quality/Profile/DeleteView',
|
'Settings/Quality/Profile/DeleteView',
|
||||||
|
'Series/SeriesCollection',
|
||||||
'Mixins/AsModelBoundView',
|
'Mixins/AsModelBoundView',
|
||||||
'Settings/Quality/Profile/AllowedLabeler'
|
'Settings/Quality/Profile/AllowedLabeler',
|
||||||
|
'bootstrap',
|
||||||
|
|
||||||
], function (App, Marionette, EditProfileView, DeleteProfileView, AsModelBoundView) {
|
], function (App, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
|
||||||
|
|
||||||
var view = Marionette.ItemView.extend({
|
var view = Marionette.ItemView.extend({
|
||||||
template: 'Settings/Quality/Profile/QualityProfileTemplate',
|
template: 'Settings/Quality/Profile/QualityProfileTemplate',
|
||||||
tagName : 'li',
|
tagName : 'li',
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
'progressbar': '.progress .bar'
|
'progressbar' : '.progress .bar',
|
||||||
|
'deleteButton': '.x-delete'
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
@ -26,6 +29,7 @@ define(
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.listenTo(this.model, 'sync', this.render);
|
this.listenTo(this.model, 'sync', this.render);
|
||||||
|
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus)
|
||||||
},
|
},
|
||||||
|
|
||||||
_editProfile: function () {
|
_editProfile: function () {
|
||||||
|
@ -34,8 +38,32 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
_deleteProfile: function () {
|
_deleteProfile: function () {
|
||||||
|
if (this._isQualityInUse()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var view = new DeleteProfileView({ model: this.model });
|
var view = new DeleteProfileView({ model: this.model });
|
||||||
App.modalRegion.show(view);
|
App.modalRegion.show(view);
|
||||||
|
},
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue