Fixed sorting in movie list view. Also added new downloaded quality column.

Fixes #128
pull/208/head v0.2.0.99
Leonardo Galli 8 years ago
parent 0b70a5c315
commit 5a8d944397

@ -0,0 +1,34 @@
var Backgrid = require('backgrid');
var ProfileCollection = require('../Profile/ProfileCollection');
var _ = require('underscore');
module.exports = Backgrid.Cell.extend({
className : 'profile-cell',
_originalInit : Backgrid.Cell.prototype.initialize,
initialize : function () {
this._originalInit.apply(this, arguments);
this.listenTo(ProfileCollection, 'sync', this.render);
},
render : function() {
this.$el.empty();
if (this.model.get("movieFile")) {
var profileId = this.model.get("movieFile").quality.quality.id;
var profile = _.findWhere(ProfileCollection.models, { id : profileId });
if (profile) {
this.$el.html(profile.get('name'));
} else {
this.$el.html(this.model.get("movieFile").quality.quality.name);
}
}
return this;
}
});

@ -3,4 +3,8 @@ var TemplatedCell = require('./TemplatedCell');
module.exports = TemplatedCell.extend({
className : 'movie-title-cell',
template : 'Cells/MovieDownloadStatusTemplate',
sortKey : function(model) {
debugger;
return 0;
}
});

@ -13,6 +13,7 @@ var MovieLinksCell = require('../../Cells/MovieLinksCell');
var MovieActionCell = require('../../Cells/MovieActionCell');
var MovieStatusCell = require('../../Cells/MovieStatusCell');
var MovieDownloadStatusCell = require('../../Cells/MovieDownloadStatusCell');
var DownloadedQualityCell = require('../../Cells/DownloadedQualityCell');
var FooterView = require('./FooterView');
var FooterModel = require('./FooterModel');
var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
@ -40,6 +41,11 @@ module.exports = Marionette.Layout.extend({
cell : MovieTitleCell,
cellValue : 'this',
},
{
name : "downloadedQuality",
label : "Downloaded",
cell : DownloadedQualityCell,
},
{
name : 'profileId',
label : 'Profile',
@ -54,12 +60,19 @@ module.exports = Marionette.Layout.extend({
name : 'this',
label : 'Links',
cell : MovieLinksCell,
className : "movie-links-cell"
className : "movie-links-cell",
sortable : false,
},
{
name : "this",
label : "Status",
cell : MovieDownloadStatusCell,
sortValue : function(m, k) {
if (m.get("downloaded")) {
return -1;
}
return 0;
}
},
{
name : 'this',

@ -9,5 +9,31 @@ module.exports = Backbone.Model.extend({
episodeCount : 0,
isExisting : false,
status : 0
},
getStatus : function() {
var monitored = this.get("monitored");
var status = this.get("status");
var inCinemas = this.get("inCinemas");
var date = new Date(inCinemas);
var timeSince = new Date().getTime() - date.getTime();
var numOfMonths = timeSince / 1000 / 60 / 60 / 24 / 30;
if (status === "announced") {
return "announced"
}
if (numOfMonths < 3 && numOfMonths > 0) {
return "inCinemas";
}
if (status === 'released') {
return "released";
}
if (numOfMonths > 3) {
return "released";//TODO: Update for PreDB.me
}
}
});

@ -75,7 +75,26 @@ var Collection = PageableCollection.extend({
title : {
sortKey : 'sortTitle'
},
statusWeight : {
sortValue : function(model, attr) {
if (model.getStatus() == "released") {
return 1;
}
if (model.getStatus() == "inCinemas") {
return 0;
}
return -1;
}
},
downloadedQuality : {
sortValue : function(model, attr) {
if (model.get("movieFile")) {
return 1000-model.get("movieFile").quality.quality.id;
}
return -1;
}
},
nextAiring : {
sortValue : function(model, attr, order) {
var nextAiring = model.get(attr);
@ -91,7 +110,15 @@ var Collection = PageableCollection.extend({
return Number.MAX_VALUE;
}
},
status: {
sortValue : function(model, attr) {
debugger;
if (model.get("downloaded")) {
return -1;
}
return 0;
}
},
percentOfEpisodes : {
sortValue : function(model, attr) {
var percentOfEpisodes = model.get(attr);

Loading…
Cancel
Save