-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version 1.0.1
- Loading branch information
Showing
83 changed files
with
1,667 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 9 additions & 4 deletions
13
src/app/_main/modules/audit-log/components/audit-log/audit-log.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
<cdk-virtual-scroll-viewport autosize class="grow"> | ||
<audit-log-entry *cdkVirtualFor="let auditLog of auditLogs; trackBy: trackByAuditLog" | ||
[auditLog]="auditLog"></audit-log-entry> | ||
</cdk-virtual-scroll-viewport> | ||
<ng-container *ngIf="!noScroll; else noScroll"> | ||
<cdk-virtual-scroll-viewport autosize class="grow"> | ||
<audit-log-entry *cdkVirtualFor="let auditLog of auditLogs; trackBy: trackByAuditLog" | ||
[auditLog]="auditLog"></audit-log-entry> | ||
</cdk-virtual-scroll-viewport> | ||
</ng-container> | ||
<ng-template #noScroll> | ||
<audit-log-entry *ngFor="let auditLog of auditLogs; trackBy: trackByAuditLog" [auditLog]="auditLog"></audit-log-entry> | ||
</ng-template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FormControl } from '@ngneat/reactive-forms'; | ||
import { expectToFail, expectToPass } from '@tests/helpers/validator-testing.helper'; | ||
import { booleanValidator } from './boolean.validator'; | ||
|
||
describe('Test boolean validator', () => { | ||
const validator = booleanValidator(); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl(true); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl(false); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should not pass', () => { | ||
const control = new FormControl(null); | ||
expectToFail(validator(control)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { AbstractControl, ValidatorFn } from '@angular/forms'; | ||
import { ValidationError } from '../interfaces/validation-error.interface'; | ||
|
||
/** | ||
* Validator to check if the variable is a boolean | ||
* @returns {ValidatorFn} | ||
*/ | ||
export function booleanValidator(): ValidatorFn { | ||
return (control: AbstractControl): ValidationError | null => { | ||
if (control.value !== true && control.value !== false) { | ||
return { | ||
type: 'boolean', | ||
message: $localize`It should be a boolean`, | ||
}; | ||
} | ||
return null; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { FormControl } from '@ngneat/reactive-forms'; | ||
import { expectToFail, expectToPass } from '@tests/helpers/validator-testing.helper'; | ||
import { lengthValidator } from './length.validator'; | ||
|
||
describe('Test length limit validator', () => { | ||
const validator = lengthValidator(3, 50); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl('a0123456789'); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl('abc'); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl(''); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should not pass', () => { | ||
const control = new FormControl('a'); | ||
expectToFail(validator(control)); | ||
}); | ||
|
||
it('should not pass', () => { | ||
const control = new FormControl('012345678901234567890123456789012345678901234567890'); | ||
expectToFail(validator(control)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AbstractControl, ValidatorFn } from '@angular/forms'; | ||
import { ValidationError } from '../interfaces/validation-error.interface'; | ||
|
||
/** | ||
* Validator to check if the length is not lesser or greater than specyfic numbers, but is different than 0 | ||
* @returns {ValidatorFn} | ||
*/ | ||
export function lengthValidator(min_length: number, max_length: number): ValidatorFn { | ||
return (control: AbstractControl): ValidationError | null => { | ||
if (control.value.length > max_length) { | ||
return { | ||
type: 'max-length', | ||
message: $localize`Length should not be greater than ${max_length}`, | ||
}; | ||
} else if (control.value.length < min_length && control.value.length != 0) { | ||
return { | ||
type: 'min-length', | ||
message: $localize`Length should not be lesser than ${min_length}`, | ||
}; | ||
} | ||
return null; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { FormControl } from '@ngneat/reactive-forms'; | ||
import { expectToFail, expectToPass } from '@tests/helpers/validator-testing.helper'; | ||
import { maxLengthValidator } from './max-length.validator'; | ||
|
||
describe('Test length limit validator', () => { | ||
describe('Test maximum length limit validator', () => { | ||
const validator = maxLengthValidator(50); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl('a0123456789'); | ||
expect(validator(control)).toBeNull(); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should not pass', () => { | ||
const control = new FormControl('012345678901234567890123456789012345678901234567890'); | ||
expect(validator(control)).toBeTruthy(); | ||
expectToFail(validator(control)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { FormControl } from '@ngneat/reactive-forms'; | ||
import { expectToFail, expectToPass } from '@tests/helpers/validator-testing.helper'; | ||
import { minLengthValidator } from './min-length.validator'; | ||
|
||
describe('Test minimum length limit validator', () => { | ||
const validator = minLengthValidator(3); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl('abc'); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should pass', () => { | ||
const control = new FormControl(''); | ||
expectToPass(validator(control)); | ||
}); | ||
|
||
it('should not pass', () => { | ||
const control = new FormControl('a'); | ||
expectToFail(validator(control)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { AbstractControl, ValidatorFn } from '@angular/forms'; | ||
import { ValidationError } from '../interfaces/validation-error.interface'; | ||
|
||
/** | ||
* Validator to check if the length is not lesser than specyfic number, but is different than 0 | ||
* @returns {ValidatorFn} | ||
*/ | ||
export function minLengthValidator(length: number): ValidatorFn { | ||
return (control: AbstractControl): ValidationError | null => { | ||
if (control.value.length < length && control.value.length != 0) { | ||
return { | ||
type: 'min-length', | ||
message: $localize`Length should not be lesser than ${length}`, | ||
}; | ||
} | ||
return null; | ||
}; | ||
} |
Oops, something went wrong.