mirror of
https://github.com/redmine/redmine.git
synced 2026-07-04 12:09:09 +02:00
Extract Gantt view structure and wire Stimulus controllers (#43397).
Patch by Katsuya HIDAKA (user:hidakatsuya). git-svn-id: https://svn.redmine.org/redmine/trunk@24085 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
63
app/javascript/controllers/gantt/options_controller.js
Normal file
63
app/javascript/controllers/gantt/options_controller.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["display", "relations", "progress"]
|
||||
|
||||
static values = {
|
||||
unavailableColumns: Array
|
||||
}
|
||||
|
||||
initialize() {
|
||||
this.$ = window.jQuery
|
||||
}
|
||||
|
||||
connect() {
|
||||
this.#dispatchInitialStates()
|
||||
this.#disableUnavailableColumns()
|
||||
}
|
||||
|
||||
toggleDisplay(event) {
|
||||
this.dispatch("toggle-display", {
|
||||
detail: { enabled: event.currentTarget.checked }
|
||||
})
|
||||
}
|
||||
|
||||
toggleRelations(event) {
|
||||
this.dispatch("toggle-relations", {
|
||||
detail: { enabled: event.currentTarget.checked }
|
||||
})
|
||||
}
|
||||
|
||||
toggleProgress(event) {
|
||||
this.dispatch("toggle-progress", {
|
||||
detail: { enabled: event.currentTarget.checked }
|
||||
})
|
||||
}
|
||||
|
||||
#dispatchInitialStates() {
|
||||
if (this.hasDisplayTarget) {
|
||||
this.dispatch("toggle-display", {
|
||||
detail: { enabled: this.displayTarget.checked }
|
||||
})
|
||||
}
|
||||
if (this.hasRelationsTarget) {
|
||||
this.dispatch("toggle-relations", {
|
||||
detail: { enabled: this.relationsTarget.checked }
|
||||
})
|
||||
}
|
||||
if (this.hasProgressTarget) {
|
||||
this.dispatch("toggle-progress", {
|
||||
detail: { enabled: this.progressTarget.checked }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#disableUnavailableColumns() {
|
||||
if (!Array.isArray(this.unavailableColumnsValue)) {
|
||||
return
|
||||
}
|
||||
this.unavailableColumnsValue.forEach((column) => {
|
||||
this.$("#available_c, #selected_c").children(`[value='${column}']`).prop("disabled", true)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user