Skip to content

Commit

Permalink
fix: primeng PO tests
Browse files Browse the repository at this point in the history
* Clean dependencies.
* Fixes edition statement format.
* Fixes document detailed view metadata.
* Fixes "undefined" delete message for acquisitions.
* Opens the first item informations in the document detailed view.
* Fixes wrong date format for the exception dates of libraries.
* Fixes sort only once in the main request circulation component.
* Fixes children filter on the selec account component.

Co-Authored-by: Johnny Mariéthoz <[email protected]>
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
jma and Garfield-fr committed Feb 20, 2025
1 parent a823f59 commit b8062d6
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 59 deletions.
152 changes: 110 additions & 42 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"@angular/platform-browser-dynamic": "^17.1.0",
"@angular/router": "^17.1.0",
"@biesbjerg/ngx-translate-extract-marker": "^1.0.0",
"@ng-bootstrap/ng-bootstrap": "^16.0.0",
"@ngneat/hotkeys": "^4.0.0",
"@ngx-formly/core": "^6.3.6",
"@ngx-formly/primeng": "^6.3.6",
Expand All @@ -86,7 +85,6 @@
"@ngx-translate/core": "^15.0.0",
"@rero/ng-core": "^17.3.0",
"@vpoppy/ngx-translate-extract": "^9.0.0",
"bootstrap": "^4.6.2",
"chart.js": "^4.4.7",
"crypto-js": "^4.2.0",
"easymde": "^2.18.0",
Expand All @@ -99,6 +97,7 @@
"ngx-spinner": "^16.0.0",
"primeflex": "^3.3.1",
"primeicons": "^7.0.0",
"primelocale": "^1.0.3",
"primeng": "^17.18.0",
"rxjs": "^7.8.1",
"simple-isbn": "^1.1.5",
Expand All @@ -119,6 +118,7 @@
"@types/jasmine": "^5.1.4",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"bootstrap": "^4.6.2",
"eslint": "^8.36.0",
"jasmine-core": "^5.1.1",
"jasmine-spec-reporter": "~7.0.0",
Expand All @@ -128,7 +128,6 @@
"karma-jasmine-html-reporter": "~2.1.0",
"karma-spec-reporter": "0.0.36",
"ng-packagr": "^17.1.1",
"primelocale": "^1.0.3",
"typescript": "~5.3.3"
},
"files": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export class SelectAccountEditorWidgetComponent extends FieldType implements OnI
next: (accounts: IAcqAccount[]) => {
accounts = orderAccountsAsTree(accounts);
// filter me and my children to avoid backend recursion errors
let accountPid = this.field.props.editorConfig.pid;
if(accountPid) {
const accountPid = this.field.props?.editorConfig?.pid;
if(this.field.props?.filterChildren && accountPid) {
let newAccounts = [];
let removed = [];
accounts.map(account => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

}
<!-- Sorting loans -->
<p-dropdown [options]="sortingCriteria" (onChange)="selectingSortCriteria($event)">
<p-dropdown [options]="sortingCriteria" (onChange)="selectingSortCriteria($event.value)">
<ng-template let-item pTemplate="selectedItem">
<div class="flex align-items-center gap-2">
<i [class]="item.icon"></i>
Expand Down
5 changes: 2 additions & 3 deletions projects/admin/src/app/classes/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,14 @@ export class Library {
if (typeof exception.start_date === 'string') {
exception.start_date = DateTime.fromFormat(exception.start_date, 'yyyy-LL-dd');
}
exception.start_date = exception.start_date.plus({ [unity]: exception.repeat.interval });
exception.start_date = exception.start_date.plus({ [unity]: exception.repeat.interval }).toISODate();

if (exception.end_date) {
if (typeof exception.end_date === 'string') {
exception.end_date = DateTime.fromFormat(exception.end_date, 'yyyy-LL-dd');
}
exception.end_date = exception.end_date.plus({ [unity]: exception.repeat.interval });
exception.end_date = exception.end_date.plus({ [unity]: exception.repeat.interval }).toISODate();
}

return exception;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { AfterViewInit, Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output, ElementRef, ViewChild } from '@angular/core';
import { HoldingsService } from '@app/admin/service/holdings.service';
import { RecordPermissionService } from '@app/admin/service/record-permission.service';
import { TranslateService } from '@ngx-translate/core';
Expand All @@ -24,12 +24,13 @@ import { UserService } from '@rero/shared';
import { DialogService, DynamicDialogRef } from 'primeng/dynamicdialog';
import { forkJoin } from 'rxjs';
import { ItemRequestComponent } from '../item-request/item-request.component';
import { AccordionTab } from 'primeng/accordion';

@Component({
selector: 'admin-document-holding, [admin-document-holding]',
templateUrl: './holding.component.html'
})
export class HoldingComponent implements OnInit, OnDestroy {
export class HoldingComponent implements OnInit, OnDestroy, AfterViewInit {

protected userService: UserService = inject(UserService);
protected holdingService: HoldingsService = inject(HoldingsService);
Expand All @@ -49,6 +50,8 @@ export class HoldingComponent implements OnInit, OnDestroy {
/** Restrict the functionality of interface */
@Input() isCurrentOrganisation = true;

@Input() selected = false;

/** shortcut for holding type */
holdingType: 'electronic' | 'serial' | 'standard';
/** Items */
Expand All @@ -62,6 +65,8 @@ export class HoldingComponent implements OnInit, OnDestroy {
/** number of item to load/display */
displayItemsCounter = 10;

@ViewChild(AccordionTab) tab: AccordionTab;

// GETTER & SETTER ==========================================================
/** Current interface language */
get language() {
Expand All @@ -79,6 +84,10 @@ export class HoldingComponent implements OnInit, OnDestroy {
}
}

ngAfterViewInit() {
this.tab.selected = this.selected;
}

/** onDestroy hook */
ngOnDestroy() {
if (this.itemsRef != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
}

@if (holdings) {
<!-- TODO: activeIndex does not works for now as accordionTab is in a child component-->
<p-accordion multiple="true" [activeIndex]="[0]">
@for (holding of holdings; track holding) {
@for (holding of holdings; track holding; let i = $index) {
<div
class="my-2 border-1 surface-border border-round"
admin-document-holding
[holding]="holding"
[selected]="i === 0"
[isItemsCollapsed]="holdingsTotal > 1"
[isCurrentOrganisation]="isCurrentOrganisation"
(deleteHolding)="deleteHolding($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class RecordPermissionService {
"=1": this.translateService.instant("has 1 acquisition receipt line attached"),
other: this.translateService.instant("has # acquisition receipts lines attached"),
},
acq_receipt: {
acq_receipts: {
"=1": this.translateService.instant("has 1 acquisition receipt attached"),
other: this.translateService.instant("has # acquisition receipts attached"),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class DocumentDetailViewComponent implements OnInit {
ngOnInit(): void {
// Set view code to app settings
this.appSettingsService.currentViewCode = this.viewcode;
this.recordService.getRecord('documents', this.documentpid).subscribe((doc) => (this.document = doc));
this.recordService.getRecord('documents', this.documentpid, 1).subscribe(doc => this.document = doc);
this.exportItems = [
{
icon: "fa fa-file-code-o",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<div>
<b>{{ fieldLabel }}</b>:
<dl class="metadata">
<dt>{{ fieldLabel }}</dt>
<dd>
<ul class="inline list-none m-0 p-0">
@for (edition of field; track edition; let last=$last) {
<li class="inline">
Expand All @@ -30,4 +31,5 @@
</li>
}
</ul>
</div>
</dd>
</dl>

0 comments on commit b8062d6

Please sign in to comment.