-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from chonla/main
feat: Auto color when all capabilities in block are checked
- Loading branch information
Showing
5 changed files
with
40 additions
and
10 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
19 changes: 19 additions & 0 deletions
19
cdmm/app/javascript/controllers/checklist_ui_controller.js
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,19 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
// Connects to data-controller="checklist-ui" | ||
export default class extends Controller { | ||
static values = { itemCount: Number, completeClasses: String } | ||
|
||
connect() { | ||
} | ||
|
||
refresh(event) { | ||
const uncheckedChecklists = this.element.querySelectorAll("input[type='hidden'][value='unchecked']"); | ||
if (uncheckedChecklists.length === 0) { | ||
this.element.classList.add(this.completeClassesValue); | ||
} else { | ||
this.element.classList.remove(this.completeClassesValue); | ||
} | ||
} | ||
|
||
} |
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,7 @@ | ||
<td data-controller="checklist-ui" data-checklist-ui-complete-classes-value="bg-green-100" data-checklist-ui-item-count-value="<%= get_data_at(table, row_index, col_index).count %>" data-action="capability:toggled->checklist-ui#refresh" class="relative border-gray-300 border border-l-0 border-t-0 p-2 text-xs md:text-sm align-top <%= all_checked?(table, row_index, col_index) ? "bg-green-100" : "" %>"> | ||
<div class="flex flex-col gap-y-4 items-start"> | ||
<% get_data_at(table, row_index, col_index).each_with_index do |data, data_index| %> | ||
<%= render :partial => "capability_item", :locals => { key: data[:key], label: data[:label], description: data[:description], value: data[:value] } %> | ||
<% end %> | ||
</div> | ||
</td> |
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