mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
* Add lookbook + viewcomponent, organize design system file * Build menu component * Button updates * More button fixes * Replace all menus with new ViewComponent * Checkpoint: fix tests, all buttons and menus converted * Split into Link and Button components for clarity * Button cleanup * Simplify custom confirmation configuration in views * Finalize button, link component API * Add toggle field to custom form builder + Component * Basic tabs component * Custom tabs, convert all menu / tab instances in app * Gem updates * Centralized icon helper * Update all icon usage to central helper * Lint fixes * Centralize all disclosure instances * Dialog replacements * Consolidation of all dialog styles * Test fixes * Fix app layout issues, move to component with slots * Layout simplification * Flakey test fix * Fix dashboard mobile issues * Finalize homepage * Lint fixes * Fix shadows and borders in dark mode * Fix tests * Remove stale class * Fix filled icon logic * Move transparent? to public interface
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
import { Controller } from "@hotwired/stimulus";
|
|
|
|
// Connects to data-controller="rule--actions"
|
|
export default class extends Controller {
|
|
static values = { actionExecutors: Array };
|
|
static targets = ["destroyField", "actionValue"];
|
|
|
|
remove(e) {
|
|
if (e.params.destroy) {
|
|
this.destroyFieldTarget.value = true;
|
|
this.element.classList.add("hidden");
|
|
} else {
|
|
this.element.remove();
|
|
}
|
|
}
|
|
|
|
handleActionTypeChange(e) {
|
|
const actionExecutor = this.actionExecutorsValue.find(
|
|
(executor) => executor.key === e.target.value,
|
|
);
|
|
|
|
if (actionExecutor.type === "select") {
|
|
this.#updateValueSelectFor(actionExecutor);
|
|
this.#showAndEnableValueSelect();
|
|
} else {
|
|
this.#hideAndDisableValueSelect();
|
|
}
|
|
}
|
|
|
|
get valueSelectEl() {
|
|
return this.actionValueTarget.querySelector("select");
|
|
}
|
|
|
|
#showAndEnableValueSelect() {
|
|
this.actionValueTarget.classList.remove("hidden");
|
|
this.valueSelectEl.disabled = false;
|
|
}
|
|
|
|
#hideAndDisableValueSelect() {
|
|
this.actionValueTarget.classList.add("hidden");
|
|
this.valueSelectEl.disabled = true;
|
|
}
|
|
|
|
#updateValueSelectFor(actionExecutor) {
|
|
// Clear existing options
|
|
this.valueSelectEl.innerHTML = "";
|
|
|
|
// Add new options
|
|
for (const option of actionExecutor.options) {
|
|
const optionEl = document.createElement("option");
|
|
optionEl.value = option[1];
|
|
optionEl.textContent = option[0];
|
|
this.valueSelectEl.appendChild(optionEl);
|
|
}
|
|
}
|
|
}
|