-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disable table action links if no samples are seleceted (#305)
* chore: Disable action links if no samples are seleceted * chore: Fixed undefined issue * chore: Made the number of required samples optional for each link * chore: Removed logging statement * chore: Fixed typo and update comments * chore: Updated css class to handle linking action-links * chore: Updated to work with primary buttons * chore: Fixed empty storage value issue * chore: Fixed typo
- Loading branch information
Showing
4 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Controller } from "@hotwired/stimulus"; | ||
|
||
export default class extends Controller { | ||
static values = { required: { type: Number, default: 0 } }; | ||
|
||
// # indicates private attribute or method | ||
// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties | ||
#event_classes = ["pointer-events-none", "cursor-not-allowed"]; | ||
|
||
#default_colours = ["bg-slate-200", "text-slate-400"]; | ||
|
||
#primary_colours = ["bg-primary-200", "text-slate-400", "border-primary-200"]; | ||
|
||
setDisabled(count = 0) { | ||
if (this.requiredValue > count) { | ||
this.element.classList.add(...this.#event_classes); | ||
if (this.element.classList.contains("button--state-primary")) { | ||
this.element.classList.add(...this.#primary_colours); | ||
} else { | ||
this.element.classList.add(...this.#default_colours); | ||
} | ||
} else { | ||
this.element.classList.remove(...this.#event_classes); | ||
if (this.element.classList.contains("button--state-primary")) { | ||
this.element.classList.remove(...this.#primary_colours); | ||
} else { | ||
this.element.classList.remove(...this.#default_colours); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters