Merge branch 'because-kayone' into develop

This commit is contained in:
Mark McDowall 2013-08-20 18:42:19 -07:00
commit 298bc07be7
15 changed files with 153 additions and 32 deletions

View file

@ -0,0 +1,69 @@
'use strict';
define(
[
'backgrid',
'Settings/Quality/Profile/QualityProfileSchemaCollection'
], function (Backgrid, QualityProfileSchemaCollection) {
return Backgrid.CellEditor.extend({
className: 'quality-cell-editor',
template : 'Cells/Edit/QualityCellEditorTemplate',
tagName : 'select',
events: {
'change': 'save',
'blur': 'close',
'keydown': 'close'
},
render: function () {
var self = this;
var qualityProfileSchemaCollection = new QualityProfileSchemaCollection();
var promise = qualityProfileSchemaCollection.fetch();
promise.done(function () {
var templateName = self.template;
self.schema = qualityProfileSchemaCollection.first();
var selected = _.find(self.schema.get('available'), { 'id': self.cell.cellValue.get('quality').id });
selected.selected = true;
self.templateFunction = Marionette.TemplateCache.get(templateName);
var data = self.schema.toJSON();
var html = self.templateFunction(data);
self.$el.html(html);
});
return this;
},
save: function (e) {
var model = this.model;
var column = this.column;
var selected = parseInt(this.$el.val());
var quality = _.find(this.schema.get('available'), { 'id': selected });
var newQuality = {
proper: false,
quality: quality
};
model.set(column.get("name"), newQuality);
model.trigger("backgrid:edited", model, column, new Backgrid.Command(e));
},
close: function (e) {
var model = this.model;
var column = this.column;
var command = new Backgrid.Command(e);
model.trigger("backgrid:edited", model, column, command);
},
_setOptions: function (options) {
this.cell = options.cell
}
});
});

View file

@ -0,0 +1,7 @@
{{#each available}}
{{#if selected}}
<option value="{{id}}" selected="selected">{{name}}</option>
{{else}}
<option value="{{id}}">{{name}}</option>
{{/if}}
{{/each}}

View file

@ -14,6 +14,12 @@ define(
this.cellValue = this._getValue();
this.listenTo(this.model, 'change', this._refresh);
this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) {
if (column.get("name") == this.column.get("name")) {
this._startEditing(model, column, cell, editor);
}
});
},
_refresh: function () {

View file

@ -1,12 +1,17 @@
'use strict';
define(
[
'Cells/TemplatedCell'
], function (TemplatedCell) {
'Cells/TemplatedCell',
'Cells/Edit/QualityCellEditor'
], function (TemplatedCell, QualityCellEditor) {
return TemplatedCell.extend({
className: 'quality-cell',
template : 'Cells/QualityCellTemplate'
template : 'Cells/QualityCellTemplate',
editor : QualityCellEditor,
_startEditing: function (model, column, cell, editor) {
editor._setOptions({ cell: cell });
}
});
});

View file

@ -7,7 +7,6 @@ define(
], function (Marionette, NzbDroneCell) {
return NzbDroneCell.extend({
render: function () {
var templateName = this.column.get('template') || this.template;
@ -17,6 +16,7 @@ define(
var html = this.templateFunction(data);
this.$el.html(html);
this.delegateEvents();
return this;
}
});

View file

@ -5,11 +5,10 @@
<h3>
<i class="icon-bookmark x-episode-monitored" title="Toggle monitored status" />
{{#if episodeTitle}}
{{episodeTitle}}
{{title}} - {{EpisodeNumber}} - {{episodeTitle}}
{{else}}
{{title}}
{{series.title}} - {{EpisodeNumber}} - {{title}}
{{/if}}
- {{EpisodeNumber}}
</h3>
</div>

View file

@ -34,7 +34,8 @@ define(
name : 'quality',
label : 'Quality',
cell : QualityCell,
sortable: false
sortable: false,
editable: true
}
],

View file

@ -1,4 +1,14 @@
<div class="episode-overview">
<div class="episode-info">
{{#with series}}
{{qualityProfile qualityProfileId}}
<span class="label label-info">{{network}}</span>
{{/with}}
<span class="label label-info">{{StartTime airDateUtc}}</span>
<span class="label label-info">{{NextAiring airDateUtc}}</span>
</div>
<div class="episode-overview">
{{overview}}
</div>
<div class="episode-file-info"></div>

View file

@ -197,13 +197,15 @@
.episode-detail-modal {
.episode-overview {
.episode-info {
margin-bottom: 10px;
}
.episode-overview {
font-style : italic;
}
.episode-file-info {
margin-top : 30px;
font-size : 12px;
}

View file

@ -4,8 +4,8 @@ define(['app',
'marionette',
'Settings/Quality/Profile/QualityProfileView',
'Settings/Quality/Profile/EditQualityProfileView',
'Settings/Quality/Profile/QualityProfileSchemaCollection'],
function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
'Settings/Quality/Profile/QualityProfileSchemaCollection'
], function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
return Marionette.CompositeView.extend({
itemView : QualityProfileView,
@ -24,7 +24,6 @@ define(['app',
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_addProfile: function () {
var self = this;
var schemaCollection = new ProfileCollection();