Files
Readarr/src/UI/Artist/TrackCollection.js
Qstick d8ea0a3243 Many UI and API Improvements (#8)
This fixes and implements many items on the ArtistIndex Page and ArtistDetailPage

* Create ArtistStatistics Core Module and tie into API.
* Create Members Class and tie into ArtistModel and Artist API resource.
* Finish Out Album API resources and pass to ArtistDetailPage.
* Finish Out Track and TrackFile API resources and pass to ArtistDetailPage.
* Lots of UI work on Artist Detail Page to get Albums and Track list working.
* Add Cover and Disc Image Types to MediaCover Class
* Remove AddSeries UI Flow, since we have replaced with AddArtist (Cleanup)
2017-06-25 08:17:49 -05:00

62 lines
1.4 KiB
JavaScript

var Backbone = require('backbone');
var PageableCollection = require('backbone.pageable');
var TrackModel = require('./TrackModel');
require('./TrackCollection');
module.exports = PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/track',
model : TrackModel,
state : {
sortKey : 'trackNumber',
order : 1,
pageSize : 100000
},
mode : 'client',
originalFetch : Backbone.Collection.prototype.fetch,
initialize : function(options) {
this.artistId = options.artistId;
},
byAlbum : function(album) {
var filtered = this.filter(function(track) {
return track.get('albumId') === album;
});
var TrackCollection = require('./TrackCollection');
return new TrackCollection(filtered);
},
comparator : function(model1, model2) {
var track1 = model1.get('trackNumber');
var track2 = model2.get('trackNumber');
if (track1 < track2) {
return -1;
}
if (track1 > track2) {
return 1;
}
return 0;
},
fetch : function(options) {
if (!this.artistId) {
throw 'artistId is required';
}
if (!options) {
options = {};
}
options.data = { artistId : this.artistId };
return this.originalFetch.call(this, options);
}
});