135 lines
4.8 KiB
JavaScript
135 lines
4.8 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);
|
|
|
|
console.log("jsonRow");
|
|
console.log(jsonRow);
|
|
|
|
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.' + flagLocationParent + ' div.' + flagLocationParent
|
|
].join('');
|
|
newestRow.querySelectorAll(clickableElementsSelector).forEach((clickableElement) => {
|
|
clickableElement.click();
|
|
});
|
|
}
|
|
|
|
hookupTableMain() {
|
|
super.hookupTableMain();
|
|
this.hookupFieldsLocationParent();
|
|
this.hookupFieldsNameTable();
|
|
this.hookupFieldsActive();
|
|
}
|
|
hookupFieldsLocationParent() {
|
|
/*
|
|
this.hookupTableCellDdlPreviews(
|
|
flagLocationParent
|
|
, Utils.getListFromDict(locations).filter(location =>
|
|
(
|
|
location[attrIdLocation] == idLocationRow
|
|
|| idLocationRow < 1
|
|
)
|
|
) // .sort((a, b) => a[flagName].localeCompare(b[flagName]))
|
|
, null // cellSelector
|
|
, (cellSelector) => { this.hookupLocationParentDdls(cellSelector); }
|
|
,
|
|
);
|
|
|
|
fieldFlag
|
|
, optionList
|
|
, cellSelector = null
|
|
, ddlHookup = (ddlSelector) => { this.hookupTableCellDdls(ddlSelector); }
|
|
, changeHandler = (event, element) => { this.handleChangeNestedElementCellTable(event, element); }
|
|
) {
|
|
|
|
*/
|
|
let cellSelector = idTableMain + ' > tbody > tr > td.' + flagLocationParent;
|
|
Events.hookupEventHandler("click", cellSelector + ' div.' + flagLocationParent, (event, div) => {
|
|
let row = DOM.getRowFromElement(div);
|
|
let idLocationRow = Number(row.getAttribute(attrIdLocation));
|
|
Utils.consoleLogIfNotProductionEnvironment({ idLocationRow });
|
|
this.handleClickTableCellDdlPreview(
|
|
event
|
|
, div
|
|
, flagLocationParent
|
|
, Utils.getListFromDict(locations).filter(location =>
|
|
(
|
|
location[attrIdLocation] != idLocationRow
|
|
|| idLocationRow < 1
|
|
)
|
|
) // .sort((a, b) => a[flagName].localeCompare(b[flagName]))
|
|
, cellSelector
|
|
, (ddlSelector) => { this.hookupTableCellDdls(
|
|
ddlSelector
|
|
, (event, element) => { this.handleChangeNestedElementCellTable(event, element); }
|
|
); }
|
|
);
|
|
});
|
|
this.hookupTableCellDdls(
|
|
cellSelector + ' select.' + flagLocationParent
|
|
, (event, element) => { this.handleChangeNestedElementCellTable(event, element); }
|
|
);
|
|
}
|
|
/*
|
|
hookupLocationParentDdls(ddlSelector) {
|
|
this.hookupChangeHandlerTableCells(ddlSelector, (event, element) => { this.handleChangeNestedElementCellTable(event, element); });
|
|
}
|
|
*/
|
|
|
|
leave() {
|
|
super.leave();
|
|
}
|
|
}
|
|
|