1. New Router and Base Page Class architecture to avoid circular references and conform to module bundler requirements. \n 2. Relative path bug fix for lib/validation.js file to work using module bundler.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation";
|
||||
import Validation from "./lib/validation.js";
|
||||
|
||||
function mapHashToController(hash) {
|
||||
if (hash == null) return mapHashToController(hashPageHome);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation";
|
||||
import Validation from "./lib/validation.js";
|
||||
|
||||
|
||||
// Date picker inputs
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation";
|
||||
import Validation from "./lib/validation.js";
|
||||
|
||||
|
||||
export default class Table {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation";
|
||||
import Validation from "./lib/validation.js";
|
||||
|
||||
export default class TextArea {
|
||||
removeBlankTextAreaLines(textarea) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./lib/validation";
|
||||
import Validation from "./lib/validation.js";
|
||||
|
||||
// Module for DOM manipulation
|
||||
export default class DOM {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./validation";
|
||||
import Validation from "./validation.js";
|
||||
|
||||
export default class Common {
|
||||
static parseCSSPropertyToFloat(element, propertyName) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import Validation from "./validation";
|
||||
import Validation from "./validation.js";
|
||||
|
||||
export default class LocalStorage {
|
||||
/*
|
||||
|
||||
@@ -3,10 +3,16 @@ import Events from "../lib/events.js";
|
||||
import LocalStorage from "../lib/local_storage.js";
|
||||
import API from "../api.js";
|
||||
import DOM from "../dom.js";
|
||||
import { router } from "../router.js";
|
||||
|
||||
export class BasePage {
|
||||
constructor() {
|
||||
export default class BasePage {
|
||||
constructor(router) {
|
||||
if (!router) {
|
||||
throw new Error("Router is required");
|
||||
}
|
||||
else {
|
||||
console.log("initialising with router: ", router);
|
||||
}
|
||||
this.router = router;
|
||||
this.title = titlePageCurrent;
|
||||
// this.hash = hashPageCurrent;
|
||||
if (this.constructor === BasePage) {
|
||||
@@ -74,51 +80,51 @@ export class BasePage {
|
||||
this.hookupButtonNavAdminHome();
|
||||
}
|
||||
hookupButtonNavHome() {
|
||||
Events.initialiseEventHandler('.' + flagNavHome, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavHome, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageHome);
|
||||
this.router.navigateToHash(hashPageHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavServices() {
|
||||
Events.initialiseEventHandler('.' + flagNavServices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavServices, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
console.log('going to services page');
|
||||
router.navigateToHash(hashPageServices);
|
||||
this.router.navigateToHash(hashPageServices);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavContact() {
|
||||
Events.initialiseEventHandler('.' + flagNavContact, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavContact, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageContact);
|
||||
this.router.navigateToHash(hashPageContact);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavUserAccount() {
|
||||
Events.initialiseEventHandler('.' + flagNavUserAccount, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavUserAccount, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageUserAccount);
|
||||
this.router.navigateToHash(hashPageUserAccount);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavUserLogout() {
|
||||
Events.initialiseEventHandler('.' + flagNavUserLogout, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavUserLogout, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageUserLogout);
|
||||
this.router.navigateToHash(hashPageUserLogout);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavUserLogin() {
|
||||
Events.initialiseEventHandler('.' + flagNavUserLogin, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavUserLogin, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
// router.navigateToHash(hashPageUserLogin);
|
||||
// this.router.navigateToHash(hashPageUserLogin);
|
||||
/*
|
||||
let dataRequest = {};
|
||||
dataRequest[keyCallback] = hashPageCurrent;
|
||||
@@ -128,7 +134,7 @@ export class BasePage {
|
||||
API.loginUser()
|
||||
.then(function(response) {
|
||||
if (response.Success) {
|
||||
window.app.router.navigateToUrl(response[keyCallback], null, false);
|
||||
this.router.navigateToUrl(response[keyCallback], null, false); // window.app.
|
||||
} else {
|
||||
DOM.alertError("Error", response.Message);
|
||||
}
|
||||
@@ -137,76 +143,76 @@ export class BasePage {
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreHome() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreHome, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreHome, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreHome);
|
||||
this.router.navigateToHash(hashPageStoreHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductCategories() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductCategories, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductCategories, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductCategories);
|
||||
this.router.navigateToHash(hashPageStoreProductCategories);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProducts() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProducts, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProducts, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProducts);
|
||||
this.router.navigateToHash(hashPageStoreProducts);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductPermutations() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductPermutations, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductPermutations, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductPermutations);
|
||||
this.router.navigateToHash(hashPageStoreProductPermutations);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductPrices() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductPrices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductPrices, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductPrices);
|
||||
this.router.navigateToHash(hashPageStoreProductPrices);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreProductVariations() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductVariations, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreProductVariations, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreProductVariations);
|
||||
this.router.navigateToHash(hashPageStoreProductVariations);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavStoreStockItems() {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreStockItems, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavStoreStockItems, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageStoreStockItems);
|
||||
this.router.navigateToHash(hashPageStoreStockItems);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavAdminHome() {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminHome, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminHome, flagInitialised, (navigator) => {
|
||||
navigator.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageAdminHome);
|
||||
this.router.navigateToHash(hashPageAdminHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
hookupImagesLogo() {
|
||||
let selectorImagesLogo = "img." + flagImageLogo;
|
||||
Events.initialiseEventHandler(selectorImagesLogo, flagInitialised, function(imageLogo) {
|
||||
imageLogo.addEventListener("click", function(event) {
|
||||
Events.initialiseEventHandler(selectorImagesLogo, flagInitialised, (buttonImageLogo) => {
|
||||
buttonImageLogo.addEventListener("click", (event) => {
|
||||
event.stopPropagation();
|
||||
router.navigateToHash(hashPageHome);
|
||||
this.router.navigateToHash(hashPageHome);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
|
||||
import Events from "../lib/events.js";
|
||||
import LocalStorage from "../lib/local_storage.js";
|
||||
import Validation from "../lib/validation";
|
||||
import { BasePage } from "./base.js";
|
||||
import Validation from "../lib/validation.js";
|
||||
import BasePage from "./base.js";
|
||||
import API from "../api.js";
|
||||
import DOM from "../dom.js";
|
||||
|
||||
export class TableBasePage extends BasePage {
|
||||
export default class TableBasePage extends BasePage {
|
||||
// callFilterTableContent
|
||||
// callSaveTableContent
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
/*
|
||||
if (!this.constructor.callFilterTableContent) {
|
||||
throw new Error(`Class ${this.constructor.name} must have a static callFilterTableContent method attribute that takes a single argument - the filters as json.`);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import { BasePage } from "../base.js";
|
||||
// import { router } from "../../router.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageAdminHome extends BasePage {
|
||||
export default class PageAdminHome extends BasePage {
|
||||
static hash = hashPageAdminHome;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
@@ -29,14 +28,14 @@ export class PageAdminHome extends BasePage {
|
||||
hookupButtonNavAdminStoreStripeProducts() {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminStoreStripeProducts, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
router.navigateToHash(hashPageAdminStoreStripeProducts);
|
||||
this.router.navigateToHash(hashPageAdminStoreStripeProducts);
|
||||
});
|
||||
});
|
||||
}
|
||||
hookupButtonNavAdminStoreStripePrices() {
|
||||
Events.initialiseEventHandler('.' + flagNavAdminStoreStripePrices, flagInitialised, function(navigator) {
|
||||
navigator.addEventListener("click", function(event) {
|
||||
router.navigateToHash(hashPageAdminStoreStripePrices);
|
||||
this.router.navigateToHash(hashPageAdminStoreStripePrices);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageContact extends BasePage {
|
||||
export default class PageContact extends BasePage {
|
||||
static hash = hashPageContact;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageHome extends BasePage {
|
||||
export default class PageHome extends BasePage {
|
||||
static hash = hashPageHome;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageServices extends BasePage {
|
||||
export default class PageServices extends BasePage {
|
||||
static hash = hashPageServices;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
17
static/js/pages/legal/accessibility_report.js
Normal file
17
static/js/pages/legal/accessibility_report.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export default class PageAccessibilityReport extends BasePage {
|
||||
static hash = hashPageAccessibilityReport;
|
||||
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageAccessibilityStatement extends BasePage {
|
||||
export default class PageAccessibilityStatement extends BasePage {
|
||||
static hash = hashPageAccessibilityStatement;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageLicense extends BasePage {
|
||||
export default class PageLicense extends BasePage {
|
||||
static hash = hashPageLicense;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
18
static/js/pages/legal/privacy_policy.js
Normal file
18
static/js/pages/legal/privacy_policy.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export default class PagePrivacyPolicy extends BasePage {
|
||||
static hash = hashPagePrivacyPolicy;
|
||||
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
17
static/js/pages/legal/retention_schedule.js
Normal file
17
static/js/pages/legal/retention_schedule.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export default class PageRetentionSchedule extends BasePage {
|
||||
static hash = hashPageDataRetentionSchedule;
|
||||
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.sharedInitialize();
|
||||
}
|
||||
|
||||
leave() {
|
||||
super.leave();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import LocalStorage from "../../lib/local_storage.js";
|
||||
import Validation from "../../lib/validation";
|
||||
// import { BasePage } from "../base.js";
|
||||
import Validation from "../../lib/validation.js";
|
||||
// import BasePage from "../base.js";
|
||||
import DOM from "../../dom.js";
|
||||
import { isEmpty } from "../../lib/utils.js";
|
||||
|
||||
export class StoreMixinPage { // extends BasePage {
|
||||
export default class StoreMixinPage {
|
||||
constructor() {
|
||||
// super();
|
||||
}
|
||||
|
||||
initialize(thisPage) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import LocalStorage from "../../lib/local_storage.js";
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageStoreBasket extends BasePage {
|
||||
export default class PageStoreBasket extends BasePage {
|
||||
static hash = hashPageStoreBasket;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageStoreHome extends BasePage {
|
||||
export default class PageStoreHome extends BasePage {
|
||||
static hash = hashPageStoreHome;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import { TableBasePage } from "../base_table.js";
|
||||
import TableBasePage from "../base_table.js";
|
||||
import API from "../../api.js";
|
||||
import DOM from "../../dom.js";
|
||||
|
||||
export class PageStoreProductCategories extends TableBasePage {
|
||||
export default class PageStoreProductCategories extends TableBasePage {
|
||||
static hash = hashPageStoreProductCategories;
|
||||
callFilterTableContent = API.getCategoriesByFilters;
|
||||
callSaveTableContent = API.saveCategories;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import { BasePage } from "../base.js";
|
||||
import Validation from "../../lib/validation";
|
||||
import BasePage from "../base.js";
|
||||
import Validation from "../../lib/validation.js";
|
||||
|
||||
|
||||
export class PageStoreProductPermutations extends BasePage {
|
||||
export default class PageStoreProductPermutations extends BasePage {
|
||||
static hash = hashPageStoreProductPermutations;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
|
||||
|
||||
import Events from "../../lib/events.js";
|
||||
import Validation from "../../lib/validation";
|
||||
import { BasePage } from "../base.js";
|
||||
import Validation from "../../lib/validation.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageStoreStockItems extends BasePage {
|
||||
export default class PageStoreStockItems extends BasePage {
|
||||
static hash = hashPageStoreStockItems;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
@@ -374,7 +374,7 @@ export class PageStoreStockItems extends BasePage {
|
||||
}
|
||||
|
||||
|
||||
import { TableBasePage } from "../base_table.js";
|
||||
import TableBasePage from "../base_table.js";
|
||||
import API from "../../api.js";
|
||||
import DOM from "../../dom.js";
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
import { BasePage } from "../base.js";
|
||||
import BasePage from "../base.js";
|
||||
|
||||
export class PageUser extends BasePage {
|
||||
export default class PageUser extends BasePage {
|
||||
static hash = hashPageUser;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
constructor(router) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
initialize() {
|
||||
|
||||
@@ -1,20 +1,30 @@
|
||||
|
||||
// Pages
|
||||
// Core
|
||||
import PageAdminHome from './pages/core/admin_home.js';
|
||||
import PageHome from './pages/core/home.js';
|
||||
import PageContact from './pages/core/contact.js';
|
||||
import PageServices from './pages/core/services.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';
|
||||
// Store
|
||||
import PageStoreBasket from './pages/store/basket.js';
|
||||
import PageStoreHome from './pages/store/home.js';
|
||||
import PageStoreProductCategories from './pages/store/product_categories.js';
|
||||
import PageStoreProductPermutations from './pages/store/product_permutations.js';
|
||||
// import PageStoreProductPrices from './pages/store/product_prices.js';
|
||||
// import PageStoreProducts from './pages/store/products.js';
|
||||
// import PageStoreProductVariations from './pages/store/product_variations.js';
|
||||
import PageStoreStockItems from './pages/store/stock_items.js';
|
||||
// User
|
||||
// import PageUserLogin from './pages/user/login.js';
|
||||
// import PageUserLogout from './pages/user/logout.js';
|
||||
// import PageUserAccount from './pages/user/account.js';
|
||||
|
||||
|
||||
/*
|
||||
import { PageAdminHome } from './pages/core/admin_home.js';
|
||||
import { PageHome } from './pages/core/home.js';
|
||||
import { PageContact } from './pages/core/contact.js';
|
||||
import { PageAccessibilityStatement } from './pages/legal/accessibility_statement.js';
|
||||
import { PageLicense } from './pages/legal/license.js';
|
||||
import { PageServices } from './pages/core/services.js';
|
||||
import { PageStoreBasket } from './pages/store/basket.js';
|
||||
import { PageStoreHome } from './pages/store/home.js';
|
||||
import { PageStoreProductCategories } from './pages/store/product_categories.js';
|
||||
import { PageStoreProductPermutations } from './pages/store/product_permutations.js';
|
||||
// import { PageStoreProductPrices } from './pages/store/product_prices.js';
|
||||
// import { PageStoreProducts } from './pages/store/products.js';
|
||||
// import { PageStoreProductVariations } from './pages/store/product_variations.js';
|
||||
import { PageStoreStockItems } from './pages/store/stock_items.js';
|
||||
*/
|
||||
import "./lib/common.js";
|
||||
import "./lib/constants.js";
|
||||
import "./lib/events.js";
|
||||
@@ -23,11 +33,15 @@ import "./lib/extras.js";
|
||||
import "./lib/local_storage.js";
|
||||
import "./lib/utils.js";
|
||||
import "./lib/validation.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';
|
||||
|
||||
// Create a context for the pages
|
||||
const pagesContext = require.context('./pages', true, /\.js$/);
|
||||
// const pagesContext = require.context('./pages', true, /\.js$/);
|
||||
|
||||
/*
|
||||
const pageModules = {
|
||||
@@ -53,23 +67,26 @@ export default class Router {
|
||||
// Pages
|
||||
this.pages = {};
|
||||
// Core
|
||||
this.pages[hashPageHome] = { name: 'PageHome', pathModule: './core/home.js' };
|
||||
this.pages[hashPageContact] = { name: 'PageContact', pathModule: './core/contact.js' };
|
||||
this.pages[hashPageServices] = { name: 'PageServices', pathModule: './core/services.js' };
|
||||
this.pages[hashPageAdminHome] = { name: 'PageAdminHome', pathModule: './core/admin_home.js' };
|
||||
this.pages[hashPageHome] = { name: 'PageHome', module: PageAdminHome }; // 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[hashPageServices] = { name: 'PageServices', module: PageServices }; // pathModule: './pages/core/services.js' };
|
||||
this.pages[hashPageAdminHome] = { name: 'PageAdminHome', module: PageAdminHome }; // pathModule: './pages/core/admin_home.js' };
|
||||
// Legal
|
||||
this.pages[hashPageAccessibilityStatement] = { name: 'PageAccessibilityStatement', pathModule: './legal/accessibility_statement.js' };
|
||||
this.pages[hashPageLicense] = { name: 'PageLicense', pathModule: './legal/license.js' };
|
||||
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'); }
|
||||
// Store
|
||||
this.pages[hashPageStoreProductCategories] = { name: 'PageStoreProductCategories', pathModule: './store/product_categories.js' };
|
||||
this.pages[hashPageStoreProductPermutations] = { name: 'PageStoreProductPermutations', pathModule: './store/product_permutations.js' };
|
||||
// this.pages[hashPageStoreProductPrices] = { name: 'PageStoreProductPrices', pathModule: './store/product_prices.js' };
|
||||
this.pages[hashPageStoreProducts] = { name: 'PageStoreProducts', pathModule: './store/products.js' };
|
||||
// this.pages[hashPageStoreProductVariations] = { name: 'PageStoreProductVariations', pathModule: './store/product_variations.js' };
|
||||
this.pages[hashPageStoreProductCategories] = { name: 'PageStoreProductCategories', module: PageStoreProductCategories }; // pathModule: './pages/store/product_categories.js' };
|
||||
this.pages[hashPageStoreProductPermutations] = { name: 'PageStoreProductPermutations', module: PageStoreProductPermutations }; // pathModule: './pages/store/product_permutations.js' };
|
||||
// this.pages[hashPageStoreProductPrices] = { name: 'PageStoreProductPrices', module: PageStoreProductPrices }; // pathModule: './pages/store/product_prices.js' };
|
||||
// this.pages[hashPageStoreProducts] = { name: 'PageStoreProducts', module: PageStoreProducts }; // pathModule: './pages/store/products.js' };
|
||||
// this.pages[hashPageStoreProductVariations] = { name: 'PageStoreProductVariations', module: PageStoreProductVariations }; // pathModule: './pages/store/product_variations.js' };
|
||||
this.pages[hashPageStoreStockItems] = { name: 'PageStoreStockItems', module: PageStoreStockItems };
|
||||
// User
|
||||
// this.pages[hashPageUserLogin] = { name: 'PageUserLogin', pathModule: './user/login.js' };
|
||||
// this.pages[hashPageUserLogout] = { name: 'PageUserLogout', pathModule: './user/logout.js' };
|
||||
// this.pages[hashPageUserAccount] = { name: 'PageUserAccount', pathModule: './user/account.js' };
|
||||
// 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' };
|
||||
|
||||
// Routes
|
||||
this.routes = {};
|
||||
@@ -80,7 +97,9 @@ export default class Router {
|
||||
this.routes[hashPageAdminHome] = (isPopState = false) => this.navigateToHash(hashPageAdminHome, isPopState);
|
||||
// Legal
|
||||
this.routes[hashPageAccessibilityStatement] = (isPopState = false) => this.navigateToHash(hashPageAccessibilityStatement, isPopState);
|
||||
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);
|
||||
// Store
|
||||
this.routes[hashPageStoreProductCategories] = (isPopState = false) => this.navigateToHash(hashPageStoreProductCategories, isPopState);
|
||||
this.routes[hashPageStoreProductPermutations] = (isPopState = false) => this.navigateToHash(hashPageStoreProductPermutations, isPopState);
|
||||
@@ -97,7 +116,7 @@ export default class Router {
|
||||
console.log("loadPage: " + hashPage);
|
||||
const PageClass = await this.getClassPageFromHash(hashPage);
|
||||
console.log("PageClass: ", PageClass);
|
||||
this.currentPage = new PageClass();
|
||||
this.currentPage = new PageClass(this);
|
||||
console.log("this.currentPage: ", this.currentPage);
|
||||
this.currentPage.initialize(isPopState);
|
||||
}
|
||||
@@ -106,11 +125,19 @@ export default class Router {
|
||||
let pageJson = this.pages[hashPage];
|
||||
console.log("pageJson: ", pageJson);
|
||||
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;
|
||||
console.log("module: ", module);
|
||||
return module; // [pageJson.name];
|
||||
}
|
||||
catch (error) {
|
||||
console.log("this.pages: ", this.pages);
|
||||
console.error('Page not found:', hashPage);
|
||||
throw error;
|
||||
}
|
||||
@@ -144,12 +171,12 @@ export default class Router {
|
||||
*/
|
||||
let url = API.getUrlFromHash(hash, params);
|
||||
// if (!isPopState)
|
||||
history.pushState(data, '', url);
|
||||
history.pushState({data: data, params: params}, '', hash);
|
||||
API.goToUrl(url, data);
|
||||
}
|
||||
async beforeLeave() {
|
||||
const ClassPageCurrent = await this.getClassPageFromHash(DOM.getHashPageCurrent());
|
||||
const pageCurrent = new ClassPageCurrent();
|
||||
const pageCurrent = new ClassPageCurrent(this);
|
||||
pageCurrent.leave();
|
||||
}
|
||||
|
||||
|
||||
0
static/js/sections/legal.js
Normal file
0
static/js/sections/legal.js
Normal file
Reference in New Issue
Block a user