Skip to content

Commit 28f96e9

Browse files
Added numberOfTeachers for Schools and further adoptions
1 parent 63de237 commit 28f96e9

File tree

8 files changed

+51
-54
lines changed

8 files changed

+51
-54
lines changed

src/app/child-dev-project/children/demo-data-generators/demo-school-generator.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class DemoSchoolGenerator extends DemoDataGenerator<Entity> {
5656
$localize`:School demo timing:11 a.m. - 4 p.m.`,
5757
$localize`:School demo timing:6:30-11:00 and 11:30-16:00`,
5858
]);
59-
59+
school["numberOfTeachers"] = faker.number.int({ min: 3, max: 75 });
6060
school["address"] = faker.geoAddress();
6161

6262
data.push(school);

src/app/core/basic-datatypes/number/number-range-filter/number-range-filter.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<mat-label>{{ filterConfig.label || filterConfig.name }}</mat-label>
33
<app-range-input
44
[formControl]="formControl"
5-
[deactivateValidation]="false"
5+
[activateValidation]="true"
66
></app-range-input>
77
</mat-form-field>

src/app/core/basic-datatypes/number/number-range-filter/number-range-filter.component.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,12 @@ export class NumberRangeFilterComponent<T extends Entity> {
2727
from: number;
2828
to: number;
2929

30-
// private validatorFunction: ValidatorFn = (): ValidationErrors | null => {
31-
// if (
32-
// this.formControl.value.from &&
33-
// this.formControl.value.to &&
34-
// this.formControl.value.from === this.formControl.value.to
35-
// ) {
36-
// return {
37-
// sameValue: "The from value is the same as the to value.",
38-
// };
39-
// } else {
40-
// return null;
41-
// }
42-
// };
43-
4430
ngOnInit() {
45-
console.log("filterConfig", this.filterConfig);
4631
this.formControl = new FormControl<NumericRange>({
4732
from: Number(this.filterConfig.selectedOptionValues[0]),
4833
to: Number(this.filterConfig.selectedOptionValues[1]),
4934
});
5035
this.formControl.valueChanges.subscribe((value) => {
51-
console.log(this.formControl.valid, this.formControl.errors);
52-
5336
this.filterConfig.selectedOptionValues = [
5437
this.formControl.value.from?.toString() ?? "",
5538
this.formControl.value.to?.toString() ?? "",
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
import { ComponentFixture, TestBed } from '@angular/core/testing';
1+
import { ComponentFixture, TestBed } from "@angular/core/testing";
22

3-
import { RangeInputComponent } from './range-input.component';
3+
import { RangeInputComponent } from "./range-input.component";
44

5-
describe('RangeInputComponent', () => {
5+
describe("RangeInputComponent", () => {
66
let component: RangeInputComponent;
77
let fixture: ComponentFixture<RangeInputComponent>;
88

99
beforeEach(async () => {
1010
await TestBed.configureTestingModule({
11-
imports: [RangeInputComponent]
12-
})
13-
.compileComponents();
14-
11+
imports: [RangeInputComponent],
12+
}).compileComponents();
13+
1514
fixture = TestBed.createComponent(RangeInputComponent);
1615
component = fixture.componentInstance;
1716
fixture.detectChanges();
1817
});
1918

20-
it('should create', () => {
19+
it("should create", () => {
2120
expect(component).toBeTruthy();
2221
});
2322
});

src/app/core/basic-datatypes/number/number-range-filter/range-input/range-input.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class RangeInputComponent extends CustomFormControlDirective<NumericRange
4242
}
4343

4444
@Input()
45-
deactivateValidation: boolean = false;
45+
activateValidation: boolean = true;
4646

4747
constructor(
4848
elementRef: ElementRef<HTMLElement>,
@@ -67,7 +67,11 @@ export class RangeInputComponent extends CustomFormControlDirective<NumericRange
6767
}
6868

6969
private validatorFunction: ValidatorFn = (): ValidationErrors | null => {
70-
if (this.value.from && this.value.to && this.value.from > this.value.to) {
70+
if (
71+
this.value.from != undefined &&
72+
this.value.to != undefined &&
73+
this.value.from > this.value.to
74+
) {
7175
return {
7276
fromGreaterThanTo: "The 'from' value is greater than the 'to' value.",
7377
};
@@ -77,7 +81,7 @@ export class RangeInputComponent extends CustomFormControlDirective<NumericRange
7781
};
7882

7983
ngAfterViewInit() {
80-
if (!this.deactivateValidation) {
84+
if (this.activateValidation) {
8185
this.formControlDirective.form.addValidators([this.validatorFunction]);
8286
}
8387
}

src/app/core/config/config-fix.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,14 @@ export const defaultJsonConfig = {
395395
"name",
396396
{ id: "DisplayParticipantsCount", viewComponent: "DisplayParticipantsCount", label: $localize`Children` },
397397
"privateSchool",
398-
"language"
398+
"language",
399+
"numberOfTeachers"
399400
],
400401
"filters": [
401-
{ "id": "privateSchool" }
402+
{ "id": "privateSchool"},
403+
{ "id": "numberOfTeachers", "type": "numbers",
404+
"label": "Number of Teachers"
405+
}
402406
]
403407
}
404408
},
@@ -418,7 +422,7 @@ export const defaultJsonConfig = {
418422
{ "fields": ["name", "privateSchool", "parentSchool"] },
419423
{ "fields": ["address", "phone"] },
420424
{ "fields": ["language", "timing"] },
421-
{ "fields": ["remarks"] }
425+
{ "fields": ["remarks", "numberOfTeachers"] }
422426
]
423427
}
424428
}
@@ -503,7 +507,6 @@ export const defaultJsonConfig = {
503507
"name",
504508
"age",
505509
"gender",
506-
"shoeSize",
507510
"schoolClass",
508511
"schoolId",
509512
"center",
@@ -565,11 +568,6 @@ export const defaultJsonConfig = {
565568
"id": "schoolId",
566569
"type": "School",
567570
"label": $localize`:Label of schools filter:School`
568-
},
569-
{
570-
"id": "shoeSize",
571-
"type": "numbers",
572-
"label": "Shoe Size"
573571
}
574572
],
575573
"exportConfig": [
@@ -600,7 +598,7 @@ export const defaultJsonConfig = {
600598
"header": $localize`:Header for form section:Personal Information`
601599
},
602600
{
603-
"fields": ["dateOfBirth", "birth_certificate", "gender", "motherTongue","shoeSize"],
601+
"fields": ["dateOfBirth", "birth_certificate", "gender", "motherTongue"],
604602
"header": $localize`:Header for form section:Additional`
605603
},
606604
{
@@ -1036,10 +1034,6 @@ export const defaultJsonConfig = {
10361034
"dataType": "location",
10371035
"label": $localize`:Label for the address of a child:Address`
10381036
},
1039-
"shoeSize": {
1040-
"dataType": "number",
1041-
"label": $localize`:Label for a child attribute:Shoe Size`
1042-
},
10431037
"health_bloodGroup": {
10441038
"dataType": "string",
10451039
"label": $localize`:Label for a child attribute:Blood Group`
@@ -1100,6 +1094,10 @@ export const defaultJsonConfig = {
11001094
"dataType": "string",
11011095
"label": $localize`:Label for the timing of a school:School Timing`
11021096
},
1097+
"numberOfTeachers": {
1098+
"dataType": "number",
1099+
"label": $localize`:Label for a school attribute:Number of Teachers`
1100+
},
11031101
"remarks": {
11041102
"dataType": "string",
11051103
"label": $localize`:Label for the remarks for a school:Remarks`

src/app/core/filter/filters/filters.spec.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,40 @@ describe("Filters", () => {
7474
testFilter(filter, [recordFalse, recordTrue], [recordFalse, recordTrue]);
7575
});
7676

77-
fit("should support a numbers filter", async () => {
77+
it("should support a numbers filter", async () => {
7878
const filter = new NumberFilter("value", "My Filter");
7979

80-
const record_5 = { value: -5 };
80+
const recordMinus5 = { value: -5 };
8181
const record0 = { value: 0 };
8282
const record1 = { value: 1 };
83+
const record1_6 = { value: 1.6 };
8384
const record2 = { value: 2 };
8485
const record3 = { value: 3 };
8586
const record10 = { value: 10 };
86-
const records = [record_5, record0, record1, record2, record3, record10];
87+
const records = [
88+
recordMinus5,
89+
record0,
90+
record1,
91+
record1_6,
92+
record2,
93+
record3,
94+
record10,
95+
];
8796

8897
filter.selectedOptionValues = ["2", "3"];
8998
testFilter(filter, records, [record2, record3]);
9099

100+
filter.selectedOptionValues = ["0", "3"];
101+
testFilter(filter, records, [
102+
record0,
103+
record1,
104+
record1_6,
105+
record2,
106+
record3,
107+
]);
108+
91109
filter.selectedOptionValues = ["-8", "1"];
92-
testFilter(filter, records, [record_5, record0, record1]);
110+
testFilter(filter, records, [recordMinus5, record0, record1]);
93111

94112
filter.selectedOptionValues = ["10", "10"];
95113
testFilter(filter, records, [record10]);
@@ -98,7 +116,7 @@ describe("Filters", () => {
98116
testFilter(filter, records, [record10]);
99117

100118
filter.selectedOptionValues = ["", "-1"];
101-
testFilter(filter, records, [record_5]);
119+
testFilter(filter, records, [recordMinus5]);
102120

103121
filter.selectedOptionValues = ["", ""];
104122
testFilter(filter, records, records);

src/app/core/filter/filters/numberFilter.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export class NumberFilter<T extends Entity> extends Filter<T> {
1717
}
1818

1919
getFilter(): DataFilter<T> {
20-
console.log("Peter this.selectedOptionValues", this.selectedOptionValues);
21-
2220
const filterObject: { $gte?; $lte?: number } = {};
2321
if (this.selectedOptionValues[0]) {
2422
filterObject.$gte = Number(this.selectedOptionValues[0]);
@@ -27,9 +25,6 @@ export class NumberFilter<T extends Entity> extends Filter<T> {
2725
filterObject.$lte = Number(this.selectedOptionValues[1]);
2826
}
2927
if (filterObject.$gte || filterObject.$lte) {
30-
console.log("Peter data filter", {
31-
[this.name]: filterObject,
32-
} as DataFilter<T>);
3328
return {
3429
[this.name]: filterObject,
3530
} as DataFilter<T>;

0 commit comments

Comments
 (0)