Added the JavaScript JournalEntryEditor instance to the parameters of the constructor of the JavaScript OriginalEntrySelector class, so that it always have access to the JournalEntryEditor instance. Removed the JournalEntryEditor instance from the parameters of the onOpen method of the JournalEntryEditor class.
This commit is contained in:
parent
b69a519904
commit
5d0757c845
@ -238,8 +238,8 @@ class JournalEntryEditor {
|
|||||||
this.#amountError = document.getElementById(this.#prefix + "-amount-error");
|
this.#amountError = document.getElementById(this.#prefix + "-amount-error");
|
||||||
this.#summaryEditors = SummaryEditor.getInstances(this);
|
this.#summaryEditors = SummaryEditor.getInstances(this);
|
||||||
this.#accountSelectors = AccountSelector.getInstances(this);
|
this.#accountSelectors = AccountSelector.getInstances(this);
|
||||||
this.originalEntrySelector = new OriginalEntrySelector();
|
this.originalEntrySelector = new OriginalEntrySelector(this);
|
||||||
this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen(this, this.originalEntryId)
|
this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen(this.originalEntryId)
|
||||||
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
|
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
|
||||||
this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen();
|
this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen();
|
||||||
this.#accountControl.onclick = () => this.#accountSelectors[this.entryType].onOpen();
|
this.#accountControl.onclick = () => this.#accountSelectors[this.entryType].onOpen();
|
||||||
|
@ -28,6 +28,12 @@
|
|||||||
*/
|
*/
|
||||||
class OriginalEntrySelector {
|
class OriginalEntrySelector {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The journal entry editor
|
||||||
|
* @type {JournalEntryEditor}
|
||||||
|
*/
|
||||||
|
entryEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The prefix of the HTML ID and class
|
* The prefix of the HTML ID and class
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -64,12 +70,6 @@ class OriginalEntrySelector {
|
|||||||
*/
|
*/
|
||||||
#optionById;
|
#optionById;
|
||||||
|
|
||||||
/**
|
|
||||||
* The journal entry editor
|
|
||||||
* @type {JournalEntryEditor}
|
|
||||||
*/
|
|
||||||
entryEditor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The currency code
|
* The currency code
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -84,8 +84,10 @@ class OriginalEntrySelector {
|
|||||||
/**
|
/**
|
||||||
* Constructs an original entry selector.
|
* Constructs an original entry selector.
|
||||||
*
|
*
|
||||||
|
* @param entryEditor {JournalEntryEditor} the journal entry editor
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor(entryEditor) {
|
||||||
|
this.entryEditor = entryEditor;
|
||||||
this.#query = document.getElementById(this.#prefix + "-query");
|
this.#query = document.getElementById(this.#prefix + "-query");
|
||||||
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
|
||||||
this.#optionList = document.getElementById(this.#prefix + "-option-list");
|
this.#optionList = document.getElementById(this.#prefix + "-option-list");
|
||||||
@ -174,13 +176,11 @@ class OriginalEntrySelector {
|
|||||||
/**
|
/**
|
||||||
* The callback when the original entry selector is shown.
|
* The callback when the original entry selector is shown.
|
||||||
*
|
*
|
||||||
* @param entryEditor {JournalEntryEditor} the journal entry editor
|
|
||||||
* @param originalEntryId {string|null} the ID of the original entry
|
* @param originalEntryId {string|null} the ID of the original entry
|
||||||
*/
|
*/
|
||||||
onOpen(entryEditor, originalEntryId = null) {
|
onOpen(originalEntryId = null) {
|
||||||
this.entryEditor = entryEditor
|
this.#currencyCode = this.entryEditor.getCurrencyCode();
|
||||||
this.#currencyCode = entryEditor.getCurrencyCode();
|
this.#entryType = this.entryEditor.entryType;
|
||||||
this.#entryType = entryEditor.entryType;
|
|
||||||
for (const option of this.#options) {
|
for (const option of this.#options) {
|
||||||
option.setActive(option.id === originalEntryId);
|
option.setActive(option.id === originalEntryId);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ class SummaryEditor {
|
|||||||
this.currentTab = this.tabPlanes.general;
|
this.currentTab = this.tabPlanes.general;
|
||||||
this.#initializeSuggestedAccounts();
|
this.#initializeSuggestedAccounts();
|
||||||
this.summary.onchange = () => this.#onSummaryChange();
|
this.summary.onchange = () => this.#onSummaryChange();
|
||||||
this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen(this.#entryEditor);
|
this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen();
|
||||||
this.#form.onsubmit = () => {
|
this.#form.onsubmit = () => {
|
||||||
if (this.currentTab.validate()) {
|
if (this.currentTab.validate()) {
|
||||||
this.#submit();
|
this.#submit();
|
||||||
|
Loading…
Reference in New Issue
Block a user