-
+
+

Circulation policy

+
+
+ + +
+
+
+
- Name is required. + This field is required.
- Name must be at least 2 characters long. + This field must be at least 2 characters long.
-
- Name is already taken. +
+ This name is already taken.
@@ -49,11 +63,11 @@

Circulation Policy

-
- Circulation settings -
+
+
Circulation settings
+
-
+
@@ -62,7 +76,6 @@

Circulation Policy

class="custom-control-input" type="checkbox" id="is_pickup" - (click)="allowCheckoutCheckbox($event.target.checked)" [checked]="allow_checkout.value" >
-
-
+
+
- Checkout duration is required. + This field is required.
- Must be greater than 0 + This field must be greater than or equal to 0.
@@ -101,7 +114,6 @@

Circulation Policy

class="custom-control-input" type="checkbox" id="renewals" - (click)="allowRenewalsCheckbox($event.target.checked)" [checked]="allow_renewals.value" >
-
-
+
+
- +
- Checkout duration is required. + This field is required.
- Must be greater than 0 + This field must be greater than 0
@@ -138,10 +149,10 @@

Circulation Policy

- Renewal duration is required. + This field is required.
- Must be greater than 0 + This field must be greater than 0
@@ -177,56 +188,102 @@

Circulation Policy

-
- Notifications and fees -
-
- +
+
Notifications and fees
+
+ +
- -
-
- First reminder days is required. +
+
+ +
-
- First reminder days must be greater than 0. +
+
+
+
+ + +
+
+ This field is required. +
+
+ This field must be greater than or equal to 0. +
-
- + +
- -
-
- Days before due date is required. -
-
- Days before due date must be greater or equal to 0. +
+
+ +
-
- -
- -
- -
-
- Overdue amount is required. +
+
+ + +
+
+ This field is required. +
+
+ This field must be greater than 0. +
-
- Overdue amount must be great than 0. +
+
+ +
+
+
+ {{ currency }} +
+ +
+
+
+ This field is required. +
+
+ This field must be greater than 0. +
+
@@ -238,9 +295,9 @@

Circulation Policy

-
- Application -
+
+
Application
+
@@ -303,12 +360,5 @@

Circulation Policy

- -
-
- - -
-
diff --git a/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.scss b/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.scss new file mode 100644 index 000000000..c889d1818 --- /dev/null +++ b/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.scss @@ -0,0 +1,38 @@ +/* You can add global styles to this file, and also import other style files */ +/* + * RERO ILS UI + * Copyright (C) 2020 RERO + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +@import "node_modules/bootstrap/scss/functions"; +@import "node_modules/bootstrap/scss/mixins"; +@import 'node_modules/bootstrap/scss/variables'; +@import 'node_modules/bootstrap/scss/bootstrap'; + +.sticky { + @supports (position: sticky) { + position: sticky; + top: 0rem; + z-index: 500; + background: white; + height: 100%; + } + border-bottom: 1px solid #ccc; + } + .actions { + position: absolute; + right: 2rem; + top: 0.75rem; +} diff --git a/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.ts b/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.ts index b3dd2a312..34e222bb0 100644 --- a/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.ts +++ b/projects/admin/src/app/record/custom-editor/circulation-settings/circulation-policy/circulation-policy.component.ts @@ -15,10 +15,10 @@ * along with this program. If not, see . */ -import { Location } from '@angular/common'; +import { Location, getCurrencySymbol } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { ApiService, RecordService, UniqueValidator } from '@rero/ng-core'; import { UserService } from '@rero/shared'; import { CirculationMappingService } from '../circulation-mapping.service'; @@ -30,20 +30,34 @@ import { CirculationPolicyService } from '../circulation-policy.service'; @Component({ selector: 'admin-circulation-settings-circulation-policy', templateUrl: './circulation-policy.component.html', - styles: [] + styleUrls: [ './circulation-policy.component.scss'] }) export class CirculationPolicyComponent implements OnInit { - private circulationPolicy: CirculationPolicy; + /** Circulation policy */ + private _circulationPolicy: CirculationPolicy; + /** Circulation form */ public circulationForm: FormGroup; + /** Libraries of current organisation */ public librariesOrg = []; - public organisation; + /** Current organisation */ + public organisation: any; + /** + * Constructor + * @param route - AcivatedRoute + * @param circulationPolicyService - CirculationPolicyService + * @param circulationPolicyForm - CirculationPolicyFormService + * @param userService - UserService + * @param circulationMapping - CirculationMappingService + * @param apiService - ApiService + * @param recordService - RecordService + * @param location - Location + */ constructor( - private router: Router, private route: ActivatedRoute, private circulationPolicyService: CirculationPolicyService, private circulationPolicyForm: CirculationPolicyFormService, @@ -54,6 +68,7 @@ export class CirculationPolicyComponent implements OnInit { private location: Location ) { } + /** On init hook */ ngOnInit() { const user = this.userService.user; if (user) { @@ -63,7 +78,7 @@ export class CirculationPolicyComponent implements OnInit { .loadOrCreateCirculationPolicy(pid) .subscribe((circulation: CirculationPolicy) => { circulation.organisation.$ref = this.apiService.getRefEndpoint('organisations', user.library.organisation.pid); - this.circulationPolicy = circulation; + this._circulationPolicy = circulation; // Load organisation this.recordService.getRecord('organisations', user.library.organisation.pid) .subscribe(data => this.organisation = data.metadata); @@ -74,12 +89,12 @@ export class CirculationPolicyComponent implements OnInit { this.circulationMapping.setPolicyLevel(circulation.policy_library_level); this.recordService.getRecords('libraries', '', 1, RecordService.MAX_REST_RESULTS_SIZE) .subscribe((libraries: any) => { - libraries.hits.hits.forEach(library => { + libraries.hits.hits.forEach((library: any) => { this.librariesOrg.push({ id: library.metadata.pid, name: library.metadata.name }); - this.circulationPolicyForm.populate(this.circulationPolicy); + this.circulationPolicyForm.populate(this._circulationPolicy); this.circulationForm = this.circulationPolicyForm.getForm(); this.circulationForm.controls.name.setAsyncValidators([ UniqueValidator.createValidator( @@ -97,31 +112,10 @@ export class CirculationPolicyComponent implements OnInit { } } - allowCheckoutCheckbox(checkbox: boolean) { - if (!this.allow_checkout.value) { - this.checkout_duration.setValue(null); - this.allow_renewals.setValue(false); - this.number_renewals.setValue(null); - this.renewal_duration.setValue(null); - this.number_of_days_after_due_date.setValue(null); - this.number_of_days_before_due_date.setValue(null); - this.reminder_fee_amount.setValue(null); - } - } - - allowRenewalsCheckbox(checkbox: boolean) { - if (!this.allow_renewals.value) { - this.number_renewals.setValue(null); - this.renewal_duration.setValue(null); - } - } - - numberRenewalsCheck() { - if (this.number_renewals.value < 1) { - this.renewal_duration.setValue(null); - } - } - + /** + * Display the settings and the libraries according to the cipo level + * @param level - cipo level + */ policyLevelEvent(level: boolean) { this.circulationMapping.setPolicyLevel(level); this.getField('settings').setValue([]); @@ -130,11 +124,22 @@ export class CirculationPolicyComponent implements OnInit { } } + /** + * Check if the library is linked to the cipo + * @param libraryPid - library pid + * + * @returns true or false + */ libraryCheck(libraryPid: string) { const librariesControl = this.getField('libraries'); return librariesControl.value.indexOf(libraryPid) >= 0; } + /** + * Adds or remove the library to the list if its checked or not + * @param checkbox - is checked or not + * @param libraryId - library id + */ libraryClickEvent(checkbox: boolean, libraryId: string) { const values = this.getField('libraries').value; if (checkbox) { @@ -149,19 +154,35 @@ export class CirculationPolicyComponent implements OnInit { } } + /** + * Get patron types list + */ patronTypes() { return this.circulationMapping.getPatronTypes(); } + /** + * Is patron type checked + * @param patronTypeId - patron type id + */ isPatronTypeChecked(patronTypeId: string) { const settingsControl = this.getField('settings'); return patronTypeId in settingsControl.value; } + /** + * Is patron type disabled + * @param patronTypeId - patron type id + */ isPatronTypeDisabled(patronTypeId: string) { return this.circulationMapping.isPatronTypeDisabled(patronTypeId); } + /** + * Add or remove patron type in settings if it's checked or not + * @param checkbox - is checked or not + * @param patronTypeId - patron type id + */ patronTypeClickEvent(checkbox: boolean, patronTypeId: string) { const settings = this.getField('settings').value; if (checkbox) { @@ -173,15 +194,28 @@ export class CirculationPolicyComponent implements OnInit { } } + /** + * Get item types list + */ itemTypes() { return this.circulationMapping.getItemTypes(); } + /** + * Control if item type is checked + * @param patronTypeId - patron type id + * @param itemTypeId - item type id + */ isItemTypeChecked(patronTypeId: string, itemTypeId: string) { const settingsControl = this.getField('settings'); return settingsControl.value[patronTypeId].indexOf(itemTypeId) > -1; } + /** + * Check if item type is disabled + * @param patronTypeId - patron type id + * @param itemTypeId - item type id + */ isItemTypeDisabled(patronTypeId: string, itemTypeId: string) { return this.circulationMapping.isItemTypeDisabled( patronTypeId, @@ -189,6 +223,12 @@ export class CirculationPolicyComponent implements OnInit { ); } + /** + * Adds or remove item type linke to patron type if it's checked or not + * @param checkbox - is checked or not + * @param patronTypeId - patron type id + * @param itemTypeId - item type id + */ itemTypeClickEvent( checkbox: boolean, patronTypeId: string, @@ -207,21 +247,34 @@ export class CirculationPolicyComponent implements OnInit { } } + /** + * Submit form + */ onSubmit() { - this.circulationPolicy.update(this.circulationPolicyForm.getValues()); - this.circulationPolicyService.save(this.circulationPolicy); + this.circulationPolicyService.save({ + pid: this._circulationPolicy.pid, + organisation: this._circulationPolicy.organisation, + ...this.circulationPolicyForm.getValues()}); } - onCancel(event) { + /** + * Cancel form and go back to previous page + * @param event - click event + */ + onCancel(event: any) { event.preventDefault(); this.location.back(); } + /** + * Get field by name + * @param field - field name + */ getField(field: string) { return this.circulationPolicyForm.getControlByFieldName(field); } - /* Control Fields */ + /* Get form controls to use them in template */ get name() { return this.getField('name'); } @@ -256,7 +309,13 @@ export class CirculationPolicyComponent implements OnInit { return this.getField('reminder_fee_amount'); } get currency() { - return this.organisation.default_currency; + return getCurrencySymbol(this.organisation.default_currency, 'wide'); + } + get loan_expiry_notice() { + return this.getField('loan_expiry_notice'); + } + get send_first_reminder() { + return this.getField('send_first_reminder'); } get policy_library_level() { return this.getField('policy_library_level'); 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 20101d01c..93d159588 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 @@ -22,148 +22,135 @@

{{ data.name | translate }}

-
- {{ 'Name' | translate }}: -
-
+
Name
+
{{ data.name }}
-
-
- {{ 'Description' | translate }}: -
-
+
+
Description
+
{{ data.description }}
-
- {{ 'Level' | translate }}: -
+
Level
-
+
Library
-
+
Organisation
-
-

Circulation settings

- -
-
- {{ 'Allow checkout' | translate }}: -
-
- - - - - - - - -
-
- -
-
- {{ 'Allow requests' | translate }}: -
-
- - - - - - - -
-
- -
-
- {{ 'Is default' | translate }}: -
-
- - - - - - - -
-
- -
-
- {{ 'Checkout duration' | translate }}: -
-
- {{ data.checkout_duration }} -
-
- -
-
- {{ 'Number of renewals' | translate }}: -
-
- {{ data.number_renewals }} -
-
- -
-
- {{ 'Renewal duration' | translate }}: -
-
- {{ data.renewal_duration }} -
-
+
+
+ Circulation settings +
+
+ +
+
Allow checkout
+
+ + + + + + + + +
+
+ +
+
Checkout duration
+
+ {{ data.checkout_duration }} +
+
+ +
+
Number of renewals
+
+ {{ data.number_renewals }} +
+
+ +
+
Renewal duration
+
+ {{ data.renewal_duration }} +
+
+ +
+
Allow requests
+
+ + + + + + + +
+
+ +
+
Is default
+
+ + + + + + + +
+
+
-
-

Notifications and fees

- -
-
- {{ 'Number of days after due date' | translate }}: -
-
- {{ data.number_of_days_after_due_date }} -
-
- -
-
- {{ 'Number of days before due date' | translate }}: -
-
- {{ data.number_of_days_before_due_date }} -
-
- -
-
- {{ 'Reminder fee amount' | translate }}: -
-
- {{ data.reminder_fee_amount }} -
-
+
+
+ Notifications and fees +
+
+ +
+
Number of days after due date
+
+ {{ data.number_of_days_after_due_date }} +
+
+ +
+
Number of days before due date
+
+ {{ data.number_of_days_before_due_date }} +
+
+ +
+
Reminder fee amount
+
+ {{ data.reminder_fee_amount }} +
+
+