_formBuilder in separate _getForm method
This commit is contained in:
parent
1a4433f714
commit
d230ab1a5c
@ -39,12 +39,12 @@ export class NotificationsComponent extends AutoUnsubscribe implements OnInit {
|
|||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.notifications$ = this._notifications$.asObservable().pipe(shareLast());
|
this.notifications$ = this._notifications$.asObservable().pipe(shareLast());
|
||||||
this.groupedNotifications$ = this.notifications$.pipe(map(notifications => this._groupNotifications(notifications)));
|
this.groupedNotifications$ = this._groupedNotifications$;
|
||||||
this.hasUnreadNotifications$ = this.notifications$.pipe(
|
this.hasUnreadNotifications$ = this._hasUnreadNotifications$;
|
||||||
map(notifications => notifications.filter(n => !n.readDate).length > 0),
|
}
|
||||||
distinctUntilChanged(),
|
|
||||||
shareLast(),
|
async ngOnInit(): Promise<void> {
|
||||||
);
|
await this._loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
@ -58,6 +58,14 @@ export class NotificationsComponent extends AutoUnsubscribe implements OnInit {
|
|||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private get _hasUnreadNotifications$(): Observable<boolean> {
|
||||||
|
return this.notifications$.pipe(
|
||||||
|
map(notifications => notifications.filter(n => !n.readDate).length > 0),
|
||||||
|
distinctUntilChanged(),
|
||||||
|
shareLast(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async markRead($event, notifications: List<string> = this._notifications$.getValue().map(n => n.id), isRead = true): Promise<void> {
|
async markRead($event, notifications: List<string> = this._notifications$.getValue().map(n => n.id), isRead = true): Promise<void> {
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise();
|
await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise();
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import { ReportTemplateService } from '@services/report-template.service';
|
|||||||
export class AddDossierDialogComponent {
|
export class AddDossierDialogComponent {
|
||||||
readonly iconButtonTypes = IconButtonTypes;
|
readonly iconButtonTypes = IconButtonTypes;
|
||||||
|
|
||||||
dossierForm: FormGroup;
|
readonly dossierForm: FormGroup;
|
||||||
hasDueDate = false;
|
hasDueDate = false;
|
||||||
downloadTypes: { key: DownloadFileType; label: string }[] = ['ORIGINAL', 'PREVIEW', 'REDACTED'].map((type: DownloadFileType) => ({
|
downloadTypes: { key: DownloadFileType; label: string }[] = ['ORIGINAL', 'PREVIEW', 'REDACTED'].map((type: DownloadFileType) => ({
|
||||||
key: type,
|
key: type,
|
||||||
@ -33,7 +33,11 @@ export class AddDossierDialogComponent {
|
|||||||
readonly dialogRef: MatDialogRef<AddDossierDialogComponent>,
|
readonly dialogRef: MatDialogRef<AddDossierDialogComponent>,
|
||||||
) {
|
) {
|
||||||
this._getDossierTemplates();
|
this._getDossierTemplates();
|
||||||
this.dossierForm = this._formBuilder.group(
|
this.dossierForm = this._getForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
|
return this._formBuilder.group(
|
||||||
{
|
{
|
||||||
dossierName: [null, Validators.required],
|
dossierName: [null, Validators.required],
|
||||||
dossierTemplateId: [null, Validators.required],
|
dossierTemplateId: [null, Validators.required],
|
||||||
|
|||||||
@ -57,6 +57,14 @@ export class ChangeLegalBasisDialogComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
|
this.isDocumentAdmin = this._permissionsService.isApprover();
|
||||||
|
return this._formBuilder.group({
|
||||||
|
reason: [null, Validators.required],
|
||||||
|
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
save() {
|
save() {
|
||||||
this.dialogRef.close({
|
this.dialogRef.close({
|
||||||
legalBasis: this.legalBasisForm.get('reason').value.legalBasis,
|
legalBasis: this.legalBasisForm.get('reason').value.legalBasis,
|
||||||
|
|||||||
@ -10,16 +10,17 @@
|
|||||||
icon="red:attribute"
|
icon="red:attribute"
|
||||||
></iqser-empty-state>
|
></iqser-empty-state>
|
||||||
|
|
||||||
<div *ngFor="let attr of customAttributes" [class.datepicker-wrapper]="isDate(attr)" class="iqser-input-group">
|
<div *ngFor="let attr of customAttributes" [class.datepicker-wrapper]="isSpecificType(attr, dossierAttributeConfigTypes.DATE)"
|
||||||
|
class="iqser-input-group">
|
||||||
<label>{{ attr.label }}</label>
|
<label>{{ attr.label }}</label>
|
||||||
<input
|
<input
|
||||||
*ngIf="isNumber(attr) || isText(attr)"
|
*ngIf="isSpecificType(attr, dossierAttributeConfigTypes.NUMBER) || isSpecificType(attr, dossierAttributeConfigTypes.TEXT)"
|
||||||
[formControlName]="attr.id"
|
[formControlName]="attr.id"
|
||||||
[name]="attr.id"
|
[name]="attr.id"
|
||||||
[type]="isNumber(attr) ? 'number' : 'text'"
|
[type]="isSpecificType(attr, dossierAttributeConfigTypes.NUMBER) ? 'number' : 'text'"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ng-container *ngIf="isDate(attr)">
|
<ng-container *ngIf="isSpecificType(attr, dossierAttributeConfigTypes.DATE)">
|
||||||
<input [formControlName]="attr.id" [matDatepicker]="picker" placeholder="dd/mm/yy"/>
|
<input [formControlName]="attr.id" [matDatepicker]="picker" placeholder="dd/mm/yy"/>
|
||||||
<mat-datepicker-toggle [for]="picker" matSuffix>
|
<mat-datepicker-toggle [for]="picker" matSuffix>
|
||||||
<mat-icon matDatepickerToggleIcon svgIcon="red:calendar"></mat-icon>
|
<mat-icon matDatepickerToggleIcon svgIcon="red:calendar"></mat-icon>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
|
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
|
||||||
import { EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
import { EditDossierSectionInterface } from '../edit-dossier-section.interface';
|
||||||
import { Dossier, DossierAttributeWithValue } from '@red/domain';
|
import {Dossier, DossierAttributeConfigType, DossierAttributeConfigTypes, DossierAttributeWithValue} from '@red/domain';
|
||||||
import { PermissionsService } from '@services/permissions.service';
|
import { PermissionsService } from '@services/permissions.service';
|
||||||
import { CircleButtonTypes, IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
import { CircleButtonTypes, IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
||||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
@ -15,6 +15,7 @@ import { DossierAttributesService } from '@shared/services/controller-wrappers/d
|
|||||||
export class EditDossierAttributesComponent implements EditDossierSectionInterface, OnInit {
|
export class EditDossierAttributesComponent implements EditDossierSectionInterface, OnInit {
|
||||||
readonly iconButtonTypes = IconButtonTypes;
|
readonly iconButtonTypes = IconButtonTypes;
|
||||||
readonly circleButtonTypes = CircleButtonTypes;
|
readonly circleButtonTypes = CircleButtonTypes;
|
||||||
|
readonly dossierAttributeConfigTypes = DossierAttributeConfigTypes;
|
||||||
|
|
||||||
@Input() dossier: Dossier;
|
@Input() dossier: Dossier;
|
||||||
@Output() readonly updateDossier = new EventEmitter();
|
@Output() readonly updateDossier = new EventEmitter();
|
||||||
@ -34,7 +35,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
|||||||
|
|
||||||
get changed() {
|
get changed() {
|
||||||
for (const attr of this.attributes) {
|
for (const attr of this.attributes) {
|
||||||
if (this.isDate(attr) && attr.value) {
|
if (this.isSpecificType(attr, this.dossierAttributeConfigTypes.DATE) && attr.value) {
|
||||||
if (!moment(attr.value).isSame(moment(this.currentAttrValue(attr)))) {
|
if (!moment(attr.value).isSame(moment(this.currentAttrValue(attr)))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -75,20 +76,8 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
|||||||
this._getFileInputById(attr.id).nativeElement.click();
|
this._getFileInputById(attr.id).nativeElement.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
isNumber(attr: DossierAttributeWithValue): boolean {
|
isSpecificType(attr: DossierAttributeWithValue, type: DossierAttributeConfigType): boolean {
|
||||||
return attr.type === 'NUMBER';
|
return attr.type === type;
|
||||||
}
|
|
||||||
|
|
||||||
isDate(attr: DossierAttributeWithValue): boolean {
|
|
||||||
return attr.type === 'DATE';
|
|
||||||
}
|
|
||||||
|
|
||||||
isImage(attr: DossierAttributeWithValue): boolean {
|
|
||||||
return attr.type === 'IMAGE';
|
|
||||||
}
|
|
||||||
|
|
||||||
isText(attr: DossierAttributeWithValue): boolean {
|
|
||||||
return attr.type === 'TEXT';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadImage($event, attr: DossierAttributeWithValue) {
|
async uploadImage($event, attr: DossierAttributeWithValue) {
|
||||||
@ -132,8 +121,8 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
|||||||
|
|
||||||
private async _loadAttributes() {
|
private async _loadAttributes() {
|
||||||
this.attributes = await this._dossierAttributesService.getWithValues(this.dossier);
|
this.attributes = await this._dossierAttributesService.getWithValues(this.dossier);
|
||||||
this.customAttributes = this.attributes.filter(attr => !this.isImage(attr));
|
this.customAttributes = this.attributes.filter(attr => !this.isSpecificType(attr, this.dossierAttributeConfigTypes.IMAGE));
|
||||||
this.imageAttributes = this.attributes.filter(attr => this.isImage(attr));
|
this.imageAttributes = this.attributes.filter(attr => this.isSpecificType(attr, this.dossierAttributeConfigTypes.IMAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _initForm() {
|
private _initForm() {
|
||||||
|
|||||||
@ -67,7 +67,11 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS
|
|||||||
this.availableReportTypes =
|
this.availableReportTypes =
|
||||||
(await this._reportTemplateController.getAvailableReportTemplates(this.dossier.dossierTemplateId).toPromise()) || [];
|
(await this._reportTemplateController.getAvailableReportTemplates(this.dossier.dossierTemplateId).toPromise()) || [];
|
||||||
|
|
||||||
this.dossierForm = this._formBuilder.group(
|
this.dossierForm = this._getForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
|
return this._formBuilder.group(
|
||||||
{
|
{
|
||||||
reportTemplateIds: [this.dossier.reportTemplateIds],
|
reportTemplateIds: [this.dossier.reportTemplateIds],
|
||||||
downloadFileTypes: [this.dossier.downloadFileTypes],
|
downloadFileTypes: [this.dossier.downloadFileTypes],
|
||||||
|
|||||||
@ -68,7 +68,12 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this._filterInvalidDossierTemplates();
|
this._filterInvalidDossierTemplates();
|
||||||
this.dossierForm = this._formBuilder.group({
|
this.dossierForm = this._getForm();
|
||||||
|
this.hasDueDate = !!this.dossier.dueDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
|
return this._formBuilder.group({
|
||||||
dossierName: [this.dossier.dossierName, Validators.required],
|
dossierName: [this.dossier.dossierName, Validators.required],
|
||||||
dossierTemplateId: [
|
dossierTemplateId: [
|
||||||
{
|
{
|
||||||
@ -82,7 +87,6 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
|||||||
watermarkEnabled: [this.dossier.watermarkEnabled],
|
watermarkEnabled: [this.dossier.watermarkEnabled],
|
||||||
watermarkPreviewEnabled: [this.dossier.watermarkPreviewEnabled],
|
watermarkPreviewEnabled: [this.dossier.watermarkPreviewEnabled],
|
||||||
});
|
});
|
||||||
this.hasDueDate = !!this.dossier.dueDate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
revert() {
|
revert() {
|
||||||
|
|||||||
@ -38,9 +38,13 @@ export class ForceRedactionDialogComponent implements OnInit {
|
|||||||
public dialogRef: MatDialogRef<ForceRedactionDialogComponent>,
|
public dialogRef: MatDialogRef<ForceRedactionDialogComponent>,
|
||||||
@Inject(MAT_DIALOG_DATA) private readonly _data: { readonly dossier: Dossier },
|
@Inject(MAT_DIALOG_DATA) private readonly _data: { readonly dossier: Dossier },
|
||||||
) {
|
) {
|
||||||
|
this.redactionForm = this._getForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
this.isDocumentAdmin = this._permissionsService.isApprover(this._data.dossier);
|
||||||
|
|
||||||
this.redactionForm = this._formBuilder.group({
|
return this._formBuilder.group({
|
||||||
reason: [null, Validators.required],
|
reason: [null, Validators.required],
|
||||||
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
||||||
});
|
});
|
||||||
|
|||||||
@ -44,21 +44,33 @@ export class ManualAnnotationDialogComponent implements OnInit {
|
|||||||
this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
|
this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE';
|
||||||
this.isDictionaryRequest = this.data.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest;
|
this.isDictionaryRequest = this.data.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest;
|
||||||
|
|
||||||
this.redactionForm = this._formBuilder.group({
|
this.redactionForm = this._getForm();
|
||||||
|
|
||||||
|
this.redactionDictionaries = this._redactionDictionaries;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _getForm(): FormGroup {
|
||||||
|
return this._formBuilder.group({
|
||||||
reason: this.isDictionaryRequest ? [null] : [null, Validators.required],
|
reason: this.isDictionaryRequest ? [null] : [null, Validators.required],
|
||||||
dictionary: this.isDictionaryRequest
|
dictionary: this.isDictionaryRequest
|
||||||
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
|
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
|
||||||
: ['manual', Validators.required],
|
: ['manual', Validators.required],
|
||||||
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
comment: this.isDocumentAdmin ? [null] : [null, Validators.required],
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private get _redactionDictionaries(): Dictionary[] {
|
||||||
|
const redactionDictionaries: Dictionary[] = [];
|
||||||
|
|
||||||
for (const key of Object.keys(this._appStateService.dictionaryData[data.dossier.dossierTemplateId])) {
|
for (const key of Object.keys(this._appStateService.dictionaryData[data.dossier.dossierTemplateId])) {
|
||||||
const dictionaryData = this._appStateService.getDictionary(key, data.dossier.dossierTemplateId);
|
const dictionaryData = this._appStateService.getDictionary(key, data.dossier.dossierTemplateId);
|
||||||
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
|
if (!dictionaryData.virtual && dictionaryData.addToDictionaryAction) {
|
||||||
this.redactionDictionaries.push(dictionaryData);
|
redactionDictionaries.push(dictionaryData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.redactionDictionaries.sort((a, b) => a.label.localeCompare(b.label));
|
redactionDictionaries.sort((a, b) => a.label.localeCompare(b.label));
|
||||||
|
|
||||||
|
return redactionDictionaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user