some renaming of variables
All checks were successful
Build, test and publish / verify (push) Successful in 5m55s
All checks were successful
Build, test and publish / verify (push) Successful in 5m55s
This commit is contained in:
@@ -242,7 +242,7 @@ test('links a coach and finalizes performances spread across multiple dates', as
|
||||
data: { assignments: groupIds.map((id) => [id]) },
|
||||
});
|
||||
await page.goto(`/schools/${school.id}/shows`);
|
||||
await expect(page.getByText(/exceeds x=1/)).toBeVisible();
|
||||
await expect(page.getByText(/exceeds preferredDayParts=1/)).toBeVisible();
|
||||
await tab(page, 'Dansers');
|
||||
await page.getByText('Coaches koppelen aan dansers', { exact: true }).click();
|
||||
await page.getByLabel('Danser als coach registreren').selectOption({ label: 'Dancing coach' });
|
||||
|
||||
@@ -352,7 +352,8 @@
|
||||
<div class="show-details">
|
||||
<h3>{{ show.name }}</h3>
|
||||
<p>
|
||||
{{ show.finalized ? 'Definitief' : 'Concept' }} · x = {{ show.preferredDayParts }}
|
||||
{{ show.finalized ? 'Definitief' : 'Concept' }} · preferredDayParts =
|
||||
{{ show.preferredDayParts }}
|
||||
</p>
|
||||
@for (violation of show.violations; track $index) {
|
||||
<p class="alert error">{{ violation }}</p>
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('EntityEditor', () => {
|
||||
appearances: { REGULAR: 2, SELECTION: 2, PRE_SCHOOLER: 1, SHOW_CASE: 2, PRE_EDUCATION: 2 },
|
||||
};
|
||||
|
||||
it('defaults x to two and rejects duplicate dated dayparts and fractional x', () => {
|
||||
it('defaults preferredDayParts to two and rejects duplicate dated dayparts and fractional preferredDayParts', () => {
|
||||
const component = editor({ kind: 'show' });
|
||||
component.name = 'Show';
|
||||
expect(component.validDetails()).toBe(true);
|
||||
@@ -99,7 +99,27 @@ describe('EntityEditor', () => {
|
||||
expect(component.validDetails()).toBe(false);
|
||||
});
|
||||
|
||||
it('retains x when dayparts are removed so it can be explicitly corrected', () => {
|
||||
it('preserves an explicitly chosen preferredDayParts when adding dayparts to a new show', async () => {
|
||||
api.saveShow.mockReturnValue(of(show));
|
||||
const component = editor({ kind: 'show' });
|
||||
component.name = 'Show';
|
||||
component.addPart();
|
||||
component.dayParts[0].date = '2027-06-01';
|
||||
component.addPart();
|
||||
component.dayParts[1].date = '2027-06-02';
|
||||
component.preferredDayParts = 1;
|
||||
component.addPart();
|
||||
component.dayParts[2].date = '2027-06-03';
|
||||
expect(component.preferredDayParts).toBe(1);
|
||||
await component.save();
|
||||
expect(api.saveShow).toHaveBeenCalledWith(
|
||||
7,
|
||||
expect.objectContaining({ preferredDayParts: 1 }),
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it('retains preferredDayParts when dayparts are removed so it can be explicitly corrected', () => {
|
||||
const component = editor({ kind: 'show', value: show });
|
||||
component.addPart();
|
||||
component.dayParts[2].date = '2027-06-03';
|
||||
@@ -144,7 +164,7 @@ describe('EntityEditor', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('displays one editable x field with a default of one for a one-daypart show', async () => {
|
||||
it('displays one editable preferredDayParts field with a default of one for a one-daypart show', async () => {
|
||||
// jsdom does not implement native dialog opening.
|
||||
const descriptor = Object.getOwnPropertyDescriptor(HTMLDialogElement.prototype, 'showModal');
|
||||
Object.defineProperty(HTMLDialogElement.prototype, 'showModal', {
|
||||
|
||||
@@ -185,7 +185,16 @@ export class EntityEditor implements OnInit {
|
||||
readonly today = new Date().toLocaleDateString('en-CA');
|
||||
private readonly api = inject(SchoolApi);
|
||||
dayParts: DayPart[] = [];
|
||||
preferredDayParts = 2;
|
||||
private preferredDayPartsValue = 2;
|
||||
private preferredDayPartsEdited = false;
|
||||
|
||||
get preferredDayParts(): number {
|
||||
return this.preferredDayPartsValue;
|
||||
}
|
||||
set preferredDayParts(value: number) {
|
||||
this.preferredDayPartsValue = value;
|
||||
this.preferredDayPartsEdited = true;
|
||||
}
|
||||
name = '';
|
||||
date = '';
|
||||
type: GroupType = 'REGULAR';
|
||||
@@ -218,7 +227,8 @@ export class EntityEditor implements OnInit {
|
||||
addPart(): void {
|
||||
if (this.dayParts.length >= 6) return;
|
||||
this.dayParts.push({ date: '', type: 'AFTERNOON', danceGroupIds: [] });
|
||||
if (!this.target().value) this.preferredDayParts = Math.min(2, this.dayParts.length);
|
||||
if (!this.target().value && !this.preferredDayPartsEdited)
|
||||
this.preferredDayPartsValue = Math.min(2, this.dayParts.length);
|
||||
}
|
||||
removePart(index: number): void {
|
||||
this.dayParts.splice(index, 1);
|
||||
|
||||
@@ -16,7 +16,7 @@ import { DialogFrame } from './dialog-frame';
|
||||
(dismissed)="closed.emit()"
|
||||
>
|
||||
<p>
|
||||
{{ !dirty() && current()?.finalized ? 'Definitief' : 'Concept' }} · x =
|
||||
{{ !dirty() && current()?.finalized ? 'Definitief' : 'Concept' }} · preferredDayParts =
|
||||
{{ show().preferredDayParts }}
|
||||
</p>
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user