Files
63e28dc964 feat(tracker): Gantt chart for the issue tracker (#10992)
* feat(tracker): Gantt chart for the issue tracker

Builds on the merged search/filter rework (#10998). Introduces @hcengineering/gantt, a dependency-free scheduling/zoom/drag/viewport engine package (with a neutral GanttDependency contract), and wires the tracker-specific adapter, Svelte UI, model schema, dependency-shift notifications and sanity coverage in tracker-resources.

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

* fix(tracker): source Gantt holidays from HR and scope confirm-gate per view

Follow-up to review feedback on #10992:

- Confirm-gate: the module-global flag is replaced by a createConfirmGate()
  factory - one instance per mounted GanttView, so two Gantt views mounted at
  once in the same JS context no longer block each other's pointer input. A
  two-instance independence test guards the regression.

- Sidebar sorting: the stale deadline cast is dropped and issue.deadline is
  read directly (the field was added to the Issue model in this PR).

- HR holidays: the per-project WorkingDaysConfig.holidays field duplicated the
  workspace-wide hr.class.PublicHoliday concept and could drift from the real
  HR calendar. It is removed. WorkingDaysConfig now carries only the weekday
  mask and an optional holidayDepartment. The tracker adapter resolves holidays
  for the selected department plus all ancestors up to hr.ids.Head, matching
  HR's existing inheritance semantics (hr-resources ScheduleView). A missing or
  invalid reference falls back to company-wide (root) holidays; unrelated
  departments are never included. The ancestor walk is cycle/missing-parent
  safe.

  A small WorkingDaysEditor in the existing project create/edit dialog lets
  users with the existing project permission enable the mode, choose weekdays,
  and select an HR department (default: Company-wide). It persists through the
  existing project create/update transaction paths (createDoc on create,
  client.update on edit) and uses $unset when the mode is disabled. At least
  one working day must stay active.

  Calendar loading is explicit via a CalendarStateMachine: project-scoped drag,
  resize, cascade, keyboard-shift and auto-schedule mutations stay disabled
  until both the project config and the holiday data have loaded. A monotonic
  generation ticket (bumped synchronously on project switch) is re-checked
  immediately before every calendar-dependent date commit, so work started in
  one project can never persist after a switch to another. The all-projects
  view has no single project calendar, so calendar-dependent edits are
  read-only there; display, selection, the context menu and the manual
  date-picker (which does no calendar arithmetic and takes no mutation ticket)
  stay available.

  This depends on the lightweight @hcengineering/hr model package, but not on
  hr-resources; the tracker adapter uses hr.class.* and hr.ids.Head at runtime,
  and actual HR model presence is checked through the hierarchy - without the
  HR model, holidays resolve to an empty set. The @hcengineering/gantt engine
  package stays domain-neutral (no @hcengineering imports, no runtime deps).

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

* fix(gantt): measure FS gap-preservation floor in working days

The finish-to-start gap-preservation floor in the cascade scheduler mixed
two time measures: the FS snap anchor is working-calendar aware, but the
floor added a raw calendar-millisecond start-side delta. With an active
working calendar the two diverge, so dragging a predecessor over a weekend
over-shifted the successor across non-working days (a Fri->Mon body drag is
3 calendar days but only 1 working day, and could even land a successor on
a Saturday).

Measure the floor on the DUE side in working days instead: translate the
predecessor's shift via the new workingDayDelta helper and advance the
floor base with addWorkingDays over the calendar. A day-granular resize
gate (utcMidnight comparison, not a raw === 0 test) arms the floor only on
a start-DAY move, so a pure due-resize stays a pure snap even when the
stored issue carries a time-of-day on the cascade-commit path. The floor
base is normalized via utcMidnight(targetAnchor). The legacy path
(cfg === undefined) stays byte-identical to today's raw-ms floor. A
left-resize in working-days mode now correctly no-ops the floor (the due,
and thus the FS gap, did not move) instead of shifting on the raw start
delta.

Engine: add workingDayDelta (signed, half-open from-exclusive/to-inclusive
working-day step count) and export the previously-private utcMidnight from
packages/gantt/src/working-days.ts. The engine stays domain-neutral (no
@hcengineering imports, empty dependencies).

Adds engine and adapter test coverage: workingDayDelta cases and the full
FS floor matrix (right-resize no-push, weekend-spanner body drag, floor
wins over snap, holiday in the floor path, floor-dominant multi-hop chain,
negative delta, legacy no-cfg, SS pure-snap, raw time-of-day right-resize,
direct left-resize).

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>

---------

Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Co-authored-by: Michael Uray <michaeluray@users.noreply.github.com>
2026-08-27 20:24:38 +07:00

702 lines
16 KiB
SCSS

//
// Copyright © 2021 Anticrm Platform Contributors.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
/* Popups */
.hulyPopup-container {
display: flex;
flex-direction: column;
max-height: 22.625rem;
background: var(--theme-popup-color); // var(--global-popover-BackgroundColor);
border: 1px solid var(--theme-popup-divider); // var(--global-popover-BorderColor);
border-radius: var(--small-BorderRadius);
box-shadow:
var(--global-popover-ShadowX)
var(--global-popover-ShadowY)
var(--global-popover-ShadowBlur)
var(--global-popover-ShadowSpread)
var(--global-popover-ShadowColor);
&:not(.noPadding) { padding: 1px; }
&:not(.autoWidth) {
min-width: 16.5rem;
max-width: 16.5rem;
}
.hulyPopup-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
align-self: stretch;
gap: var(--spacing-1);
padding: var(--spacing-1_5);
min-width: 0;
min-height: 0;
text-align: left;
border-radius: var(--extra-small-BorderRadius);
border: none;
&.withKeys {
align-items: center;
padding: 0 var(--spacing-1_5);
min-height: var(--global-medium-Size);
}
&__icon {
flex-shrink: 0;
width: var(--global-min-Size);
height: var(--global-min-Size);
color: var(--global-primary-TextColor);
}
&__labels-wrapper {
display: flex;
flex-direction: column;
flex-grow: 1;
gap: var(--spacing-0_25);
min-width: 0;
min-height: 0;
}
&__label {
flex-grow: 1;
font-weight: 400;
line-height: 1rem;
&:not(.small) { font-size: .875rem; }
&.small { font-size: .75rem; }
&:not(.dark) {
color: var(--global-primary-TextColor); // var(--global-on-accent-TextColor);
}
&.dark {
color: var(--theme-dark-color); // var(--global-secondary-TextColor);
}
}
&__keys,
&__keys .key {
display: flex;
justify-content: center;
align-items: center;
}
&__keys {
gap: var(--spacing-0_25);
margin-left: var(--spacing-1);
.key {
padding: var(--spacing-0_5);
min-width: var(--global-extra-small-Size);
font-size: 0.75rem;
color: var(--global-primary-TextColor);
background-color: var(--theme-tooltip-key-bg);
border: 1px solid var(--theme-button-border);
border-radius: var(--extra-small-BorderRadius);
}
}
&:not(.disabled, :disabled, .noHover):hover {
background-color: var(--theme-popup-hover); // var(--global-popover-hover-BackgroundColor);
cursor: pointer;
}
&.disabled,
&:disabled {
cursor: default;
.hulyPopup-row__label { opacity: .5; }
}
&.noHover {
cursor: default;
}
}
.hulyPopup-group {
display: flex;
flex-direction: column;
flex-shrink: 0;
padding: var(--spacing-0_5);
}
.hulyPopup-divider {
flex-shrink: 0;
width: 100%;
height: 1px;
background-color: var(--theme-popup-divider);
}
}
// ----- //
.selectPopup {
overflow: hidden;
display: flex;
flex-direction: column;
width: fit-content;
min-width: 12.5rem;
max-width: 17rem;
max-height: 22rem;
&:focus {
outline: 0;
}
&:not(.embedded) {
background: var(--theme-popup-color);
border: 1px solid var(--theme-popup-divider);
border-radius: .5rem;
box-shadow: var(--theme-popup-shadow);
}
&.noShadow,
&.embedded {
background: none;
border: none;
box-shadow: none;
}
&.auto {
max-width: unset;
}
&.full-width {
flex-grow: 1;
background: none;
border-radius: 0;
box-shadow: none;
width: 100%;
max-width: 100%;
}
&.width-resizable {
width: 48rem;
max-width: min(96vw, 80rem);
min-width: 28rem;
height: 36rem;
max-height: min(96vh, 60rem);
min-height: 16rem;
resize: both;
overflow: hidden;
}
&.maxHeight { height: 22rem; }
&.autoHeight {
max-height: calc(100vh - 2rem);
height: auto;
}
&.width-40 {
max-width: 40rem !important;
width: 40rem !important;
}
&.max-width-40 {
max-width: 40rem !important;
}
.header {
flex-shrink: 0;
padding: .5rem;
&:not(.no-border) {
margin-bottom: .5rem;
border-bottom: 1px solid var(--theme-popup-divider);
}
.clear-btn {
display: flex;
justify-content: center;
align-items: center;
width: .75rem;
height: .75rem;
border-radius: 50%;
.icon {
width: .625rem;
height: .625rem;
}
&.show {
color: var(--theme-content-color);
background-color: var(--theme-button-default);
cursor: pointer;
&:hover {
color: var(--theme-caption-color);
background-color: var(--theme-button-hovered);
}
}
}
}
.header + .header { padding: 0 1rem .5rem; }
.scroll {
flex-grow: 1;
min-height: 0;
height: max-content;
overflow-x: hidden;
overflow-y: auto;
&::-webkit-scrollbar { width: 0; }
.box {
display: flex;
flex-direction: column;
height: 100%;
}
}
.menu-item {
flex-shrink: 0;
justify-content: flex-start;
padding: .25rem .5rem;
// width: 100%;
min-width: 0;
min-height: 2.25rem;
text-align: left;
color: var(--theme-caption-color);
border-radius: .25rem;
&:not(.default-cursor) { cursor: pointer; }
&.high { height: 3rem; }
.icon, .color, .tag {
flex-shrink: 0;
margin-right: .5rem;
}
.icon,
div.check {
width: 1rem;
height: 1rem;
color: var(--theme-dark-color);
}
div.check {
flex-shrink: 0;
&:not(.ml-0) { margin-left: .5rem; }
}
.color {
width: .875rem;
height: .875rem;
border: 1px solid rgba(0, 0, 0, .1);
border-radius: .25rem;
}
.tag {
width: .5rem;
height: .5rem;
border-radius: 50%;
}
.label {
flex-grow: 1;
min-width: 0;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
color: var(--theme-caption-color);
}
.tool {
visibility: hidden;
flex-shrink: 0;
}
&:not(.withList) {
margin: 0 .5rem;
}
&:not(.withList, .no-focus):focus,
&:not(.withList, .no-hover):hover {
background-color: var(--theme-popup-hover);
.tool { visibility: visible; }
}
}
.sticky-wrapper {
display: flex;
flex-direction: column;
// &:not(:first-child) { margin-top: 1px; }
}
.menu-group {
overflow: hidden;
display: flex;
flex-direction: column;
height: 0;
transition: height .5s ease;
&__header {
position: sticky;
top: 0;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: .25rem 1rem;
font-weight: 500;
font-size: .625rem;
text-transform: uppercase;
text-align: left;
color: var(--theme-caption-color);
background-color: var(--theme-popup-color);
&:not(.default-cursor) { cursor: pointer; }
.icon {
width: .25rem;
transform-origin: 40% 50%;
transform: rotate(0deg);
transition: transform .15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chevron {
width: 1rem;
height: 1rem;
color: var(--theme-trans-color);
transform-origin: center;
transform: rotate(-90deg);
transition: transform .2s ease;
}
&.show {
.icon { transform: rotate(90deg); }
.chevron { transform: rotate(0deg); }
}
&:hover { color: var(--theme-caption-color); }
&.show + .menu-group { height: auto; }
}
}
.menu-space {
flex-shrink: 0;
height: .5rem;
}
.menu-separator {
flex-shrink: 0;
margin: .5rem 0;
height: 1px;
background-color: var(--theme-popup-divider);
}
}
.antiPopup {
display: flex;
flex-direction: column;
width: auto;
min-height: 0;
min-width: 0;
user-select: none;
-webkit-user-select: none;
&:not(.embedded) {
max-width: 30rem;
background: var(--theme-popup-color);
border-radius: .5rem;
border: 1px solid var(--theme-popup-divider);
box-shadow: var(--theme-popup-shadow);
}
&.isDock {
border-radius: 0;
height: 100%;
}
.ap-space {
flex-shrink: 0;
height: .25rem;
&.x1-5 { height: .375rem; }
&.x2 { height: .5rem; }
&.x3 { height: .75rem; }
}
.ap-scroll {
flex-grow: 1;
margin: 0;
min-width: 0;
min-height: 0;
overflow-x: hidden;
overflow-y: auto;
scrollbar-width: thin;
&::-webkit-scrollbar-track { margin: 0; }
&::-webkit-scrollbar-thumb {
background-color: var(--scrollbar-bar-color);
&:hover { background-color: var(--scrollbar-bar-hover); }
}
}
.ap-box {
display: flex;
flex-direction: column;
padding: 0;
height: 100%;
min-width: 0;
min-height: 0;
}
.ap-menuItem {
flex-shrink: 0;
justify-content: flex-start;
text-align: left;
min-width: 0;
color: var(--theme-caption-color);
cursor: pointer;
&:not(.separator) {
min-height: 2.25rem;
border-radius: .25rem;
}
&:not(.separator, .noMargin) {
margin-left: .5rem;
margin-right: .5rem;
}
&.withComp {
display: flex;
align-items: center;
flex-wrap: nowrap;
padding: .25rem .5rem .25rem 0;
min-width: 0;
min-height: 0;
}
&.selected,
&.hoverable:hover { background: var(--theme-popup-hover); }
&.empty {
display: flex;
justify-content: center;
font-style: italic;
color: var(--theme-dark-color);
cursor: default;
&:hover {
color: var(--theme-content-color);
background-color: transparent;
}
}
&.withCheck { justify-content: space-between; }
&.withIcon {
.icon { color: var(--theme-dark-color); }
&.hover .icon { color: var(--theme-dark-color); }
}
&.withDrag {
width: calc(100% - 1rem);
padding: .5rem .5rem .5rem .125rem;
.drag {
flex-shrink: 0;
margin-right: .375rem;
color: var(--theme-trans-color);
}
.icon {
flex-shrink: 0;
margin-right: .5rem;
}
.logo {
overflow: hidden;
flex-shrink: 0;
margin-right: .5rem;
width: 2rem;
height: 2rem;
border-radius: .25rem;
&.empty { background-color: var(--theme-button-pressed); }
}
.label { font-weight: 500; }
.description {
font-size: 0.6875rem;
color: var(--theme-halfcontent-color);
}
}
// &:hover { background-color: var(--popup-bg-hover); }
&.hover {
background-color: var(--theme-popup-hover);
outline: none;
// box-shadow: inset 0 0 1px 1px var(--primary-edit-border-color);
}
&.redlight {
color: var(--highlight-red);
&:hover { color: var(--highlight-red-hover); }
&:active { color: var(--highlight-red-press); }
&:focus { color: var(--highlight-red-press); }
}
&.separator {
flex-shrink: 0;
height: 1px;
background-color: var(--theme-popup-divider);
&:not(.halfMargin) { margin: .5rem 0; }
&.halfMargin { margin: .25rem 0; }
}
}
&:not(.thinStyle) .ap-menuItem:not(.separator, .withComp) { padding: .625rem .5rem; }
&.thinStyle {
border-radius: .75rem;
.ap-menuItem:not(.separator) {
padding: 0 .5rem;
min-height: 2rem;
font-size: .8125rem;
border-radius: .375rem;
}
.ap-menuItem:not(.separator, .noMargin) {
margin-left: .375rem;
margin-right: .375rem;
}
}
.ap-check {
flex-shrink: 0;
margin-left: 1rem;
width: 1rem;
height: 1rem;
color: var(--theme-popup-checkicon);
}
.ap-subheader {
flex-shrink: 0;
padding: .5rem 1rem;
min-width: 0;
min-height: 2rem;
text-transform: uppercase;
font-weight: 500;
font-size: .625rem;
color: var(--theme-dark-color);
&:not(.caption) { letter-spacing: 1px; }
&.caption {
padding-top: 1rem;
color: var(--theme-caption-color);
}
}
.ap-menuHeader {
display: flex;
flex-direction: column;
&:not(.noBorder) { border-bottom: 1px solid var(--theme-popup-divider); }
.tabs {
display: flex;
align-items: center;
padding: 0 .375rem;
min-width: 0;
.tab {
position: relative;
display: flex;
justify-content: center;
align-items: center;
min-width: 2.25rem;
min-height: 2.75rem;
color: var(--theme-dark-color);
outline: none;
&:not(:last-child) { margin-right: .375rem; }
&:not(.selected, .disabled) { cursor: pointer; }
&.disabled { color: var(--theme-darker-color); }
&.selected { color: var(--theme-caption-color); }
}
&:not(.bordered) .tab.selected::after {
position: absolute;
content: '';
left: 0;
bottom: -1px;
width: 100%;
height: 2px;
background-color: var(--theme-link-color);
}
&.bordered .tab {
min-height: 2.25rem;
border: 1px solid transparent;
border-radius: .375rem;
&.selected { border-color: var(--theme-button-border); }
}
}
}
&-withHeader {
.ap-header {
flex-shrink: 0;
display: flex;
flex-direction: column;
margin: 0 .5rem;
text-align: left;
.ap-caption {
margin: .5rem 0 0 .75rem;
font-size: .75rem;
font-weight: 600;
text-transform: uppercase;
color: var(--theme-dark-color);
}
}
}
}
// Submenu
.antiPopup-submenu {
display: flex;
align-items: center;
flex-shrink: 0;
justify-content: flex-start;
margin: 0 .5rem;
padding: .25rem .5rem;
min-width: 0;
min-height: 2.25rem;
text-align: left;
color: var(--theme-caption-color);
border-radius: .25rem;
outline: none;
cursor: pointer;
.icon {
margin-right: .5rem;
color: var(--theme-dark-color);
}
&.withHover:hover { background-color: var(--theme-popup-hover); }
}
.antiPopup .ap-menuItem.arrow,
.selectPopup .menu-item.arrow,
.antiPopup-submenu {
position: relative;
span {
padding-right: 1rem;
}
&::after {
content: '▶';
position: absolute;
top: 50%;
right: 0.5rem;
font-size: 0.375rem;
color: var(--theme-dark-color);
transform: translateY(-50%);
}
}
.notifyPopup, .helpAndSupportPopup {
overflow: hidden;
display: flex;
flex-direction: column;
padding: .5rem;
min-height: 22rem;
background: var(--theme-popup-color);
border-radius: .5rem;
box-shadow: var(--theme-popup-shadow);
&:not(.min-w-168) { min-width: 22rem; }
.header {
display: flex;
align-items: center;
flex-shrink: 0;
padding: 0 .75rem .5rem 1rem;
height: 3rem;
min-height: 0;
}
.space {
flex-shrink: 0;
height: .25rem;
&.x2 { height: .5rem; }
&.x3 { height: .75rem; }
}
}
.notifyPopup .comment::after,
.notifyPopup .mention::after { content: none !important; }
.notifyPopup .content .mention { margin-top: 0 !important; }
.helpAndSupportPopup {
height: 100%;
min-height: 100%;
min-width: 20rem;
}
// Remove highlights table rows and hide dots in popups
.popup .tr-body:hover, .popup-tooltip .tr-body:hover { background-color: transparent !important; }
.popup-tooltip .tr-body .menuRow { visibility: hidden !important; }