2013-03-14 00:26:30 +00:00
|
|
|
|
'use strict';
|
2013-06-19 01:02:23 +00:00
|
|
|
|
define(['app', 'marionette', 'Mixins/AsModelBoundView'], function (App, Marionette, AsModelBoundView) {
|
2013-03-14 00:26:30 +00:00
|
|
|
|
|
2013-06-19 01:02:23 +00:00
|
|
|
|
var view = Marionette.ItemView.extend({
|
2013-05-31 05:56:00 +00:00
|
|
|
|
template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
|
2013-03-14 00:26:30 +00:00
|
|
|
|
|
|
|
|
|
events: {
|
2013-05-31 05:56:00 +00:00
|
|
|
|
'click .x-save' : 'saveQualityProfile',
|
|
|
|
|
'dblclick .x-available-list': '_moveQuality',
|
|
|
|
|
'dblclick .x-allowed-list' : '_moveQuality'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_moveQuality: function (event) {
|
|
|
|
|
|
|
|
|
|
var quality;
|
|
|
|
|
var qualityId = event.target.value;
|
|
|
|
|
var availableCollection = new Backbone.Collection(this.model.get('available'));
|
|
|
|
|
availableCollection.comparator = function (model) {
|
|
|
|
|
return model.get('weight');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var allowedCollection = new Backbone.Collection(this.model.get('allowed'));
|
|
|
|
|
allowedCollection.comparator = function (model) {
|
|
|
|
|
return model.get('weight');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (availableCollection.get(qualityId)) {
|
|
|
|
|
quality = availableCollection.get(qualityId);
|
|
|
|
|
availableCollection.remove(quality);
|
|
|
|
|
allowedCollection.add(quality);
|
|
|
|
|
}
|
|
|
|
|
else if (allowedCollection.get(qualityId)) {
|
|
|
|
|
quality = allowedCollection.get(qualityId);
|
|
|
|
|
|
|
|
|
|
allowedCollection.remove(quality);
|
|
|
|
|
availableCollection.add(quality);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
throw 'couldnt find quality id ' + qualityId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.model.set('available', availableCollection.toJSON());
|
|
|
|
|
this.model.set('allowed', allowedCollection.toJSON());
|
|
|
|
|
|
|
|
|
|
this.render();
|
2013-03-14 00:26:30 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
saveQualityProfile: function () {
|
|
|
|
|
//Todo: Make sure model is updated with Allowed, Cutoff, Name
|
|
|
|
|
|
|
|
|
|
this.model.save();
|
|
|
|
|
this.trigger('saved');
|
2013-06-19 01:02:23 +00:00
|
|
|
|
App.modalRegion.closeModal();
|
2013-04-07 23:15:04 +00:00
|
|
|
|
}
|
2013-03-14 00:26:30 +00:00
|
|
|
|
});
|
|
|
|
|
|
2013-06-19 01:02:23 +00:00
|
|
|
|
return AsModelBoundView.call(view);
|
|
|
|
|
|
2013-06-01 17:38:21 +00:00
|
|
|
|
});
|