Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit f5444f3

Browse files
committed
Fixing the issue FINCN-101:Group Definition Minimum and Maximum Numbers should not be decimals
1 parent 0eda8ae commit f5444f3

File tree

8 files changed

+133
-12
lines changed

8 files changed

+133
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"karma": "karma start ./karma.conf.js --single-run",
1414
"devTest": "ng test",
1515
"dev": "ng serve --watch --verbose --proxy-config proxy.conf.json",
16-
"runProd": "ng serve --proxy-config proxy.conf.json --prod",
17-
"build": "ng build --prod",
16+
"runProd": "ng serve --proxy-config proxy.conf.json --environment=prod",
17+
"build": "ng build --environment=prod",
1818
"checkLicenses": "license-to-fail ./license.config.js",
1919
"bundle-report": "webpack-bundle-analyzer dist/stats.json"
2020
},

src/app/common/common.module.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import {DateInputComponent} from './date-input/date-input.component';
6565
import {TextInputComponent} from './text-input/text-input.component';
6666
import {DisplayFimsNumber} from './number/fims-number.pipe';
6767
import {DisplayFimsFinancialNumber} from './number/fims-financial-number.pipe';
68+
import {NumberGroupInputComponent} from './number-group-input/number-group-input.component'
6869

6970
@NgModule({
7071
imports: [
@@ -120,7 +121,8 @@ import {DisplayFimsFinancialNumber} from './number/fims-financial-number.pipe';
120121
FimsFabButtonComponent,
121122
DisplayFimsDate,
122123
DisplayFimsNumber,
123-
DisplayFimsFinancialNumber
124+
DisplayFimsFinancialNumber,
125+
NumberGroupInputComponent
124126
],
125127
exports: [
126128
LayoutCardOverComponent,
@@ -151,7 +153,8 @@ import {DisplayFimsFinancialNumber} from './number/fims-financial-number.pipe';
151153
FimsFabButtonComponent,
152154
DisplayFimsDate,
153155
DisplayFimsNumber,
154-
DisplayFimsFinancialNumber
156+
DisplayFimsFinancialNumber,
157+
NumberGroupInputComponent
155158
],
156159
entryComponents: [
157160
ImageComponent
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<mat-form-field layout-margin flex [formGroup]="form">
19+
<input matInput type="text" [textMask]="{mask: mask}" [placeholder]="placeholder" [formControlName]="controlName"/>
20+
<mat-error *ngIf="hasRequiredError" translate>
21+
Required
22+
</mat-error>
23+
<mat-error *ngIf="hasMinValueError" translate>
24+
{{ 'Value must be greater than or equal to' | translate:{value: form.get(controlName).errors.minValue.value} }}
25+
</mat-error>
26+
<mat-error *ngIf="hasMaxValueError" translate>
27+
{{ 'Value must be smaller than or equal to' | translate:{value: form.get(controlName).errors.maxValue.value} }}
28+
</mat-error>
29+
<mat-error *ngIf="hasGreaterThanValueError" translate>
30+
{{ 'Value must be greater than' | translate:{value: form.get(controlName).errors.greaterThanValue.value} }}
31+
</mat-error>
32+
<mat-error *ngIf="hasScaleError">
33+
{{ 'Must have decimal places' | translate:{value: form.get(controlName).errors.scale.value} }}
34+
</mat-error>
35+
<mat-hint align="end" *ngIf="form.get(controlName).enabled">
36+
{{hint}}
37+
</mat-hint>
38+
</mat-form-field>
39+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
import {Component, Input} from '@angular/core';
20+
import {FormGroup} from '@angular/forms';
21+
import {createNumberMask} from 'text-mask-addons/dist/textMaskAddons';
22+
23+
@Component({
24+
selector: 'fims-number-group-input',
25+
templateUrl: './number-group-input.component.html'
26+
})
27+
export class NumberGroupInputComponent {
28+
29+
@Input() placeholder;
30+
31+
@Input() controlName: string;
32+
33+
@Input() form: FormGroup;
34+
35+
@Input() requireDecimal = false;
36+
37+
@Input() decimalLimit = 2;
38+
39+
@Input() hint: string;
40+
41+
mask: any;
42+
43+
constructor() {
44+
this.mask = createNumberMask({
45+
prefix: '',
46+
suffix: '',
47+
includeThousandsSeparator: false,
48+
requireDecimal: this.requireDecimal,
49+
allowNegative: false,
50+
allowLeadingZeroes: true,
51+
decimalLimit: this.decimalLimit
52+
});
53+
}
54+
55+
get hasRequiredError(): boolean {
56+
return this.hasError('required');
57+
}
58+
59+
get hasMinValueError(): boolean {
60+
return this.hasError('minValue');
61+
}
62+
63+
get hasGreaterThanValueError(): boolean {
64+
return this.hasError('greaterThanValue');
65+
}
66+
67+
get hasMaxValueError(): boolean {
68+
return this.hasError('maxValue');
69+
}
70+
71+
get hasScaleError(): boolean {
72+
return this.hasError('maxScale');
73+
}
74+
75+
hasError(key: string): boolean {
76+
return this.form.get(this.controlName).hasError(key);
77+
}
78+
}

src/app/common/number-input/number-input.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class NumberInputComponent {
3232

3333
@Input() form: FormGroup;
3434

35-
@Input() requireDecimal = false;
35+
@Input() requireDecimal = true;
3636

3737
@Input() decimalLimit = 2;
3838

src/app/groups/definition/form/form.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<td-step #detailsStep label="{{'Group Definition details' | translate}}" [state]="form.valid ? 'complete' : form.pristine ? 'none' : 'required'">
2020
<form [formGroup]="form" layout="column">
2121
<fims-id-input flex [form]="form" controlName="identifier" [readonly]="editMode"></fims-id-input>
22-
<fims-number-input [form]="form" placeholder="Minimal Size" controlName="minimal"></fims-number-input>
23-
<fims-number-input [form]="form" placeholder="Maximal Size" controlName="maximal"></fims-number-input>
22+
<fims-number-group-input [form]="form" placeholder="Minimal Size" controlName="minimal"></fims-number-group-input>
23+
<fims-number-group-input [form]="form" placeholder="Maximal Size" controlName="maximal"></fims-number-group-input>
2424
<mat-form-field layout-margin flex>
2525
<textarea matInput placeholder="{{'Description' | translate}}" formControlName="description"></textarea>
2626
<mat-error *ngIf="form.get('description').hasError('required')" translate>
@@ -30,7 +30,7 @@
3030

3131
<h4 translate> Cycle details </h4>
3232

33-
<fims-number-input [form]="form" controlName="number" placeholder="{{'Number of meeting' | translate}}"></fims-number-input>
33+
<fims-number-group-input [form]="form" controlName="number" placeholder="{{'Number of meeting' | translate}}"></fims-number-group-input>
3434
<mat-form-field layout-margin>
3535
<mat-select formControlName="frequency" placeholder="{{ 'Frequency' | translate }}">
3636
<mat-option *ngFor="let frequency of frequencyOptions" [value]="frequency.type">

src/app/groups/detail/signOffMeeting/signOff-meeting.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
<td-steps mode="'vertical'">
2121
<td-step #detailsStep [state]="form.valid ? 'complete' : form.pristine ? 'none' : 'required'">
2222
<form [formGroup]="form" layout="column">
23-
<fims-number-input [form]="form" placeholder="Meeting Sequence" controlName="sequence"></fims-number-input>
24-
<fims-number-input [form]="form" placeholder="Current Cycle" controlName="cycle"></fims-number-input>
25-
<fims-number-input [form]="form" controlName="duration" placeholder="Duration"></fims-number-input>
23+
<fims-number-group-input [form]="form" placeholder="Meeting Sequence" controlName="sequence"></fims-number-group-input>
24+
<fims-number-group-input [form]="form" placeholder="Current Cycle" controlName="cycle"></fims-number-group-input>
25+
<fims-number-group-input [form]="form" controlName="duration" placeholder="Duration"></fims-number-group-input>
2626
<h3> Attendance </h3>
2727
<div layout="row">
2828
<table td-data-table>

src/app/quickAccess/quick-access.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</mat-card>
8181
</div>
8282
</div>
83-
83+
<!--
8484
<div layout="column" layout-gt-sm="row" class="inset">
8585
<div flex-gt-sm="40">
8686
<mat-card>
@@ -98,6 +98,7 @@
9898
</div>
9999
</div>
100100
101+
-->
101102
<div layout="column" layout-gt-sm="row" class="inset">
102103
<div flex-gt-sm="40" *hasPermission="{ id: 'identity_roles', accessLevel: 'READ'}">
103104
<mat-card>

0 commit comments

Comments
 (0)