From 070d60614385a5456e29685641bcf0dc44688934 Mon Sep 17 00:00:00 2001 From: Renaud Michotte Date: Fri, 19 Feb 2021 16:38:36 +0100 Subject: [PATCH] admin: fix circulation policies detail view. * Fixes some display problems about circulation policies detail view. * Closes rero/rero-ils#1389 Co-Authored-by: Renaud Michotte --- .../circ-policy-detail-view.component.html | 228 +++++++++--------- .../circ-policy-detail-view.component.ts | 44 ++-- .../app/routes/circulation-policies-route.ts | 2 +- proxy.conf.json | 11 +- 4 files changed, 141 insertions(+), 144 deletions(-) diff --git a/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.html b/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.html index bbf3feff9..46c71db69 100644 --- a/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.html +++ b/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.html @@ -20,81 +20,73 @@

{{ data.name | translate }}

- -
-
Name
-
- {{ data.name }} -
-
- -
-
Description
-
- {{ data.description }} +
+
Name
+
{{ data.name }}
+ +
Description
+
{{ data.description }}
+
+
Level
+
+ + {{ 'Library' | translate }} +
    +
  • + + {{ lib.pid | getRecord: 'libraries' : 'field' : 'name' | async }} +
  • +
+
+ {{ 'Organisation' | translate }}
- -
-
Level
- - -
- Library -
-
- -
- Organisation -
-
-
+
-
- Circulation settings -
+
Circulation settings
-
-
Allow checkout
-
- - - - + +
Is default
+
+ + + - - + +
-
- -
-
Checkout duration
-
- {{ data.checkout_duration }} -
-
- -
-
Number of renewals
-
- {{ data.number_renewals }} -
-
- -
-
Renewal duration
-
- {{ data.renewal_duration }} -
-
- -
-
Allow requests
-
+ +
Allow checkout
+ +
+ +
+
Checkout duration
+
+ {{ data.checkout_duration }} + {{ data.checkout_duration | i18nPlural: {'=1': 'day', 'other': 'days'} | translate }} +
+
Number of renewals
+
+ {{ data.number_renewals }} +
+
Renewal duration
+
+ {{ data.renewal_duration }} + {{ data.renewal_duration | i18nPlural: {'=1': 'day', 'other': 'days'} | translate }} +
+
+ +
+ +
+
+
Allow requests
+
@@ -104,65 +96,68 @@

{{ data.name | translate }}

- -
-
Is default
-
- - - - - - - -
-
-
- Reminders -
+
Reminders
-
-
Type
-
Days Delay
-
Communication channel
-
Amount
- -
{{ reminder.type | translate }}
-
{{ reminder.days_delay }}
-
{{ reminder.communication_channel | translate }}
-
- {{ reminder.fee_amount | currency:currency:true }} -
-
- -
-
-
-
+ + + + + + + + + + + + + + + + + +
#TypeDays DelayCommunication channelAmount
{{ idx + 1 }}{{ reminder.type | translate }} + + {{ reminder.days_delay }} + {{ reminder.communication_channel | translate }} + + {{ reminder.fee_amount | currency: org_currency:true }} + + +
-
- Overdue fees -
+
Overdue fees
-
-
Interval of days
-
Amount
- -
{{ overdue.from }} - {{ overdue.to }}
-
{{ overdue.fee_amount | currency:currency:true }} / {{ 'day' | translate }}
-
-
+ + + + + + + + + + + +
Interval of daysAmount/day
+ {{ interval.from }} + + {{ interval.to }} + No limit + + {{ interval.fee_amount | currency: org_currency:true }} / {{ 'day' | translate }} +
Maximun total amount
@@ -173,9 +168,10 @@

{{ data.name | translate }}

-
-

Application

- + +
+
Application
+
@@ -203,7 +199,7 @@

Application

- +
diff --git a/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.ts b/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.ts index 880b379bb..a21fcecd8 100644 --- a/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.ts +++ b/projects/admin/src/app/record/detail-view/circ-policy-detail-view/circ-policy-detail-view.component.ts @@ -26,40 +26,46 @@ import { OrganisationService } from '../../../service/organisation.service'; export class CircPolicyDetailViewComponent implements OnInit, OnDestroy { + // COMPONENT ATTIBUTES ====================================================== /** The observable resolving record data */ record$: Observable; - /** The resource type */ type: string; - /** The record */ record: any; - /** Reminders */ reminders = []; - /** Overdues */ overdues = []; - /** The settings to display, patron type pid as a key */ settings = new Map(); + /** The list of item types concerned by the circulation policy */ + itemTypes = new Set(); /** The observer to the record observable */ private _recordObs = null; - /** The list of item types concerned by the circulation policy */ - itemTypes = new Set(); - + // GETTER & SETTER ========================================================== /** Organisation currency */ - get currency() { + get org_currency() { return this._organisationService.organisation.default_currency; } + /** checkout is allowed ? */ + get checkoutIsAllowed() { + return this.record && this.record.metadata.checkout_duration > 0; + } + + + + // CONSTRUCTOR & HOOKS ====================================================== /** * Constructor * @param _organisationService - OrganisationService */ - constructor(private _organisationService: OrganisationService) {} + constructor( + private _organisationService: OrganisationService + ) {} /** On init hook */ ngOnInit() { @@ -80,16 +86,20 @@ export class CircPolicyDetailViewComponent implements OnInit, OnDestroy { } }); - // reminders order + // sort reminders to ensure a better display this.reminders = record.metadata.reminders - .sort((a: any, b: any) => (a.type > b.type) - ? 1 - : (a.days_delay > b.days_delay) ? 1 : -1 + .sort((a: any, b: any) => { + return (a.type > b.type) + ? 1 + : a.days_delay - b.days_delay; + } ); - // Overdue fees - this.overdues = record.metadata.overdue_fees.intervals - .sort((a: any, b: any) => (a.from > b.from) ? 1 : -1); + // sort incremental overdue intervals + if (record.metadata.hasOwnProperty('overdue_fees') && record.metadata.overdue_fees.hasOwnProperty('intervals')) { + this.overdues = record.metadata.overdue_fees.intervals + .sort((a: any, b: any) => a.from - b.from); + } } }); } diff --git a/projects/admin/src/app/routes/circulation-policies-route.ts b/projects/admin/src/app/routes/circulation-policies-route.ts index b98a9bb60..54014538c 100644 --- a/projects/admin/src/app/routes/circulation-policies-route.ts +++ b/projects/admin/src/app/routes/circulation-policies-route.ts @@ -155,7 +155,7 @@ export class CirculationPoliciesRoute extends BaseRoute implements RouteInterfac ...field.hooks, afterContentInit: (f: FormlyFieldConfig) => { f.templateOptions.options = this._routeToolService.httpClient - .get('/notifications/templates/list') + .get('/api/notifications/templates/list') .pipe( map((response: any) => { return response.templates.map((tpl: any) => { diff --git a/proxy.conf.json b/proxy.conf.json index 5a22c8816..96ee69a9f 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -26,16 +26,7 @@ "^/api": "https://localhost:5000/api" } }, - "/notifications/*": { - "target": "https://localhost:5000", - "secure": false, - "logLevel": "debug", - "changeOrigin": true, - "pathRewrite": { - "^/notifications": "https://localhost:5000/notifications" - } - }, - "/lang/*": { + "/lang/*": { "target": "https://localhost:5000", "secure": false, "logLevel": "debug",