mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
cleaned up all the cells. there is a cell for pretty much everything.
This commit is contained in:
parent
ac3582d5c4
commit
70cfa5e685
42 changed files with 432 additions and 261 deletions
15
UI/Cells/AirDateCell.js
Normal file
15
UI/Cells/AirDateCell.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
define(['app', 'Shared/FormatHelpers'], function () {
|
||||
NzbDrone.Cells.AirDateCell = Backgrid.Cell.extend({
|
||||
className: "air-date-cell",
|
||||
|
||||
render: function () {
|
||||
|
||||
this.$el.empty();
|
||||
var airDate = this.model.get(this.column.get("name"));
|
||||
this.$el.html(NzbDrone.Shared.FormatHelpers.DateHelper(airDate));
|
||||
return this;
|
||||
|
||||
}
|
||||
});
|
||||
});
|
34
UI/Cells/EpisodeNumberCell.js
Normal file
34
UI/Cells/EpisodeNumberCell.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
define(['app', 'Cells/NzbDroneCell'], function () {
|
||||
NzbDrone.Cells.EpisodeNumberCell = NzbDrone.Cells.NzbDroneCell.extend({
|
||||
|
||||
className: "episode-number-cell",
|
||||
|
||||
render: function () {
|
||||
|
||||
var airDate = this.cellValue.get('airDate') || this.get(this.column.get("airDate"));
|
||||
var seasonNumber = this.cellValue.get('seasonNumber') || this.model.get(this.column.get("seasonNumber"));
|
||||
var episodes = this.cellValue.get('episodeNumber') || this.model.get(this.column.get("episodes"));
|
||||
|
||||
var result = 'Unknown';
|
||||
|
||||
if (airDate) {
|
||||
|
||||
result = new Date(airDate).toLocaleDateString();
|
||||
}
|
||||
else {
|
||||
|
||||
var paddedEpisodes = _.map(episodes, function (episodeNumber) {
|
||||
return episodeNumber.pad(2);
|
||||
});
|
||||
|
||||
result = 'S{0}-E{1}'.format(seasonNumber, paddedEpisodes.join());
|
||||
}
|
||||
|
||||
this.$el.html(result);
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
34
UI/Cells/EpisodeStatusCell.js
Normal file
34
UI/Cells/EpisodeStatusCell.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
|
||||
define(['app' ], function () {
|
||||
NzbDrone.Cells.EpisodeStatusCell = Backgrid.Cell.extend({
|
||||
|
||||
className: 'episode-status-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
if (this.model) {
|
||||
|
||||
var icon;
|
||||
|
||||
if (this.model.get('episodeFile')) {
|
||||
icon = 'icon-ok';
|
||||
|
||||
}
|
||||
else {
|
||||
if (this.model.get('hasAired')) {
|
||||
icon = 'icon-warning-sign';
|
||||
}
|
||||
else {
|
||||
icon = 'icon-time';
|
||||
}
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}"/>'.format(icon));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
22
UI/Cells/EpisodeTitleCell.js
Normal file
22
UI/Cells/EpisodeTitleCell.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
"use strict";
|
||||
|
||||
define(['app', 'Cells/NzbDroneCell'], function () {
|
||||
NzbDrone.Cells.EpisodeTitleCell = NzbDrone.Cells.NzbDroneCell.extend({
|
||||
|
||||
className: 'episode-title-cell',
|
||||
|
||||
events: {
|
||||
'click': 'showDetails'
|
||||
},
|
||||
|
||||
showDetails: function () {
|
||||
var view = new NzbDrone.Episode.Layout({ model: this.cellValue });
|
||||
NzbDrone.modalRegion.show(view);
|
||||
},
|
||||
|
||||
render: function () {
|
||||
this.$el.html(this.cellValue.get('title'));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
15
UI/Cells/FileSizeCell.js
Normal file
15
UI/Cells/FileSizeCell.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
"use strict";
|
||||
|
||||
define(['app', 'Shared/FormatHelpers'], function () {
|
||||
NzbDrone.Cells.FileSizeCell = Backgrid.Cell.extend({
|
||||
|
||||
className: "file-size-cell",
|
||||
|
||||
render: function () {
|
||||
var size = this.model.get(this.column.get("name"));
|
||||
this.$el.html(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
13
UI/Cells/IndexerCell.js
Normal file
13
UI/Cells/IndexerCell.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
define(['app'], function () {
|
||||
NzbDrone.Cells.IndexerCell = Backgrid.Cell.extend({
|
||||
|
||||
class : 'indexer-cell',
|
||||
|
||||
render: function () {
|
||||
var indexer = this.model.get(this.column.get('name'));
|
||||
this.$el.html(indexer);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
40
UI/Cells/NzbDroneCell.js
Normal file
40
UI/Cells/NzbDroneCell.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
"use strict";
|
||||
|
||||
define(['app'], function () {
|
||||
NzbDrone.Cells.NzbDroneCell = Backgrid.Cell.extend({
|
||||
|
||||
_originalInit: Backgrid.Cell.prototype.initialize,
|
||||
|
||||
|
||||
initialize: function () {
|
||||
this._originalInit.apply(this, arguments);
|
||||
this.cellValue = this._getValue();
|
||||
|
||||
this.model.on('change', this._refresh, this);
|
||||
},
|
||||
|
||||
_refresh: function () {
|
||||
this.cellValue = this._getValue();
|
||||
this.render();
|
||||
},
|
||||
|
||||
_getValue: function () {
|
||||
|
||||
var name = this.column.get('name');
|
||||
|
||||
if(name === 'this'){
|
||||
return this.model;
|
||||
}
|
||||
|
||||
var value = this.model.get(name);
|
||||
|
||||
//if not a model
|
||||
if (!value.get) {
|
||||
return value = new Backbone.Model(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
9
UI/Cells/QualityCell.js
Normal file
9
UI/Cells/QualityCell.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
define(['app', 'Cells/TemplatedCell'], function () {
|
||||
NzbDrone.Cells.QualityCell = NzbDrone.Cells.TemplatedCell.extend({
|
||||
|
||||
className: 'quality-cell',
|
||||
template : 'Cells/QualityTemplate'
|
||||
|
||||
});
|
||||
});
|
5
UI/Cells/QualityTemplate.html
Normal file
5
UI/Cells/QualityTemplate.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{quality.quality.name}}
|
||||
|
||||
{{#if quality.proper}}
|
||||
[PROPER]
|
||||
{{/if}}
|
13
UI/Cells/RelativeDateCell.js
Normal file
13
UI/Cells/RelativeDateCell.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
define(['app'], function () {
|
||||
NzbDrone.Cells.RelativeDateCell = Backgrid.Cell.extend({
|
||||
|
||||
render: function () {
|
||||
|
||||
var date = this.model.get(this.column.get('name'));
|
||||
this.$el.html(Date.create(date).relative());
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
9
UI/Cells/SeriesTitleCell.js
Normal file
9
UI/Cells/SeriesTitleCell.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
"use strict";
|
||||
define(['app', 'Cells/TemplatedCell'], function () {
|
||||
NzbDrone.Cells.SeriesTitleCell = NzbDrone.Cells.TemplatedCell.extend({
|
||||
|
||||
className: 'series-title',
|
||||
template : 'Cells/SeriesTitleTemplate'
|
||||
|
||||
});
|
||||
});
|
2
UI/Cells/SeriesTitleTemplate.html
Normal file
2
UI/Cells/SeriesTitleTemplate.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
<a href="{{route}}">{{title}}</a>
|
||||
{{debug}}
|
19
UI/Cells/TemplatedCell.js
Normal file
19
UI/Cells/TemplatedCell.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
"use strict";
|
||||
|
||||
define(['app','Cells/NzbDroneCell'], function () {
|
||||
NzbDrone.Cells.TemplatedCell = NzbDrone.Cells.NzbDroneCell.extend({
|
||||
|
||||
|
||||
render: function () {
|
||||
|
||||
var templateName = this.column.get('template') || this.template;
|
||||
|
||||
this.templateFunction = Marionette.TemplateCache.get(templateName);
|
||||
var data = this.cellValue.toJSON();
|
||||
var html = this.templateFunction(data);
|
||||
this.$el.html(html);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
39
UI/Cells/ToggleCell.js
Normal file
39
UI/Cells/ToggleCell.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
"use strict";
|
||||
|
||||
define(['app', 'Episode/Layout'], function () {
|
||||
NzbDrone.Cells.ToggleCell = Backgrid.Cell.extend({
|
||||
|
||||
className: 'toggle-cell clickable',
|
||||
|
||||
events: {
|
||||
'click': '_onClick'
|
||||
},
|
||||
|
||||
|
||||
_onClick: function () {
|
||||
var name = this.column.get('name');
|
||||
this.model.set(name, !this.model.get(name));
|
||||
this.render();
|
||||
|
||||
this.model.save();
|
||||
},
|
||||
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
|
||||
this.$el.html('<i />');
|
||||
|
||||
var name = this.column.get('name');
|
||||
|
||||
if (this.model.get(name)) {
|
||||
this.$('i').addClass(this.column.get('trueClass'));
|
||||
}
|
||||
else {
|
||||
this.$('i').addClass(this.column.get('falseClass'));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
7
UI/Cells/cells.less
Normal file
7
UI/Cells/cells.less
Normal file
|
@ -0,0 +1,7 @@
|
|||
@import "../content/Bootstrap/mixins";
|
||||
@import "../content/Bootstrap/variables";
|
||||
@import "../content/Bootstrap/buttons";
|
||||
|
||||
.episode-title-cell {
|
||||
.btn-link;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue