Skip to content

Commit

Permalink
primeng: admin circulatin policies
Browse files Browse the repository at this point in the history
Co-Authored-by: Johnny Mariéthoz <[email protected]>
Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
jma and Garfield-fr committed Jan 8, 2025
1 parent 59cc949 commit c2d87c9
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,20 @@ import { ResultItem } from '@rero/ng-core';
@Component({
selector: 'admin-circ-policies-brief-view',
template: `
<h5 class="mb-0 card-title">
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a>
<span class="badge badge-light ml-2 align-top">
<small>
<h5>
<a [routerLink]="[detailUrl.link]">{{ record.metadata.name }}</a>&nbsp;
<p-tag class="vertical-align-bottom" severity="secondary">
@if (record.metadata.policy_library_level) {
{{ 'Library' | translate }}
} @else {
{{ 'Organisation' | translate }}
}
</small>
</span>
</p-tag>
</h5>
<div class="card-text">
@if (record.metadata.description) {
{{ record.metadata.description }}
}
</div>
`,
styles: []
@if (record.metadata.description) {
<span [innerHtml]="record.metadata.description | nl2br"></span>
}
`
})
export class CircPoliciesBriefViewComponent implements ResultItem {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@
-->

@if (record) {
<h1 class="mb-3">{{ record.metadata.name | translate }}</h1>
<header>
<h1 class="mb-3">{{ record.metadata.name | translate }}</h1>
</header>
<article>
<!-- DETAILS -->
<section class="m-2 p-2">
<dl class="row">
<dt class="col-3 label-title" translate>Name</dt>
<dd id="cipo-name" class="col-9">{{ record.metadata.name }}</dd>
<dl class="metadata">
<dt translate>Name</dt>
<dd id="cipo-name">{{ record.metadata.name }}</dd>
@if (record.metadata.description) {
<dt class="col-3 label-title" translate>Description</dt>
<dd id="cipo-description" class="col-9">{{ record.metadata.description }}</dd>
<dt translate>Description</dt>
<dd id="cipo-description">{{ record.metadata.description }}</dd>
}
<dt class="col-3 label-title" translate>Level</dt>
<dd id="cipo-level" class="col-9">
<dt translate>Level</dt>
<dd id="cipo-level">
@if (record.metadata.policy_library_level) {
{{ 'Library' | translate }}
<ul>
<ul class="list-none m-0 p-0">
@for (library of record.metadata.libraries; track library) {
<li>
<i class="fa fa-university pr-2"></i>
<i class="fa fa-university"></i>&nbsp;
{{ library.pid | getRecord: 'libraries' : 'field' : 'name' | async }}
</li>
}
Expand All @@ -47,189 +49,171 @@ <h1 class="mb-3">{{ record.metadata.name | translate }}</h1>
</section>

<!-- CIRCULATION SETTINGS -->
<section class="card mt-4">
<div class="card-header"><h5 class="mb-0" translate>Circulation settings</h5></div>
<div class="card-body">
<dl class="row mb-0">
<section class="mt-3">
<p-fieldset [legend]="'Circulation settings'|translate">
<dl class="metadata">
<!-- IS DEFAULT -->
<dt class="col-3 label-title" translate>Is default</dt>
<dd class="col-9">
<dt translate>Is default</dt>
<dd>
@if (record.metadata.is_default) {
<i id="cipo-is-default" class="fa fa-check text-success" aria-hidden="true"></i>
} @else {
<i id="cipo-is-default" class="fa fa-times text-danger" aria-hidden="true"></i>
}
</dd>
<!-- CHECKOUT SETTINGS-->
<dt class="col-3 mb-0 label-title" translate>Allow checkout</dt>
<dt translate>Allow checkout</dt>
@if (checkoutIsAllowed) {
<dd class="col-1 mb-0">
<dd class="flex gap-2">
<i id="cipo-allow-checkout" class="fa fa-check text-success" aria-hidden="true"></i>
</dd>
<dt class="col-3 label-title" translate>Checkout duration</dt>
<dd id="cipo-checkout-duration" class="col-3 mb-0">
<dl class="metadata" style="padding-top: 0 !important;">
<dt translate>Checkout duration</dt>
<dd id="cipo-checkout-duration">
{{ record.metadata.checkout_duration }}
{{ record.metadata.checkout_duration | i18nPlural: {'=1': 'day', 'other': 'days'} | translate }}
</dd>
<dt class="col-3 offset-4 label-title" translate>Number of renewals</dt>
<dd id="cipo-cnumber-renewals" class="col-5 mb-0">
<dt translate>Number of renewals</dt>
<dd id="cipo-cnumber-renewals">
{{ record.metadata.number_renewals }}
</dd>
<dt class="col-3 offset-4 label-title" translate>Renewal duration</dt>
<dd id="cipo-renewal-duration" class="col-5 mb-0">
<dt translate>Renewal duration</dt>
<dd id="cipo-renewal-duration">
{{ record.metadata.renewal_duration }}
{{ record.metadata.renewal_duration | i18nPlural: {'=1': 'day', 'other': 'days'} | translate }}
</dd>
<dt class="col-3 offset-4 label-title" translate>Automatic renewal</dt>
<dd id="cipo-auto-renewal" class="col-5 mb-0">
<dt translate>Automatic renewal</dt>
<dd id="cipo-auto-renewal">
@if (record.metadata.automatic_renewal) {
<i class="fa fa-check text-success" aria-hidden="true"></i>
} @else {
<i class="fa fa-times text-danger" aria-hidden="true"></i>
}
</dd>
</dl>
</dd>
} @else {
<dd class="col-9">
<dd>
<i id="cipo-allow-checkout" class="fa fa-times text-danger" aria-hidden="true"></i>
</dd>
}
<dt class="col-3 label-title" translate>Allow requests</dt>
<dd class="col-9">
<dt translate>Allow requests</dt>
<dd>
@if (record.metadata.allow_requests) {
<i id="cipo-allow-request" class="fa fa-check text-success" aria-hidden="true"></i>
} @else {
<i id="cipo-allow-request" class="fa fa-times text-danger" aria-hidden="true"></i>
}
</dd>
</dl>
</div>
</p-fieldset>
</section>

<!-- REMINDERS -->
@if (reminders.length > 0) {
<section class="card mt-2">
<div class="card-header">
<h5 class="mb-0" translate>Reminders</h5>
</div>
<div class="card-body">
<table class="table table-hover table-sm">
<thead class="thead-light">
<th scope="col">#</th>
<th scope="col" translate>Type</th>
<th scope="col" translate>Days Delay</th>
<th scope="col" translate>Communication channel</th>
<th scope="col" translate>Amount</th>
</thead>
<tbody>
@for (reminder of record.metadata.reminders; track reminder; let idx = $index) {
<tr>
<th scope="row">{{ idx + 1 }}</th>
<td>{{ reminder.type | translate }}</td>
<td>
<i class="fa" [ngClass]="{
'fa-calendar-minus-o': reminder.type === 'due_soon',
'fa-calendar-plus-o': reminder.type === 'overdue'
}"></i>
{{ reminder.days_delay }}
</td>
<td>{{ reminder.communication_channel | translate }}</td>
<td>
@if (reminder.fee_amount) {
{{ reminder.fee_amount | currency: org_currency:true }}
} @else {
&mdash;
}
</td>
</tr>
}
</tbody>
</table>
</div>
<section class="mt-3">
<p-fieldset [legend]="'Reminders'|translate">
<p-table [value]="record.metadata.reminders">
<ng-template pTemplate="header">
<tr>
<th translate>Type</th>
<th translate>Days Delay</th>
<th translate>Communication channel</th>
<th translate>Amount</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-reminder>
<tr>
<td>{{ reminder.type | translate }}</td>
<td>
<i class="fa" [ngClass]="{
'fa-calendar-minus-o': reminder.type === 'due_soon',
'fa-calendar-plus-o': reminder.type === 'overdue'
}"></i>
{{ reminder.days_delay }}
</td>
<td>{{ reminder.communication_channel | translate }}</td>
<td>
@if (reminder.fee_amount) {
{{ reminder.fee_amount | currency: org_currency:true }}
} @else {
&mdash;
}
</td>
</tr>
</ng-template>
</p-table>
</p-fieldset>
</section>
}

<!-- OVERDUE FEES -->
@if (overdues && overdues.length > 0) {
<section class="card mt-2">
<div class="card-header"><h5 class="mb-0" translate>Overdue fees</h5></div>
<div class="card-body">
<table class="table table-hover table-sm">
<thead class="thead-light">
<th scope="col" translate>Interval of days</th>
<th scope="col" translate>Amount/day</th>
</thead>
<tbody>
@for (interval of overdues; track interval) {
<tr>
<td scope="row">
{{ interval.from }}
<i class="fa fa-long-arrow-right px-4"></i>
@if (interval.to) {
{{ interval.to }}
} @else {
<span class="text-muted">&infin;</span>
}
</td>
<td>
{{ interval.fee_amount | currency: org_currency:true }} / {{ 'day' | translate }}
</td>
</tr>
}
</tbody>
</table>
@if (record.metadata.overdue_fees.maximum_total_amount) {
<div class="row col mt-3">
<div class="col-lg-3 font-weight-bold pl-0" translate>Maximun total amount</div>
<div class="col-lg-9">
{{ record.metadata.overdue_fees.maximum_total_amount | currency: org_currency:true }}
</div>
</div>
}
</div>
</section>
@if (overdues?.length > 0) {
<section class="mt-3">
<p-fieldset [legend]="'Overdue fees'|translate">
<p-table [value]="overdues">
<ng-template pTemplate="header">
<tr>
<th translate>Interval of days</th>
<th translate>Amount/day</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-overdue>
<tr>
<td>
{{ overdue.from }}
<i class="fa fa-long-arrow-right px-2"></i>
@if (overdue.to) {
{{ overdue.to }}
} @else {
<span class="text-color-secondary">&infin;</span>
}
</td>
<td>
{{ overdue.fee_amount | currency: org_currency:true }} / {{ 'day' | translate }}
</td>
</tr>
</ng-template>
</p-table>
</p-fieldset>
</section>
}

<!-- APPLICATION -->
@if (record.metadata.settings) {
<section class="card mt-2">
<div class="card-header">
<h6 class="mb-0" translate>Application</h6>
</div>
<div class="card-body table-responsive">
<table class="table table-striped table-sm">
<thead>
<section class="mt-3">
<p-fieldset [legend]="'Application'|translate">
<p-table styleClass="p-datatable-striped" [value]="settings | keyvalue">
<ng-template pTemplate="header">
<tr>
<th scope="col" rowspan="2" translate>Patron types</th>
<th scope="col" [attr.colspan]="itemTypes.size" class="text-center" translate>Item types</th>
<th rowspan="2" class="vertical-align-bottom pl-0" translate>Patron types</th>
<th [attr.colspan]="itemTypes.size" class="text-center" translate>Item types</th>
</tr>
<tr>
@for (itemType of itemTypes; track itemType) {
<th scope="col" class="text-center">
<th class="text-center">
<span id="itty-{{itemType}}">{{ itemType | getRecord: 'item_types' : 'field' : 'name' | async }}</span>
</th>
}
</tr>
</thead>
<tbody>
@for (setting of settings | keyvalue; track setting; let i = $index) {
<tr>
<th id="ptty-{{setting.key}}" scope="row" class="table-light">
{{ setting.key | getRecord: 'patron_types' : 'field' : 'name' | async }}
</th>
@for (itemType of itemTypes; track itemType) {
<td class="text-center">
@for (currentItemType of setting.value; track currentItemType) {
@if (itemType === currentItemType) {
<i id="ptty-{{setting.key}}-itty-{{currentItemType}}" class="fa fa-check text-success" aria-hidden="true"></i>
}
</ng-template>
<ng-template pTemplate="body" let-setting>
<tr>
<th id="ptty-{{setting.key}}" class="text-left">
{{ setting.key | getRecord: 'patron_types' : 'field' : 'name' | async }}
</th>
@for (itemType of itemTypes; track itemType) {
<td class="text-center">
@for (currentItemType of setting.value; track currentItemType) {
@if (itemType === currentItemType) {
<i id="ptty-{{setting.key}}-itty-{{currentItemType}}" class="fa fa-check text-success" aria-hidden="true"></i>
}
</td>
}
</tr>
}
</tbody>
</table>
</div>
}
</td>
}
</tr>
</ng-template>
</p-table>
</p-fieldset>
</section>
}
</article>
Expand Down
Loading

0 comments on commit c2d87c9

Please sign in to comment.