Feature #43678 » 0003-Update-Gantt-collapse-expand-handler-to-use-CSS-logi.patch
| app/javascript/controllers/gantt/subjects_controller.js | ||
|---|---|---|
|
handleEntryClick(event) {
|
||
|
const iconExpander = event.currentTarget
|
||
|
const $subject = this.$(iconExpander.parentElement)
|
||
|
const subjectLeft =
|
||
|
parseInt($subject.css("left"), 10) + parseInt(iconExpander.offsetWidth, 10)
|
||
|
const subjectInlineStart =
|
||
|
this.#readInlineStart($subject) + parseInt(iconExpander.offsetWidth, 10)
|
||
|
let targetShown = null
|
||
|
let targetTop = 0
|
||
| ... | ... | |
|
const barsSelector = `#gantt_area form > div[data-collapse-expand='${json.obj_id}'][data-number-of-rows='${numberOfRows}']`
|
||
|
const selectedColumnsSelector = `td.gantt_selected_column div[data-collapse-expand='${json.obj_id}'][data-number-of-rows='${numberOfRows}']`
|
||
|
if (outOfHierarchy || parseInt($element.css("left"), 10) <= subjectLeft) {
|
||
|
if (outOfHierarchy || this.#readInlineStart($element) <= subjectInlineStart) {
|
||
|
outOfHierarchy = true
|
||
|
if (targetShown === null) return false
|
||
|
const newTopVal = parseInt($element.css("top"), 10) + totalHeight * (targetShown ? -1 : 1)
|
||
|
const newTopVal = this.#readBlockStart($element) + totalHeight * (targetShown ? -1 : 1)
|
||
|
$element.css("top", newTopVal)
|
||
|
this.#setBlockStart($element, newTopVal)
|
||
|
this.$([barsSelector, selectedColumnsSelector].join()).each((__, el) => {
|
||
|
this.$(el).css("top", newTopVal)
|
||
|
this.#setBlockStart(this.$(el), newTopVal)
|
||
|
})
|
||
|
return true
|
||
| ... | ... | |
|
if (targetShown === null) {
|
||
|
targetShown = isShown
|
||
|
targetTop = parseInt($element.css("top"), 10)
|
||
|
targetTop = this.#readBlockStart($element)
|
||
|
totalHeight = 0
|
||
|
}
|
||
| ... | ... | |
|
const $task = this.$(task)
|
||
|
if (!isShown && willOpen) {
|
||
|
$task.css("top", targetTop + totalHeight)
|
||
|
this.#setBlockStart($task, targetTop + totalHeight)
|
||
|
}
|
||
|
if (!$task.hasClass("tooltip")) {
|
||
|
$task.toggle(willOpen)
|
||
| ... | ... | |
|
const $attr = this.$(attr)
|
||
|
if (!isShown && willOpen) {
|
||
|
$attr.css("top", targetTop + totalHeight)
|
||
|
this.#setBlockStart($attr, targetTop + totalHeight)
|
||
|
}
|
||
|
$attr.toggle(willOpen)
|
||
|
})
|
||
|
if (!isShown && willOpen) {
|
||
|
$element.css("top", targetTop + totalHeight)
|
||
|
this.#setBlockStart($element, targetTop + totalHeight)
|
||
|
}
|
||
|
this.#setIconState($element, willOpen)
|
||
| ... | ... | |
|
this.dispatch("toggle-tree", { bubbles: true })
|
||
|
}
|
||
|
#getComputedPx(el, property) {
|
||
|
const node = el.jquery ? el[0] : el
|
||
|
const styles = window.getComputedStyle(node)
|
||
|
const val = styles.getPropertyValue(property)
|
||
|
if (val) {
|
||
|
const num = parseFloat(val)
|
||
|
if (!Number.isNaN(num)) return num
|
||
|
}
|
||
|
return NaN
|
||
|
}
|
||
|
#readInlineStart(el) {
|
||
|
return this.#getComputedPx(el, "inset-inline-start")
|
||
|
}
|
||
|
#readBlockStart(el) {
|
||
|
return this.#getComputedPx(el, "inset-block-start")
|
||
|
}
|
||
|
#setBlockStart(el, value) {
|
||
|
const node = el.jquery ? el[0] : el
|
||
|
const px = typeof value === "number" ? `${value}px` : value
|
||
|
node.style.setProperty("inset-block-start", px)
|
||
|
}
|
||
|
#setIconState(element, open) {
|
||
|
const $element = element.jquery ? element : this.$(element)
|
||
|
const expander = $element.find(".expander")
|
||
| lib/redmine/helpers/gantt.rb | ||
|---|---|---|
|
end
|
||
|
if has_children
|
||
|
content = view.content_tag(:span,
|
||
|
view.sprite_icon('angle-down').html_safe,
|
||
|
view.sprite_icon('angle-down', rtl: true).html_safe,
|
||
|
:class => 'icon icon-expanded expander',
|
||
|
:data => {:action => 'click->gantt--subjects#handleEntryClick'}) + content
|
||
|
tag_options[:class] += ' open'
|
||