Skip to content

Commit

Permalink
Adjusted comments and params, adjusted templates
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Sep 13, 2024
1 parent 3d9fe50 commit 41b4e83
Show file tree
Hide file tree
Showing 39 changed files with 708 additions and 675 deletions.
2 changes: 1 addition & 1 deletion local/languages/ReservationList/en-gb.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
; Reservation List
@parent_ini = "finna/FinnaResourceList/en-gb.ini"
@parent_ini = "finna/ReservationList/en-gb.ini"
4 changes: 3 additions & 1 deletion local/languages/ReservationList/fi.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
; Reservation List
@parent_ini = "finna/FinnaResourceList/fi.ini"
@parent_ini = "finna/ReservationList/fi.ini"

list_description_NLF_ResearchRoom = "Kansalliskirjaston luku- ja tutkijasalin varaukset."
2 changes: 1 addition & 1 deletion local/languages/ReservationList/se.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
; Reservation List
@parent_ini = "finna/FinnaResourceList/se.ini"
@parent_ini = "finna/ReservationList/se.ini"
2 changes: 1 addition & 1 deletion local/languages/ReservationList/sv.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
; Reservation List
@parent_ini = "finna/FinnaResourceList/sv.ini"
@parent_ini = "finna/ReservationList/sv.ini"
3 changes: 2 additions & 1 deletion local/languages/finna/ReservationList/fi.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
; Reservation List
Add To Reservation List = "Lisää varauslistalle"
Add Resource to a Reservation List = "Lisää aineisto varauslistalle:"
All Lists = "Kaikki varauslistat"
Choose a List = "Valitse"
Confirm = "Kyllä"
Expand All @@ -22,7 +23,7 @@ Organisations Research Room Office = "Organisaation luku-tai tutkijasalin toimip
Order List = "Tilaa lista"
Phonenumber = "Puhelinnumero"
reservation_list_title = "Luku-tai tutkijasalin varaukset: %%title%%"
Research Room Reservations = "Luku-tai tutkijasalin varaukset"
Reservation Lists = "Varauslistat"
reserve_to_research_room = "Varaa luku-tai tutkijasaliin"
request_post_info_html = '<div class="alert-danger" style="padding: 2px"><b>Huomioithan</b> ettet voi lisätä varaukseen aineistoja lähetyksen jälkeen. Varaus jää talteen Omaan tiliisi.</div>'
request_pre_info_html = ""
Expand Down
1 change: 0 additions & 1 deletion module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,6 @@
'form_handler' => [
'factories' => [
'Finna\Form\Handler\Api' => 'Finna\Form\Handler\ApiFactory',
'Finna\Form\Handler\Database' => 'Finna\Form\Handler\DatabaseFactory',
'Finna\Form\Handler\Email' => 'VuFind\Form\Handler\EmailFactory',
\Finna\Form\Handler\FinnaResourceListEmail::class => \Finna\Form\Handler\FinnaResourceListEmailFactory::class,
],
Expand Down
31 changes: 17 additions & 14 deletions module/Finna/src/Finna/Controller/ReservationListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class ReservationListController extends AbstractBase
/**
* Constructor
*
* @param ServiceLocatorInterface $sm Service locator
* @param ReservationListService $reservationListService Reservation list service
* @param ServiceLocatorInterface $sm Service locator
* @param ReservationListService $reservationListService Reservation list service
*/
public function __construct(
ServiceLocatorInterface $sm,
Expand Down Expand Up @@ -107,6 +107,8 @@ public function addItemAction()
}

$view = $this->createViewModel();
$view->organisation = $this->getParam('organisation');
$view->listIdentifier = $this->getParam('listIdentifier');
$recordId = $this->getParam('recordId');
$source = $this->getParam('source');
$newList = $this->getParam('newList');
Expand All @@ -129,7 +131,6 @@ public function addItemAction()
$params['datasource'] = $driver->getDataSource();
$params['building'] = $driver->getBuildings()[0] ?? '';
if ('saveList' === $state) {

if (!$title) {
$this->flashMessenger()->addErrorMessage('inventory_list_missing_title');
$view->setTemplate('reservationlist/add-list');
Expand All @@ -139,7 +140,7 @@ public function addItemAction()
}

$list = $this->reservationListService->createListForUser(
$this->getUser(),
$this->getUser()
);
$this->reservationListService->updateListFromRequest($list, $user, new Parameters($params));
} elseif ('saveItem' === $state) {
Expand All @@ -160,8 +161,9 @@ public function addItemAction()
$driver->getSourceIdentifier(),
$driver->getDataSource()
);
var_dump(count($view->lists));

$view->setTemplate('reservationlist/select-list');

return $view;
}

