Replaced the JavaScript prefix attributes that are only used in the class constructors with the prefix constant variables in the constructor.
This commit is contained in:
parent
52807c5322
commit
7ed13dc0af
@ -40,12 +40,6 @@ class AccountSelector {
|
|||||||
*/
|
*/
|
||||||
#debitCredit;
|
#debitCredit;
|
||||||
|
|
||||||
/**
|
|
||||||
* The prefix of the HTML ID and class
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
#prefix;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The button to clear the account
|
* The button to clear the account
|
||||||
* @type {HTMLButtonElement}
|
* @type {HTMLButtonElement}
|
||||||
@ -91,14 +85,14 @@ class AccountSelector {
|
|||||||
constructor(lineItemEditor, debitCredit) {
|
constructor(lineItemEditor, debitCredit) {
|
||||||
this.#lineItemEditor = lineItemEditor
|
this.#lineItemEditor = lineItemEditor
|
||||||
this.#debitCredit = debitCredit;
|
this.#debitCredit = debitCredit;
|
||||||
this.#prefix = "accounting-account-selector-" + debitCredit;
|
const prefix = "accounting-account-selector-" + debitCredit;
|
||||||
this.#query = document.getElementById(this.#prefix + "-query");
|
this.#query = document.getElementById(prefix + "-query");
|
||||||
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
this.#queryNoResult = document.getElementById(prefix + "-option-no-result");
|
||||||
this.#optionList = document.getElementById(this.#prefix + "-option-list");
|
this.#optionList = document.getElementById(prefix + "-option-list");
|
||||||
// noinspection JSValidateTypes
|
// noinspection JSValidateTypes
|
||||||
this.#options = Array.from(document.getElementsByClassName(this.#prefix + "-option"));
|
this.#options = Array.from(document.getElementsByClassName(prefix + "-option"));
|
||||||
this.#more = document.getElementById(this.#prefix + "-more");
|
this.#more = document.getElementById(prefix + "-more");
|
||||||
this.#clearButton = document.getElementById(this.#prefix + "-btn-clear");
|
this.#clearButton = document.getElementById(prefix + "-btn-clear");
|
||||||
this.#more.onclick = () => {
|
this.#more.onclick = () => {
|
||||||
this.#more.classList.add("d-none");
|
this.#more.classList.add("d-none");
|
||||||
this.#filterOptions();
|
this.#filterOptions();
|
||||||
|
@ -363,12 +363,6 @@ class CurrencySubForm {
|
|||||||
*/
|
*/
|
||||||
index;
|
index;
|
||||||
|
|
||||||
/**
|
|
||||||
* The prefix of the HTML ID and class
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
#prefix;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The control
|
* The control
|
||||||
* @type {HTMLDivElement}
|
* @type {HTMLDivElement}
|
||||||
@ -427,16 +421,16 @@ class CurrencySubForm {
|
|||||||
this.element = element;
|
this.element = element;
|
||||||
this.form = form;
|
this.form = form;
|
||||||
this.index = parseInt(this.element.dataset.index);
|
this.index = parseInt(this.element.dataset.index);
|
||||||
this.#prefix = "accounting-currency-" + String(this.index);
|
const prefix = "accounting-currency-" + String(this.index);
|
||||||
this.#control = document.getElementById(this.#prefix + "-control");
|
this.#control = document.getElementById(prefix + "-control");
|
||||||
this.#error = document.getElementById(this.#prefix + "-error");
|
this.#error = document.getElementById(prefix + "-error");
|
||||||
this.no = document.getElementById(this.#prefix + "-no");
|
this.no = document.getElementById(prefix + "-no");
|
||||||
this.#code = document.getElementById(this.#prefix + "-code");
|
this.#code = document.getElementById(prefix + "-code");
|
||||||
this.#codeSelect = document.getElementById(this.#prefix + "-code-select");
|
this.#codeSelect = document.getElementById(prefix + "-code-select");
|
||||||
this.deleteButton = document.getElementById(this.#prefix + "-delete");
|
this.deleteButton = document.getElementById(prefix + "-delete");
|
||||||
const debitElement = document.getElementById(this.#prefix + "-debit");
|
const debitElement = document.getElementById(prefix + "-debit");
|
||||||
this.#debit = debitElement === null? null: new DebitCreditSubForm(this, debitElement, "debit");
|
this.#debit = debitElement === null? null: new DebitCreditSubForm(this, debitElement, "debit");
|
||||||
const creditElement = document.getElementById(this.#prefix + "-credit");
|
const creditElement = document.getElementById(prefix + "-credit");
|
||||||
this.#credit = creditElement == null? null: new DebitCreditSubForm(this, creditElement, "credit");
|
this.#credit = creditElement == null? null: new DebitCreditSubForm(this, creditElement, "credit");
|
||||||
this.#codeSelect.onchange = () => this.#code.value = this.#codeSelect.value;
|
this.#codeSelect.onchange = () => this.#code.value = this.#codeSelect.value;
|
||||||
this.deleteButton.onclick = () => {
|
this.deleteButton.onclick = () => {
|
||||||
@ -771,12 +765,6 @@ class LineItemSubForm {
|
|||||||
*/
|
*/
|
||||||
isMatched;
|
isMatched;
|
||||||
|
|
||||||
/**
|
|
||||||
* The prefix of the HTML ID and class
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
#prefix;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The control
|
* The control
|
||||||
* @type {HTMLDivElement}
|
* @type {HTMLDivElement}
|
||||||
@ -867,20 +855,20 @@ class LineItemSubForm {
|
|||||||
this.debitCredit = element.dataset.debitCredit;
|
this.debitCredit = element.dataset.debitCredit;
|
||||||
this.lineItemIndex = parseInt(element.dataset.lineItemIndex);
|
this.lineItemIndex = parseInt(element.dataset.lineItemIndex);
|
||||||
this.isMatched = element.classList.contains("accounting-matched-line-item");
|
this.isMatched = element.classList.contains("accounting-matched-line-item");
|
||||||
this.#prefix = "accounting-currency-" + element.dataset.currencyIndex + "-" + this.debitCredit + "-" + this.lineItemIndex;
|
const prefix = "accounting-currency-" + element.dataset.currencyIndex + "-" + this.debitCredit + "-" + this.lineItemIndex;
|
||||||
this.#control = document.getElementById(this.#prefix + "-control");
|
this.#control = document.getElementById(prefix + "-control");
|
||||||
this.#error = document.getElementById(this.#prefix + "-error");
|
this.#error = document.getElementById(prefix + "-error");
|
||||||
this.no = document.getElementById(this.#prefix + "-no");
|
this.no = document.getElementById(prefix + "-no");
|
||||||
this.#accountCode = document.getElementById(this.#prefix + "-account-code");
|
this.#accountCode = document.getElementById(prefix + "-account-code");
|
||||||
this.#accountText = document.getElementById(this.#prefix + "-account-text");
|
this.#accountText = document.getElementById(prefix + "-account-text");
|
||||||
this.#description = document.getElementById(this.#prefix + "-description");
|
this.#description = document.getElementById(prefix + "-description");
|
||||||
this.#descriptionText = document.getElementById(this.#prefix + "-description-text");
|
this.#descriptionText = document.getElementById(prefix + "-description-text");
|
||||||
this.#originalLineItemId = document.getElementById(this.#prefix + "-original-line-item-id");
|
this.#originalLineItemId = document.getElementById(prefix + "-original-line-item-id");
|
||||||
this.#originalLineItemText = document.getElementById(this.#prefix + "-original-line-item-text");
|
this.#originalLineItemText = document.getElementById(prefix + "-original-line-item-text");
|
||||||
this.#offsets = document.getElementById(this.#prefix + "-offsets");
|
this.#offsets = document.getElementById(prefix + "-offsets");
|
||||||
this.#amount = document.getElementById(this.#prefix + "-amount");
|
this.#amount = document.getElementById(prefix + "-amount");
|
||||||
this.#amountText = document.getElementById(this.#prefix + "-amount-text");
|
this.#amountText = document.getElementById(prefix + "-amount-text");
|
||||||
this.deleteButton = document.getElementById(this.#prefix + "-delete");
|
this.deleteButton = document.getElementById(prefix + "-delete");
|
||||||
this.#control.onclick = () => this.debitCreditSubForm.currency.form.lineItemEditor.onEdit(this);
|
this.#control.onclick = () => this.debitCreditSubForm.currency.form.lineItemEditor.onEdit(this);
|
||||||
this.deleteButton.onclick = () => {
|
this.deleteButton.onclick = () => {
|
||||||
this.element.parentElement.removeChild(this.element);
|
this.element.parentElement.removeChild(this.element);
|
||||||
|
@ -33,12 +33,6 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
*/
|
*/
|
||||||
class PeriodChooser {
|
class PeriodChooser {
|
||||||
|
|
||||||
/**
|
|
||||||
* The prefix of the HTML ID and class
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
prefix;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The modal of the period chooser
|
* The modal of the period chooser
|
||||||
* @type {HTMLDivElement}
|
* @type {HTMLDivElement}
|
||||||
@ -56,8 +50,8 @@ class PeriodChooser {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.prefix = "accounting-period-chooser";
|
const prefix = "accounting-period-chooser";
|
||||||
this.modal = document.getElementById(this.prefix + "-modal");
|
this.modal = document.getElementById(prefix + "-modal");
|
||||||
for (const cls of [MonthTab, YearTab, DayTab, CustomTab]) {
|
for (const cls of [MonthTab, YearTab, DayTab, CustomTab]) {
|
||||||
const tab = new cls(this);
|
const tab = new cls(this);
|
||||||
this.tabPlanes[tab.tabId()] = tab;
|
this.tabPlanes[tab.tabId()] = tab;
|
||||||
|
Loading…
Reference in New Issue
Block a user