Files
dog_training/static/js/pages/dog/button_icons.js

86 lines
2.6 KiB
JavaScript

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 PageDogButtonIcons extends TableBasePage {
static hash = hashPageDogButtonIcons;
static attrIdRowObject = attrIdButtonIcon;
callSaveTableContent = API.saveButtonIcons;
constructor(router) {
super(router);
this.dogMixin = new DogTableMixinPage(this);
}
initialize() {
this.sharedInitialize();
}
hookupFilters() {
this.sharedHookupFilters();
this.hookupFilterActive();
}
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 buttonActive = row.querySelector('td.' + flagActive + ' .' + flagActive);
let jsonRow = {};
jsonRow[attrIdButtonIcon] = row.getAttribute(attrIdButtonIcon);
jsonRow[flagImage] = this.getIdImageRow(row);
jsonRow[flagName] = DOM.getElementAttributeValueCurrent(inputName);
jsonRow[flagActive] = buttonActive.classList.contains(flagDelete);
console.log("jsonRow");
console.log(jsonRow);
return jsonRow;
}
getIdImageRow(row) {
let elementImage = row.querySelector('td.' + flagImage + ' .' + flagImage);
return DOM.getElementAttributeValueCurrent(elementImage);
}
initialiseRowNew(tbody, row) {
}
postInitialiseRowNewCallback(tbody) {
let newRows = tbody.querySelectorAll('tr.' + flagRowNew);
let newestRow = newRows[0];
let clickableElementsSelector = [
'td.' + flagImage + ' div.' + flagImage
].join('');
newestRow.querySelectorAll(clickableElementsSelector).forEach((clickableElement) => {
clickableElement.click();
});
}
hookupTableMain() {
super.hookupTableMain();
this.hookupFieldsImage();
this.hookupFieldsNameTable();
this.hookupFieldsActive();
}
hookupFieldsImage() {
this.hookupTableCellDdlPreviews(
flagImage
, Utils.getListFromDict(buttonicons) // .sort((a, b) => a[flagName].localeCompare(b[flagName]))
);
}
leave() {
super.leave();
}
}