From db240e1ff4341746e034883c7e658a5996c23f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Marie=CC=81thoz?= Date: Mon, 6 Jan 2025 14:19:21 +0100 Subject: [PATCH] primeng: fix first admin tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-by: Johnny Mariéthoz Co-Authored-by: Bertrand Zuchuat --- .../detail-button.component.html | 20 ++++++++++------ .../detail-button/detail-button.component.ts | 17 -------------- .../editor/formly/primeng/select/select.ts | 13 +++++++---- .../search/menu-sort/menu-sort.component.html | 8 ++++++- .../record-search-result.component.html | 23 ++++++++++++------- .../result/record-search-result.component.ts | 9 -------- 6 files changed, 43 insertions(+), 47 deletions(-) diff --git a/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.html b/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.html index 1c859856..49f5da05 100644 --- a/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.html +++ b/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.html @@ -27,11 +27,10 @@
@if (record() && adminMode().can) { - @if (useStatus && useStatus.can && useStatus.url) { + @if (useStatus() && useStatus().can && useStatus().url) { @@ -40,20 +39,27 @@ } @if (deleteStatus()) { - + + + } } diff --git a/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.ts b/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.ts index 5ca302c3..880fdff6 100644 --- a/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.ts +++ b/projects/rero/ng-core/src/lib/record/detail/detail-button/detail-button.component.ts @@ -52,23 +52,6 @@ export class DetailButtonComponent { /** Delete record message event */ deleteMessageEvent = output(); - /** - * define if an action is the primary action for the resource - * @param actionName - string: the action name to check - * @return boolean - */ - isPrimaryAction(actionName: string): boolean { - switch (actionName) { - case 'edit': - case 'update': - return this.updateStatus() && this.updateStatus().can && (!this.useStatus() || !this.useStatus().can); - case 'use': - return this.useStatus() && this.useStatus().can; - default: - return false; - } - } - /** Use the record */ useRecord(): void { this.recordEvent.emit({ action: 'use', url: this.updateStatus().url }) diff --git a/projects/rero/ng-core/src/lib/record/editor/formly/primeng/select/select.ts b/projects/rero/ng-core/src/lib/record/editor/formly/primeng/select/select.ts index 4e61906d..f99f92fa 100644 --- a/projects/rero/ng-core/src/lib/record/editor/formly/primeng/select/select.ts +++ b/projects/rero/ng-core/src/lib/record/editor/formly/primeng/select/select.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ import { CommonModule } from '@angular/common'; -import { Component, NgModule, OnInit, Type } from '@angular/core'; +import { ChangeDetectorRef, Component, inject, NgModule, OnInit, Type } from '@angular/core'; import { ReactiveFormsModule } from '@angular/forms'; import { FieldType, FormlyFieldConfig, FormlyModule } from '@ngx-formly/core'; import { FormlySelectModule as FormlyCoreSelectModule, FormlyFieldSelectProps } from '@ngx-formly/core/select'; @@ -54,8 +54,8 @@ export interface IFormlySelectFieldConfig extends FormlyFieldConfig - 0) { +
} - + + } `, styles: ` :host ::ng-deep .p-dropdown-panel .p-dropdown-items .p-dropdown-item-group { @@ -111,6 +112,7 @@ export interface IFormlySelectFieldConfig extends FormlyFieldConfig> implements OnInit { + protected cd: ChangeDetectorRef = inject(ChangeDetectorRef); /** Default properties */ defaultOptions: Partial> = { defaultValue: null, @@ -131,7 +133,7 @@ export class SelectComponent extends FieldType> } }; - selectOptions: any[] = []; + selectOptions: any[]; ngOnInit(): void { if (!isObservable(this.props.options)) { @@ -156,6 +158,7 @@ export class SelectComponent extends FieldType> } else { this.selectOptions = this.props.sort ? this.sortOptions(options) : options; } + this.cd.markForCheck(); }); } diff --git a/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html b/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html index 263eb2ec..d5551444 100644 --- a/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html +++ b/projects/rero/ng-core/src/lib/record/search/menu-sort/menu-sort.component.html @@ -20,8 +20,14 @@
@if (selectedOption()?.icon) { + } @else if (selectedOption()) { + {{'Sort by' | translate }} : + } + @if (selectedOption()?.label) { + {{ selectedOption()?.label | translate }} + } @else { + {{'Sort by' | translate }} … } - {{ selectedOption()?.label | translate }} …
diff --git a/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.html b/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.html index 436cb0d5..4670358f 100644 --- a/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.html +++ b/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.html @@ -25,9 +25,9 @@ @if (useStatus && useStatus.can && useStatus.url) { } @@ -37,7 +37,6 @@ @@ -46,12 +45,20 @@ @if (deleteStatus) { + icon="fa fa-trash" + severity="danger" + class="pointer-events-auto" + outlined + [title]="'Delete'|translate" + (onClick)="deleteRecord(record.id, deleteStatus?.type)" + [pTooltip]="tooltipContent" + tooltipPosition="top" + [disabled]="!deleteStatus.can" + [tooltipDisabled]="deleteStatus.can" + /> + + + } } diff --git a/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.ts b/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.ts index 6c73cc3f..c532a193 100644 --- a/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.ts +++ b/projects/rero/ng-core/src/lib/record/search/result/record-search-result.component.ts @@ -142,15 +142,6 @@ export class RecordSearchResultComponent implements OnInit, AfterViewInit { } } - /** - * Edit a record - * @param pid - string: the pid to edit - */ - editRecord(pid: string, url?: string[]): void { - const params = url ?? ['/', 'records', this.type, 'edit', pid]; - this.router.navigate(params); - } - /** * Use a record */