Skip to content

Commit c3fb276

Browse files
authored
Gantt - fix strip lines disappearing (T1298090) (DevExpress#30400)
1 parent 8265c10 commit c3fb276

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

packages/devextreme/js/ui/gantt/ui.gantt.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class Gantt extends Widget {
188188
scaleTypeRange: this.option('scaleTypeRange'),
189189
editing: this.option('editing'),
190190
validation: this.option('validation'),
191-
stripLines: this.option('stripLines'),
191+
stripLines: this.option('stripLines')?.map(item => ({ ...item })),
192192
bars: this._bars,
193193
mainElement: this.$element(),
194194
onSelectionChanged: (e) => { this._ganttTreeList.selectRows(GanttHelper.getArrayFromOneElement(e.id)); },
@@ -653,9 +653,9 @@ class Gantt extends Widget {
653653
assignResourceToTask(resourceKey, taskKey) {
654654
this._ganttView._ganttViewCore.assignResourceToTask(resourceKey, taskKey);
655655
}
656-
// eslint-disable-next-line spellcheck/spell-checker
656+
657657
unassignResourceFromTask(resourceKey, taskKey) {
658-
// eslint-disable-next-line spellcheck/spell-checker
658+
659659
this._ganttView._ganttViewCore.unassignResourceFromTask(resourceKey, taskKey);
660660
}
661661
unassignAllResourcesFromTask(taskKey) {
@@ -738,6 +738,7 @@ class Gantt extends Widget {
738738
_getDefaultOptions() {
739739
return extend(super._getDefaultOptions(), GanttHelper.getDefaultOptions());
740740
}
741+
741742
_optionChanged(args) {
742743
switch(args.name) {
743744
case 'tasks':
@@ -846,11 +847,11 @@ class Gantt extends Widget {
846847
this._actionsManager?.createResourceAssignedAction();
847848
break;
848849
case 'onResourceUnassigning':
849-
// eslint-disable-next-line spellcheck/spell-checker
850+
850851
this._actionsManager?.createResourceUnassigningAction();
851852
break;
852853
case 'onResourceUnassigned':
853-
// eslint-disable-next-line spellcheck/spell-checker
854+
854855
this._actionsManager?.createResourceUnassignedAction();
855856
break;
856857
case 'onCustomCommand':
@@ -871,7 +872,7 @@ class Gantt extends Widget {
871872
this._setGanttViewOption('showRowLines', args.value);
872873
break;
873874
case 'stripLines':
874-
this._setGanttViewOption('stripLines', args.value);
875+
this._setGanttViewOption(args.fullName, args.value);
875876
break;
876877
case 'scaleType':
877878
this._setGanttViewOption('scaleType', args.value);

packages/devextreme/js/ui/gantt/ui.gantt.view.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { format } from '../../core/utils/string';
99
import coreLocalization from '../../common/core/localization/core';
1010
import { requestAnimationFrame, cancelAnimationFrame } from '../../common/core/animation/frame';
1111

12-
1312
const visualStateKey = 'visualState';
1413
const fullScreenModeKey = 'fullScreen';
1514

@@ -41,7 +40,7 @@ export class GanttView extends Widget {
4140
endDateRange: this.option('endDateRange'),
4241
editing: this._parseEditingSettings(this.option('editing')),
4342
validation: this.option('validation'),
44-
stripLines: { stripLines: this.option('stripLines') },
43+
stripLines: { stripLines: this.option('stripLines')?.map(item => ({ ...item })) },
4544
areHorizontalBordersEnabled: this.option('showRowLines'),
4645
areAlternateRowsEnabled: false,
4746
viewType: this._getViewTypeByScaleType(this.option('scaleType')),
@@ -256,7 +255,7 @@ export class GanttView extends Widget {
256255
this._ganttViewCore.setViewTypeRange(this._getViewTypeByScaleType(args.value.min), this._getViewTypeByScaleType(args.value.max));
257256
break;
258257
case 'stripLines':
259-
this._ganttViewCore.setStripLines({ stripLines: args.value });
258+
this._ganttViewCore.setStripLines({ stripLines: this.option('stripLines') });
260259
break;
261260
case 'taskTooltipContentTemplate':
262261
this._ganttViewCore.setTaskTooltipContentTemplate(args.value);

packages/devextreme/testing/tests/DevExpress.ui.widgets/ganttParts/stripLines.tests.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ QUnit.module('Strip Lines', moduleConfig, () => {
3838
assert.ok($timeIntervals.eq(0).hasClass(stripLines[2].cssClass), 'custom cssClass rendered');
3939
assert.equal($stripLines.eq(0).attr('title'), stripLines[0].title, 'title rendered');
4040
});
41+
4142
test('changing', function(assert) {
4243
this.createInstance(options.tasksOnlyOptions);
4344
this.clock.tick(10);
@@ -60,4 +61,33 @@ QUnit.module('Strip Lines', moduleConfig, () => {
6061
$stripLines = this.$element.find(Consts.TIME_MARKER_SELECTOR);
6162
assert.equal($stripLines.length, 0, 'gantt has no strip lines');
6263
});
64+
65+
test('partial changing', function(assert) {
66+
const stripLines = [
67+
{ start: data.tasks[0].start, title: 'First' },
68+
{ start: new Date(2019, 2, 1) },
69+
{ start: new Date(2019, 5, 5), end: () => data.tasks[data.tasks.length - 1].end, title: 'Interval', cssClass: 'end' }
70+
];
71+
const options = {
72+
tasks: { dataSource: data.tasks },
73+
stripLines: stripLines
74+
};
75+
this.createInstance(options);
76+
this.clock.tick(10);
77+
78+
let $timeMarkers = this.$element.find(Consts.TIME_MARKER_SELECTOR);
79+
assert.equal($timeMarkers.length, 2, 'gantt has time markesr');
80+
let $timeIntervals = this.$element.find(Consts.TIME_INTERVAL_SELECTOR);
81+
assert.equal($timeIntervals.length, 1, 'gantt has time intervals');
82+
83+
const firstTimeMarkerPosition = $timeMarkers[0].style.left;
84+
85+
this.instance.option('stripLines[0].start', new Date('2019-02-29'));
86+
$timeMarkers = this.$element.find(Consts.TIME_MARKER_SELECTOR);
87+
assert.equal($timeMarkers.length, 2, 'gantt has strip line');
88+
$timeIntervals = this.$element.find(Consts.TIME_INTERVAL_SELECTOR);
89+
assert.equal($timeIntervals.length, 1, 'gantt has time interval');
90+
91+
assert.notEqual($timeMarkers[0].style.left, firstTimeMarkerPosition, 'strip line position changed');
92+
});
6393
});

0 commit comments

Comments
 (0)