feat(ui): show the calendar directly under the plan summary (#354)
Move the time-window, if-then and declared time-off period blocks into one closed "applied rules detail" disclosure next to the placement explanation, so the legend and the first row of months sit under the summary figures. Put the status and the calculation date on the heading line. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
7ebc87be33
commit
6660e7e6bb
9 files changed
+247
-80
No files matched your search
@@ -2610,6 +2610,94 @@ describe('CalendarYear planning outcome boundary', () => {
|
||||
expect(meta.previousElementSibling.classList).toContain('planning-status');
|
||||
});
|
||||
|
||||
it.each([true, false])(
|
||||
'groups the applied rules in one closed disclosure between the summary and the calendar (rules: %s)',
|
||||
async (withRules) => {
|
||||
const applied: PlanOutcome = {
|
||||
...plan,
|
||||
timeWindowContributions: [
|
||||
{
|
||||
ruleId: 'window',
|
||||
label: 'Window rule',
|
||||
requested: 2,
|
||||
declaredDays: [{ date: '2024-05-02', type: 'cp' }],
|
||||
placementDates: ['2024-05-03'],
|
||||
},
|
||||
],
|
||||
ifThenContributions: [
|
||||
{
|
||||
ruleId: 'bridge',
|
||||
label: 'Bridge rule',
|
||||
occurrence: '2024-05-08',
|
||||
requested: 1,
|
||||
declaredDays: [],
|
||||
placementDates: ['2024-05-06'],
|
||||
},
|
||||
],
|
||||
timeOffPeriods: [
|
||||
{
|
||||
start: '2024-05-02',
|
||||
end: '2024-05-05',
|
||||
duration: 4,
|
||||
placementDates: ['2024-05-03'],
|
||||
declaredDates: ['2024-05-02'],
|
||||
nonWorkingDates: ['2024-05-04', '2024-05-05'],
|
||||
nonWorkingDayGain: 2,
|
||||
},
|
||||
],
|
||||
};
|
||||
const { calendar, creation } = calendarFor(withRules ? applied : plan, explanation);
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CalendarYear],
|
||||
providers: [
|
||||
provideZonelessChangeDetection(),
|
||||
{ provide: CalendarService, useValue: calendar },
|
||||
],
|
||||
}).compileComponents();
|
||||
spyOnCreation().mockImplementation(creation);
|
||||
const translation = TestBed.inject(TranslationService);
|
||||
translation.setLanguage('en');
|
||||
const fixture = TestBed.createComponent(CalendarYear);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
fixture.detectChanges();
|
||||
const root: HTMLElement = fixture.nativeElement;
|
||||
const details = root.querySelector<HTMLDetailsElement>(
|
||||
'.plan-insights > .applied-rules',
|
||||
);
|
||||
if (!withRules) {
|
||||
expect(details).toBeNull();
|
||||
expect(root.querySelector('.declared-rule, .declared-period')).toBeNull();
|
||||
return;
|
||||
}
|
||||
expect(details!.open).toBe(false);
|
||||
const summary = details!.querySelector<HTMLElement>('summary')!;
|
||||
expect(summary.textContent?.replace(/\s+/g, ' ')).toContain('Applied rules detail');
|
||||
expect(summary.textContent?.replace(/\s+/g, ' ')).toContain('Entries : 3');
|
||||
expect(root.querySelectorAll('.declared-rule, .declared-period')).toHaveLength(3);
|
||||
expect(
|
||||
root.querySelectorAll(
|
||||
'.applied-rules .declared-rule, .applied-rules .declared-period',
|
||||
),
|
||||
).toHaveLength(3);
|
||||
const follows = (earlier: Element, later: Element) =>
|
||||
Boolean(earlier.compareDocumentPosition(later) & Node.DOCUMENT_POSITION_FOLLOWING);
|
||||
expect(follows(root.querySelector('.plan-summary')!, details!)).toBe(true);
|
||||
expect(follows(root.querySelector('.plan-details')!, details!)).toBe(true);
|
||||
expect(follows(details!, root.querySelector('.calendar-legend')!)).toBe(true);
|
||||
expect(follows(details!, root.querySelector('.month-grid')!)).toBe(true);
|
||||
for (const [language, copy] of Object.entries(translationsMap)) {
|
||||
translation.setLanguage(language);
|
||||
fixture.detectChanges();
|
||||
expect(summary.textContent).toContain(copy.planning.appliedRules.title);
|
||||
expect(summary.textContent).toContain(copy.planning.appliedRules.entries);
|
||||
}
|
||||
activateWithKeyboard(summary);
|
||||
expect(details!.open).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
it('shows muted, disabled context dates in an adjacent year', async () => {
|
||||
if (explanation.kind !== 'PlanExplanation') throw new Error('Expected plan explanation');
|
||||
const boundaryPlan: PlanOutcome = {
|
||||
@@ -3255,6 +3343,9 @@ describe('CalendarYear planning outcome boundary', () => {
|
||||
await fixture.whenStable();
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
fixture.detectChanges();
|
||||
expect(
|
||||
fixture.nativeElement.querySelector('.conflict-explanation').closest('details'),
|
||||
).toBeNull();
|
||||
expect(fixture.nativeElement.querySelector('.conflict-explanation').textContent).toContain(
|
||||
'Required spring leave',
|
||||
);
|
||||
|
||||
@@ -158,84 +158,6 @@
|
||||
<dd>{{ plan.metrics.longestWorkSequence }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
@for (contribution of plan.timeWindowContributions ?? []; track contribution.ruleId) {
|
||||
<section class="outcome-explanation declared-rule">
|
||||
<h3>{{ contribution.label }}</h3>
|
||||
<p>
|
||||
{{ contribution.declaredDays.length }} {{ tr().bookedDays.booked }} +
|
||||
{{ contribution.placementDates.length }}
|
||||
{{ tr().planning.explanation.leaveDays }} =
|
||||
<strong
|
||||
>{{
|
||||
contribution.declaredDays.length + contribution.placementDates.length
|
||||
}}
|
||||
/ {{ contribution.requested }}</strong
|
||||
>
|
||||
</p>
|
||||
<p>
|
||||
@for (day of contribution.declaredDays; track day.date) {
|
||||
<span>{{ displayDate(day.date) }} · {{ tr().dayTypes[day.type] }} </span>
|
||||
}
|
||||
</p>
|
||||
<p>{{ tr().bookedDays.fixed }}</p>
|
||||
</section>
|
||||
}
|
||||
@for (
|
||||
contribution of plan.ifThenContributions ?? [];
|
||||
track contribution.ruleId + contribution.occurrence
|
||||
) {
|
||||
<section class="outcome-explanation declared-rule">
|
||||
<h3>{{ contribution.label }} · {{ displayDate(contribution.occurrence) }}</h3>
|
||||
<p>
|
||||
{{ contribution.declaredDays.length }} {{ tr().bookedDays.booked }} +
|
||||
{{ contribution.placementDates.length }}
|
||||
{{ tr().planning.explanation.leaveDays }} =
|
||||
<strong>{{ contribution.requested }} / {{ contribution.requested }}</strong>
|
||||
</p>
|
||||
@for (day of contribution.declaredDays; track day.date) {
|
||||
<span>{{ displayDate(day.date) }} · {{ tr().dayTypes[day.type] }} </span>
|
||||
}
|
||||
@if (contribution.declaredDays.length) {
|
||||
<p>{{ tr().bookedDays.fixed }}</p>
|
||||
}
|
||||
@if (contribution.earnedEntitlement; as earned) {
|
||||
<p>
|
||||
{{
|
||||
earned.added
|
||||
? tr().planning.futureEntitlement
|
||||
: tr().planning.includedEntitlement
|
||||
}}
|
||||
: {{ earned.quantity }} {{ tr().dayTypes[earned.type] }}
|
||||
</p>
|
||||
<p>
|
||||
{{ tr().planning.details.available }}
|
||||
{{ displayDate(earned.availableFrom) }} ·
|
||||
{{ tr().planning.details.expires }} {{ displayDate(earned.expiryDate) }}
|
||||
</p>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
@for (period of plan.timeOffPeriods; track period.start) {
|
||||
@if (period.declaredDates?.length) {
|
||||
<section class="outcome-explanation declared-period">
|
||||
<h3>
|
||||
{{ tr().planning.explanation.breakTitle }} ·
|
||||
{{ displayDate(period.start) }} – {{ displayDate(period.end) }}
|
||||
</h3>
|
||||
<p>
|
||||
{{ period.declaredDates!.length }} {{ tr().bookedDays.booked }} +
|
||||
{{ period.placementDates.length }}
|
||||
{{ tr().planning.explanation.leaveDays }} +
|
||||
{{ period.nonWorkingDates.length }}
|
||||
{{ tr().planning.explanation.freeDays }} =
|
||||
<strong
|
||||
>{{ period.duration }} {{ tr().planning.explanation.daysOff }}</strong
|
||||
>
|
||||
</p>
|
||||
<p>{{ tr().bookedDays.fixed }}</p>
|
||||
</section>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<div class="plan-insights">
|
||||
@@ -518,6 +440,122 @@
|
||||
{{ tr().planning.explanationError }} {{ reasonLabel(explanationError()!) }}
|
||||
</p>
|
||||
}
|
||||
@if (displayedPlan(); as plan) {
|
||||
@if (appliedRuleCount(); as count) {
|
||||
<details class="applied-rules">
|
||||
<summary>
|
||||
<mat-icon aria-hidden="true">rule</mat-icon>
|
||||
<span
|
||||
>{{ tr().planning.appliedRules.title
|
||||
}}<small
|
||||
>{{ tr().planning.appliedRules.entries }} : {{ count }}</small
|
||||
></span
|
||||
>
|
||||
<mat-icon class="disclosure-chevron" aria-hidden="true"
|
||||
>expand_more</mat-icon
|
||||
>
|
||||
</summary>
|
||||
<div class="applied-rules-content">
|
||||
@for (
|
||||
contribution of plan.timeWindowContributions ?? [];
|
||||
track contribution.ruleId
|
||||
) {
|
||||
<section class="outcome-explanation declared-rule">
|
||||
<h3>{{ contribution.label }}</h3>
|
||||
<p>
|
||||
{{ contribution.declaredDays.length }}
|
||||
{{ tr().bookedDays.booked }} +
|
||||
{{ contribution.placementDates.length }}
|
||||
{{ tr().planning.explanation.leaveDays }} =
|
||||
<strong
|
||||
>{{
|
||||
contribution.declaredDays.length +
|
||||
contribution.placementDates.length
|
||||
}}
|
||||
/ {{ contribution.requested }}</strong
|
||||
>
|
||||
</p>
|
||||
<p>
|
||||
@for (day of contribution.declaredDays; track day.date) {
|
||||
<span
|
||||
>{{ displayDate(day.date) }} ·
|
||||
{{ tr().dayTypes[day.type] }}
|
||||
</span>
|
||||
}
|
||||
</p>
|
||||
<p>{{ tr().bookedDays.fixed }}</p>
|
||||
</section>
|
||||
}
|
||||
@for (
|
||||
contribution of plan.ifThenContributions ?? [];
|
||||
track contribution.ruleId + contribution.occurrence
|
||||
) {
|
||||
<section class="outcome-explanation declared-rule">
|
||||
<h3>
|
||||
{{ contribution.label }} ·
|
||||
{{ displayDate(contribution.occurrence) }}
|
||||
</h3>
|
||||
<p>
|
||||
{{ contribution.declaredDays.length }}
|
||||
{{ tr().bookedDays.booked }} +
|
||||
{{ contribution.placementDates.length }}
|
||||
{{ tr().planning.explanation.leaveDays }} =
|
||||
<strong
|
||||
>{{ contribution.requested }} /
|
||||
{{ contribution.requested }}</strong
|
||||
>
|
||||
</p>
|
||||
@for (day of contribution.declaredDays; track day.date) {
|
||||
<span
|
||||
>{{ displayDate(day.date) }} · {{ tr().dayTypes[day.type] }}
|
||||
</span>
|
||||
}
|
||||
@if (contribution.declaredDays.length) {
|
||||
<p>{{ tr().bookedDays.fixed }}</p>
|
||||
}
|
||||
@if (contribution.earnedEntitlement; as earned) {
|
||||
<p>
|
||||
{{
|
||||
earned.added
|
||||
? tr().planning.futureEntitlement
|
||||
: tr().planning.includedEntitlement
|
||||
}}
|
||||
: {{ earned.quantity }} {{ tr().dayTypes[earned.type] }}
|
||||
</p>
|
||||
<p>
|
||||
{{ tr().planning.details.available }}
|
||||
{{ displayDate(earned.availableFrom) }} ·
|
||||
{{ tr().planning.details.expires }}
|
||||
{{ displayDate(earned.expiryDate) }}
|
||||
</p>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
@for (period of declaredPeriods(); track period.start) {
|
||||
<section class="outcome-explanation declared-period">
|
||||
<h3>
|
||||
{{ tr().planning.explanation.breakTitle }} ·
|
||||
{{ displayDate(period.start) }} – {{ displayDate(period.end) }}
|
||||
</h3>
|
||||
<p>
|
||||
{{ period.declaredDates!.length }}
|
||||
{{ tr().bookedDays.booked }} +
|
||||
{{ period.placementDates.length }}
|
||||
{{ tr().planning.explanation.leaveDays }} +
|
||||
{{ period.nonWorkingDates.length }}
|
||||
{{ tr().planning.explanation.freeDays }} =
|
||||
<strong
|
||||
>{{ period.duration }}
|
||||
{{ tr().planning.explanation.daysOff }}</strong
|
||||
>
|
||||
</p>
|
||||
<p>{{ tr().bookedDays.fixed }}</p>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
</details>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<p class="calendar-help">
|
||||
|
||||
@@ -31,8 +31,10 @@ code {
|
||||
padding-block: 0.25rem 0.5rem;
|
||||
}
|
||||
.results-heading {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 1rem;
|
||||
}
|
||||
.calculation-date {
|
||||
color: var(--ui-text-secondary);
|
||||
@@ -158,6 +160,12 @@ code {
|
||||
}
|
||||
}
|
||||
|
||||
.applied-rules-content {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.statistics-content {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
|
||||
@@ -154,6 +154,19 @@ export class CalendarYear {
|
||||
}
|
||||
|
||||
protected readonly displayedPlan = this.calculations.displayedPlan;
|
||||
protected readonly declaredPeriods = computed(() =>
|
||||
(this.displayedPlan()?.timeOffPeriods ?? []).filter(
|
||||
({ declaredDates }) => declaredDates?.length,
|
||||
),
|
||||
);
|
||||
protected readonly appliedRuleCount = computed(() => {
|
||||
const plan = this.displayedPlan();
|
||||
return (
|
||||
(plan?.timeWindowContributions?.length ?? 0) +
|
||||
(plan?.ifThenContributions?.length ?? 0) +
|
||||
this.declaredPeriods().length
|
||||
);
|
||||
});
|
||||
protected readonly weekendConnectedHolidays = computed(() => {
|
||||
const isWeekend = (date: string) => {
|
||||
const day = new Date(`${date}T00:00:00Z`).getUTCDay();
|
||||
|
||||
@@ -236,6 +236,7 @@ export interface AppTranslations {
|
||||
calendarHelp: string;
|
||||
explanationHelp: string;
|
||||
technicalDetails: string;
|
||||
appliedRules: { title: string; entries: string };
|
||||
compareDates: string;
|
||||
stopComparing: string;
|
||||
daysPlaced: string;
|
||||
|
||||
@@ -296,6 +296,10 @@
|
||||
"calendarHelp": "Wählen Sie einen Urlaubstag, um seinen Beitrag zum Plan zu sehen.",
|
||||
"explanationHelp": "Sehen Sie Ihre Auszeit und den Beitrag jedes Tages.",
|
||||
"technicalDetails": "Berechnungsdetails",
|
||||
"appliedRules": {
|
||||
"title": "Details zu angewendeten Regeln",
|
||||
"entries": "Einträge"
|
||||
},
|
||||
"compareDates": "Andere Termine vergleichen",
|
||||
"stopComparing": "Datumsvergleich schließen",
|
||||
"explanation": {
|
||||
|
||||
@@ -296,6 +296,10 @@
|
||||
"calendarHelp": "Select a leave day to see its contribution to your plan.",
|
||||
"explanationHelp": "See the break you get and what each day changes.",
|
||||
"technicalDetails": "Calculation details",
|
||||
"appliedRules": {
|
||||
"title": "Applied rules detail",
|
||||
"entries": "Entries"
|
||||
},
|
||||
"compareDates": "Compare other dates",
|
||||
"stopComparing": "Close date comparison",
|
||||
"explanation": {
|
||||
|
||||
@@ -296,6 +296,10 @@
|
||||
"calendarHelp": "Selecciona un día de permiso para ver su aportación al plan.",
|
||||
"explanationHelp": "Consulta tu descanso y qué cambia con cada día.",
|
||||
"technicalDetails": "Detalles del cálculo",
|
||||
"appliedRules": {
|
||||
"title": "Detalle de las reglas aplicadas",
|
||||
"entries": "Elementos"
|
||||
},
|
||||
"compareDates": "Comparar otras fechas",
|
||||
"stopComparing": "Cerrar comparación",
|
||||
"explanation": {
|
||||
|
||||
@@ -296,6 +296,10 @@
|
||||
"calendarHelp": "Sélectionnez un jour de congé pour voir son apport au planning.",
|
||||
"explanationHelp": "Découvrez votre pause et ce que chaque jour change.",
|
||||
"technicalDetails": "Détails du calcul",
|
||||
"appliedRules": {
|
||||
"title": "Détail des règles appliquées",
|
||||
"entries": "Éléments"
|
||||
},
|
||||
"compareDates": "Comparer d’autres dates",
|
||||
"stopComparing": "Fermer la comparaison",
|
||||
"explanation": {
|
||||
|
||||
Reference in new issue
Block a user