Expand All @@ -180,12 +182,13 @@ public function listAction(): \Laminas\View\Model\ViewModel|\Laminas\Http\Respon
// Try to open the list page, if the list is not found, redirect to home.
try {
$results = $this->getListAsResults($request);
$currentList = $this->reservationListService->getAndRememberListObject($request['id'], $user);
$list = $this->reservationListService->getResourceListAsFormattedArray($request['id']);

$viewParams = [
'list' => $currentList,
'list' => $list,
'results' => $results,
'params' => $results->getParams(),
'enabled' => $this->listsEnabledForDatasource($currentList['datasource']),
'enabled' => $this->listsEnabledForDatasource($list['datasource']),
];
try {
return $this->createViewModel($viewParams);
Expand Down Expand Up @@ -268,8 +271,8 @@ public function orderAction()
$handler->setListId($listId);
$success = $handler->handle($form, $this->params(), $user);
if ($success) {
$this->flashMessenger()->addSuccessMessage('FinnaResourceList::form_response');
$this->reservationListService->setOrdered($user, $listId, $request['pickup_date'] ?? '');
$this->flashMessenger()->addSuccessMessage('ReservationList::form_response');
$this->reservationListService->updateListFromRequest($user, $listId, $request['pickup_date'] ?? '');
return $this->inLightbox() // different behavior for lightbox context
? $this->getRefreshResponse()
: $this->redirect()->toRoute('reservationlist-list', ['id' => $listId]);
Expand Down Expand Up @@ -310,7 +313,7 @@ public function deleteAction()
$listID,
$this->url()->fromRoute('reservationlist-delete'),
$this->url()->fromRoute('reservationlist-home'),
'FinnaResourceList::confirm_delete_list',
'ReservationList::confirm_delete_list',
[],
['id' => $listID]
);
Expand All @@ -336,7 +339,7 @@ public function deleteBulkAction()
}
if ($this->getParam('confirm')) {
try {
$this->reservationListService->deleteItems($ids, $listID, $user);
$this->reservationListService->deleteResourcesFromList($ids, $listID, $user);
} catch (LoginRequiredException | ListPermissionException $e) {
$user = $this->getUser();
if ($user == false) {
Expand All @@ -354,7 +357,7 @@ public function deleteBulkAction()
$listID,
$this->url()->fromRoute('reservationlist-deletebulk'),
$this->url()->fromRoute('reservationlist-home'),
'FinnaResourceList::confirm_delete_bulk',
'ReservationList::confirm_delete_bulk',
[],
[
'listID' => $listID,
Expand All @@ -379,7 +382,7 @@ protected function confirmDelete(
$id,
$url,
$fallbackUrl,
$title = 'FinnaResourceList::confirm_delete',
$title = 'ReservationList::confirm_delete',
$messages = 'confirm_delete',
$extras = []
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace Finna\Db\Entity;

use DateTime;
use VuFind\Db\Entity\EntityInterface;
use VuFind\Db\Entity\UserEntityInterface;
use VuFind\Exception\ListPermission as ListPermissionException;
Expand Down Expand Up @@ -59,6 +60,11 @@
*/
interface FinnaResourceListEntityInterface extends EntityInterface
{
/**
* Get the ID of the list.
*
* @return int
*/
public function getId(): int;

/**
Expand Down Expand Up @@ -143,6 +149,11 @@ public function removeResourcesById($user, $ids, $source = DEFAULT_SEARCH_BACKEN
*/
public function getUserId(): int;

/**
* Get user entity
*
* @return UserEntityInterface
*/
public function getUser(): UserEntityInterface;

/**
Expand All @@ -154,7 +165,7 @@ public function getUser(): UserEntityInterface;
*/
public function setUser(UserEntityInterface $user): FinnaResourceListEntityInterface;

/**
/**
* Set title.
*
* @param string $title Title
Expand All @@ -170,15 +181,67 @@ public function setTitle(string $title): FinnaResourceListEntityInterface;
*/
public function getTitle(): string;

/**
* Get datasource.
*
* @return string
*/
public function getDataSource(): string;

/**
* Set datasource.
*
* @param string $dataSource Datasource
*
* @return FinnaResourceListEntityInterface
*/
public function setDataSource(string $dataSource): FinnaResourceListEntityInterface;

/**
* Get description.
*
* @return string
*/
public function getDescription(): string;

/**
* Set description.
*
* @param string $description Description
*
* @return FinnaResourceListEntityInterface
*/
public function setDescription(string $description = ''): FinnaResourceListEntityInterface;

/**
* Get building.
*
* @return string
*/
public function getBuilding(): string;

/**
* Set building.
*
* @param string $building Building
*
* @return FinnaResourceListEntityInterface
*/
public function setBuilding(string $building = ''): FinnaResourceListEntityInterface;

/**
* Created setter
*
* @param DateTime $dateTime Created date
*
* @return FinnaResourceListEntityInterface
*/
public function setCreated(Datetime $dateTime): FinnaResourceListEntityInterface;

/**
* Created getter
*
* @return DateTime
*/
public function getCreated(): DateTime;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
<?php

/**
* Finna resource list resource entity interface.
*
* 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 Finna_Db
* @author Juha Luoma <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/

namespace Finna\Db\Entity;

use DateTime;
use VuFind\Db\Entity\EntityInterface;
use VuFind\Db\Entity\ResourceEntityInterface;
use VuFind\Db\Entity\UserEntityInterface;

/**
* Finna resource list resource entity interface.
*
* @category VuFind
* @package Finna_Db
* @author Juha Luoma <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
interface FinnaResourceListResourceEntityInterface extends EntityInterface
{
/**
Expand All @@ -19,7 +52,7 @@ public function getId(): ?int;
/**
* Resource ID setter
*
* @param ResourceEntityInterface $id Resource ID
* @param ResourceEntityInterface $resource Resource entity
*
* @return FinnaResourceListResourceEntityInterface
*/
Expand All @@ -42,7 +75,7 @@ public function getListId(): int;
/**
* Set list id
*
* @param FinnaResourceListEntityInterface $listId Id of list
* @param FinnaResourceListEntityInterface $list List entity
*
* @return FinnaResourceListResourceEntityInterface
*/
Expand All @@ -67,7 +100,7 @@ public function getSaved(): Datetime;
/**
* Data setter
*
* @param string $data Data
* @param string $note Note
*
* @return FinnaResourceListResourceEntityInterface
*/
Expand Down
Loading

0 comments on commit 41b4e83

Please sign in to comment.