Better Backgrid.Column defaults, much cleaner

pull/2/head
Mark McDowall 12 years ago
parent 16e13e0c24
commit 92d913e4ac

@ -15,73 +15,59 @@ define([
pager : '#x-pager' pager : '#x-pager'
}, },
showTable: function () { columns: [
{
name : 'indexer',
label : '',
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/IndexerTemplate' })
},
{
name : 'Series.Title',
label : 'Series Title',
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' })
},
{
name : 'episode',
label : 'Episode',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' })
},
{
name : 'Episode.Title',
label : 'Episode Title',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/EpisodeTitleTemplate' })
},
{
name : 'quality',
label : 'Quality',
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/QualityTemplate' })
},
{
name : 'date',
label : 'Grabbed',
cell : 'airDate'
},
{
name : 'edit',
label : '',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/ControlsColumnTemplate' })
}
],
var columns = [ showTable: function () {
{
name : 'indexer',
label : '',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/IndexerTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'Series.Title',
label : 'Series Title',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'episode',
label : 'Episode',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'Episode.Title',
label : 'Episode Title',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/EpisodeTitleTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'quality',
label : 'Quality',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/QualityTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'date',
label : 'Grabbed',
editable : false,
cell : 'airDate',
headerCell: 'nzbDrone'
},
{
name : 'edit',
label : '',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/ControlsColumnTemplate' }),
headerCell: 'nzbDrone'
}
];
this.history.show(new Backgrid.Grid( this.history.show(new Backgrid.Grid(
{ {
row : NzbDrone.History.Row, row : NzbDrone.History.Row,
columns : columns, columns : this.columns,
collection: this.historyCollection, collection: this.historyCollection,
className : 'table table-hover' className : 'table table-hover'
})); }));
this.pager.show(new Backgrid.NzbDronePaginator({ this.pager.show(new Backgrid.NzbDronePaginator({
columns: columns, columns: this.columns,
collection: this.historyCollection collection: this.historyCollection
})); }));
}, },

@ -16,59 +16,48 @@ define([
pager : '#x-pager' pager : '#x-pager'
}, },
showTable: function () { columns: [
{
var columns = [ name : 'series.Title',
{ label : 'Series Title',
name : 'series.Title', cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' })
label : 'Series Title', },
editable : false, {
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' }), name : 'episode',
headerCell: 'nzbDrone' label : 'Episode',
}, sortable : false,
{ cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' })
name : 'episode', },
label : 'Episode', {
editable : false, name : 'title',
sortable : false, label : 'Episode Title',
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' }), sortable : false,
headerCell: 'nzbDrone' cell : 'string'
}, },
{ {
name : 'title', name : 'airDate',
label : 'Episode Title', label : 'Air Date',
editable : false, cell : 'airDate'
sortable : false, },
cell : 'string', {
headerCell: 'nzbDrone' name : 'edit',
}, label : '',
{ sortable : false,
name : 'airDate', cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/ControlsColumnTemplate' })
label : 'Air Date', }
editable : false, ],
cell : 'airDate',
headerCell: 'nzbDrone'
},
{
name : 'edit',
label : '',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/ControlsColumnTemplate' }),
headerCell: 'nzbDrone'
}
];
showTable: function () {
this.missing.show(new Backgrid.Grid( this.missing.show(new Backgrid.Grid(
{ {
row : NzbDrone.Missing.Row, row : NzbDrone.Missing.Row,
columns : columns, columns : this.columns,
collection: this.missingCollection, collection: this.missingCollection,
className : 'table table-hover' className : 'table table-hover'
})); }));
this.pager.show(new Backgrid.NzbDronePaginator({ this.pager.show(new Backgrid.NzbDronePaginator({
columns: columns, columns: this.columns,
collection: this.missingCollection collection: this.missingCollection
})); }));
}, },

@ -1,5 +1,16 @@
"use strict"; "use strict";
Backgrid.Column.prototype.defaults = {
name: undefined,
label: undefined,
sortable: true,
editable: false,
renderable: true,
formatter: undefined,
cell: undefined,
headerCell: 'nzbDrone'
};
Backgrid.TemplateBackedCell = Backgrid.Cell.extend({ Backgrid.TemplateBackedCell = Backgrid.Cell.extend({
className: '', className: '',
template: 'Series/Index/Table/ControlsColumnTemplate', template: 'Series/Index/Table/ControlsColumnTemplate',

@ -10,26 +10,23 @@ define(['app', 'Series/Details/EpisodeDetailCell'], function () {
columns: [ columns: [
{ {
name : 'details', name : 'details',
editable: false, label : 'Details',
cell : NzbDrone.Series.Details.EpisodeDetailCell cell : NzbDrone.Series.Details.EpisodeDetailCell
}, },
{ {
name : 'episodeNumber', name : 'episodeNumber',
label : '#', label : '#',
editable: false,
cell : 'integer' cell : 'integer'
}, },
{ {
name : 'title', name : 'title',
label : 'Title', label : 'Title',
editable: false,
cell : 'string' cell : 'string'
}, },
{ {
name : 'airDate', name : 'airDate',
label : 'Air Date', label : 'Air Date',
editable: false,
cell : 'date' cell : 'date'
//formatter: new Backgrid.AirDateFormatter() //formatter: new Backgrid.AirDateFormatter()
} }

@ -18,73 +18,57 @@ define([
toolbar: '#x-toolbar' toolbar: '#x-toolbar'
}, },
showTable: function () { columns: [
{
name : 'status',
label : '',
cell : 'seriesStatus'
},
{
name : 'title',
label : 'Title',
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/SeriesTitleTemplate' })
},
{
name : 'seasonCount',
label : 'Seasons',
cell : 'integer'
},
{
name : 'quality',
label : 'Quality',
cell : 'integer'
},
{
name : 'network',
label : 'Network',
cell : 'string'
},
{
name : 'nextAiring',
label : 'Next Airing',
cell : 'airDate'
},
{
name : 'episodes',
label : 'Episodes',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/EpisodeProgressTemplate' })
},
{
name : 'edit',
label : '',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/ControlsColumnTemplate' })
}
],
var columns = [ showTable: function () {
{
name : 'status',
label : '',
editable : false,
cell : 'seriesStatus',
headerCell: 'nzbDrone'
},
{
name : 'title',
label : 'Title',
editable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/SeriesTitleTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'seasonCount',
label : 'Seasons',
editable : false,
cell : 'integer',
headerCell: 'nzbDrone'
},
{
name : 'quality',
label : 'Quality',
editable : false,
cell : 'integer',
headerCell: 'nzbDrone'
},
{
name : 'network',
label : 'Network',
editable : false,
cell : 'string',
headerCell: 'nzbDrone'
},
{
name : 'nextAiring',
label : 'Next Airing',
editable : false,
cell : 'airDate',
headerCell: 'nzbDrone'
},
{
name : 'episodes',
label : 'Episodes',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/EpisodeProgressTemplate' }),
headerCell: 'nzbDrone'
},
{
name : 'edit',
label : '',
editable : false,
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/ControlsColumnTemplate' }),
headerCell: 'nzbDrone'
}
];
this.series.show(new Backgrid.Grid( this.series.show(new Backgrid.Grid(
{ {
row : NzbDrone.Series.Index.Table.Row, row : NzbDrone.Series.Index.Table.Row,
columns : columns, columns : this.columns,
collection: this.seriesCollection, collection: this.seriesCollection,
className : 'table table-hover' className : 'table table-hover'
})); }));

Loading…
Cancel
Save