Skip to content

Commit

Permalink
Break up ResultRow #1 - BulkActionResultRow
Browse files Browse the repository at this point in the history
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
danrahn committed Mar 10, 2024
1 parent ce76d8b commit 22deb02
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 63 deletions.
69 changes: 69 additions & 0 deletions Client/Script/BulkActionResultRow.js
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);
}
}
64 changes: 1 addition & 63 deletions Client/Script/ResultRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { ClientEpisodeData, ClientMovieData } from './ClientDataExtensions.js';
import { errorMessage, errorResponseOverlay, errorToast } from './ErrorHandling.js';
import { FilterDialog, FilterSettings, SortConditions, SortOrder } from './FilterDialog.js';
import { UISection, UISections } from './ResultSections.js';
import BulkActionResultRow from './BulkActionResultRow.js';
import { BulkActionType } from './BulkActionCommon.js';
import BulkAddOverlay from './BulkAddOverlay.js';
import BulkDeleteOverlay from './BulkDeleteOverlay.js';
import BulkShiftOverlay from './BulkShiftOverlay.js';
import ButtonCreator from './ButtonCreator.js';
import { ClientSettings } from './ClientSettings.js';
import { getSvgIcon } from './SVGHelper.js';
Expand Down Expand Up @@ -320,66 +318,6 @@ class ResultRow {
}
}

/**
* A result row that offers bulk marker actions, like shifting everything X milliseconds.
*/
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);
}
}

/**
* A section-wide header that is displayed no matter what the current view state is (beside the blank state).
* Currently only contains the Filter entrypoint.
Expand Down

0 comments on commit 22deb02

Please sign in to comment.