WEB-460 Shares per Client Field Allows Zero and Negative Values in Share Product Creation Form
This commit is contained in:
+41
-6
@@ -12,21 +12,56 @@
|
|||||||
|
|
||||||
<mat-form-field class="flex-31">
|
<mat-form-field class="flex-31">
|
||||||
<mat-label>{{ 'labels.inputs.Minimum' | translate }}</mat-label>
|
<mat-label>{{ 'labels.inputs.Minimum' | translate }}</mat-label>
|
||||||
<input type="number" matInput formControlName="minimumShares" />
|
<input type="number" matInput formControlName="minimumShares" min="1" step="1" required />
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('minimumShares').hasError('required')">
|
||||||
|
Minimum is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('minimumShares').hasError('min')">
|
||||||
|
{{ 'labels.inputs.Minimum Shares per Client' | translate }}
|
||||||
|
{{ 'labels.commons.must be greater than zero' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('minimumShares').hasError('pattern')">
|
||||||
|
{{ 'labels.inputs.Minimum Shares per Client' | translate }}
|
||||||
|
{{ 'labels.commons.must be an integer' | translate }}
|
||||||
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="flex-31">
|
<mat-form-field class="flex-31">
|
||||||
<mat-label>{{ 'labels.inputs.Default' | translate }}</mat-label>
|
<mat-label>{{ 'labels.inputs.Default' | translate }}</mat-label>
|
||||||
<input type="number" matInput formControlName="nominalShares" required />
|
<input type="number" matInput formControlName="nominalShares" min="1" step="1" required />
|
||||||
<mat-error>
|
<mat-error *ngIf="shareProductSettingsForm.get('nominalShares').hasError('required')">
|
||||||
{{ 'labels.inputs.Default Shares per Client' | translate }} {{ 'labels.commons.is' | translate }}
|
Default is <strong>required</strong>
|
||||||
<strong>{{ 'labels.commons.required' | translate }}</strong>
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('nominalShares').hasError('min')">
|
||||||
|
{{ 'labels.inputs.Default Shares per Client' | translate }}
|
||||||
|
{{ 'labels.commons.must be greater than zero' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('nominalShares').hasError('pattern')">
|
||||||
|
{{ 'labels.inputs.Default Shares per Client' | translate }}
|
||||||
|
{{ 'labels.commons.must be an integer' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field class="flex-31">
|
<mat-form-field class="flex-31">
|
||||||
<mat-label>{{ 'labels.inputs.Maximum' | translate }}</mat-label>
|
<mat-label>{{ 'labels.inputs.Maximum' | translate }}</mat-label>
|
||||||
<input type="number" matInput formControlName="maximumShares" />
|
<input type="number" matInput formControlName="maximumShares" min="1" step="1" required />
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('maximumShares').hasError('required')">
|
||||||
|
Maximum is <strong>required</strong>
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('maximumShares').hasError('min')">
|
||||||
|
{{ 'labels.inputs.Maximum Shares per Client' | translate }}
|
||||||
|
{{ 'labels.commons.must be greater than zero' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.get('maximumShares').hasError('pattern')">
|
||||||
|
{{ 'labels.inputs.Maximum Shares per Client' | translate }}
|
||||||
|
{{ 'labels.commons.must be an integer' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="shareProductSettingsForm.hasError('sharesOrder')">
|
||||||
|
{{
|
||||||
|
'labels.commons.minimum must be less than or equal to default and default must be less than or equal to maximum'
|
||||||
|
| translate
|
||||||
|
}}
|
||||||
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<h4 class="mat-h4 flex-98">
|
<h4 class="mat-h4 flex-98">
|
||||||
|
|||||||
+48
-13
@@ -53,19 +53,54 @@ export class ShareProductSettingsStepComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createShareProductSettingsForm() {
|
createShareProductSettingsForm() {
|
||||||
this.shareProductSettingsForm = this.formBuilder.group({
|
this.shareProductSettingsForm = this.formBuilder.group(
|
||||||
minimumShares: [''],
|
{
|
||||||
nominalShares: [
|
minimumShares: [
|
||||||
'',
|
'',
|
||||||
Validators.required
|
[
|
||||||
],
|
Validators.required,
|
||||||
maximumShares: [''],
|
Validators.min(1),
|
||||||
minimumActivePeriodForDividends: [''],
|
Validators.pattern(/^[0-9]+$/)
|
||||||
minimumactiveperiodFrequencyType: [''],
|
]
|
||||||
lockinPeriodFrequency: [''],
|
],
|
||||||
lockinPeriodFrequencyType: [''],
|
nominalShares: [
|
||||||
allowDividendCalculationForInactiveClients: [false]
|
'',
|
||||||
});
|
[
|
||||||
|
Validators.required,
|
||||||
|
Validators.min(1),
|
||||||
|
Validators.pattern(/^[0-9]+$/)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
maximumShares: [
|
||||||
|
'',
|
||||||
|
[
|
||||||
|
Validators.required,
|
||||||
|
Validators.min(1),
|
||||||
|
Validators.pattern(/^[0-9]+$/)
|
||||||
|
]
|
||||||
|
],
|
||||||
|
minimumActivePeriodForDividends: [''],
|
||||||
|
minimumactiveperiodFrequencyType: [''],
|
||||||
|
lockinPeriodFrequency: [''],
|
||||||
|
lockinPeriodFrequencyType: [''],
|
||||||
|
allowDividendCalculationForInactiveClients: [false]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validators: this.validateSharesOrder
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private validateSharesOrder(group: UntypedFormGroup): { [key: string]: any } | null {
|
||||||
|
const min = Number(group.get('minimumShares')?.value);
|
||||||
|
const nominal = Number(group.get('nominalShares')?.value);
|
||||||
|
const max = Number(group.get('maximumShares')?.value);
|
||||||
|
if (min && nominal && max) {
|
||||||
|
if (min > nominal || nominal > max) {
|
||||||
|
return { sharesOrder: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get shareProductSettings() {
|
get shareProductSettings() {
|
||||||
|
|||||||
Reference in New Issue
Block a user