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

84 lines
2.7 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 PageDogLocations extends TableBasePage {
static hash = hashPageDogLocations;
static attrIdRowObject = attrIdLocation;
callSaveTableContent = API.saveLocations;
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[attrIdLocation] = row.getAttribute(attrIdLocation);
jsonRow[flagLocationParent] = this.getIdLocationParentRow(row);
jsonRow[flagName] = DOM.getElementAttributeValueCurrent(inputName);
jsonRow[flagActive] = buttonActive.classList.contains(flagDelete);
return jsonRow;
}
getIdLocationParentRow(row) {
let elementLocationParent = row.querySelector('td.' + flagLocationParent + ' .' + flagLocationParent);
return DOM.getElementAttributeValueCurrent(elementLocationParent);
}
initialiseRowNew(tbody, row) {
}
postInitialiseRowNewCallback(tbody) {
let newRows = tbody.querySelectorAll('tr.' + flagRowNew);
let newestRow = newRows[0];
let clickableElementsSelector = [
'td.' + flagDog + ' div.' + flagDog
, ',td.' + flagLocationCategory + ' div.' + flagLocationCategory
, ',td.' + flagLocation + ' div.' + flagLocation
].join('');
newestRow.querySelectorAll(clickableElementsSelector).forEach((clickableElement) => {
clickableElement.click();
});
}
hookupTableMain() {
super.hookupTableMain();
this.hookupFieldsLocationCategory();
this.hookupFieldsNameTable();
this.hookupFieldsActive();
}
hookupFieldsLocationParent() {
this.hookupTableCellDdlPreviews(
flagLocationParent
, Utils.getListFromDict(locations)
);
}
leave() {
super.leave();
}
}