From 7320342123d6ed9296b9c13c305d3ab3a1da0314 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 18 Sep 2013 22:49:15 -0700 Subject: [PATCH] Added search button/menu to series details grid Also fixed some names to make name navigation easier. --- UI/Cells/EpisodeActionsCell.js | 54 +++++++++++++++++++ UI/Cells/EpisodeActionsCellTemplate.html | 10 ++++ UI/Cells/EpisodeTitleCell.js | 2 +- UI/Cells/cells.less | 22 ++++++++ .../{Layout.js => EpisodeDetailsLayout.js} | 16 ++++-- ...html => EpisodeDetailsLayoutTemplate.html} | 0 .../{Layout.js => EpisodeSearchLayout.js} | 10 +++- ....html => EpisodeSearchLayoutTemplate.html} | 0 UI/Release/DownloadReportCell.js | 2 +- UI/Series/Details/SeasonLayout.js | 9 +++- UI/Shared/Modal/Controller.js | 6 +-- 11 files changed, 120 insertions(+), 11 deletions(-) create mode 100644 UI/Cells/EpisodeActionsCell.js create mode 100644 UI/Cells/EpisodeActionsCellTemplate.html rename UI/Episode/{Layout.js => EpisodeDetailsLayout.js} (88%) rename UI/Episode/{LayoutTemplate.html => EpisodeDetailsLayoutTemplate.html} (100%) rename UI/Episode/Search/{Layout.js => EpisodeSearchLayout.js} (89%) rename UI/Episode/Search/{LayoutTemplate.html => EpisodeSearchLayoutTemplate.html} (100%) diff --git a/UI/Cells/EpisodeActionsCell.js b/UI/Cells/EpisodeActionsCell.js new file mode 100644 index 000000000..27bcd893e --- /dev/null +++ b/UI/Cells/EpisodeActionsCell.js @@ -0,0 +1,54 @@ +'use strict'; + +define( + [ + 'app', + 'Cells/NzbDroneCell', + 'Commands/CommandController' + ], function (App, NzbDroneCell, CommandController) { + return NzbDroneCell.extend({ + + className: 'episode-actions-cell', + template : 'Cells/EpisodeActionsCellTemplate', + + ui: { + automaticSearch: '.x-automatic-search-icon' + }, + + events: { + 'click .x-automatic-search': '_automaticSearch', + 'click .x-manual-search' : '_manualSearch' + }, + + 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); + + CommandController.bindToCommand({ + element: this.$(this.ui.automaticSearch), + command: { + name : 'episodeSearch', + episodeId: this.model.get('id') + } + }); + + this.delegateEvents(); + return this; + }, + + _automaticSearch: function () { + CommandController.Execute('episodeSearch', { + name : 'episodeSearch', + episodeId: this.model.get('id') + }); + }, + + _manualSearch: function () { + App.vent.trigger(App.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: true, openingTab: 'search' }); + } + }); + }); diff --git a/UI/Cells/EpisodeActionsCellTemplate.html b/UI/Cells/EpisodeActionsCellTemplate.html new file mode 100644 index 000000000..cea3bef98 --- /dev/null +++ b/UI/Cells/EpisodeActionsCellTemplate.html @@ -0,0 +1,10 @@ +
+ + + +
\ No newline at end of file diff --git a/UI/Cells/EpisodeTitleCell.js b/UI/Cells/EpisodeTitleCell.js index f5e2651c9..ae0143c0c 100644 --- a/UI/Cells/EpisodeTitleCell.js +++ b/UI/Cells/EpisodeTitleCell.js @@ -27,7 +27,7 @@ define( _showDetails: function () { var hideSeriesLink = this.column.get('hideSeriesLink'); - App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: this.cellValue, hideSeriesLink: hideSeriesLink }); + App.vent.trigger(App.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: hideSeriesLink }); } }); }); diff --git a/UI/Cells/cells.less b/UI/Cells/cells.less index 9cd18c9a6..1c699302e 100644 --- a/UI/Cells/cells.less +++ b/UI/Cells/cells.less @@ -61,4 +61,26 @@ td.episode-status-cell, td.quality-cell { .nzb-title-cell { max-width: 600px; word-wrap: break-word; +} + +.episode-actions-cell { + width: 20px; + + li { + .clickable(); + + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 20px; + color: rgb(51, 51, 51); + white-space: nowrap; + } + + li:hover { + text-decoration: none; + color: rgb(255, 255, 255); + background-color: rgb(0, 129, 194); + } } \ No newline at end of file diff --git a/UI/Episode/Layout.js b/UI/Episode/EpisodeDetailsLayout.js similarity index 88% rename from UI/Episode/Layout.js rename to UI/Episode/EpisodeDetailsLayout.js index a785aaad4..590351b40 100644 --- a/UI/Episode/Layout.js +++ b/UI/Episode/EpisodeDetailsLayout.js @@ -3,12 +3,12 @@ define( [ 'marionette', 'Episode/Summary/EpisodeSummaryLayout', - 'Episode/Search/Layout', + 'Episode/Search/EpisodeSearchLayout', 'Series/SeriesCollection' ], function (Marionette, SummaryLayout, SearchLayout, SeriesCollection) { return Marionette.Layout.extend({ - template: 'Episode/LayoutTemplate', + template: 'Episode/EpisodeDetailsLayoutTemplate', regions: { summary : '#episode-summary', @@ -38,11 +38,21 @@ define( this.series = SeriesCollection.find({ id: this.model.get('seriesId') }); this.templateHelpers.series = this.series.toJSON(); + this.openingTab = options.openingTab || 'summary' }, onShow: function () { - this._showSummary(); this.searchLayout = new SearchLayout({ model: this.model }); + + if (this.openingTab === 'search') { + this.searchLayout.startManualSearch = true; + this._showSearch(); + } + + else { + this._showSummary(); + } + this._setMonitoredState(); }, diff --git a/UI/Episode/LayoutTemplate.html b/UI/Episode/EpisodeDetailsLayoutTemplate.html similarity index 100% rename from UI/Episode/LayoutTemplate.html rename to UI/Episode/EpisodeDetailsLayoutTemplate.html diff --git a/UI/Episode/Search/Layout.js b/UI/Episode/Search/EpisodeSearchLayout.js similarity index 89% rename from UI/Episode/Search/Layout.js rename to UI/Episode/Search/EpisodeSearchLayout.js index 2d812ce4c..08d003e2c 100644 --- a/UI/Episode/Search/Layout.js +++ b/UI/Episode/Search/EpisodeSearchLayout.js @@ -12,7 +12,7 @@ define( ], function (App, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) { return Marionette.Layout.extend({ - template: 'Episode/Search/LayoutTemplate', + template: 'Episode/Search/EpisodeSearchLayoutTemplate', regions: { main: '#episode-search-region' @@ -29,7 +29,13 @@ define( }, onShow: function () { - this._showMainView(); + if (this.startManualSearch) { + this._searchManual(); + } + + else { + this._showMainView(); + } }, _searchAuto: function (e) { diff --git a/UI/Episode/Search/LayoutTemplate.html b/UI/Episode/Search/EpisodeSearchLayoutTemplate.html similarity index 100% rename from UI/Episode/Search/LayoutTemplate.html rename to UI/Episode/Search/EpisodeSearchLayoutTemplate.html diff --git a/UI/Release/DownloadReportCell.js b/UI/Release/DownloadReportCell.js index 47694fab5..49a666f8b 100644 --- a/UI/Release/DownloadReportCell.js +++ b/UI/Release/DownloadReportCell.js @@ -29,7 +29,7 @@ define( }, render: function () { - this.$el.html(''); + this.$el.empty(); if (this.model.get('downloadAllowed')) { diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js index 91b4d8d1c..ddc2f74d2 100644 --- a/UI/Series/Details/SeasonLayout.js +++ b/UI/Series/Details/SeasonLayout.js @@ -8,9 +8,10 @@ define( 'Cells/EpisodeTitleCell', 'Cells/RelativeDateCell', 'Cells/EpisodeStatusCell', + 'Cells/EpisodeActionsCell', 'Commands/CommandController', 'moment' - ], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, CommandController, Moment) { + ], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment) { return Marionette.Layout.extend({ template: 'Series/Details/SeasonLayoutTemplate', @@ -67,6 +68,12 @@ define( label : 'Status', cell : EpisodeStatusCell, sortable: false + }, + { + name : 'this', + label : '', + cell : EpisodeActionsCell, + sortable: false } ], diff --git a/UI/Shared/Modal/Controller.js b/UI/Shared/Modal/Controller.js index a1303a453..cbb97ebf5 100644 --- a/UI/Shared/Modal/Controller.js +++ b/UI/Shared/Modal/Controller.js @@ -5,9 +5,9 @@ define( 'marionette', 'Series/Edit/EditSeriesView', 'Series/Delete/DeleteSeriesView', - 'Episode/Layout', + 'Episode/EpisodeDetailsLayout', 'History/Details/HistoryDetailsView' - ], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeLayout, HistoryDetailsView) { + ], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView) { var router = Marionette.AppRouter.extend({ @@ -34,7 +34,7 @@ define( }, _showEpisode: function (options) { - var view = new EpisodeLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink }); + var view = new EpisodeDetailsLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink, openingTab: options.openingTab }); App.modalRegion.show(view); },