Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FINNA-2767] Initial implementation of disec support for reservation lists #3091

Merged
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7c15adb
Initial implementation of disec support for reservation lists
LuomaJuha Nov 28, 2024
a8a59ae
Adjusted to log values, added ReservationListStatus enumerator
LuomaJuha Nov 29, 2024
9adda13
Merge branch 'dev' into reservationlist-disec-implementation
LuomaJuha Dec 3, 2024
412e76b
Review fixes
LuomaJuha Dec 5, 2024
64f5ee2
Adjusted sample file to match
LuomaJuha Dec 5, 2024
f18570f
Added missing empty translation
LuomaJuha Dec 5, 2024
389e207
Moved properties to proper class
LuomaJuha Dec 5, 2024
83221b9
Adjusted keys
LuomaJuha Dec 5, 2024
04db089
Fixed typos in translations, moved Connection specific classes to the…
LuomaJuha Dec 10, 2024
8427a2d
Manipulate post params less, use form more properly.
LuomaJuha Dec 11, 2024
371302a
Adjusted setListOrdered default values set
LuomaJuha Dec 11, 2024
a5f3652
Moved reservation list specific form functionality to its own class
LuomaJuha Dec 11, 2024
ea5f3bc
Removed unused parts of code
LuomaJuha Dec 11, 2024
94fa86a
Readded in_process as it is a plausible state for order, adjusted com…
LuomaJuha Dec 11, 2024
030f466
Revert php versions to 8
LuomaJuha Dec 11, 2024
7c9b98f
And also this one
LuomaJuha Dec 11, 2024
8add8c4
Adjusted to not use feedback
LuomaJuha Jan 3, 2025
2a072c7
Removed sample from feedbackforms.yaml.sample
LuomaJuha Jan 3, 2025
d5515e6
Removed odd variable from default values
LuomaJuha Jan 3, 2025
01dac99
Adjusted param types
LuomaJuha Jan 3, 2025
ef99018
Renamed to match handler instead of connection
LuomaJuha Jan 14, 2025
ae47fcd
Adjusted comments
LuomaJuha Jan 14, 2025
61d0be0
Adjusted variable name in reservationlistservice
LuomaJuha Jan 15, 2025
a7873af
Line length fix
LuomaJuha Jan 15, 2025
e40eaea
removed switch case from reservationlist ajax handler
LuomaJuha Jan 15, 2025
a7501a9
Adjusted to use function defined in abstractbase to fetch required va…
LuomaJuha Jan 15, 2025
cd30dcb
Removed some calls to helper
LuomaJuha Jan 15, 2025
57d01e7
Update module/Finna/src/Finna/ReservationList/ReservationListService.php
LuomaJuha Jan 15, 2025
8d2cfc1
Update module/Finna/src/Finna/ReservationList/ReservationListService.php
LuomaJuha Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions local/config/finna/FeedbackForms.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -341,47 +341,3 @@ forms:
label: feedback_message
settings:
- [rows, 3]
ReservationListRequest:
allowLocalOverride: true
title: ReservationList::form_title
enabled: true
sendMethod: "email"
onlyForLoggedUsers: true
emailSubject: ReservationList::form_email_subject
response: ReservationList::form_response
hideSenderInfo: true
hideRecipientInfo: true
primaryHandler: email
senderNameRequired: true
includePatronId: true
help:
pre: ReservationList::request_pre_info_html
post: ReservationList::request_post_info_html

