import { InitiativeTrackerRowDataViewDefaultParty, } from "./dmscreen-initiativetracker-rowsdefaultparty.js"; export class InitiativeTrackerDefaultParty extends BaseComponent { static _RenderState = class { constructor () { this.cbDoClose = null; this.fnsCleanup = []; } }; constructor ({comp, roller, rowStateBuilder}) { super(); this._comp = comp; this._roller = roller; this._rowStateBuilder = rowStateBuilder; this._prop = "rowsDefaultParty"; this._viewRowsDefaultParty = null; } /* -------------------------------------------- */ pGetShowModalResults () { const rdState = new this.constructor._RenderState(); const {$modalInner, $modalFooter, pGetResolved, doClose} = UiUtil.getShowModal({ title: "Edit Default Party", isHeaderBorder: true, isUncappedHeight: true, hasFooter: true, cbClose: () => rdState.fnsCleanup.forEach(fn => fn()), $titleSplit: this._render_$getBtnAdd({rdState}), }); rdState.cbDoClose = doClose; this._render_renderBody({rdState, $modalInner}); this._render_renderFooter({rdState, $modalFooter}); return pGetResolved(); } _render_$getBtnAdd ({rdState}) { return $(``) .on("click", async () => { this._comp._state[this._prop] = [ ...this._comp._state[this._prop], await this._rowStateBuilder.pGetNewRowState(), ]; }); } /* -------------------------------------------- */ _render_renderBody ({rdState, $modalInner}) { this._viewRowsDefaultParty = new InitiativeTrackerRowDataViewDefaultParty({ comp: this._comp, prop: this._prop, roller: this._roller, rowStateBuilder: this._rowStateBuilder, }); this._viewRowsDefaultPartyMeta = this._viewRowsDefaultParty.getRenderedView(); this._viewRowsDefaultPartyMeta.$ele.appendTo($modalInner); rdState.fnsCleanup.push(this._viewRowsDefaultPartyMeta.cbDoCleanup); } /* -------------------------------------------- */ _render_renderFooter ({rdState, $modalFooter}) { const $btnSave = $(``) .click(() => rdState.cbDoClose(true)); $$($modalFooter)`