RED-4590: Fixed some sonar cube issues

This commit is contained in:
Adina Țeudan 2022-07-11 22:50:13 +03:00
parent bded45362f
commit ed8cb15687
20 changed files with 43 additions and 57 deletions

View File

@ -9,7 +9,6 @@ import { UserPreferenceService } from '@services/user-preference.service';
@Component({
selector: 'redaction-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
// ViewContainerRef needs to be injected for the color picker to work

View File

@ -103,7 +103,7 @@ export class BaseScreenComponent {
return !isDossierOverview;
}
trackByName(index: number, item: MenuItem) {
trackByName(_index: number, item: MenuItem) {
return item.name;
}

View File

@ -1,7 +1,7 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Observable } from 'rxjs';
import { IWatermark } from '@red/domain';
import { WatermarkService } from '../../services/entity-services/watermark.service';
import { WatermarkService } from '@services/entity-services/watermark.service';
import { mapEach, Required } from '@iqser/common-ui';
import { OptionWatermark } from '@components/dossier-watermark-selector/option-watermark.model';
import { map, tap } from 'rxjs/operators';
@ -27,14 +27,11 @@ export class DossierWatermarkSelectorComponent implements OnInit {
@Input() watermarkId: string | null;
@Input() previewWatermarkId: string | null;
@Output() readonly idsUpdate = new EventEmitter<UpdateWatermarkIdsEvent>();
watermarks$: Observable<OptionWatermark[]>;
readonly documentTypes = DocumentTypes;
#oldWatermarkId: string | null;
#oldPreviewWatermarkId: string | null;
watermarks$: Observable<OptionWatermark[]>;
readonly documentTypes = DocumentTypes;
constructor(private readonly _watermarkService: WatermarkService) {}
ngOnInit(): void {

View File

@ -18,7 +18,7 @@ export class DossierTemplateExistsGuard implements CanActivate {
if (dossiersListView) {
const dossierTemplateStats = this._dashboardStatsService.find(dossierTemplateId);
if (!dossierTemplateStats || (dossiersListView && dossierTemplateStats.isEmpty)) {
if (!dossierTemplateStats || dossierTemplateStats.isEmpty) {
await this._router.navigate(['']);
return false;
}

View File

@ -1,5 +1,5 @@
import { AnnotationWrapper } from './annotation.wrapper';
import { Dictionary, User } from '@red/domain';
import { Dictionary } from '@red/domain';
import { isArray } from 'lodash-es';
export class AnnotationPermissions {
@ -16,7 +16,7 @@ export class AnnotationPermissions {
canRecategorizeImage = true;
canForceHint = true;
static forUser(isApprover: boolean, user: User, annotations: AnnotationWrapper | AnnotationWrapper[], entities: Dictionary[]) {
static forUser(isApprover: boolean, annotations: AnnotationWrapper | AnnotationWrapper[], entities: Dictionary[]) {
if (!isArray(annotations)) {
annotations = [annotations];
}

View File

@ -103,7 +103,15 @@ export class AnnotationWrapper implements IListable, Record<string, unknown> {
}
get colorKey(): KeysOf<Dictionary> {
return this.isSkipped || this.isIgnoredHint ? 'skippedHexColor' : this.isRecommendation ? 'recommendationHexColor' : 'hexColor';
if (this.isSkipped || this.isIgnoredHint) {
return 'skippedHexColor';
}
if (this.isRecommendation) {
return 'recommendationHexColor';
}
return 'hexColor';
}
get isSkipped() {
@ -155,13 +163,19 @@ export class AnnotationWrapper implements IListable, Record<string, unknown> {
}
get iconShape(): AnnotationIconType {
return this.isRecommendation
? 'hexagon'
: this.isHint || this.isIgnoredHint
? 'circle'
: this.isSuggestion || this.isDeclinedSuggestion
? 'rhombus'
: 'square';
if (this.isRecommendation) {
return 'hexagon';
}
if (this.isHint || this.isIgnoredHint) {
return 'circle';
}
if (this.isSuggestion || this.isDeclinedSuggestion) {
return 'rhombus';
}
return 'square';
}
get isIgnoredHint() {
@ -446,8 +460,17 @@ export class AnnotationWrapper implements IListable, Record<string, unknown> {
switch (lastManualChange.annotationStatus) {
case LogEntryStatus.APPROVED:
return isHintDictionary ? SuperTypes.IgnoredHint : SuperTypes.Skipped;
case LogEntryStatus.DECLINED:
return isHintDictionary ? SuperTypes.Hint : redactionLogEntry.redacted ? SuperTypes.Redaction : SuperTypes.Skipped;
case LogEntryStatus.DECLINED: {
if (isHintDictionary) {
return SuperTypes.Hint;
}
if (redactionLogEntry.redacted) {
return SuperTypes.Redaction;
}
return SuperTypes.Skipped;
}
case LogEntryStatus.REQUESTED:
return SuperTypes.SuggestionRemove;
}

View File

@ -8,14 +8,6 @@
</div>
<div *ngIf="isCategoryActive(category)" class="options-content">
<!-- <div class="radio-container" *ngIf="category === 'emailNotifications'">-->
<!-- <div class="radio-button" *ngFor="let type of emailNotificationScheduleTypes">-->
<!-- <iqser-round-checkbox [active]="getEmailNotificationType() === type" (click)="setEmailNotificationType(type)">-->
<!-- </iqser-round-checkbox>-->
<!-- <span> {{ translations[type.toLocaleLowerCase()] | translate }} </span>-->
<!-- </div>-->
<!-- </div>-->
<div class="statement" translate="notifications-screen.options-title"></div>
<div *ngFor="let key of notificationGroupsKeys; let i = index" class="group">

View File

@ -3,12 +3,7 @@ import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { NotificationPreferencesService } from '../../../services/notification-preferences.service';
import { BaseFormComponent, LoadingService, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import {
EmailNotificationScheduleTypesValues,
NotificationCategoriesValues,
NotificationGroupsKeys,
NotificationGroupsValues,
} from '@red/domain';
import { NotificationCategoriesValues, NotificationGroupsKeys, NotificationGroupsValues } from '@red/domain';
import { firstValueFrom } from 'rxjs';
import { notificationsSettingsTranslations } from '@translations/notifications-settings-translations';
@ -18,7 +13,6 @@ import { notificationsSettingsTranslations } from '@translations/notifications-s
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class NotificationsScreenComponent extends BaseFormComponent implements OnInit {
readonly emailNotificationScheduleTypes = EmailNotificationScheduleTypesValues;
readonly notificationCategories = NotificationCategoriesValues;
readonly notificationGroupsKeys = NotificationGroupsKeys;
readonly notificationGroupsValues = NotificationGroupsValues;
@ -42,14 +36,6 @@ export class NotificationsScreenComponent extends BaseFormComponent implements O
return this.form.get(`${category}Enabled`).value;
}
setEmailNotificationType(type: string) {
this.form.get('emailNotificationType').setValue(type);
}
getEmailNotificationType() {
return this.form.get('emailNotificationType').value;
}
isPreferenceChecked(category: string, preference: string) {
return this.form.get(category).value.includes(preference);
}

View File

@ -10,7 +10,6 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
@Component({
templateUrl: './add-edit-dossier-attribute-dialog.component.html',
styleUrls: ['./add-edit-dossier-attribute-dialog.component.scss'],
})
export class AddEditDossierAttributeDialogComponent extends BaseDialogComponent implements OnDestroy {
dossierAttribute: IDossierAttributeConfig = this.data.dossierAttribute;

View File

@ -138,7 +138,7 @@ export class AddEditCloneDossierTemplateDialogComponent extends BaseDialogCompon
}
if (clonesCount >= 1) {
return `Copy of ${nameOfClonedTemplate} ${clonesCount === 1 ? '(1)' : `(${clonesCount})`}`;
return `Copy of ${nameOfClonedTemplate} (${clonesCount})`;
}
return `Copy of ${nameOfClonedTemplate}`;
}

View File

@ -7,7 +7,6 @@ import { BaseDialogComponent } from '@iqser/common-ui';
@Component({
selector: 'redaction-add-edit-user-dialog',
templateUrl: './add-edit-user-dialog.component.html',
styleUrls: ['./add-edit-user-dialog.component.scss'],
})
export class AddEditUserDialogComponent extends BaseDialogComponent {
resettingPassword = false;

View File

@ -9,7 +9,6 @@ import { firstValueFrom } from 'rxjs';
@Component({
selector: 'redaction-reset-password',
templateUrl: './reset-password.component.html',
styleUrls: ['./reset-password.component.scss'],
})
export class ResetPasswordComponent {
readonly form = this._getForm();

View File

@ -7,7 +7,6 @@ import { BaseDialogComponent } from '@iqser/common-ui';
@Component({
templateUrl: './file-attributes-configurations-dialog.component.html',
styleUrls: ['./file-attributes-configurations-dialog.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class FileAttributesConfigurationsDialogComponent extends BaseDialogComponent implements OnInit {

View File

@ -3,7 +3,6 @@ import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { PermissionsService } from '@services/permissions.service';
import { AnnotationPermissions } from '@models/file/annotation.permissions';
import { AnnotationActionsService } from '../../services/annotation-actions.service';
import { UserService } from '@services/user.service';
import { AnnotationReferencesService } from '../../services/annotation-references.service';
import { MultiSelectService } from '../../services/multi-select.service';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
@ -38,7 +37,6 @@ export class AnnotationActionsComponent implements OnChanges {
readonly annotationReferencesService: AnnotationReferencesService,
readonly helpModeService: HelpModeService,
private readonly _changeRef: ChangeDetectorRef,
private readonly _userService: UserService,
private readonly _annotationManager: REDAnnotationManager,
private readonly _state: FilePreviewStateService,
private readonly _permissionsService: PermissionsService,
@ -120,7 +118,6 @@ export class AnnotationActionsComponent implements OnChanges {
const dossier = this._state.dossier;
this.annotationPermissions = AnnotationPermissions.forUser(
this._permissionsService.isApprover(dossier),
this._userService.currentUser,
this.annotations,
this._state.dictionaries,
);

View File

@ -2,8 +2,6 @@ import { inject, Injectable, NgZone } from '@angular/core';
import { AnnotationWrapper } from '../../../models/file/annotation.wrapper';
import { AnnotationPermissions } from '../../../models/file/annotation.permissions';
import { PermissionsService } from '../../../services/permissions.service';
import { UserService } from '../../../services/user.service';
import { DictionariesMapService } from '../../../services/entity-services/dictionaries-map.service';
import { FilePreviewStateService } from './file-preview-state.service';
import { TranslateService } from '@ngx-translate/core';
import { AnnotationActionsService } from './annotation-actions.service';
@ -14,8 +12,6 @@ import { IHeaderElement } from '@red/domain';
@Injectable()
export class PdfAnnotationActionsService {
readonly #permissionsService = inject(PermissionsService);
readonly #currentUser = inject(UserService).currentUser;
readonly #dictionariesMapService = inject(DictionariesMapService);
readonly #state = inject(FilePreviewStateService);
readonly #translateService = inject(TranslateService);
readonly #ngZone = inject(NgZone);
@ -145,7 +141,7 @@ export class PdfAnnotationActionsService {
const dossier = this.#state.dossier;
const isApprover = this.#permissionsService.isApprover(dossier);
const permissions = annotations.map(a => AnnotationPermissions.forUser(isApprover, this.#currentUser, a, this.#state.dictionaries));
const permissions = annotations.map(a => AnnotationPermissions.forUser(isApprover, a, this.#state.dictionaries));
return {
canResize: permissions.length === 1 && permissions[0].canResizeAnnotation,
canChangeLegalBasis: permissions.reduce((acc, next) => acc && next.canChangeLegalBasis, true),