fields:
- name: record_ids
type: textarea
label: ReservationList::Reservation Resources
settings:
- [rows, 3]
- [readonly, true]
- name: name
type: text
label: feedback_name
- name: email
type: email
label: Email
- name: phone
type: text
label: Phone
- name: pickup_date
type: date
label: ReservationList::Delivery Time Request
minValue: now + 2 days
maxValue: now + 1 year
required: true
- name: message
type: textarea
label: ReservationList::Message
settings:
- [rows, 3]
69 changes: 66 additions & 3 deletions local/config/finna/ReservationList.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
# List can contain same information as under institution information to be more specific
# about where the order is being delivered
# LibraryCardSources is used to check for active connection to ILS to be able to use lists
# Connection holds information about type of lists, currently only value supported is type: Database
# and is the default value, if omitted
# Connection defines how the orders are handled with institutions:
# Type:
# email: Uses email to place orders
# Sender:
# name: Name to be shown as the sender of the email
# email: Email address to be shown as where the email was sent
# subject: Subject to be shown in the email
# disec: Uses Disec api for sending orders
# base_url: Api base url
# secret: Api specific secret
# use_cat_id: [Optional] Use catalog id for user instead of firstName, lastName, email. Default false.
#
# Each list declared uses their own translation keys under translation domain ReservationList::
#
Expand Down Expand Up @@ -43,7 +52,61 @@ Institutions:
Address: teststreet 10
Postal: 000001
City: Test city
Forms:
- PlaceOrder: default
LibraryCardSources:
- connection_established_to_use_lists
Connection:
type: Database
type: email
Sender:
name: Service sender
email: [email protected]
subject: Reservation List
PlaceOrder:
default:
allowLocalOverride: false
title: ReservationList::form_title
enabled: true
onlyForLoggedUsers: true
emailSubject: ReservationList::form_email_subject
response: ReservationList::form_response
hideSenderInfo: true
hideRecipientInfo: true
senderNameRequired: true
includePatronId: true
help:
pre: ReservationList::request_pre_info_html
post: ReservationList::request_post_info_html

fields:
- name: record_ids_text
type: textarea
label: ReservationList::Reservation Resources
settings:
- [rows, 3]
- [readonly, true]
- name: firstName
type: text
label: First Name
required: true
- name: lastName
type: text
label: Last Name
required: true
- name: email
type: email
label: Email
- name: phone
type: text
label: Phone
- name: pickup_date
type: date
label: ReservationList::Delivery Time Request
minValue: now + 2 days
maxValue: now + 1 year
required: true
- name: message
type: textarea
label: ReservationList::Message
settings:
- [rows, 3]
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/en-gb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Reservation lists name"
Send Reservation Request = "Send reservation request"
select_desired_contact_method = "Select desired contact method"
Select = "Select"

; List statuses:
status_unknown = ""
status_delivered = "Delivered"
status_in_process = "In process"
status_canceled = "Cancelled"
status_on_loan = "On Loan"
status_returned = "Returned"
status_renewed = "Renewed"
status_pending = "Pending"
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Varauslistan nimi"
Send Reservation Request = "Lähetä varauspyyntö"
select_desired_contact_method = "Valitse haluamasi yhteydenottotapa"
Select = "Valitse"

; List statuses:
status_unknown = ""
status_delivered = "Toimitettu"
status_in_process = "Käsittelyssä"
status_canceled = "Peruutettu"
status_on_loan = "Lainassa"
status_returned = "Palautettu"
status_renewed = "Uusittu"
status_pending = "Odottaa"
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/se.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = ""
Send Reservation Request = ""
select_desired_contact_method = ""
Select = ""

; List statuses:
status_unknown = ""
status_delivered = ""
status_in_process = ""
status_canceled = ""
status_on_loan = ""
status_returned = ""
status_renewed = ""
status_pending = ""
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Namn för bokningslista"
Send Reservation Request = "Skicka bokningsförfrågan"
select_desired_contact_method = "Välj önskad kontaktmetod"
Select = "Välj"

