RED-6778, add dossier only toggle.
This commit is contained in:
parent
62dc457476
commit
94f36a1494
@ -84,15 +84,39 @@
|
||||
</mat-slide-toggle>
|
||||
</div>
|
||||
|
||||
<div *ngIf="form.get('caseSensitive')" class="iqser-input-group">
|
||||
<mat-checkbox color="primary" formControlName="caseSensitive" name="caseSensitive">
|
||||
{{ 'add-edit-entity.form.case-sensitive' | translate }}
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
<div *ngIf="form.get('hasDictionary')?.value" class="dictionary-extras">
|
||||
<ng-container *deny="roles.getRss">
|
||||
<span
|
||||
(click)="toggleDossierOnlyEntity()"
|
||||
*ngIf="form.get('dossierDictionaryOnly') as field"
|
||||
[class.cursor-pointer]="!field.disabled"
|
||||
[class.disabled]="field.disabled"
|
||||
class="round-checkbox-form-entry"
|
||||
>
|
||||
<iqser-round-checkbox [active]="!field.value" [size]="18"></iqser-round-checkbox>
|
||||
{{ 'add-edit-entity.form.template-and-dossier-dictionaries' | translate }}
|
||||
</span>
|
||||
<span
|
||||
(click)="toggleDossierOnlyEntity()"
|
||||
*ngIf="form.get('dossierDictionaryOnly') as field"
|
||||
[class.cursor-pointer]="!field.disabled"
|
||||
[class.disabled]="field.disabled"
|
||||
class="round-checkbox-form-entry"
|
||||
>
|
||||
<iqser-round-checkbox [active]="field.value" [size]="18"></iqser-round-checkbox>
|
||||
{{ 'add-edit-entity.form.dossier-dictionary-only' | translate }}
|
||||
</span>
|
||||
</ng-container>
|
||||
|
||||
<div *ngIf="form.get('addToDictionaryAction')" class="iqser-input-group">
|
||||
<mat-checkbox color="primary" formControlName="addToDictionaryAction" name="addToDictionaryAction">
|
||||
{{ 'add-edit-entity.form.add-to-dictionary-action' | translate }}
|
||||
</mat-checkbox>
|
||||
<div *ngIf="form.get('manageEntriesInDictionaryEditorOnly')" class="iqser-input-group">
|
||||
<mat-checkbox color="primary" formControlName="manageEntriesInDictionaryEditorOnly" name="manageEntriesInDictionaryEditorOnly">
|
||||
{{ 'add-edit-entity.form.manage-entries-in-dictionary-editor-only' | translate }}
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
<div *ngIf="form.get('caseSensitive')" class="iqser-input-group">
|
||||
<mat-checkbox color="primary" formControlName="caseSensitive" name="caseSensitive">
|
||||
{{ 'add-edit-entity.form.case-sensitive' | translate }}
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -9,3 +9,27 @@
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.dictionary-extras {
|
||||
margin-left: 38px;
|
||||
margin-top: 14px;
|
||||
|
||||
.round-checkbox-form-entry:first-of-type {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.round-checkbox-form-entry {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 20px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.disabled {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import { PermissionsService } from '@services/permissions.service';
|
||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||
import { DictionaryService } from '@services/entity-services/dictionary.service';
|
||||
import { BaseFormComponent, LoadingService, Toaster } from '@iqser/common-ui';
|
||||
import { Roles } from '@users/roles';
|
||||
|
||||
const REDACTION_FIELDS = ['defaultReason'];
|
||||
|
||||
@ -35,6 +36,7 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
technicalName$: Observable<string>;
|
||||
|
||||
colors: Color[];
|
||||
readonly roles = Roles;
|
||||
|
||||
constructor(
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
@ -48,10 +50,6 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
super();
|
||||
}
|
||||
|
||||
cpDisabled(color: Color) {
|
||||
return this.form.get(color.controlName).disabled;
|
||||
}
|
||||
|
||||
get #isDossierRedaction(): boolean {
|
||||
return this.entity?.type === 'dossier_redaction';
|
||||
}
|
||||
@ -60,26 +58,34 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
return !!this.entity?.systemManaged;
|
||||
}
|
||||
|
||||
get #addToDictionaryActionControl() {
|
||||
return { value: !!this.entity?.addToDictionaryAction, disabled: this.#isSystemManaged && !this.#isDossierRedaction };
|
||||
}
|
||||
|
||||
get #isHint(): boolean {
|
||||
return !!this.form.get('hint')?.value;
|
||||
}
|
||||
|
||||
cpDisabled(color: Color) {
|
||||
return this.form.get(color.controlName).disabled;
|
||||
}
|
||||
|
||||
revert(): void {
|
||||
this.form.patchValue(this.initialFormValue);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this._initializeForm();
|
||||
this.#initializeForm();
|
||||
}
|
||||
|
||||
toggleDossierOnlyEntity() {
|
||||
const propName = 'dossierDictionaryOnly';
|
||||
const control = this.form.get(propName);
|
||||
if (control.disabled) {
|
||||
return;
|
||||
}
|
||||
this.form.patchValue({ [propName]: !control?.value });
|
||||
}
|
||||
|
||||
async save(): Promise<void> {
|
||||
this._loadingService.start();
|
||||
const dictionary = this._formToObject();
|
||||
|
||||
const dictionary = this.#formToObject();
|
||||
try {
|
||||
if (this.entity) {
|
||||
// edit mode
|
||||
@ -108,26 +114,26 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
labelParams: () => ({ type: this.#isHint ? 'hint' : 'redaction' }),
|
||||
placeholder: _('add-edit-entity.form.color-placeholder'),
|
||||
controlName: 'hexColor',
|
||||
hasColor$: this._colorEmpty$(form, 'hexColor'),
|
||||
hasColor$: this.#colorEmpty$(form, 'hexColor'),
|
||||
},
|
||||
{
|
||||
label: _('add-edit-entity.form.color'),
|
||||
labelParams: () => ({ type: 'recommendation' }),
|
||||
placeholder: _('add-edit-entity.form.color-placeholder'),
|
||||
controlName: 'recommendationHexColor',
|
||||
hasColor$: this._colorEmpty$(form, 'recommendationHexColor'),
|
||||
hasColor$: this.#colorEmpty$(form, 'recommendationHexColor'),
|
||||
},
|
||||
{
|
||||
label: _('add-edit-entity.form.color'),
|
||||
labelParams: () => ({ type: this.#isHint ? 'ignored' : 'skipped' }),
|
||||
placeholder: _('add-edit-entity.form.color-placeholder'),
|
||||
controlName: 'skippedHexColor',
|
||||
hasColor$: this._colorEmpty$(form, 'skippedHexColor'),
|
||||
hasColor$: this.#colorEmpty$(form, 'skippedHexColor'),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
private _initializeForm(): void {
|
||||
#initializeForm(): void {
|
||||
let controlsConfig: Record<string, any> = {
|
||||
label: [this.entity?.label, [Validators.required, Validators.minLength(3)]],
|
||||
hexColor: [this.entity?.hexColor, [Validators.required, Validators.minLength(7)]],
|
||||
@ -143,26 +149,28 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
rank: [{ value: this.entity?.rank, disabled: this.#isSystemManaged }, Validators.required],
|
||||
hint: [{ value: !!this.entity?.hint, disabled: this.#isSystemManaged }],
|
||||
hasDictionary: [{ value: !!this.entity?.hasDictionary, disabled: this.#isSystemManaged }],
|
||||
caseSensitive: [{ value: this.entity ? !this.entity.caseInsensitive : false, disabled: this.#isSystemManaged }],
|
||||
dossierDictionaryOnly: [{ value: !!this.entity?.dossierDictionaryOnly, disabled: this.#isSystemManaged || this.entity }],
|
||||
caseSensitive: [{ value: !!this.entity?.caseInsensitive, disabled: this.#isSystemManaged }],
|
||||
manageEntriesInDictionaryEditorOnly: [
|
||||
{
|
||||
value: !this.entity?.addToDictionaryAction,
|
||||
disabled: this.#isSystemManaged && !this.#isDossierRedaction,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (!this.entity?.hint && !this.#isDossierRedaction) {
|
||||
Object.assign(controlsConfig, {
|
||||
controlsConfig = {
|
||||
...controlsConfig,
|
||||
defaultReason: [{ value: null, disabled: true }],
|
||||
});
|
||||
}
|
||||
|
||||
if (this.entity?.hasDictionary || this.#isDossierRedaction) {
|
||||
Object.assign(controlsConfig, {
|
||||
addToDictionaryAction: [this.#addToDictionaryActionControl],
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const form = this._formBuilder.group(controlsConfig);
|
||||
|
||||
this.#initializeColors(form);
|
||||
this.technicalName$ = form.get('label').valueChanges.pipe(map((value: string) => this._toTechnicalName(value)));
|
||||
this.technicalName$ = form.get('label').valueChanges.pipe(map((value: string) => this.#toTechnicalName(value)));
|
||||
|
||||
if (!this.#isDossierRedaction) {
|
||||
form.get('hint').valueChanges.subscribe(isHint => {
|
||||
@ -173,17 +181,9 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
}
|
||||
});
|
||||
|
||||
form.get('hasDictionary').valueChanges.subscribe(hasDictionary => {
|
||||
if (hasDictionary) {
|
||||
form.addControl('addToDictionaryAction', new UntypedFormControl(this.#addToDictionaryActionControl));
|
||||
} else {
|
||||
form.removeControl('addToDictionaryAction');
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.entity) {
|
||||
form.get('label').valueChanges.subscribe((label: string) => {
|
||||
form.get('type').setValue(this._toTechnicalName(label));
|
||||
form.get('type').setValue(this.#toTechnicalName(label));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
private _toTechnicalName(value: string) {
|
||||
#toTechnicalName(value: string) {
|
||||
const existingTechnicalNames = this._dictionariesMapService.get(this.dossierTemplateId).map(dict => dict.type);
|
||||
const baseTechnicalName = toSnakeCase(value.trim());
|
||||
let technicalName = baseTechnicalName.replaceAll(/[^A-Za-z0-9_-]/g, '');
|
||||
@ -211,19 +211,20 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
return technicalName;
|
||||
}
|
||||
|
||||
private _colorEmpty$(form: UntypedFormGroup, field: string) {
|
||||
#colorEmpty$(form: UntypedFormGroup, field: string) {
|
||||
return form.get(field).valueChanges.pipe(
|
||||
startWith(form.get(field).value),
|
||||
map((value: string) => !value || value?.length === 0),
|
||||
);
|
||||
}
|
||||
|
||||
private _formToObject(): IDictionary {
|
||||
#formToObject(): IDictionary {
|
||||
// Fields which aren't set for hints, need additional check
|
||||
const addToDictionaryAction = !!this.form.get('addToDictionaryAction')?.value;
|
||||
const addToDictionaryAction = !this.form.get('manageEntriesInDictionaryEditorOnly')?.value;
|
||||
const hasDictionary = !!this.form.get('hasDictionary')?.value;
|
||||
const dossierDictionaryOnly = !!this.form.get('dossierDictionaryOnly')?.value;
|
||||
|
||||
let entity = {
|
||||
const entity = {
|
||||
...this.entity,
|
||||
label: this.form.get('label').value,
|
||||
hexColor: this.form.get('hexColor').value,
|
||||
@ -231,10 +232,11 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
|
||||
skippedHexColor: this.form.get('skippedHexColor').value,
|
||||
dossierTemplateId: this.dossierTemplateId,
|
||||
addToDictionaryAction,
|
||||
dossierDictionaryOnly,
|
||||
};
|
||||
|
||||
if (this.entity?.type !== 'dossier_redaction') {
|
||||
entity = {
|
||||
return {
|
||||
...entity,
|
||||
type: this.form.get('type').value,
|
||||
description: this.form.get('description').value,
|
||||
|
||||
@ -15,6 +15,7 @@ import {
|
||||
IqserAllowDirective,
|
||||
IqserDenyDirective,
|
||||
IqserHelpModeModule,
|
||||
RoundCheckboxComponent,
|
||||
StopPropagationDirective,
|
||||
} from '@iqser/common-ui';
|
||||
import { NavigateLastDossiersScreenDirective } from './directives/navigate-last-dossiers-screen.directive';
|
||||
@ -98,6 +99,7 @@ const deleteThisWhenAllComponentsAreStandalone = [DonutChartComponent];
|
||||
IqserAllowDirective,
|
||||
IqserDenyDirective,
|
||||
SelectComponent,
|
||||
RoundCheckboxComponent,
|
||||
],
|
||||
exports: [...modules, ...components, ...utils, ...deleteThisWhenAllComponentsAreStandalone],
|
||||
providers: [
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
{
|
||||
"ADMIN_CONTACT_NAME": null,
|
||||
"ADMIN_CONTACT_URL": null,
|
||||
"API_URL": "https://dev-04.iqser.cloud",
|
||||
"APP_NAME": "DocuMine",
|
||||
"IS_DOCUMINE": true,
|
||||
"API_URL": "https://dan.iqser.cloud",
|
||||
"APP_NAME": "RedactManager",
|
||||
"IS_DOCUMINE": false,
|
||||
"AUTO_READ_TIME": 3,
|
||||
"BACKEND_APP_VERSION": "4.4.40",
|
||||
"EULA_URL": "EULA_URL",
|
||||
@ -12,13 +12,13 @@
|
||||
"MAX_RETRIES_ON_SERVER_ERROR": 3,
|
||||
"OAUTH_CLIENT_ID": "redaction",
|
||||
"OAUTH_IDP_HINT": null,
|
||||
"OAUTH_URL": "https://dev-04.iqser.cloud/auth",
|
||||
"OAUTH_URL": "https://dan.iqser.cloud/auth",
|
||||
"RECENT_PERIOD_IN_HOURS": 24,
|
||||
"SELECTION_MODE": "structural",
|
||||
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",
|
||||
"ANNOTATIONS_THRESHOLD": 1000,
|
||||
"THEME": "scm",
|
||||
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/scm/",
|
||||
"THEME": "redact",
|
||||
"BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/redact/",
|
||||
"AVAILABLE_NOTIFICATIONS_DAYS": 30,
|
||||
"AVAILABLE_OLD_NOTIFICATIONS_MINUTES": 60,
|
||||
"NOTIFICATIONS_THRESHOLD": 1000,
|
||||
|
||||
@ -118,7 +118,6 @@
|
||||
"invalid-color-or-rank": ""
|
||||
},
|
||||
"form": {
|
||||
"add-to-dictionary-action": "",
|
||||
"case-sensitive": "",
|
||||
"color": "",
|
||||
"color-placeholder": "",
|
||||
@ -126,15 +125,19 @@
|
||||
"default-reason-placeholder": "",
|
||||
"description": "",
|
||||
"description-placeholder": "",
|
||||
"dossier-dictionary-only": "",
|
||||
"has-dictionary": "",
|
||||
"hint": "",
|
||||
"linked-to-global-entity": "",
|
||||
"manage-entries-in-dictionary-editor-only": "",
|
||||
"name": "",
|
||||
"name-placeholder": "",
|
||||
"rank": "",
|
||||
"rank-placeholder": "",
|
||||
"redaction": "",
|
||||
"technical-name": "",
|
||||
"technical-name-hint": ""
|
||||
"technical-name-hint": "",
|
||||
"template-and-dossier-dictionaries": ""
|
||||
},
|
||||
"success": {
|
||||
"create": "",
|
||||
|
||||
@ -118,7 +118,6 @@
|
||||
"invalid-color-or-rank": "Invalid color or rank! Rank is already used by another entity or the color is not a valid hexColor!"
|
||||
},
|
||||
"form": {
|
||||
"add-to-dictionary-action": "Enable 'Add to dictionary'",
|
||||
"case-sensitive": "Case Sensitive",
|
||||
"color": "{type, select, redaction{Redaction} hint{Hint} recommendation{Recommendation} skipped{Skipped Redaction} ignored{Ignored Hint} other{}} Color",
|
||||
"color-placeholder": "#",
|
||||
@ -126,15 +125,19 @@
|
||||
"default-reason-placeholder": "No Default Reason",
|
||||
"description": "Description",
|
||||
"description-placeholder": "Enter Description",
|
||||
"dossier-dictionary-only": "Dossier dictionary only",
|
||||
"has-dictionary": "Has dictionary",
|
||||
"hint": "Hint",
|
||||
"linked-to-global-entity": "Linked to global entity",
|
||||
"manage-entries-in-dictionary-editor-only": "Manage entries in Dictionary editor only",
|
||||
"name": "Display Name",
|
||||
"name-placeholder": "Enter Name",
|
||||
"rank": "Rank",
|
||||
"rank-placeholder": "1000",
|
||||
"redaction": "Redaction",
|
||||
"technical-name": "Technical Name",
|
||||
"technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}"
|
||||
"technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}",
|
||||
"template-and-dossier-dictionaries": "Template & dossier dictionaries"
|
||||
},
|
||||
"success": {
|
||||
"create": "Entity added!",
|
||||
|
||||
@ -118,7 +118,6 @@
|
||||
"invalid-color-or-rank": ""
|
||||
},
|
||||
"form": {
|
||||
"add-to-dictionary-action": "",
|
||||
"case-sensitive": "",
|
||||
"color": "",
|
||||
"color-placeholder": "",
|
||||
@ -126,15 +125,19 @@
|
||||
"default-reason-placeholder": "",
|
||||
"description": "",
|
||||
"description-placeholder": "",
|
||||
"dossier-dictionary-only": "",
|
||||
"has-dictionary": "",
|
||||
"hint": "",
|
||||
"linked-to-global-entity": "",
|
||||
"manage-entries-in-dictionary-editor-only": "",
|
||||
"name": "",
|
||||
"name-placeholder": "",
|
||||
"rank": "",
|
||||
"rank-placeholder": "",
|
||||
"redaction": "",
|
||||
"technical-name": "",
|
||||
"technical-name-hint": ""
|
||||
"technical-name-hint": "",
|
||||
"template-and-dossier-dictionaries": ""
|
||||
},
|
||||
"success": {
|
||||
"create": "",
|
||||
|
||||
@ -118,7 +118,6 @@
|
||||
"invalid-color-or-rank": "Invalid color or rank! Rank is already used by another entity or the color is not a valid hexColor!"
|
||||
},
|
||||
"form": {
|
||||
"add-to-dictionary-action": "Enable 'Add to dictionary'",
|
||||
"case-sensitive": "Case Sensitive",
|
||||
"color": "{type, select, redaction{Component} hint{Hint} recommendation{Recommendation} skipped{Skipped Component} ignored{Ignored Hint} other{}} Color",
|
||||
"color-placeholder": "#",
|
||||
@ -126,15 +125,19 @@
|
||||
"default-reason-placeholder": "No Default Reason",
|
||||
"description": "Description",
|
||||
"description-placeholder": "Enter Description",
|
||||
"dossier-dictionary-only": "",
|
||||
"has-dictionary": "Has dictionary",
|
||||
"hint": "Hint",
|
||||
"linked-to-global-entity": "",
|
||||
"manage-entries-in-dictionary-editor-only": "",
|
||||
"name": "Display Name",
|
||||
"name-placeholder": "Enter Name",
|
||||
"rank": "Rank",
|
||||
"rank-placeholder": "1000",
|
||||
"redaction": "Component",
|
||||
"technical-name": "Technical Name",
|
||||
"technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}"
|
||||
"technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}",
|
||||
"template-and-dossier-dictionaries": ""
|
||||
},
|
||||
"success": {
|
||||
"create": "Entity added!",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user