-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up ResultRow #9 - Split SeasonResultRow
While there are not currently any circular dependencies involving this class, align with ShowResultRow's new structure and break it into "real" and "title" variants: * SeasonResultRowBase - Common season result row functionality * SeasonResultRow - A "real" row that will load episodes when clicked. * SeasonTitleResultRow - A placeholder row displayed when a season is already active.
- Loading branch information
Showing
4 changed files
with
115 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { $$, buildNode } from './Common.js'; | ||
import { ContextualLog } from '../../Shared/ConsoleLog.js'; | ||
import { PurgedMarkers } from './PurgedMarkerManager.js'; | ||
import { ResultRow } from './ResultRow.js'; | ||
|
||
/** @typedef {!import('../../Shared/PlexTypes').SeasonData} SeasonData */ | ||
|
||
|
||
const Log = new ContextualLog('SeasonRowBase'); | ||
|
||
export default class SeasonResultRowBase extends ResultRow { | ||
|
||
/** @param {SeasonData} season */ | ||
constructor(season) { | ||
super(season, 'seasonResult'); | ||
} | ||
|
||
/** Whether this row is a placeholder title row, used when a specific season is selected. */ | ||
titleRow() { return false; } | ||
|
||
/** | ||
* Return the underlying season data associated with this result row. | ||
* @returns {SeasonData} */ | ||
season() { return this.mediaItem(); } | ||
|
||
onClick() { return null; } | ||
|
||
/** | ||
* Creates a DOM element for this season. */ | ||
buildRow() { | ||
if (this.html()) { | ||
Log.warn('buildRow has already been called for this SeasonResultRow, that shouldn\'t happen'); | ||
return this.html(); | ||
} | ||
|
||
const season = this.season(); | ||
const title = buildNode('div', { class : 'selectedSeasonTitle' }, buildNode('span', {}, `Season ${season.index}`)); | ||
if (season.title.length > 0 && season.title.toLowerCase() !== `season ${season.index}`) { | ||
title.appendChild(buildNode('span', { class : 'resultRowAltTitle' }, ` (${season.title})`)); | ||
} | ||
|
||
const row = this.buildRowColumns(title, null, this.onClick()); | ||
this.setHtml(row); | ||
return row; | ||
} | ||
|
||
/** | ||
* Returns the callback invoked when clicking on the marker count when purged markers are present. */ | ||
getPurgeEventListener() { | ||
return this.#onSeasonPurgeClick.bind(this); | ||
} | ||
|
||
/** | ||
* Show the purge overlay for this season. */ | ||
#onSeasonPurgeClick() { | ||
// For dummy rows, set focus back to the first tabbable row, as the purged icon might not exist anymore | ||
const focusBack = this.titleRow() ? $$('.tabbableRow', this.html().parentElement) : this.html(); | ||
PurgedMarkers.showSingleSeason(this.season().metadataId, focusBack); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { UISection, UISections } from './ResultSections.js'; | ||
import SeasonResultRowBase from './SeasonResultRowBase.js'; | ||
|
||
export default class SeasonTitleResultRow extends SeasonResultRowBase { | ||
|
||
/** @param {SeasonData} season */ | ||
constructor(season) { | ||
super(season, 'seasonResult'); | ||
} | ||
|
||
titleRow() { return true; } | ||
|
||
/** | ||
* Build this placeholder row. Take the bases row and adds a 'back' button */ | ||
buildRow() { | ||
if (this.html()) { | ||
// Extra data has already been added, and super.buildRow accounts for this, and gives us some warning logging. | ||
return super.buildRow(); | ||
} | ||
|
||
const row = super.buildRow(); | ||
this.addBackButton(row, 'Back to seasons', async () => { | ||
await UISections.hideSections(UISection.Episodes); | ||
UISections.clearSections(UISection.Episodes); | ||
UISections.showSections(UISection.Seasons); | ||
}); | ||
|
||
row.classList.add('dynamicText'); | ||
return row; | ||
} | ||
} |