Compare commits

...

6 Commits

6 changed files with 22 additions and 30 deletions

View File

@ -38,7 +38,7 @@ class AccountSelector {
* The entry type
* @type {string}
*/
entryType;
#entryType;
/**
* The prefix of the HTML ID and class
@ -90,7 +90,7 @@ class AccountSelector {
*/
constructor(entryEditor, entryType) {
this.#entryEditor = entryEditor
this.entryType = entryType;
this.#entryType = entryType;
this.#prefix = "accounting-account-selector-" + entryType;
this.#query = document.getElementById(this.#prefix + "-query");
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
@ -143,7 +143,7 @@ class AccountSelector {
* @return {string[]} the account codes that are used in the form
*/
#getCodesUsedInForm() {
const inUse = this.#entryEditor.form.getAccountCodesUsed(this.entryType);
const inUse = this.#entryEditor.form.getAccountCodesUsed(this.#entryType);
if (this.#entryEditor.accountCode !== null) {
inUse.push(this.#entryEditor.accountCode);
}

View File

@ -238,8 +238,8 @@ class JournalEntryEditor {
this.#amountError = document.getElementById(this.#prefix + "-amount-error");
this.#summaryEditors = SummaryEditor.getInstances(this);
this.#accountSelectors = AccountSelector.getInstances(this);
this.originalEntrySelector = new OriginalEntrySelector();
this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen(this, this.originalEntryId)
this.originalEntrySelector = new OriginalEntrySelector(this);
this.#originalEntryControl.onclick = () => this.originalEntrySelector.onOpen()
this.#originalEntryDelete.onclick = () => this.clearOriginalEntry();
this.#summaryControl.onclick = () => this.#summaryEditors[this.entryType].onOpen();
this.#accountControl.onclick = () => this.#accountSelectors[this.entryType].onOpen();

View File

@ -28,18 +28,18 @@
*/
class OriginalEntrySelector {
/**
* The journal entry editor
* @type {JournalEntryEditor}
*/
entryEditor;
/**
* The prefix of the HTML ID and class
* @type {string}
*/
#prefix = "accounting-original-entry-selector";
/**
* The modal of the original entry editor
* @type {HTMLDivElement}
*/
#modal;
/**
* The query input
* @type {HTMLInputElement}
@ -70,12 +70,6 @@ class OriginalEntrySelector {
*/
#optionById;
/**
* The journal entry editor
* @type {JournalEntryEditor}
*/
entryEditor;
/**
* The currency code
* @type {string}
@ -90,9 +84,10 @@ class OriginalEntrySelector {
/**
* Constructs an original entry selector.
*
* @param entryEditor {JournalEntryEditor} the journal entry editor
*/
constructor() {
this.#modal = document.getElementById(this.#prefix + "-modal");
constructor(entryEditor) {
this.entryEditor = entryEditor;
this.#query = document.getElementById(this.#prefix + "-query");
this.#queryNoResult = document.getElementById(this.#prefix + "-option-no-result");
this.#optionList = document.getElementById(this.#prefix + "-option-list");
@ -181,15 +176,12 @@ class OriginalEntrySelector {
/**
* 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
*/
onOpen(entryEditor, originalEntryId = null) {
this.entryEditor = entryEditor
this.#currencyCode = entryEditor.getCurrencyCode();
this.#entryType = entryEditor.entryType;
onOpen() {
this.#currencyCode = this.entryEditor.getCurrencyCode();
this.#entryType = this.entryEditor.entryType;
for (const option of this.#options) {
option.setActive(option.id === originalEntryId);
option.setActive(option.id === this.entryEditor.originalEntryId);
}
this.#query.value = "";
this.#updateNetBalances();

View File

@ -175,7 +175,7 @@ class MonthTab extends TabPlane {
let start = monthChooser.dataset.start;
this.#monthChooser = new tempusDominus.TempusDominus(monthChooser, {
restrictions: {
minDate: start,
minDate: new Date(start),
},
display: {
inline: true,
@ -184,7 +184,7 @@ class MonthTab extends TabPlane {
clock: false,
},
},
defaultDate: monthChooser.dataset.default,
defaultDate: new Date(monthChooser.dataset.default),
});
monthChooser.addEventListener(tempusDominus.Namespace.events.change, (e) => {
const date = e.detail.date;

View File

@ -132,7 +132,7 @@ class SummaryEditor {
this.currentTab = this.tabPlanes.general;
this.#initializeSuggestedAccounts();
this.summary.onchange = () => this.#onSummaryChange();
this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen(this.#entryEditor);
this.#offsetButton.onclick = () => this.#entryEditor.originalEntrySelector.onOpen();
this.#form.onsubmit = () => {
if (this.currentTab.validate()) {
this.#submit();

View File

@ -32,7 +32,7 @@ First written: 2023/1/27
<script src="{{ url_for("babel_catalog") }}"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/decimal.js-light@2.5.1/decimal.min.js" integrity="sha384-QdsxGEq4Y0erX8WUIsZJDtfoSSyBF6dmNCnzRNYCa2AOM/xzNsyhHu0RbdFBAm+l" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.2.10/dist/js/tempus-dominus.min.js" integrity="sha384-BiIgBzfRUwCKCLJTFUfZPl8n4yeDooQYkgtJBNVI4Gg6OAfIFO6FhEK6KiO1dvhA" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.4.3/dist/js/tempus-dominus.min.js" integrity="sha384-2MkID2vkc9sxBCqs2us3mB8fV+c0o7uPtOvAPjaC8gKv9Bk21UHT0r2Q7Kv70+zO" crossorigin="anonymous"></script>
{% block scripts %}{% endblock %}
<title>{% block title %}{% endblock %}</title>
</head>