-
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 #1 - BulkActionResultRow
ResultRow has gotten massive and should be split up. Do this one class at a time for better git file history tracking, starting with BulkActionResultRow Note that things will likely be broken during these intermediate commits, but should work itself out by the end.
- Loading branch information
Showing
2 changed files
with
70 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { appendChildren, buildNode } from './Common.js'; | ||
import BulkAddOverlay from './BulkAddOverlay.js'; | ||
import BulkDeleteOverlay from './BulkDeleteOverlay.js'; | ||
import BulkShiftOverlay from './BulkShiftOverlay.js'; | ||
import ButtonCreator from './ButtonCreator.js'; | ||
import { ContextualLog } from '../../Shared/ConsoleLog.js'; | ||
import { ResultRow } from './ResultRow.js'; | ||
|
||
const Log = new ContextualLog('BulkActionRow'); | ||
|
||
/** | ||
* A result row that offers bulk marker actions, like shifting everything X milliseconds. | ||
*/ | ||
export default class BulkActionResultRow extends ResultRow { | ||
/** @type {HTMLElement} */ | ||
#bulkAddButton; | ||
/** @type {HTMLElement} */ | ||
#bulkShiftButton; | ||
/** @type {HTMLElement} */ | ||
#bulkDeleteButton; | ||
constructor(mediaItem) { | ||
super(mediaItem, 'bulkResultRow'); | ||
} | ||
|
||
/** | ||
* Build the bulk result row, returning the row */ | ||
buildRow() { | ||
if (this.html()) { | ||
Log.warn(`buildRow has already been called for this BulkActionResultRow, that shouldn't happen!`); | ||
return this.html(); | ||
} | ||
|
||
const titleNode = buildNode('div', { class : 'bulkActionTitle' }, 'Bulk Actions'); | ||
const row = buildNode('div', { class : 'bulkResultRow' }); | ||
this.#bulkAddButton = ButtonCreator.textButton('Bulk Add', this.#bulkAdd.bind(this), { style : 'margin-right: 10px' }); | ||
this.#bulkShiftButton = ButtonCreator.textButton('Bulk Shift', this.#bulkShift.bind(this), { style : 'margin-right: 10px' }); | ||
this.#bulkDeleteButton = ButtonCreator.textButton('Bulk Delete', this.#bulkDelete.bind(this)); | ||
appendChildren(row, | ||
titleNode, | ||
appendChildren(row.appendChild(buildNode('div', { class : 'goBack' })), | ||
this.#bulkAddButton, | ||
this.#bulkShiftButton, | ||
this.#bulkDeleteButton)); | ||
|
||
this.setHtml(row); | ||
return row; | ||
} | ||
|
||
// Override default behavior and don't show anything here, since we override this with our own actions. | ||
episodeDisplay() { } | ||
|
||
/** | ||
* Launch the bulk add overlay for the current media item (show/season). */ | ||
#bulkAdd() { | ||
new BulkAddOverlay(this.mediaItem()).show(this.#bulkAddButton); | ||
} | ||
|
||
/** | ||
* Launch the bulk shift overlay for the current media item (show/season). */ | ||
#bulkShift() { | ||
new BulkShiftOverlay(this.mediaItem()).show(this.#bulkShiftButton); | ||
} | ||
|
||
/** | ||
* Launch the bulk delete overlay for the current media item (show/season). */ | ||
#bulkDelete() { | ||
new BulkDeleteOverlay(this.mediaItem()).show(this.#bulkDeleteButton); | ||
} | ||
} |
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