_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();
|
||||
this.notifications$ = this._notifications$.asObservable().pipe(shareLast());
|
||||
this.groupedNotifications$ = this.notifications$.pipe(map(notifications => this._groupNotifications(notifications)));
|
||||
this.hasUnreadNotifications$ = this.notifications$.pipe(
|
||||
map(notifications => notifications.filter(n => !n.readDate).length > 0),
|
||||
distinctUntilChanged(),
|
||||
shareLast(),
|
||||
);
|
||||
this.groupedNotifications$ = this._groupedNotifications$;
|
||||
this.hasUnreadNotifications$ = this._hasUnreadNotifications$;
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
await this._loadData();
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
@ -58,6 +58,14 @@ export class NotificationsComponent extends AutoUnsubscribe implements OnInit {
|
||||
.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> {
|
||||
$event.stopPropagation();
|
||||
await this._notificationsService.toggleNotificationRead(notifications, isRead).toPromise();
|
||||
|
||||
@ -16,7 +16,7 @@ import { ReportTemplateService } from '@services/report-template.service';
|
||||
export class AddDossierDialogComponent {
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
|
||||
dossierForm: FormGroup;
|
||||
readonly dossierForm: FormGroup;
|
||||
hasDueDate = false;
|
||||
downloadTypes: { key: DownloadFileType; label: string }[] = ['ORIGINAL', 'PREVIEW', 'REDACTED'].map((type: DownloadFileType) => ({
|
||||
key: type,
|
||||
@ -33,7 +33,11 @@ export class AddDossierDialogComponent {
|
||||
readonly dialogRef: MatDialogRef<AddDossierDialogComponent>,
|
||||
) {
|
||||
this._getDossierTemplates();
|
||||
this.dossierForm = this._formBuilder.group(
|
||||
this.dossierForm = this._getForm();
|
||||
}
|
||||
|
||||
private _getForm(): FormGroup {
|
||||
return this._formBuilder.group(
|
||||
{
|
||||
dossierName: [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() {
|
||||
this.dialogRef.close({
|
||||
legalBasis: this.legalBasisForm.get('reason').value.legalBasis,
|
||||
|
||||
@ -10,17 +10,18 @@
|
||||
icon="red:attribute"
|
||||
></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>
|
||||
<input
|
||||
*ngIf="isNumber(attr) || isText(attr)"
|
||||
*ngIf="isSpecificType(attr, dossierAttributeConfigTypes.NUMBER) || isSpecificType(attr, dossierAttributeConfigTypes.TEXT)"
|
||||
[formControlName]="attr.id"
|
||||
[name]="attr.id"
|
||||
[type]="isNumber(attr) ? 'number' : 'text'"
|
||||
[type]="isSpecificType(attr, dossierAttributeConfigTypes.NUMBER) ? 'number' : 'text'"
|
||||
/>
|
||||
|
||||
<ng-container *ngIf="isDate(attr)">
|
||||
<input [formControlName]="attr.id" [matDatepicker]="picker" placeholder="dd/mm/yy" />
|
||||
<ng-container *ngIf="isSpecificType(attr, dossierAttributeConfigTypes.DATE)">
|
||||
<input [formControlName]="attr.id" [matDatepicker]="picker" placeholder="dd/mm/yy"/>
|
||||
<mat-datepicker-toggle [for]="picker" matSuffix>
|
||||
<mat-icon matDatepickerToggleIcon svgIcon="red:calendar"></mat-icon>
|
||||
</mat-datepicker-toggle>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
|
||||
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 { CircleButtonTypes, IconButtonTypes, LoadingService } from '@iqser/common-ui';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
@ -15,6 +15,7 @@ import { DossierAttributesService } from '@shared/services/controller-wrappers/d
|
||||
export class EditDossierAttributesComponent implements EditDossierSectionInterface, OnInit {
|
||||
readonly iconButtonTypes = IconButtonTypes;
|
||||
readonly circleButtonTypes = CircleButtonTypes;
|
||||
readonly dossierAttributeConfigTypes = DossierAttributeConfigTypes;
|
||||
|
||||
@Input() dossier: Dossier;
|
||||
@Output() readonly updateDossier = new EventEmitter();
|
||||
@ -34,7 +35,7 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
||||
|
||||
get changed() {
|
||||
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)))) {
|
||||
return true;
|
||||
}
|
||||
@ -75,20 +76,8 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
||||
this._getFileInputById(attr.id).nativeElement.click();
|
||||
}
|
||||
|
||||
isNumber(attr: DossierAttributeWithValue): boolean {
|
||||
return attr.type === 'NUMBER';
|
||||
}
|
||||
|
||||
isDate(attr: DossierAttributeWithValue): boolean {
|
||||
return attr.type === 'DATE';
|
||||
}
|
||||
|
||||
isImage(attr: DossierAttributeWithValue): boolean {
|
||||
return attr.type === 'IMAGE';
|
||||
}
|
||||
|
||||
isText(attr: DossierAttributeWithValue): boolean {
|
||||
return attr.type === 'TEXT';
|
||||
isSpecificType(attr: DossierAttributeWithValue, type: DossierAttributeConfigType): boolean {
|
||||
return attr.type === type;
|
||||
}
|
||||
|
||||
async uploadImage($event, attr: DossierAttributeWithValue) {
|
||||
@ -132,8 +121,8 @@ export class EditDossierAttributesComponent implements EditDossierSectionInterfa
|
||||
|
||||
private async _loadAttributes() {
|
||||
this.attributes = await this._dossierAttributesService.getWithValues(this.dossier);
|
||||
this.customAttributes = this.attributes.filter(attr => !this.isImage(attr));
|
||||
this.imageAttributes = 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.isSpecificType(attr, this.dossierAttributeConfigTypes.IMAGE));
|
||||
}
|
||||
|
||||
private _initForm() {
|
||||
|
||||
@ -67,7 +67,11 @@ export class EditDossierDownloadPackageComponent implements OnInit, EditDossierS
|
||||
this.availableReportTypes =
|
||||
(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],
|
||||
downloadFileTypes: [this.dossier.downloadFileTypes],
|
||||
|
||||
@ -68,7 +68,12 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
|
||||
ngOnInit() {
|
||||
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],
|
||||
dossierTemplateId: [
|
||||
{
|
||||
@ -82,7 +87,6 @@ export class EditDossierGeneralInfoComponent implements OnInit, EditDossierSecti
|
||||
watermarkEnabled: [this.dossier.watermarkEnabled],
|
||||
watermarkPreviewEnabled: [this.dossier.watermarkPreviewEnabled],
|
||||
});
|
||||
this.hasDueDate = !!this.dossier.dueDate;
|
||||
}
|
||||
|
||||
revert() {
|
||||
|
||||
@ -38,9 +38,13 @@ export class ForceRedactionDialogComponent implements OnInit {
|
||||
public dialogRef: MatDialogRef<ForceRedactionDialogComponent>,
|
||||
@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.redactionForm = this._formBuilder.group({
|
||||
return this._formBuilder.group({
|
||||
reason: [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.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],
|
||||
dictionary: this.isDictionaryRequest
|
||||
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
|
||||
: ['manual', 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])) {
|
||||
const dictionaryData = this._appStateService.getDictionary(key, data.dossier.dossierTemplateId);
|
||||
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() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user