Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-08-02 14:44:51 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-08-02 14:51:31 -0700
commiteb3c919f7d5562e0732349f8382534c618bef448 (patch)
treef6a16356d6d70ba66aa6db76afcdbdefa2c8eea0
parenta042537c8eeff2e45bcc5d678e2657f4f542ec93 (diff)
Deselect when view changes to another squad
-rw-r--r--src/index.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/index.js b/src/index.js
index cc4dd6d..e6a8802 100644
--- a/src/index.js
+++ b/src/index.js
@@ -266,10 +266,15 @@ document.querySelectorAll('#record-sheet [data-allegiance]').forEach(el => {
squadNumbers.forEach(sn =>
sn.addEventListener('click', function() {
- recordContainer.dataset.viewSquadNumber = this.dataset.number;
- squadNumbers.forEach(sn =>
- sn.classList[sn.dataset.number === this.dataset.number ? 'add' : 'remove']('selected')
- );
+ if (!this.classList.contains('selected')) {
+ recordContainer.dataset.viewSquadNumber = this.dataset.number;
+ console.log();
+ squadNumbers.forEach(sn =>
+ sn.classList[sn.dataset.number === this.dataset.number ? 'add' : 'remove']('selected')
+ );
+
+ if (el.querySelector('.soldier-record.selected')) Observable.notify('select');
+ }
})
);
});