mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Scaffold out basic transactions model and UI (#478)
* Transaction scaffold * Rough in transaction views * Fix sort order * Fix mass assignment issue * Fix test * Simplify CI workflow * Don't seed db before test
This commit is contained in:
parent
e767aca37f
commit
87b97b3c41
26 changed files with 430 additions and 44 deletions
33
app/javascript/controllers/tabs_controller.js
Normal file
33
app/javascript/controllers/tabs_controller.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
|
||||
// Connects to data-controller="tabs"
|
||||
export default class extends Controller {
|
||||
static classes = ["active"];
|
||||
static targets = ["btn", "tab"];
|
||||
static values = { defaultTab: String };
|
||||
|
||||
connect() {
|
||||
const defaultTab = this.defaultTabValue;
|
||||
this.tabTargets.forEach((tab) => {
|
||||
if (tab.id === defaultTab) {
|
||||
tab.hidden = false;
|
||||
this.btnTargets
|
||||
.find((btn) => btn.dataset.id === defaultTab)
|
||||
.classList.add(...this.activeClasses);
|
||||
} else {
|
||||
tab.hidden = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
select(event) {
|
||||
const selectedTabId = event.currentTarget.dataset.id;
|
||||
this.tabTargets.forEach((tab) => (tab.hidden = tab.id !== selectedTabId));
|
||||
this.btnTargets.forEach((btn) =>
|
||||
btn.classList.toggle(
|
||||
...this.activeClasses,
|
||||
btn.dataset.id === selectedTabId
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue