Feat: \n 1. Contact Us page form submission success page created. \n 2. Contact Us page styling and CAPTCHA text content. \n 3. Removal of ERP, Google CAPTCHA, and ALTCHA API code and left over comments in JavaScript, Python.
This commit is contained in:
@@ -30,4 +30,4 @@ body {
|
||||
position: fixed;
|
||||
top:
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -4,19 +4,23 @@
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
max-width: 800px;
|
||||
max-width: 60vw;
|
||||
width: fit-content;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
.contact-form textarea {
|
||||
max-width: 40vw;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 200px 1fr;
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
@@ -36,13 +40,32 @@ textarea.form-input {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
.marketing-consent {
|
||||
margin: 2rem 0;
|
||||
padding-left: 200px;
|
||||
.marketing-consent input {
|
||||
display: inline-block;
|
||||
margin-left: 18vw;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.container.recaptcha {
|
||||
.container.captcha > div:first-child {
|
||||
margin-left: 15vw;
|
||||
margin-right: 15vw;
|
||||
}
|
||||
.container.captcha > div:first-child > label:first-child {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.container.captcha > p:last-child{
|
||||
font-size: 0.9rem;
|
||||
margin: 1vh 0;
|
||||
}
|
||||
|
||||
.container.captcha .altcha-main {
|
||||
padding-left: 1rem;
|
||||
padding-top: 0.75rem;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.container.captcha .altcha-main > :last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
@@ -73,7 +96,17 @@ input[type="submit"]:hover {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.data-notice ul li {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.contact-form {
|
||||
max-width: 80vw;
|
||||
}
|
||||
.contact-form textarea {
|
||||
max-width: 60vw;
|
||||
}
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
45
static/dist/css/core_contact.bundle.css
vendored
45
static/dist/css/core_contact.bundle.css
vendored
@@ -4,19 +4,23 @@
|
||||
}
|
||||
|
||||
.contact-form {
|
||||
max-width: 800px;
|
||||
max-width: 60vw;
|
||||
width: fit-content;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
padding: 2rem;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
.contact-form textarea {
|
||||
max-width: 40vw;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 200px 1fr;
|
||||
gap: 1.5rem;
|
||||
margin-bottom: 1.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
@@ -36,13 +40,32 @@ textarea.form-input {
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
.marketing-consent {
|
||||
margin: 2rem 0;
|
||||
padding-left: 200px;
|
||||
.marketing-consent input {
|
||||
display: inline-block;
|
||||
margin-left: 18vw;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.container.recaptcha {
|
||||
.container.captcha > div:first-child {
|
||||
margin-left: 15vw;
|
||||
margin-right: 15vw;
|
||||
}
|
||||
.container.captcha > div:first-child > label:first-child {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
.container.captcha > p:last-child{
|
||||
font-size: 0.9rem;
|
||||
margin: 1vh 0;
|
||||
}
|
||||
|
||||
.container.captcha .altcha-main {
|
||||
padding-left: 1rem;
|
||||
padding-top: 0.75rem;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.container.captcha .altcha-main > :last-child {
|
||||
display: none;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
@@ -73,7 +96,17 @@ input[type="submit"]:hover {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.data-notice ul li {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.contact-form {
|
||||
max-width: 80vw;
|
||||
}
|
||||
.contact-form textarea {
|
||||
max-width: 60vw;
|
||||
}
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.5rem;
|
||||
|
||||
1
static/dist/css/main.bundle.css
vendored
1
static/dist/css/main.bundle.css
vendored
@@ -31,6 +31,7 @@ body {
|
||||
top:
|
||||
}
|
||||
*/
|
||||
|
||||
.button {
|
||||
display: inline-block;
|
||||
padding: 0.75rem 1.5rem;
|
||||
|
||||
645
static/dist/js/main.bundle.js
vendored
645
static/dist/js/main.bundle.js
vendored
File diff suppressed because one or more lines are too long
104
static/js/api.js
104
static/js/api.js
@@ -56,108 +56,4 @@ export default class API {
|
||||
API.goToUrl(url);
|
||||
}
|
||||
|
||||
|
||||
// specific api calls
|
||||
/* Example:
|
||||
getUsers: () => request('/users'),
|
||||
getUserById: (id) => request(`/users/${id}`),
|
||||
createUser: (userData) => request('/users', 'POST', userData),
|
||||
updateUser: (id, userData) => request(`/users/${id}`, 'PUT', userData),
|
||||
deleteUser: (id) => request(`/users/${id}`, 'DELETE'),
|
||||
*/
|
||||
static async loginUser() {
|
||||
let callback = {};
|
||||
callback[flagCallback] = DOM.getHashPageCurrent();
|
||||
return await API.request(hashPageUserLogin, 'POST', callback);
|
||||
}
|
||||
|
||||
// store
|
||||
// product categories
|
||||
static async saveCategories(categories, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagProductCategory] = categories;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreProductCategory, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// products
|
||||
static async saveProducts(products, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagProduct] = products;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreProduct, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// product permutations
|
||||
static async saveProductPermutations(permutations, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagProductPermutation] = permutations;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreProductPermutation, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// product variations
|
||||
static async saveProductVariations(variationTypes, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagProductVariationType] = variationTypes;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreProductVariation, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// stock items
|
||||
static async saveStockItems(stockItems, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagStockItem] = stockItems;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreStockItem, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// suppliers
|
||||
static async saveSuppliers(suppliers, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagSupplier] = suppliers;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreSupplier, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// supplier purchase orders
|
||||
static async saveSupplierPurchaseOrders(supplierPurchaseOrders, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagSupplierPurchaseOrder] = supplierPurchaseOrders;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreSupplierPurchaseOrder, 'POST', dataRequest);
|
||||
}
|
||||
|
||||
// manufacturing purchase orders
|
||||
static async saveManufacturingPurchaseOrders(manufacturingPurchaseOrders, formFilters, comment) {
|
||||
let dataRequest = {};
|
||||
dataRequest[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
dataRequest[flagManufacturingPurchaseOrder] = manufacturingPurchaseOrders;
|
||||
dataRequest[flagComment] = comment;
|
||||
return await API.request(hashSaveStoreManufacturingPurchaseOrder, 'POST', dataRequest);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
const api = new API();
|
||||
export default api;
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initializeApp();
|
||||
setupEventListeners();
|
||||
initializeComponents();
|
||||
|
||||
// Example of using the API
|
||||
API.getData('/some-endpoint')
|
||||
.then(data => console.log('Data received:', data))
|
||||
.catch(error => console.error('Error:', error));
|
||||
});
|
||||
*/
|
||||
@@ -1,13 +1,15 @@
|
||||
|
||||
import Utils from '../../lib/utils.js';
|
||||
|
||||
function videoPlay(elemVideo) {
|
||||
if (!_loading) { // elemVideo.paused &&
|
||||
elemVideo.play();
|
||||
if (_verbose) { console.log("Playing video element: " + elemVideo.name)};
|
||||
Utils.consoleLogIfNotProductionEnvironment("Playing video element: " + elemVideo.name);
|
||||
}
|
||||
}
|
||||
|
||||
function videoPause(elemVideo) {
|
||||
elemVideo.pause();
|
||||
if (_verbose) { console.log("Pausing video element: " + elemVideo.name)};
|
||||
Utils.consoleLogIfNotProductionEnvironment("Pausing video element: " + elemVideo.name);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
import Utils from "./lib/utils.js";
|
||||
import Validation from "./lib/validation.js";
|
||||
|
||||
export default class DOM {
|
||||
@@ -138,18 +139,10 @@ export default class DOM {
|
||||
debugger;
|
||||
if (Validation.isEmpty(element)) return null;
|
||||
return element.getAttribute(attrValueCurrent);
|
||||
if (!Validation.isEmpty(value) && element.type === "checkbox") {
|
||||
value = (value === 'true');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
static getElementAttributeValuePrevious(element) {
|
||||
if (Validation.isEmpty(element)) return null;
|
||||
return element.getAttribute(attrValuePrevious);
|
||||
if (!Validation.isEmpty(value) && element.type === "checkbox") {
|
||||
value = (value === 'true');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
/* base_table.handleChangeElementCellTable
|
||||
static updateAndCheckIsTableElementDirty(element) {
|
||||
@@ -158,28 +151,17 @@ export default class DOM {
|
||||
let wasDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
|
||||
let isDirty = DOM.updateAndCheckIsElementDirty(element);
|
||||
let cell = DOM.getCellFromElement(element);
|
||||
console.log({element, row, cell, isDirty, wasDirty});
|
||||
Utils.consoleLogIfNotProductionEnvironment({element, row, cell, isDirty, wasDirty});
|
||||
if (isDirty != wasDirty) {
|
||||
DOM.handleDirtyElement(cell, isDirty);
|
||||
let isDirtyRow = DOM.hasDirtyChildrenNotDeletedContainer(row);
|
||||
console.log({isDirtyRow, wasDirtyRow});
|
||||
Utils.consoleLogIfNotProductionEnvironment({isDirtyRow, wasDirtyRow});
|
||||
if (isDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(row, isDirtyRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
static updateElement(id, data) {
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
element.textContent = data;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/* non-static method on page object to use
|
||||
static handleChangeElement(element) {}
|
||||
*/
|
||||
static scrollToElement(parent, element) {
|
||||
// REQUIRED: parent has scroll-bar
|
||||
parent.scrollTop(parent.scrollTop() + (element.offset().top - parent.offset().top));
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
import Utils from '../utils.js';
|
||||
|
||||
export default class BusinessObjects {
|
||||
static getOptionJsonFromObjectJsonAndKeys(objectJson, keyText, keyValue, valueSelected = null) {
|
||||
@@ -11,16 +12,9 @@ export default class BusinessObjects {
|
||||
static getOptionJsonFromObjectJson(objectJson, valueSelected = null) {
|
||||
let keyText = objectJson[flagNameAttrOptionText];
|
||||
let keyValue = objectJson[flagNameAttrOptionValue];
|
||||
if (_verbose) { console.log({objectJson, keyText, keyValue}); };
|
||||
Utils.consoleLogIfNotProductionEnvironment({objectJson, keyText, keyValue});
|
||||
return BusinessObjects.getOptionJsonFromObjectJsonAndKeys(objectJson, keyText, keyValue, valueSelected);
|
||||
}
|
||||
/*
|
||||
static getOptionJsonFromProductPermutation(permutation) {
|
||||
return {
|
||||
text: permutation
|
||||
};
|
||||
}
|
||||
*/
|
||||
static getObjectText(objectJson) {
|
||||
return objectJson == null ? '' : objectJson[objectJson[flagNameAttrOptionText]];
|
||||
}
|
||||
|
||||
@@ -16,4 +16,9 @@ export default class Utils {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
static consoleLogIfNotProductionEnvironment(message) {
|
||||
if (!environment.is_production) {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import Events from "../lib/events.js";
|
||||
import LocalStorage from "../lib/local_storage.js";
|
||||
import API from "../api.js";
|
||||
import DOM from "../dom.js";
|
||||
import Utils from "../lib/utils.js";
|
||||
|
||||
import OverlayConfirm from "../components/common/temporary/overlay_confirm.js";
|
||||
import OverlayError from "../components/common/temporary/overlay_error.js";
|
||||
@@ -14,11 +15,10 @@ export default class BasePage {
|
||||
throw new Error("Router is required");
|
||||
}
|
||||
else {
|
||||
if (_verbose) { console.log("initialising with router: ", router); }
|
||||
Utils.consoleLogIfNotProductionEnvironment("initialising with router: ", router);
|
||||
}
|
||||
this.router = router;
|
||||
this.title = titlePageCurrent;
|
||||
// this.hash = hashPageCurrent;
|
||||
if (this.constructor === BasePage) {
|
||||
throw new Error("Cannot instantiate abstract class");
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export default class BasePage {
|
||||
}
|
||||
|
||||
logInitialisation() {
|
||||
if (_verbose) { console.log('Initializing ' + this.title + ' page'); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('Initializing ' + this.title + ' page');
|
||||
}
|
||||
|
||||
hookupCommonElements() {
|
||||
@@ -58,7 +58,7 @@ export default class BasePage {
|
||||
|
||||
hookupLogos() {
|
||||
this.hookupEventHandler("click", "." + flagImageLogo + "," + "." + flagLogo, (event, element) => {
|
||||
if (_verbose) { console.log('clicking logo'); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('clicking logo');
|
||||
this.router.navigateToHash(hashPageHome);
|
||||
});
|
||||
}
|
||||
@@ -81,15 +81,14 @@ export default class BasePage {
|
||||
Events.initialiseEventHandler('form.' + flagFilter + ' button.' + flagSave, flagInitialised, (button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
if (_verbose) { console.log('saving page: ', this.title); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('saving page: ', this.title);
|
||||
OverlayConfirm.show();
|
||||
});
|
||||
// button.classList.add(flagCollapsed);
|
||||
});
|
||||
}
|
||||
|
||||
leave() {
|
||||
if (_verbose) { console.log('Leaving ' + this.title + ' page'); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('Leaving ' + this.title + ' page');
|
||||
if (this.constructor === BasePage) {
|
||||
throw new Error("Must implement leave() method.");
|
||||
}
|
||||
@@ -107,11 +106,11 @@ export default class BasePage {
|
||||
if (show) {
|
||||
buttonCancel.classList.remove(flagCollapsed);
|
||||
buttonSave.classList.remove(flagCollapsed);
|
||||
if (_verbose) { console.log('showing buttons'); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('showing buttons');
|
||||
} else {
|
||||
buttonCancel.classList.add(flagCollapsed);
|
||||
buttonSave.classList.add(flagCollapsed);
|
||||
if (_verbose) { console.log('hiding buttons'); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('hiding buttons');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,4 +119,5 @@ export default class BasePage {
|
||||
if (isDirty) document.querySelectorAll(idTableMain + ' tbody tr').remove();
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,7 +122,7 @@ export default class TableBasePage extends BasePage {
|
||||
getAndLoadFilteredTableContentSinglePageApp() {
|
||||
this.callFilterTableContent()
|
||||
.then(data => {
|
||||
if (_verbose) { console.log('Table data received:', data); }
|
||||
Utils.consoleLogIfNotProductionEnvironment('Table data received:', data);
|
||||
this.callbackLoadTableContent(data);
|
||||
})
|
||||
.catch(error => console.error('Error:', error));
|
||||
@@ -144,13 +144,13 @@ export default class TableBasePage extends BasePage {
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
if (_verbose) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
Utils.consoleLogIfNotProductionEnvironment('Records saved!');
|
||||
Utils.consoleLogIfNotProductionEnvironment('Data received:', data);
|
||||
}
|
||||
this.callFilterTableContent();
|
||||
}
|
||||
else {
|
||||
if (_verbose) { console.log("error: ", data[flagMessage]); }
|
||||
Utils.consoleLogIfNotProductionEnvironment("error: ", data[flagMessage]);
|
||||
OverlayError.show(data[flagMessage]);
|
||||
}
|
||||
})
|
||||
@@ -181,13 +181,13 @@ export default class TableBasePage extends BasePage {
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
if (_verbose) {
|
||||
console.log('Records saved!');
|
||||
console.log('Data received:', data);
|
||||
Utils.consoleLogIfNotProductionEnvironment('Records saved!');
|
||||
Utils.consoleLogIfNotProductionEnvironment('Data received:', data);
|
||||
}
|
||||
this.callbackLoadTableContent(data);
|
||||
}
|
||||
else {
|
||||
if (_verbose) { console.log("error: ", data[flagMessage]); }
|
||||
Utils.consoleLogIfNotProductionEnvironment("error: ", data[flagMessage]);
|
||||
OverlayError.show(data[flagMessage]);
|
||||
}
|
||||
})
|
||||
@@ -236,7 +236,7 @@ export default class TableBasePage extends BasePage {
|
||||
cacheRowBlank() {
|
||||
let selectorRowNew = idTableMain + ' tbody tr.' + flagRowNew;
|
||||
let rowBlankTemp = document.querySelector(selectorRowNew);
|
||||
if (_verbose) { console.log("row blank temp: ", rowBlankTemp); }
|
||||
Utils.consoleLogIfNotProductionEnvironment("row blank temp: ", rowBlankTemp);
|
||||
let countRows = document.querySelectorAll(idTableMain + ' > tbody > tr').length;
|
||||
_rowBlank = rowBlankTemp.cloneNode(true);
|
||||
document.querySelectorAll(selectorRowNew).forEach(function(row) {
|
||||
@@ -257,23 +257,6 @@ export default class TableBasePage extends BasePage {
|
||||
}
|
||||
hookupSlidersDisplayOrderTable() {
|
||||
let selectorDisplayOrder = idTableMain + ' tbody tr td.' + flagDisplayOrder + ' input.' + flagSlider + '.' + flagDisplayOrder;
|
||||
/*
|
||||
Events.initialiseEventHandler(selectorDisplayOrder, flagInitialised, (sliderDisplayOrder) => {
|
||||
/*
|
||||
sliderDisplayOrder.setAttribute('draggable', true);
|
||||
sliderDisplayOrder.addEventListener('dragstart', this.handleDragSliderStart.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('dragenter', this.handleDragSliderEnter.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('dragover', this.handleDragSliderOver.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('dragleave', this.handleDragSliderLeave.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('drop', this.handleDropSlider.bind(this), false);
|
||||
sliderDisplayOrder.addEventListener('dragend', this.handleDragSliderEnd.bind(this), false);
|
||||
*
|
||||
sliderDisplayOrder.addEventListener('change', (event) => {
|
||||
console.log("slider change event");
|
||||
this.handleChangeNestedElementCellTable(sliderDisplayOrder);
|
||||
});
|
||||
});
|
||||
*/
|
||||
this.hookupChangeHandlerTableCells(selectorDisplayOrder);
|
||||
}
|
||||
hookupChangeHandlerTableCells(inputSelector, handler = (event, element) => { this.handleChangeNestedElementCellTable(event, element); }) {
|
||||
@@ -283,7 +266,6 @@ export default class TableBasePage extends BasePage {
|
||||
});
|
||||
handler(null, input);
|
||||
});
|
||||
// this.hookupEventHandler("change", inputSelector, handler);
|
||||
}
|
||||
/*
|
||||
handleChangeElementCellTable(event, element) {
|
||||
@@ -339,15 +321,15 @@ export default class TableBasePage extends BasePage {
|
||||
let wasDirtyRowTable = DOM.hasDirtyChildrenContainer(rowTable);
|
||||
let wasDirtyElement = element.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
|
||||
console.log({isDirtyElement, wasDirtyElement});
|
||||
Utils.consoleLogIfNotProductionEnvironment({isDirtyElement, wasDirtyElement});
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
DOM.handleDirtyElement(td, isDirtyElement);
|
||||
let isNowDirtyRowSubtable = DOM.hasDirtyChildrenContainer(rowSubtable);
|
||||
console.log({isNowDirtyRowSubtable, wasDirtyRowSubtable});
|
||||
Utils.consoleLogIfNotProductionEnvironment({isNowDirtyRowSubtable, wasDirtyRowSubtable});
|
||||
if (isNowDirtyRowSubtable != wasDirtyRowSubtable) {
|
||||
DOM.handleDirtyElement(rowSubtable, isNowDirtyRowSubtable);
|
||||
let isNowDirtyRowTable = DOM.hasDirtyChildrenContainer(rowTable);
|
||||
console.log({isNowDirtyRowTable, wasDirtyRowTable});
|
||||
Utils.consoleLogIfNotProductionEnvironment({isNowDirtyRowTable, wasDirtyRowTable});
|
||||
if (isNowDirtyRowTable != wasDirtyRowTable) {
|
||||
DOM.handleDirtyElement(rowTable, isNowDirtyRowTable);
|
||||
let rows = this.getTableRecords(true);
|
||||
@@ -362,7 +344,7 @@ export default class TableBasePage extends BasePage {
|
||||
let wasDirtyParentRows = this.getAllIsDirtyRowsInParentTree(element);
|
||||
let wasDirtyElement = element.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.updateAndCheckIsElementDirty(element);
|
||||
if (_verbose) { console.log({isDirtyElement, wasDirtyElement, wasDirtyParentRows}); }
|
||||
Utils.consoleLogIfNotProductionEnvironment({isDirtyElement, wasDirtyElement, wasDirtyParentRows});
|
||||
let td = DOM.getCellFromElement(element);
|
||||
DOM.setElementAttributeValueCurrent(td, DOM.getElementAttributeValueCurrent(element));
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
@@ -392,7 +374,7 @@ export default class TableBasePage extends BasePage {
|
||||
let tr = DOM.getRowFromElement(td);
|
||||
let isDirtyRow = isDirtyTd || DOM.hasDirtyChildrenContainer(tr);
|
||||
let wasDirtyRow = wasDirtyParentRows.shift();
|
||||
if (_verbose) { console.log({isDirtyRow, wasDirtyRow}); }
|
||||
Utils.consoleLogIfNotProductionEnvironment({isDirtyRow, wasDirtyRow});
|
||||
if (isDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(tr, isDirtyRow);
|
||||
this.updateAndToggleShowButtonsSaveCancel();
|
||||
@@ -404,64 +386,6 @@ export default class TableBasePage extends BasePage {
|
||||
}) {
|
||||
this.hookupEventHandler("change", inputSelector, handler);
|
||||
}
|
||||
/* ToDo: Fix this slider drag and drop functionality
|
||||
handleDragSliderStart(event) {
|
||||
this.dragSrcEl = event.target;
|
||||
event.dataTransfer.effectAllowed = flagMove;
|
||||
/*
|
||||
console.log("setting outer html: ", this.dragSrcEl.outerHTML);
|
||||
event.dataTransfer.setData('text/html', this.dragSrcEl.outerHTML);
|
||||
*
|
||||
this.dragSrcRow = DOM.getRowFromElement(this.dragSrcEl);
|
||||
this.dragSrcEl.classList.add(flagDragging);
|
||||
}
|
||||
handleDragSliderOver(event) {
|
||||
if (event.preventDefault) {
|
||||
event.preventDefault();
|
||||
}
|
||||
event.dataTransfer.dropEffect = flagMove;
|
||||
return false;
|
||||
}
|
||||
handleDragSliderEnter(event) {
|
||||
event.target.closest('tr').classList.add(flagDragOver);
|
||||
}
|
||||
handleDragSliderLeave(event) {
|
||||
event.target.closest('tr').classList.remove(flagDragOver);
|
||||
}
|
||||
handleDropSlider(event) {
|
||||
event.stopPropagation();
|
||||
let targetRow = DOM.getRowFromElement(event.target);
|
||||
if (this.dragSourceRow != targetRow) {
|
||||
targetRow.classList.remove(flagDragOver);
|
||||
this.dragSrcEl.classList.remove(flagDragging);
|
||||
let sourceRowClone = this.dragSrcRow.cloneNode(true);
|
||||
let targetRowClone = targetRow.cloneNode(true);
|
||||
console.log("sourceRowClone: ", sourceRowClone);
|
||||
console.log("targetRowClone: ", targetRowClone);
|
||||
let tbody = targetRow.closest('tbody');
|
||||
tbody.replaceChild(sourceRowClone, targetRow);
|
||||
tbody.replaceChild(targetRowClone, this.dragSrcRow);
|
||||
this.refreshDisplayOrders();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
handleDragSliderEnd(event) {
|
||||
let table = TableBasePage.getTableMain();
|
||||
let rows = table.querySelectorAll('tr');
|
||||
rows.forEach(row => {
|
||||
row.classList.remove(flagDragOver);
|
||||
row.classList.remove(flagDragging);
|
||||
});
|
||||
}
|
||||
refreshDisplayOrders() {
|
||||
console.log("updating display order values");
|
||||
let rows = document.querySelectorAll(idTableMain + 'tbody tr.' + flagRow);
|
||||
rows.forEach((row, indexRow) => {
|
||||
sliderDisplayOrder = row.querySelector('td.' + flagDisplayOrder + ' .' + flagSlider);
|
||||
sliderDisplayOrder.setAttribute(attrValueCurrent, indexRow);
|
||||
});
|
||||
}
|
||||
*/
|
||||
hookupTextareasCodeTable() {
|
||||
this.hookupChangeHandlerTableCells(idTableMain + ' tbody tr td.' + flagCode + ' textarea');
|
||||
}
|
||||
@@ -475,7 +399,7 @@ export default class TableBasePage extends BasePage {
|
||||
let selectorButton = 'table' + (Validation.isEmpty(flagTable) ? '' : '.' + flagTable) + ' > tbody > tr > td.' + flagActive + ' button';
|
||||
let selectorButtonDelete = selectorButton + '.' + flagDelete;
|
||||
let selectorButtonUndelete = selectorButton + ':not(.' + flagDelete + ')';
|
||||
console.log("hookupFieldsActive: ", selectorButtonDelete, selectorButtonUndelete);
|
||||
Utils.consoleLogIfNotProductionEnvironment("hookupFieldsActive: ", selectorButtonDelete, selectorButtonUndelete);
|
||||
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete);
|
||||
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete);
|
||||
this.hookupEventHandler(
|
||||
@@ -549,7 +473,6 @@ export default class TableBasePage extends BasePage {
|
||||
}
|
||||
handleClickTableCellDdlPreview(event, td, optionObjectList, cellSelector, ddlHookup = (cellSelector) => { this.hookupTableCellDdls(cellSelector); }) {
|
||||
if (td.querySelector('select')) return;
|
||||
// td.removeEventListener("click", ddlHookup);
|
||||
let tdNew = td.cloneNode(true);
|
||||
td.parentNode.replaceChild(tdNew, td);
|
||||
let idSelected = DOM.getElementAttributeValueCurrent(tdNew);
|
||||
@@ -558,8 +481,8 @@ export default class TableBasePage extends BasePage {
|
||||
DOM.setElementValuesCurrentAndPrevious(ddl, idSelected);
|
||||
let optionJson, option;
|
||||
if (_verbose) {
|
||||
console.log("click table cell ddl preview");
|
||||
console.log({optionObjectList, cellSelector});
|
||||
Utils.consoleLogIfNotProductionEnvironment("click table cell ddl preview");
|
||||
Utils.consoleLogIfNotProductionEnvironment({optionObjectList, cellSelector});
|
||||
}
|
||||
option = DOM.createOption(null);
|
||||
ddl.appendChild(option);
|
||||
@@ -572,34 +495,6 @@ export default class TableBasePage extends BasePage {
|
||||
let ddlSelector = cellSelector + ' select';
|
||||
ddlHookup(ddlSelector);
|
||||
}
|
||||
/*
|
||||
handleChangeTableCellDdl(event, ddl) {
|
||||
let row = DOM.getRowFromElement(ddl);
|
||||
let td = DOM.getCellFromElement(ddl);
|
||||
console.log("td: ", td);
|
||||
let wasDirtyRow = DOM.hasDirtyChildrenContainer(row);
|
||||
let wasDirtyElement = ddl.classList.contains(flagDirty);
|
||||
let isDirtyElement = DOM.updateAndCheckIsElementDirty(ddl);
|
||||
console.log("isDirtyElement: ", isDirtyElement);
|
||||
console.log("wasDirtyElement: ", wasDirtyElement);
|
||||
if (isDirtyElement != wasDirtyElement) {
|
||||
DOM.handleDirtyElement(td, isDirtyElement);
|
||||
let optionSelected = ddl.options[ddl.selectedIndex];
|
||||
DOM.setElementAttributeValueCurrent(td, optionSelected.value);
|
||||
let isNowDirtyRow = DOM.hasDirtyChildrenContainer(row);
|
||||
console.log("isNowDirtyRow: ", isNowDirtyRow);
|
||||
console.log("wasDirtyRow: ", wasDirtyRow);
|
||||
if (isNowDirtyRow != wasDirtyRow) {
|
||||
DOM.handleDirtyElement(row, isNowDirtyRow);
|
||||
let rows = this.getTableRecords(true);
|
||||
let existsDirtyRecord = rows.length > 0;
|
||||
console.log("dirty records:", rows);
|
||||
console.log("existsDirtyRecord:", existsDirtyRecord);
|
||||
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
hookupTableCellDDlPreviewsWhenNotCollapsed(cellSelector, optionList, ddlHookup = (event, element) => { this.hookupTableCellDdls(event, element); }) {
|
||||
this.hookupEventHandler("click", cellSelector, (event, td) => {
|
||||
let div = td.querySelector('div');
|
||||
@@ -607,299 +502,13 @@ export default class TableBasePage extends BasePage {
|
||||
this.handleClickTableCellDdlPreview(event, td, optionList, cellSelector, (event, element) => { ddlHookup(event, element); });
|
||||
});
|
||||
}
|
||||
hookupProductCategoryDdls(ddlSelector) {
|
||||
this.hookupChangeHandlerTableCells(ddlSelector, (event, element) => { this.handleChangeProductCategoryDdl(event, element); });
|
||||
}
|
||||
handleChangeProductCategoryDdl(event, ddlCategory) {
|
||||
this.handleChangeNestedElementCellTable(event, ddlCategory);
|
||||
let idProductCategorySelected = DOM.getElementAttributeValueCurrent(ddlCategory);
|
||||
let row = DOM.getRowFromElement(ddlCategory);
|
||||
let tdProduct = row.querySelector('td.' + flagProduct);
|
||||
tdProduct.dispatchEvent(new Event('click'));
|
||||
let ddlProduct = row.querySelector('td.' + flagProduct + ' select');
|
||||
ddlProduct.innerHTML = '';
|
||||
ddlProduct.appendChild(DOM.createOption(null));
|
||||
let optionJson, option;
|
||||
Utils.getListFromDict(products).forEach((product) => {
|
||||
if (idProductCategorySelected != '0' && product[attrIdProductCategory] != idProductCategorySelected) return;
|
||||
optionJson = BusinessObjects.getOptionJsonFromObjectJson(product);
|
||||
option = DOM.createOption(optionJson);
|
||||
ddlProduct.appendChild(option);
|
||||
});
|
||||
this.handleChangeNestedElementCellTable(event, ddlProduct);
|
||||
}
|
||||
hookupFieldsProductPermutationVariation() {
|
||||
this.hookupPreviewsProductPermutationVariation();
|
||||
this.hookupDdlsProductPermutationVariationType();
|
||||
this.hookupDdlsProductPermutationVariation();
|
||||
this.hookupButtonsProductPermutationVariationAddDelete();
|
||||
}
|
||||
hookupPreviewsProductPermutationVariation() {
|
||||
this.hookupEventHandler("click", idTableMain + ' td.' + flagProductVariations, (event, element) => this.handleClickProductPermutationVariationsPreview(event, element));
|
||||
}
|
||||
handleClickProductPermutationVariationsPreview(event, element) {
|
||||
let tblVariations = element.querySelector('table.' + flagProductVariations);
|
||||
if (!Validation.isEmpty(tblVariations)) return;
|
||||
this.toggleColumnCollapsed(flagProductVariations, false);
|
||||
let permutationVariations = this.getElementProductVariations(element);
|
||||
tblVariations = document.createElement("table");
|
||||
tblVariations.classList.add(flagProductVariations);
|
||||
let thead = document.createElement("thead");
|
||||
let tr = document.createElement("tr");
|
||||
let thVariationType = document.createElement("th");
|
||||
thVariationType.classList.add(flagProductVariationType);
|
||||
thVariationType.textContent = 'Type';
|
||||
let thNameVariation = document.createElement("th");
|
||||
thNameVariation.classList.add(flagProductVariation);
|
||||
thNameVariation.textContent = 'Name';
|
||||
let buttonAdd = document.createElement("button");
|
||||
buttonAdd.classList.add(flagAdd);
|
||||
buttonAdd.textContent = '+';
|
||||
let thAddDelete = document.createElement("th");
|
||||
thAddDelete.classList.add(flagAdd);
|
||||
thAddDelete.appendChild(buttonAdd);
|
||||
tr.appendChild(thVariationType);
|
||||
tr.appendChild(thNameVariation);
|
||||
tr.appendChild(thAddDelete);
|
||||
thead.appendChild(tr);
|
||||
tblVariations.appendChild(thead);
|
||||
let tbody = document.createElement("tbody");
|
||||
if (!Validation.isEmpty(permutationVariations)) {
|
||||
permutationVariations.forEach((permutationVariation, index) => {
|
||||
this.addProductPermutationVariationRow(tbody, permutationVariation);
|
||||
});
|
||||
}
|
||||
tblVariations.appendChild(tbody);
|
||||
if (_verbose) {
|
||||
console.log("click product permutation variations preview");
|
||||
console.log('variations:', permutationVariations);
|
||||
console.log("tblVariations: ", tblVariations);
|
||||
}
|
||||
|
||||
let cellParent = element.closest(idTableMain + ' tbody tr td.' + flagProductVariations);
|
||||
cellParent.innerHTML = '';
|
||||
cellParent.appendChild(tblVariations);
|
||||
|
||||
this.hookupFieldsProductPermutationVariation();
|
||||
}
|
||||
toggleColumnCollapsed(flagColumn, isCollapsed) {
|
||||
this.toggleColumnHasClassnameFlag(flagColumn, isCollapsed, flagCollapsed);
|
||||
}
|
||||
toggleColumnHeaderCollapsed(flagColumn, isCollapsed) {
|
||||
this.toggleColumnHasClassnameFlag(flagColumn, isCollapsed, flagCollapsed);
|
||||
}
|
||||
getElementProductVariations(element) {
|
||||
let permutationVariations = element.getAttribute(attrValueCurrent);
|
||||
let objVariations = [];
|
||||
let parts, new_variation, new_variation_type;
|
||||
if (!Validation.isEmpty(permutationVariations)) {
|
||||
permutationVariations = permutationVariations.split(',');
|
||||
permutationVariations.forEach((variation) => {
|
||||
parts = variation.split(':');
|
||||
if (parts.length == 2) {
|
||||
if (_verbose) { console.log("parts: ", parts); }
|
||||
new_variation_type = productVariationTypes[parts[0].trim()];
|
||||
new_variation = productVariations[parts[1].trim()];
|
||||
objVariations.push({
|
||||
[flagProductVariationType]: new_variation_type,
|
||||
[flagProductVariation]: new_variation,
|
||||
});
|
||||
}
|
||||
else {
|
||||
if (_verbose) { console.log("error: invalid variation: ", variation); }
|
||||
}
|
||||
});
|
||||
}
|
||||
return objVariations;
|
||||
}
|
||||
static createOptionUnselectedProductVariation() {
|
||||
return {
|
||||
[flagProductVariationType]: {
|
||||
[flagNameAttrOptionText]: [flagName],
|
||||
[flagNameAttrOptionValue]: [attrIdProductVariationType],
|
||||
[flagName]: 'Select Variation Type',
|
||||
[attrIdProductVariationType]: 0,
|
||||
},
|
||||
[flagProductVariation]: {
|
||||
[flagNameAttrOptionText]: [flagName],
|
||||
[flagNameAttrOptionValue]: [attrIdProductVariation],
|
||||
[flagName]: 'Select Variation',
|
||||
[attrIdProductVariation]: 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
addProductPermutationVariationRow(tbody, permutationVariation) {
|
||||
if (_verbose) { console.log("permutationVariation: ", permutationVariation); }
|
||||
let productVariationType, optionProductVariationTypeJson, optionProductVariationType, productVariation, optionProductVariationJson, optionProductVariation;
|
||||
/*
|
||||
if (Validation.isEmpty(variations)) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
let productVariationKeys = Object.keys(productVariations);
|
||||
let productVariationTypeKeys = Object.keys(productVariationTypes);
|
||||
|
||||
let ddlsProductVariationType = tbody.querySelectorAll('select.' + flagProductVariationType);
|
||||
let productVariationTypeKeysSelected = new Set();
|
||||
let valueSelected;
|
||||
let doFilterProductVariationKeys = permutationVariation[attrIdProductVariationType] != 0;
|
||||
ddlsProductVariationType.forEach((ddlProductVariationType) => {
|
||||
valueSelected = DOM.getElementValueCurrent(ddlProductVariationType);
|
||||
productVariationTypeKeysSelected.add(valueSelected);
|
||||
});
|
||||
productVariationTypeKeys = productVariationTypeKeys.filter(typeKey => !productVariationTypeKeysSelected.has(typeKey));
|
||||
if (productVariationTypeKeys.length == 0) return;
|
||||
if (doFilterProductVariationKeys) {
|
||||
productVariationKeys = productVariationKeys.filter(variationKey => !productVariationTypeKeysSelected.has(productVariations[variationKey][attrIdProductVariationType]));
|
||||
}
|
||||
|
||||
let permutationVariationJson = permutationVariation[flagProductVariation];
|
||||
let permutationVariationTypeJson = permutationVariation[flagProductVariationType];
|
||||
|
||||
let tdVariationType = document.createElement("td");
|
||||
tdVariationType.classList.add(flagProductVariationType);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
|
||||
let ddlVariationType = document.createElement("select");
|
||||
ddlVariationType.classList.add(flagProductVariationType);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
|
||||
optionProductVariationType = DOM.createOption(null);
|
||||
if (_verbose) { console.log("optionProductVariationType: ", optionProductVariationType); }
|
||||
ddlVariationType.appendChild(optionProductVariationType);
|
||||
|
||||
productVariationTypeKeys.forEach((productVariationTypeKey) => {
|
||||
/*
|
||||
optionProductVariationType = document.createElement('option');
|
||||
optionProductVariationType.value = optionVariationType.value;
|
||||
optionProductVariationType.text = optionVariationType.text;
|
||||
*/
|
||||
productVariationType = productVariationTypes[productVariationTypeKey];
|
||||
optionProductVariationTypeJson = BusinessObjects.getOptionJsonFromObjectJson(productVariationType, permutationVariationTypeJson[attrIdProductVariationType]);
|
||||
optionProductVariationType = DOM.createOption(optionProductVariationTypeJson);
|
||||
if (_verbose) { console.log("optionProductVariationType: ", optionProductVariationType); }
|
||||
ddlVariationType.appendChild(optionProductVariationType);
|
||||
});
|
||||
|
||||
let tdVariation = document.createElement("td");
|
||||
tdVariation.classList.add(flagProductVariation);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(tdVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
|
||||
let ddlVariation = document.createElement("select");
|
||||
ddlVariation.classList.add(flagProductVariation);
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(ddlVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
|
||||
optionProductVariation = DOM.createOption(null);
|
||||
if (_verbose) { console.log("optionProductVariation: ", optionProductVariation); }
|
||||
ddlVariation.appendChild(optionProductVariation);
|
||||
|
||||
productVariationKeys.forEach((productVariationKey) => {
|
||||
productVariation = productVariations[productVariationKey];
|
||||
optionProductVariationJson = BusinessObjects.getOptionJsonFromObjectJson(productVariation, permutationVariationJson[attrIdProductVariation]);
|
||||
optionProductVariation = DOM.createOption(optionProductVariationJson);
|
||||
if (_verbose) { console.log("optionProductVariation: ", optionProductVariation); }
|
||||
ddlVariation.appendChild(optionProductVariation);
|
||||
});
|
||||
|
||||
let tdDelete = document.createElement("td");
|
||||
tdDelete.classList.add(flagDelete);
|
||||
|
||||
let buttonDelete = document.createElement("button");
|
||||
buttonDelete.classList.add(flagActive);
|
||||
buttonDelete.classList.add(flagDelete);
|
||||
buttonDelete.textContent = 'x';
|
||||
DOM.setElementAttributesValuesCurrentAndPrevious(buttonDelete, true);
|
||||
|
||||
let tr = document.createElement("tr");
|
||||
tr.classList.add(flagProductVariation);
|
||||
tdVariationType.appendChild(ddlVariationType);
|
||||
tr.appendChild(tdVariationType);
|
||||
tdVariation.appendChild(ddlVariation);
|
||||
tr.appendChild(tdVariation);
|
||||
tdDelete.appendChild(buttonDelete);
|
||||
tr.appendChild(tdDelete);
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
hookupDdlsProductPermutationVariationType() {
|
||||
this.hookupTableCellDdls(
|
||||
idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariationType + ' select'
|
||||
, (event, ddlVariationType) => {
|
||||
this.handleChangeProductVariationInput(event, ddlVariationType);
|
||||
let idVariationTypeSelected = DOM.getElementValueCurrent(ddlVariationType);
|
||||
let row = DOM.getRowFromElement(ddlVariationType);
|
||||
let tdVariation = row.querySelector('td.' + flagProductVariation);
|
||||
tdVariation.dispatchEvent(new Event('click'));
|
||||
let ddlVariation = row.querySelector('td.' + flagProductVariation + ' select');
|
||||
ddlVariation.innerHTML = '';
|
||||
ddlVariation.appendChild(DOM.createOption(null));
|
||||
let optionJson, option;
|
||||
let variationType = productVariationTypes[idVariationTypeSelected];
|
||||
if (variationType == null) variationType = {
|
||||
[flagProductVariations]: [],
|
||||
};
|
||||
variationType[flagProductVariations].forEach((variation) => {
|
||||
optionJson = BusinessObjects.getOptionJsonFromObjectJson(variation);
|
||||
option = DOM.createOption(optionJson);
|
||||
ddlVariation.appendChild(option);
|
||||
});
|
||||
this.handleChangeProductVariationInput(event, ddlVariation);
|
||||
}
|
||||
);
|
||||
}
|
||||
handleChangeProductVariationInput(event, element) {
|
||||
this.handleChangeNestedElementCellTable(event, element);
|
||||
this.updateProductPermutationVariations(element);
|
||||
}
|
||||
hookupDdlsProductPermutationVariation() {
|
||||
this.hookupTableCellDdls(idTableMain + ' td.' + flagProductVariations + ' td.' + flagProductVariation + ' select', (event, ddlVariation) => { this.handleChangeProductVariationInput(event, ddlVariation); });
|
||||
}
|
||||
hookupButtonsProductPermutationVariationAddDelete() {
|
||||
let selectorButton = idTableMain + ' td.' + flagProductVariations + ' tr.' + flagProductVariation + ' button';
|
||||
let selectorButtonDelete = selectorButton + '.' + flagDelete;
|
||||
let selectorButtonUndelete = selectorButton + '.' + flagAdd;
|
||||
this.hookupButtonsRowDelete(selectorButtonDelete, selectorButtonUndelete, (event, element) => { this.handleChangeProductVariationInput(event, element); });
|
||||
this.hookupButtonsRowUndelete(selectorButtonDelete, selectorButtonUndelete, (event, element) => { this.handleChangeProductVariationInput(event, element); });
|
||||
this.hookupButtonsProductPermutationVariationAdd();
|
||||
}
|
||||
hookupButtonsProductPermutationVariationAdd() {
|
||||
this.hookupEventHandler(
|
||||
"click"
|
||||
, idTableMain + ' td.' + flagProductVariations + ' button.' + flagAdd
|
||||
, (event, element) => { this.handleClickButtonProductPermutationVariationAdd(event, element); }
|
||||
);
|
||||
}
|
||||
handleClickButtonProductPermutationVariationAdd(event, element) {
|
||||
let variationsCell = element.closest('td.' + flagProductVariations);
|
||||
let tbody = variationsCell.querySelector('tbody');
|
||||
let permutationVariation = TableBasePage.createOptionUnselectedProductVariation();
|
||||
this.addProductPermutationVariationRow(tbody, permutationVariation);
|
||||
this.hookupFieldsProductPermutationVariation();
|
||||
}
|
||||
updateProductPermutationVariations(element) {
|
||||
let variationsCell = element.closest('td.' + flagProductVariations);
|
||||
let variationPairsString = this.getProductPermutationVariationsText(variationsCell);
|
||||
DOM.setElementAttributeValueCurrent(variationsCell, variationPairsString);
|
||||
this.handleChangeNestedElementCellTable(null, variationsCell);
|
||||
}
|
||||
getProductPermutationVariationsText(variationsTd) {
|
||||
let rows = variationsTd.querySelectorAll(':scope tbody tr:has(button.' + flagDelete + ')');
|
||||
let variationPairsString = '';
|
||||
let ddlVariationType, ddlVariation, idVariationType, idVariation;
|
||||
rows.forEach((row, index) => {
|
||||
ddlVariationType = row.querySelector(':scope td select.' + flagProductVariationType);
|
||||
ddlVariation = row.querySelector(':scope td select.' + flagProductVariation);
|
||||
idVariationType = DOM.getElementValueCurrent(ddlVariationType);
|
||||
idVariation = DOM.getElementValueCurrent(ddlVariation);
|
||||
if (variationPairsString != '') variationPairsString += ',';
|
||||
variationPairsString += idVariationType + ':' + idVariation;
|
||||
});
|
||||
return variationPairsString;
|
||||
}
|
||||
|
||||
hookupCurrencyFields() {
|
||||
this.hookupTableCellDdlPreviews(idTableMain + ' td.' + flagCurrency, Utils.getListFromDict(currencies));
|
||||
}
|
||||
|
||||
createTdActive(isActive) {
|
||||
let tdActive = document.createElement("td");
|
||||
tdActive.classList.add(flagActive);
|
||||
@@ -921,7 +530,6 @@ export default class TableBasePage extends BasePage {
|
||||
let dataPage = {};
|
||||
dataPage[flagFormFilters] = DOM.convertForm2JSON(formFilters);
|
||||
this.setLocalStoragePage(dataPage);
|
||||
// _rowBlank = null;
|
||||
}
|
||||
|
||||
toggleColumnHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) {
|
||||
@@ -930,12 +538,6 @@ export default class TableBasePage extends BasePage {
|
||||
let columnThHasFlag = columnTh.classList.contains(classnameFlag);
|
||||
if (isRequiredFlag == columnThHasFlag) return;
|
||||
DOM.toggleElementHasClassnameFlag(columnTh, isRequiredFlag, classnameFlag);
|
||||
/*
|
||||
let columnTds = table.querySelectorAll('td.' + columnFlag);
|
||||
columnTds.forEach((columnTd) => {
|
||||
DOM.toggleElementHasClassnameFlag(columnTd, isRequiredFlag, classnameFlag);
|
||||
});
|
||||
*/
|
||||
}
|
||||
toggleColumnHeaderHasClassnameFlag(columnFlag, isRequiredFlag, classnameFlag) {
|
||||
let table = TableBasePage.getTableMain();
|
||||
@@ -949,26 +551,3 @@ export default class TableBasePage extends BasePage {
|
||||
this.toggleShowButtonsSaveCancel(existsDirtyRecord);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Example of a subclass of TableBasePage
|
||||
import { TableBasePage } from "./page_table_base.js";
|
||||
import API from "../api.js";
|
||||
import DOM from "../dom.js";
|
||||
|
||||
export class PageStoreProductCategories extends TableBasePage {
|
||||
static hash = hashPageStoreProductCategories;
|
||||
static attrIdRowObject = attrIdProductCategory;
|
||||
callSaveTableContent = API.saveCategories;
|
||||
|
||||
constructor() {}
|
||||
initialize() {}
|
||||
hookupFilters() {}
|
||||
loadRowTable(rowJson) {}
|
||||
getJsonRow(row) {}
|
||||
initialiseRowNew(tbody, row) {}
|
||||
hookupTableMain() {}
|
||||
isDirtyRow(row) {}
|
||||
leave() {}
|
||||
}
|
||||
*/
|
||||
16
static/js/pages/core/contact-success.js
Normal file
16
static/js/pages/core/contact-success.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// internal
|
||||
import BasePage from "../base.js";
|
||||
// vendor
|
||||
import { Altcha } from "../../vendor/altcha.js";
|
||||
|
||||
export default class PageContactSuccess extends BasePage {
|
||||
static hash = hashPageContactSuccess;
|
||||
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,17 @@
|
||||
// Core
|
||||
import PageHome from './pages/core/home.js';
|
||||
import PageContact from './pages/core/contact.js';
|
||||
import PageContactSuccess from './pages/core/contact-success.js';
|
||||
// Legal
|
||||
import PageAccessibilityReport from './pages/legal/accessibility_report.js';
|
||||
import PageAccessibilityStatement from './pages/legal/accessibility_statement.js';
|
||||
import PageLicense from './pages/legal/license.js';
|
||||
// User
|
||||
// import PageUserLogin from './pages/user/login.js';
|
||||
// import PageUserLogout from './pages/user/logout.js';
|
||||
// import PageUserAccount from './pages/user/account.js';
|
||||
import PagePrivacyPolicy from './pages/legal/privacy_policy.js';
|
||||
import PageRetentionSchedule from './pages/legal/retention_schedule.js';
|
||||
|
||||
import API from './api.js';
|
||||
import DOM from './dom.js';
|
||||
import PagePrivacyPolicy from './pages/legal/privacy_policy.js';
|
||||
import PageRetentionSchedule from './pages/legal/retention_schedule.js';
|
||||
import Utils from './lib/utils.js';
|
||||
|
||||
|
||||
export default class Router {
|
||||
@@ -23,18 +21,14 @@ export default class Router {
|
||||
// Pages
|
||||
this.pages = {};
|
||||
// Core
|
||||
this.pages[hashPageHome] = { name: 'PageHome', module: PageHome }; // importModule: () => import(/* webpackChunkName: "page_core_home" */ './pages/core/home.js') , pathModule: './pages/core/home.js'
|
||||
this.pages[hashPageContact] = { name: 'PageContact', module: PageContact }; // pathModule: './pages/core/contact.js' };
|
||||
this.pages[hashPageHome] = { name: 'PageHome', module: PageHome };
|
||||
this.pages[hashPageContact] = { name: 'PageContact', module: PageContact };
|
||||
this.pages[hashPageContactSuccess] = { name: 'PageContact', module: PageContactSuccess };
|
||||
// Legal
|
||||
this.pages[hashPageAccessibilityStatement] = { name: 'PageAccessibilityStatement', module: PageAccessibilityStatement }; // pathModule: '../../static/js/pages/legal/accessibility_statement.js' }; // , page: PageAccessibilityStatement
|
||||
this.pages[hashPageDataRetentionSchedule] = { name: 'PageDataRetentionSchedule', module: PageRetentionSchedule }; // pathModule: './pages/legal/data_retention_schedule.js' };
|
||||
this.pages[hashPageLicense] = { name: 'PageLicense', module: PageLicense }; // pathModule: './pages/legal/license.js' };
|
||||
this.pages[hashPagePrivacyPolicy] = { name: 'PagePrivacyPolicy', module: PagePrivacyPolicy }; // pathModule: './pages/legal/privacy_policy.js' }; // importModule: () => {return import(/* webpackChunkName: "page_privacy_policy" */ './pages/legal/privacy_policy.js'); }
|
||||
// User
|
||||
// this.pages[hashPageUserLogin] = { name: 'PageUserLogin', module: PageUserLogin }; // pathModule: './pages/user/login.js' };
|
||||
// this.pages[hashPageUserLogout] = { name: 'PageUserLogout', module: PageUserLogout }; // pathModule: './pages/user/logout.js' };
|
||||
// this.pages[hashPageUserAccount] = { name: 'PageUserAccount', module: PageUserAccount }; // pathModule: './pages/user/account.js' };
|
||||
|
||||
this.pages[hashPageAccessibilityStatement] = { name: 'PageAccessibilityStatement', module: PageAccessibilityStatement };
|
||||
this.pages[hashPageDataRetentionSchedule] = { name: 'PageDataRetentionSchedule', module: PageRetentionSchedule };
|
||||
this.pages[hashPageLicense] = { name: 'PageLicense', module: PageLicense };
|
||||
this.pages[hashPagePrivacyPolicy] = { name: 'PagePrivacyPolicy', module: PagePrivacyPolicy };
|
||||
// Routes
|
||||
this.routes = {};
|
||||
// Core
|
||||
@@ -45,10 +39,6 @@ export default class Router {
|
||||
this.routes[hashPageDataRetentionSchedule] = (isPopState = false) => this.navigateToHash(hashPageDataRetentionSchedule, isPopState);
|
||||
this.routes[hashPageLicense] = (isPopState = false) => this.navigateToHash(hashPageLicense, isPopState);
|
||||
this.routes[hashPagePrivacyPolicy] = (isPopState = false) => this.navigateToHash(hashPagePrivacyPolicy, isPopState);
|
||||
// User
|
||||
// this.routes[hashPageUserLogin] = (isPopState = false) => this.navigateToHash(hashPageUserLogin, isPopState);
|
||||
// this.routes[hashPageUserLogout] = (isPopState = false) => this.navigateToHash(hashPageUserLogout, isPopState);
|
||||
// this.routes[hashPageUserAccount] = (isPopState = false) => this.navigateToHash(hashPageUserAccount, isPopState);
|
||||
this.initialize();
|
||||
}
|
||||
loadPage(hashPage, isPopState = false) {
|
||||
@@ -61,31 +51,17 @@ export default class Router {
|
||||
|
||||
let pageJson = this.pages[hashPage];
|
||||
try {
|
||||
/*
|
||||
const module = await pagesContext(pageJson.pathModule);
|
||||
console.log("module: ", module);
|
||||
return module[pageJson.name];
|
||||
*/
|
||||
// const module = await import(pageJson.pathModule); // pageJson.page;
|
||||
// const module = () => import(pageJson.pathModule);
|
||||
const module = pageJson.module; // importModule;
|
||||
return module; // [pageJson.name];
|
||||
const module = pageJson.module;
|
||||
return module;
|
||||
}
|
||||
catch (error) {
|
||||
if (_verbose) { console.log("this.pages: ", this.pages); };
|
||||
Utils.consoleLogIfNotProductionEnvironment("this.pages: ", this.pages);
|
||||
console.error('Page not found:', hashPage);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
initialize() {
|
||||
/*
|
||||
let pages = Router.getPages();
|
||||
for (const key of Object.keys(pages)) {
|
||||
let page = pages[key];
|
||||
this.addRoute(page.hash, page.initialize);
|
||||
}
|
||||
*/
|
||||
window.addEventListener('popstate', this.handlePopState.bind(this)); // page accessed by history navigation
|
||||
window.addEventListener('popstate', this.handlePopState.bind(this));
|
||||
}
|
||||
handlePopState(event) {
|
||||
this.loadPageCurrent();
|
||||
@@ -95,26 +71,11 @@ export default class Router {
|
||||
this.loadPage(hashPageCurrent);
|
||||
}
|
||||
navigateToHash(hash, data = null, params = null, isPopState = false) {
|
||||
// this.beforeLeave();
|
||||
/*
|
||||
if (this.routes[hash]) {
|
||||
this.routes[hash](isPopState);
|
||||
} else {
|
||||
console.error(`Hash ${hash} not found`);
|
||||
}
|
||||
*/
|
||||
let url = API.getUrlFromHash(hash, params);
|
||||
// if (!isPopState)
|
||||
history.pushState({data: data, params: params}, '', hash);
|
||||
API.goToUrl(url, data);
|
||||
}
|
||||
/* beforeunload listener
|
||||
async beforeLeave() {
|
||||
const ClassPageCurrent = await this.getClassPageFromHash(DOM.getHashPageCurrent());
|
||||
const pageCurrent = new ClassPageCurrent(this);
|
||||
pageCurrent.leave();
|
||||
}
|
||||
*/
|
||||
|
||||
navigateToUrl(url, data = null, appendHistory = true) {
|
||||
// this.beforeLeave();
|
||||
if (appendHistory) history.pushState(data, '', url);
|
||||
@@ -128,25 +89,3 @@ export default class Router {
|
||||
}
|
||||
|
||||
export const router = new Router();
|
||||
|
||||
/*
|
||||
router.addRoute('/', () => {
|
||||
console.log('Home page');
|
||||
// Load home page content
|
||||
});
|
||||
|
||||
router.addRoute('/about', () => {
|
||||
console.log('About page');
|
||||
// Load about page content
|
||||
});
|
||||
|
||||
export function setupNavigationEvents() {
|
||||
document.querySelectorAll('a[data-nav]').forEach(link => {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const url = e.target.getAttribute('href');
|
||||
router.navigateToUrl(url);
|
||||
});
|
||||
});
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user