import API from "../../api.js"; import BusinessObjects from "../../lib/business_objects/business_objects.js"; import DOM from "../../dom.js"; import Events from "../../lib/events.js"; import TableBasePage from "../base_table.js"; import Utils from "../../lib/utils.js"; import Validation from "../../lib/validation.js"; import DogTableMixinPage from "./mixin_table.js"; export default class PageDogCommands extends TableBasePage { static hash = hashPageDogCommands; static attrIdRowObject = attrIdCommand; callSaveTableContent = API.saveCommands; constructor(router) { super(router); this.dogMixin = new DogTableMixinPage(this); } initialize() { this.sharedInitialize(); } hookupFilters() { this.sharedHookupFilters(); this.hookupFilterCommandCategory(); this.hookupFilterActive(); } hookupFilterCommandCategory() { this.hookupFilter(attrIdCommandCategory); } loadRowTable(rowJson) { if (rowJson == null) return; if (_verbose) { Utils.consoleLogIfNotProductionEnvironment("applying data row: ", rowJson); } } getJsonRow(row) { if (row == null) return; let inputName = row.querySelector('td.' + flagName + ' .' + flagName); let inputHandSignalDefaultDescription = row.querySelector('td.' + flagHandSignalDefaultDescription + ' .' + flagHandSignalDefaultDescription); let inputCanHaveButton = row.querySelector('td.' + flagCanHaveButton + ' .' + flagCanHaveButton); let inputNotes = row.querySelector('td.' + flagNotes + ' .' + flagNotes); let buttonActive = row.querySelector('td.' + flagActive + ' .' + flagActive); /* Utils.consoleLogIfNotProductionEnvironment({ inputName, inputHandSignalDefaultDescription, inputCanHaveButton, inputNotes, buttonActive }); debugger; */ let jsonRow = {}; jsonRow[attrIdCommand] = row.getAttribute(attrIdCommand); jsonRow[attrIdCommandCategory] = this.getIdCommandCategoryRow(row); jsonRow[flagName] = DOM.getElementAttributeValueCurrent(inputName); jsonRow[flagHandSignalDefaultDescription] = DOM.getElementAttributeValueCurrent(inputHandSignalDefaultDescription); jsonRow[flagCanHaveButton] = (DOM.getElementAttributeValueCurrent(inputCanHaveButton) == "true"); jsonRow[flagNotes] = DOM.getElementAttributeValueCurrent(inputNotes); jsonRow[flagActive] = buttonActive.classList.contains(flagDelete); return jsonRow; } initialiseRowNew(tbody, row) { } postInitialiseRowNewCallback(tbody) { let newRows = tbody.querySelectorAll('tr.' + flagRowNew); let newestRow = newRows[newRows.length - 1]; let clickableElementsSelector = [ 'td.' + flagDog + ' div.' + flagDog , ',td.' + flagCommandCategory + ' div.' + flagCommandCategory , ',td.' + flagCommand + ' div.' + flagCommand ].join(''); newestRow.querySelectorAll(clickableElementsSelector).forEach((clickableElement) => { clickableElement.click(); }); } hookupTableMain() { super.hookupTableMain(); this.hookupFieldsCommandCategory(); this.hookupFieldsNameTable(); this.hookupTextareasHandSignalDefaultDescription(); this.hookupFieldsCanHaveButton(); this.hookupFieldsNotesTable(); this.hookupFieldsActive(); } hookupFieldsCommandCategory() { this.hookupTableCellDdlPreviews( flagCommandCategory , Utils.getListFromDict(filterCommandCategories) ); } hookupTextareasHandSignalDefaultDescription() { this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagHandSignalDefaultDescription + ' textarea'); } hookupFieldsCanHaveButton() { this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagCanHaveButton + ' input'); } leave() { super.leave(); } }