; List statuses:
status_unknown = ""
status_delivered = "Levererad"
status_in_process = "Behandlas"
status_canceled = "Annullerad"
status_on_loan = "Utlånad"
status_returned = "Returnerad"
status_renewed = "Förnyad"
status_pending = "Väntar"
6 changes: 6 additions & 0 deletions module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@
'Finna\Service\UserPreferenceService' => 'Finna\Service\UserPreferenceServiceFactory',
'Finna\Statistics\Driver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Statistics\EventHandler' => 'Finna\Statistics\EventHandlerFactory',
\Finna\ReservationList\Form\Form::class => \Finna\Form\FormFactory::class,
\Finna\ReservationList\ReservationListService::class => \Finna\ReservationList\ReservationListServiceFactory::class,
\Finna\ReservationList\Handler\PluginManager::class => \VuFind\ServiceManager\AbstractPluginManagerFactory::class,
'Finna\Favorites\FavoritesService' => 'Finna\Favorites\FavoritesServiceFactory',
'Finna\View\CustomElement\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Video\Handler\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
Expand Down Expand Up @@ -491,6 +493,8 @@
'Finna\AjaxHandler\GetUserListFactory',
'Finna\AjaxHandler\GetUserLists' =>
'Finna\AjaxHandler\GetUserListsFactory',
'Finna\AjaxHandler\ReservationList' =>
'Finna\AjaxHandler\ReservationListFactory',
'Finna\AjaxHandler\ImportFavorites' =>
'Finna\AjaxHandler\ImportFavoritesFactory',
'Finna\AjaxHandler\OnlinePaymentNotify' =>
Expand Down Expand Up @@ -531,6 +535,7 @@
'getSearchTabsRecommendations' => 'Finna\AjaxHandler\GetSearchTabsRecommendations',
'getSimilarRecords' => 'Finna\AjaxHandler\GetSimilarRecords',
'getUserList' => 'Finna\AjaxHandler\GetUserList',
'reservationList' => 'Finna\AjaxHandler\ReservationList',
'importFavorites' => 'Finna\AjaxHandler\ImportFavorites',
'onlinePaymentNotify' => 'Finna\AjaxHandler\OnlinePaymentNotify',
'registerOnlinePayment' => 'Finna\AjaxHandler\RegisterOnlinePayment',
Expand Down Expand Up @@ -763,6 +768,7 @@
],
'onlinepayment_handler' => [ /* see Finna\OnlinePayment\Handler\PluginManager for defaults */ ],
'video_handler' => [ /* see Finna\Video\Handler\PluginManager for defaults */ ],
'reservationlist_handler' => [ /* see Finna\ReservationList\Handler\PluginManager for defaults */ ],
'recommend' => [
'factories' => [
'VuFind\Recommend\CollectionSideFacets' => 'Finna\Recommend\Factory::getCollectionSideFacets',
Expand Down
3 changes: 2 additions & 1 deletion module/Finna/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ CREATE TABLE `finna_resource_list` (
`list_type` varchar(200) NOT NULL DEFAULT 'resourcelist',
`ordered` datetime DEFAULT NULL,
`pickup_date` datetime DEFAULT NULL,
`connection` varchar(40) NOT NULL DEFAULT 'database',
`connection` varchar(40) NOT NULL DEFAULT 'email',
`external_id` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `resource_list_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
Expand Down
109 changes: 109 additions & 0 deletions module/Finna/src/Finna/AjaxHandler/ReservationList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

/**
* Reservation list ajax handler
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2024.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/

namespace Finna\AjaxHandler;

use Finna\ReservationList\Handler\PluginManager;
use Finna\ReservationList\ReservationListService;
use Laminas\Mvc\Controller\Plugin\Params;
use VuFind\Db\Entity\UserEntityInterface;
use VuFind\I18n\Translator\TranslatorAwareInterface;

/**
* Reservation list ajax handler
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/
class ReservationList extends \VuFind\AjaxHandler\AbstractBase implements TranslatorAwareInterface
{
use \VuFind\I18n\Translator\TranslatorAwareTrait;

/**
* Constructor
*
* @param ?UserEntityInterface $user Logged in user (or null)
* @param ReservationListService $reservationListService Reservation list service
* @param PluginManager $connectionHandler Reservation List connection handler
*/
public function __construct(
protected ?UserEntityInterface $user,
protected ReservationListService $reservationListService,
protected PluginManager $connectionHandler,
) {
}

/**
* Handle a request.
*
* @param Params $params Parameter helper from controller
*
* @return array [response data, HTTP status code]
*/
public function handleRequest(Params $params)
{
if ($this->user === null) {
return $this->formatResponse(
$this->translate('You must be logged in first'),
self::STATUS_HTTP_NEED_AUTH
);
}
$listId = (int)$params->fromQuery('list_id');
if (!$listId) {
return $this->formatResponse(
'Bad request',
self::STATUS_HTTP_BAD_REQUEST
);
}
$list = $this->reservationListService->getListById($listId, $this->user);
if (!$list) {
return $this->formatResponse(
'Bad request',
self::STATUS_HTTP_BAD_REQUEST
);
}
$result = [];
$type = $params->fromQuery('type');
if ('status' === $type) {
$listProperties = $this->reservationListService->getListProperties(
$list->getInstitution(),
$list->getListConfigIdentifier()
)['properties'];
$handler = $this->connectionHandler->getWithConfig($listProperties);
$response = $handler->getListStatus($list, $this->user);
$result['status'] = $this->translate($response);
} else {
return $this->formatResponse('Bad request', self::STATUS_HTTP_BAD_REQUEST);
}
return $this->formatResponse($result);
}
}
Loading
Loading