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 PageDogDogCommandLinks extends TableBasePage { static hash = hashPageDogDogCommandLinks; static attrIdRowObject = attrIdDogCommandLink; callSaveTableContent = API.saveDogCommandLinks; constructor(router) { super(router); this.dogMixin = new DogTableMixinPage(this); } initialize() { this.sharedInitialize(); } hookupFilters() { this.sharedHookupFilters(); this.hookupFilterDog(); this.hookupFilterCommandCategory(); this.hookupFilterCommand(); this.hookupFilterActive(); } loadRowTable(rowJson) { if (rowJson == null) return; if (_verbose) { Utils.consoleLogIfNotProductionEnvironment("applying data row: ", rowJson); } } getJsonRow(row) { if (row == null) return; let inputHandSignalDescription = row.querySelector('td.' + flagHandSignalDescription + ' textarea'); let inputNotes = row.querySelector('td.' + flagNotes + ' textarea'); let buttonActive = row.querySelector('td.' + flagActive + ' .' + flagActive); let jsonRow = {}; jsonRow[attrIdDogCommandLink] = row.getAttribute(attrIdDogCommandLink); jsonRow[attrIdDog] = this.getIdDogRow(row); jsonRow[attrIdCommand] = this.getIdCommandRow(row); jsonRow[flagHandSignalDescription] = DOM.getElementAttributeValueCurrent(inputHandSignalDescription); 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[0]; 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.hookupFieldsDog(); this.hookupFieldsCommandCategory(); this.hookupFieldsCommand(); this.hookupTextareasHandSignalDescription(); this.hookupFieldsNotesTable(); this.hookupFieldsActive(); } hookupTextareasHandSignalDescription() { this.hookupChangeHandlerTableCells(idTableMain + ' td.' + flagHandSignalDescription + ' .' + flagHandSignalDescription); } leave() { super.leave(); } }