Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler: Fix the default resource text being rendered in the agenda view when resourceCellTemplate is defined (T1181733) #25414

Merged
merged 7 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions js/ui/scheduler/workspaces/ui.scheduler.agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,8 @@ class SchedulerAgenda extends WorkSpace {
groupTableClass: GROUP_TABLE_CLASS,
groupRowClass: GROUP_ROW_CLASS,
groupCellClass: this._getGroupHeaderClass(),
groupCellCustomContent(cell, cellText, index, data) {
groupCellCustomContent(cell, cellTextElement, index, data) {
const container = domAdapter.createElement('div');
const contentWrapper = domAdapter.createElement('div');

container.className = getGroupHeaderContentClass;
contentWrapper.appendChild(cellText);
container.appendChild(contentWrapper);
container.className = getGroupHeaderContentClass;

if(cellTemplate && cellTemplate.render) {
Expand All @@ -273,14 +268,15 @@ class SchedulerAgenda extends WorkSpace {
data: data.data,
id: data.value,
color: data.color,
text: cellText.textContent
text: cellTextElement.textContent
},
container: getPublicElement($(container)),
index: index
}));

} else {
contentWrapper.appendChild(cellText);
const contentWrapper = domAdapter.createElement('div');
contentWrapper.appendChild(cellTextElement);
container.appendChild(contentWrapper);
}

Expand Down
16 changes: 16 additions & 0 deletions testing/testcafe/model/scheduler/groupRow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const CLASS = {
groupRow: 'dx-scheduler-group-row',
groupCell: 'dx-scheduler-group-header-content',
};

export class GroupRow {
readonly element: Selector;

readonly groupCells: Selector;

constructor(scheduler: Selector) {
this.element = scheduler.find(`.${CLASS.groupRow}`);

this.groupCells = this.element.find(`.${CLASS.groupCell}`);
}
}
8 changes: 8 additions & 0 deletions testing/testcafe/model/scheduler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Toolbar from './toolbar';
import Collectors from './collectors';
import ReducedIconTooltip from './appointment/tooltip/reducedIconTooltip';
import { WidgetName } from '../../helpers/createWidget';
import { GroupRow } from './groupRow';
import { HeaderPanel } from './headerPanel';

export const CLASS = {
Expand Down Expand Up @@ -60,6 +61,8 @@ export default class Scheduler extends Widget {

readonly headerPanel: HeaderPanel;

readonly groupRow: GroupRow;

readonly headerSpaceScroll: { left: Promise<number>; top: Promise<number> };

readonly workspaceScrollable: Selector;
Expand Down Expand Up @@ -98,6 +101,7 @@ export default class Scheduler extends Widget {
this.headerPanel = new HeaderPanel(this.element);
this.toolbar = new Toolbar(this.element);
this.collectors = new Collectors(this.element);
this.groupRow = new GroupRow(this.element);

this.headerSpaceScroll = {
left: headerSpaceScroll.scrollLeft,
Expand Down Expand Up @@ -137,6 +141,10 @@ export default class Scheduler extends Widget {
return this.allDayTableCells.nth(cellIndex);
}

getGroupCell(cellIndex = 0): Selector {
return this.groupRow.groupCells.nth(cellIndex);
}

getFocusedCell(isAllDay = false): Selector {
const cells = isAllDay ? this.allDayTableCells : this.dateTableCells;

Expand Down
39 changes: 39 additions & 0 deletions testing/testcafe/tests/scheduler/grouping/resourceCellTemplate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import createWidget from '../../../helpers/createWidget';
import url from '../../../helpers/getPageUrl';
import Scheduler from '../../../model/scheduler';

fixture.disablePageReloads`ResourceCellTemplate`
.page(url(__dirname, '../../container.html'));

test('resourceCellTemplate layout should be rendered right in the agenda view', async (t) => {
const scheduler = new Scheduler('#container');
const groupHeader = scheduler.getGroupCell();

await t.expect(groupHeader.textContent).eql('Custom resource text');
}).before(async () => {
const currentDate = new Date(2017, 4, 25);
await createWidget('dxScheduler', {
dataSource: [{
text: 'appointment',
startDate: currentDate,
endDate: currentDate,
resource: 1,
}],
views: ['agenda'],
currentView: 'agenda',
currentDate,
resourceCellTemplate() {
return 'Custom resource text';
},
groups: ['resource'],
resources: [{
fieldExpr: 'resource',
dataSource: [{
text: 'Resource text',
id: 1,
}],
label: 'Resource',
}],
height: 600,
});
});