diff --git a/lib/GaletteObjectsLend/Controllers/Crud/ObjectsController.php b/lib/GaletteObjectsLend/Controllers/Crud/ObjectsController.php index f7c2f3d..78f472f 100644 --- a/lib/GaletteObjectsLend/Controllers/Crud/ObjectsController.php +++ b/lib/GaletteObjectsLend/Controllers/Crud/ObjectsController.php @@ -325,7 +325,8 @@ public function edit(Request $request, Response $response, ?int $id = null, stri 'olendsprefs' => $lendsprefs, 'categories' => $categories_list, 'statuses' => $slist, - 'picture' => $object->getPicture() + 'picture' => $object->getPicture(), + 'html_editor' => true ]; // members diff --git a/lib/GaletteObjectsLend/Entity/LendObject.php b/lib/GaletteObjectsLend/Entity/LendObject.php index 9f9b09c..0239c00 100644 --- a/lib/GaletteObjectsLend/Entity/LendObject.php +++ b/lib/GaletteObjectsLend/Entity/LendObject.php @@ -32,7 +32,7 @@ class LendObject private array $fields = [ 'object_id' => 'integer', 'name' => 'varchar(100)', - 'description' => 'varchar(500)', + 'description' => 'text', 'serial_number' => 'varchar(30)', 'price' => 'decimal', 'rent_price' => 'decimal', diff --git a/lib/GaletteObjectsLend/IO/PdfObject.php b/lib/GaletteObjectsLend/IO/PdfObject.php index e33cb55..a1f109f 100644 --- a/lib/GaletteObjectsLend/IO/PdfObject.php +++ b/lib/GaletteObjectsLend/IO/PdfObject.php @@ -24,6 +24,12 @@ */ class PdfObject extends Pdf { + /** @var array Tags kept in HTML values */ + private const array HTML_TAGS = [ + 'a', 'b', 'blockquote', 'br', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', + 'li', 'ol', 'p', 's', 'span', 'strong', 'sub', 'sup', 'u', 'ul' + ]; + private Db $zdb; private LendPreferences $lprefs; @@ -121,7 +127,7 @@ public function drawCard(LendObject $object): void $this->addCell(_T("Name", "objectslend"), $object->getName(), $wpic); if ($this->lprefs->isEnabled(LendPreferences::VIEW_DESCRIPTION)) { - $this->addCell(_T("Description", "objectslend"), $object->getDescription(), $wpic); + $this->addHtmlCell(_T("Description", "objectslend"), $object->getDescriptionHtml(), $wpic); } if ($this->lprefs->isEnabled(LendPreferences::VIEW_CATEGORY)) { $this->addCell(_T("Category", "objectslend"), $object->getCategoryName() ?? '', $wpic); @@ -218,4 +224,29 @@ private function addCell(string $title, string $value, int $width): void $this->MultiCell(0, 0, $w, 0, 'L'); } } + + /** + * Add a cell whose value is sanitized HTML + * + * Only text formatting is kept: TCPDF would load an image source from the + * server, be it an internal URL or a local file. + * + * @param string $title Cell title + * @param string $html Cell value + * @param int $width Picture width + */ + private function addHtmlCell(string $title, string $html, int $width): void + { + $html = strip_tags($html, self::HTML_TAGS); + + if ($width > 0) { + $this->Cell($width, 0, ''); + } + $this->SetFont(Pdf::FONT, 'B', 9); + $padding = 50; + $this->Cell($padding, 0, $this->cut($title, $padding)); + + $this->SetFont(Pdf::FONT, '', 9); + $this->MultiCell(0, 0, $html, 0, 'L', false, 1, null, null, true, 0, true); + } } diff --git a/lib/GaletteObjectsLend/IO/PdfObjects.php b/lib/GaletteObjectsLend/IO/PdfObjects.php index 27ddc7c..df1fbb5 100644 --- a/lib/GaletteObjectsLend/IO/PdfObjects.php +++ b/lib/GaletteObjectsLend/IO/PdfObjects.php @@ -12,6 +12,7 @@ use Galette\Core\Db; use Galette\IO\Pdf; +use Galette\Util\Html; use Galette\Core\Preferences; use Galette\Core\Login; use GaletteObjectsLend\Entity\LendObject; @@ -199,7 +200,7 @@ public function drawList(array $objects): void $fill = !$object->inStock(); $this->Cell($w_checkbox, 0, '□', 'B', 0, 'L', $fill); $this->Cell($w_name, 0, $this->cut($object->getName(), $w_name), 'B', 0, 'L', $fill); - $this->Cell($w_description, 0, $this->cut($object->getDescription(), $w_description), 'B', 0, 'L', $fill); + $this->Cell($w_description, 0, $this->cut($this->oneLine($object->getDescriptionHtml()), $w_description), 'B', 0, 'L', $fill); $this->Cell($w_serial, 0, $this->cut($object->getSerialNumber(), $w_serial), 'B', 0, 'L', $fill); $this->Cell($w_price, 0, $this->cut(number_format($object->getPrice(), 2, ',', ' '), $w_price), 'B', 0, 'R', $fill); $this->Cell($w_price, 0, $this->cut(number_format($object->getRentPrice(), 2, ',', ' '), $w_price) . '€', 'B', 0, 'R', $fill); @@ -233,4 +234,16 @@ public function drawList(array $objects): void $this->Cell($w_price, 0, '', true); $this->Cell(0, 0, _T("Available", "objectslend"), 0, 1); } + + /** + * HTML description as a single line of text + * + * @param string $html Description + */ + private function oneLine(string $html): string + { + //blocks are only separated by their tags, which are about to go + $html = (string)preg_replace('#<(/?(?:p|br|li|ul|ol|div|h[1-6]|tr|td)\b)#i', ' <$1', $html); + return trim((string)preg_replace('/\s+/u', ' ', Html::strip($html))); + } } diff --git a/scripts/mysql.sql b/scripts/mysql.sql index 8c8edaf..cc8d52d 100644 --- a/scripts/mysql.sql +++ b/scripts/mysql.sql @@ -48,7 +48,7 @@ DROP TABLE IF EXISTS galette_lend_objects; CREATE TABLE galette_lend_objects ( object_id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, - description varchar(500) NOT NULL, + description text NOT NULL, serial_number varchar(30) NOT NULL, price decimal(15,3) NOT NULL, price_per_day tinyint(1) NOT NULL DEFAULT FALSE, diff --git a/scripts/pgsql.sql b/scripts/pgsql.sql index 9c631bd..bb715c6 100644 --- a/scripts/pgsql.sql +++ b/scripts/pgsql.sql @@ -86,7 +86,7 @@ DROP TABLE IF EXISTS galette_lend_objects CASCADE; CREATE TABLE galette_lend_objects ( object_id integer DEFAULT nextval('galette_lend_objects_id_seq'::text) NOT NULL, name character varying(100) NOT NULL, - description character varying(500) NOT NULL, + description text NOT NULL, serial_number character varying(30) NOT NULL, price numeric(15,3) NOT NULL, price_per_day boolean NOT NULL DEFAULT FALSE, diff --git a/scripts/upgrade-to-1.1-mysql.sql b/scripts/upgrade-to-1.1-mysql.sql index 3d51533..6095d15 100644 --- a/scripts/upgrade-to-1.1-mysql.sql +++ b/scripts/upgrade-to-1.1-mysql.sql @@ -59,7 +59,7 @@ FROM galette_lend_rents; CREATE TABLE galette_lend_objects_new ( object_id int(10) unsigned NOT NULL AUTO_INCREMENT, name varchar(100) NOT NULL, - description varchar(500) NOT NULL, + description text NOT NULL, serial_number varchar(30) NOT NULL, price decimal(15,3) NOT NULL, price_per_day tinyint(1) NOT NULL DEFAULT FALSE, diff --git a/scripts/upgrade-to-1.1-pgsql.sql b/scripts/upgrade-to-1.1-pgsql.sql index 5f872fe..5f5e557 100644 --- a/scripts/upgrade-to-1.1-pgsql.sql +++ b/scripts/upgrade-to-1.1-pgsql.sql @@ -30,6 +30,9 @@ ALTER TABLE galette_lend_objects ALTER COLUMN weight TYPE numeric(15,3) USING ROUND(CAST(weight AS numeric), 3), ALTER COLUMN rent_price TYPE numeric(15,3) USING ROUND(CAST(rent_price AS numeric), 3); +-- Description is edited with the HTML editor, its markup does not fit in 500 characters +ALTER TABLE galette_lend_objects ALTER COLUMN description TYPE text; + -- A rent always has an object and a status UPDATE galette_lend_objects SET rent_id = NULL WHERE rent_id IN ( SELECT rent_id FROM galette_lend_rents WHERE object_id IS NULL OR status_id IS NULL diff --git a/templates/default/categories_list.html.twig b/templates/default/categories_list.html.twig index fdef393..62ffe29 100644 --- a/templates/default/categories_list.html.twig +++ b/templates/default/categories_list.html.twig @@ -6,9 +6,22 @@ {% extends 'elements/list.html.twig' %} {% import "macros.twig" as macros %} +{% import "@PluginGaletteObjectslend/macros.twig" as lend %} {% set nb = nb_categories %} +{% set columns = [ + { + 'label': '#', + 'collapse': true + }, + {'label': _T("Name", "objectslend"), order: constant('GaletteObjectsLend\\Repository\\Categories::ORDERBY_NAME')}, + { + 'label': _T("Active", "objectslend"), order: constant('GaletteObjectsLend\\Repository\\Categories::ORDERBY_ACTIVITY'), + 'collapse': true + }, +] %} + {% set form = { 'order': { 'name': 'objectslend_categories' @@ -32,62 +45,13 @@ {% endblock %} -{% block header %} - {% set columns = [ - { - 'label': '#', - 'collapse': true - }, - {'label': _T("Name", "objectslend"), order: constant('GaletteObjectsLend\\Repository\\Categories::ORDERBY_NAME')}, - { - 'label': _T("Active", "objectslend"), order: constant('GaletteObjectsLend\\Repository\\Categories::ORDERBY_ACTIVITY'), - 'collapse': true - }, - ] %} - {{ parent() }} -{% endblock %} - {% block search %}
-
- - -
+ {{ lend.searchField(filters.filter_str) }}
-
-
- -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
+ {{ lend.triStateFilter('active_filter', 'active', _T("Active:", "objectslend"), filters.active_filter, {dc: constant('GaletteObjectsLend\\Repository\\Categories::ALL_CATEGORIES'), yes: constant('GaletteObjectsLend\\Repository\\Categories::ACTIVE_CATEGORIES'), no: constant('GaletteObjectsLend\\Repository\\Categories::INACTIVE_CATEGORIES')}) }} + {{ lend.filterButtons() }}
@@ -110,7 +74,7 @@ {{ categ.getName(false) }} - + {% if categ.isActive() %}{{ _T("Active", "objectslend") }}{% else %}{{ _T("Inactive", "objectslend") }}{% endif %} {% if login.isAdmin() or login.isStaff() %} @@ -148,8 +112,7 @@ {% else %} - {{ _T("No category", "objectslend") }} + {{ _T("No category", "objectslend") }} {% endfor %} - {% endblock %} diff --git a/templates/default/category_edit.html.twig b/templates/default/category_edit.html.twig index e56c37b..9aa0e06 100644 --- a/templates/default/category_edit.html.twig +++ b/templates/default/category_edit.html.twig @@ -5,12 +5,13 @@ #} {% extends "page.html.twig" %} +{% import "@PluginGaletteObjectslend/macros.twig" as lend %} {% block content %}
-
- +
+ {{ _T("Category", "objectslend") }}
@@ -35,12 +36,7 @@ max_size: olendsprefs.getUploadSize(), input_id: "picture_file" } %} - {{ _T( + {{ lend.thumbnail("category", category.getId(), picture, olendsprefs, _T("Category photo", "objectslend")) }}
{% if picture.hasPicture() %} {% include "components/forms/checkbox.html.twig" with { @@ -57,7 +53,7 @@
diff --git a/templates/default/headers.html.twig b/templates/default/headers.html.twig deleted file mode 100644 index 51ee64a..0000000 --- a/templates/default/headers.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{# - # This file is part of Galette Objects Lend plugin (https://galette.eu). - # SPDX-FileCopyrightText: Copyright © 2013-2026 The Galette Team - # SPDX-License-Identifier: GPL-3.0-or-later - #} - -{% if olendsprefs is defined %} - -{% endif %} diff --git a/templates/default/history_modal.js.twig b/templates/default/history_modal.js.twig index 1e3f706..5e5bc9e 100644 --- a/templates/default/history_modal.js.twig +++ b/templates/default/history_modal.js.twig @@ -29,7 +29,14 @@ } %} }, error: function(){ - alert("{{ _T("An error occurred loading history display :(", "objectslend")|e("js") }}") + {% include "elements/js/modal.js.twig" with { + modal_title_twig: _T("An error occurred loading history display :(", "objectslend")|e("js"), + modal_without_content: true, + modal_class: "mini", + modal_deny_only: true, + modal_cancel_text: _T("Close")|e("js"), + modal_classname: "redalert", + } %} } }); }); diff --git a/templates/default/list_lent_object.html.twig b/templates/default/list_lent_object.html.twig index 531e2a1..dab2150 100644 --- a/templates/default/list_lent_object.html.twig +++ b/templates/default/list_lent_object.html.twig @@ -10,33 +10,29 @@ {% set no_action = true %} {% set is_paginated = false %} -{% block infoline %} -{% endblock %} +{% set columns = [ + { + 'label': _T("Id", "objectslend"), + 'collapse': true + }, + {'label': _T("Status", "objectslend")}, + { + 'label': _T("Begin date", "objectslend"), + 'collapse': true + }, + { + 'label': _T("End date", "objectslend"), + 'collapse': true + }, + { + 'label': _T("Return", "objectslend"), + 'collapse': true + }, + {'label': _T("Name", "objectslend")}, + {'label': _T("Comments", "objectslend")}, +] %} -{% block header %} - {% set columns = [ - { - 'label': _T("Id", "objectslend"), - 'collapse': true - }, - {'label': _T("Status", "objectslend")}, - { - 'label': _T("Begin date", "objectslend"), - 'collapse': true - }, - { - 'label': _T("End date", "objectslend"), - 'collapse': true - }, - { - 'label': _T("Return", "objectslend"), - 'collapse': true - }, - {'label': _T("Name", "objectslend")}, - {'label': _T("Comments", "objectslend")}, - ] %} - - {{ parent() }} +{% block infoline %} {% endblock %} {% block body %} @@ -55,7 +51,7 @@ {% else %} - {{ _T("No lend found", "objectslend") }} + {{ _T("No lend found", "objectslend") }} {% endfor %} {% endblock %} diff --git a/templates/default/macros.twig b/templates/default/macros.twig new file mode 100644 index 0000000..4ede4d7 --- /dev/null +++ b/templates/default/macros.twig @@ -0,0 +1,78 @@ +{# + # This file is part of Galette Objects Lend plugin (https://galette.eu). + # SPDX-FileCopyrightText: Copyright © 2013-2026 The Galette Team + # SPDX-License-Identifier: GPL-3.0-or-later + #} + +{# Free text search of the filter forms #} +{% macro searchField(value) %} +
+ + +
+{% endmacro %} + +{# "Don't care", "Yes" and "No" radio buttons; values are keyed by dc, yes and no. + A radio group rather than a fieldset, whose border does not belong in a filter form. #} +{% macro triStateFilter(name, suffix, label, current, values) %} +
+
+ + {% for key, text in {dc: _T("Don't care"), yes: _T("Yes"), no: _T("No")} %} +
+
+ + +
+
+ {% endfor %} +
+
+{% endmacro %} + +{# Submit and reset buttons of the filter forms #} +{% macro filterButtons(extra_class) %} +
+ + +
+{% endmacro %} + +{# Status menu; detail adds the rent days ("days") or the stock state ("stock") to each status #} +{% macro statusSelect(id, label, statuses, empty_value, detail) %} + {% set values = {(empty_value): _T("--- Select a status ---", "objectslend")} %} + {% for sta in statuses %} + {% set text = sta.getText() %} + {% if detail == 'days' and sta.getRentDayNumber() %} + {% set text = text ~ ' (' ~ _T("%days days", "objectslend")|replace({'%days': sta.getRentDayNumber()}) ~ ')' %} + {% elseif detail == 'stock' and sta.isInStock() %} + {% set text = text ~ ' (' ~ _T("In stock", "objectslend") ~ ')' %} + {% endif %} + {% set values = values + {(sta.getId()): text} %} + {% endfor %} + + {% include "components/forms/select.html.twig" with { + id: id, + value: '', + values: values, + label: label + } %} +{% endmacro %} + +{# Thumbnail, linked to the full size picture; no id for the default picture #} +{% macro thumbnail(type, id, picture, prefs, alt, extra_class) %} + {% set args = id ? {"type": type, "id": id} : {"type": type} %} + + {{ alt }} + +{% endmacro %} diff --git a/templates/default/objects_edit.html.twig b/templates/default/objects_edit.html.twig index 5530a13..67d8579 100644 --- a/templates/default/objects_edit.html.twig +++ b/templates/default/objects_edit.html.twig @@ -5,6 +5,7 @@ #} {% extends 'page.html.twig' %} +{% import "@PluginGaletteObjectslend/macros.twig" as lend %} {% block content %}
@@ -19,7 +20,7 @@ required: true } %} - {% include "components/forms/text.html.twig" with { + {% include "components/forms/textarea.html.twig" with { id: 'description', value: object.getDescription(), label: _T("Description:", "objectslend") @@ -91,17 +92,7 @@ {% if not object.getId() %} - {% set state_list_values = {(0): _T("--- Select a status ---", "objectslend")} %} - {% for sta in statuses %} - {% set state_list_values = state_list_values + {(sta.getId()): sta.getText()} %} - {% endfor %} - - {% include "components/forms/select.html.twig" with { - id: '1st_status', - value: '', - values: state_list_values, - label: _T("Where is the object?", "objectslend") - } %} + {{ lend.statusSelect('1st_status', _T("Where is the object?", "objectslend"), statuses, 0) }} {% endif %}
@@ -137,12 +128,7 @@
- {{ _T( + {{ lend.thumbnail("object", object.getId(), picture, olendsprefs, _T("Object's photo", "objectslend")) }}
{% if picture.hasPicture() %} @@ -178,21 +164,7 @@
{{ _T("Change status", "objectslend") }}
- {% set state_list_values = {(-1): _T("--- Select a status ---", "objectslend")} %} - {% for sta in statuses %} - {% set text = sta.getText() %} - {% if sta.isInStock() %} - {% set text = text ~ ' (' ~ _T("In stock", "objectslend") ~ ')' %} - {% endif %} - {% set state_list_values = state_list_values + {(sta.getId()): text} %} - {% endfor %} - - {% include "components/forms/select.html.twig" with { - id: 'new_status', - value: '', - values: state_list_values, - label: _T("Status", "objectslend") - } %} + {{ lend.statusSelect('new_status', _T("Status", "objectslend"), statuses, -1, 'stock') }} {% include "components/forms/text.html.twig" with { id: 'new_comment', @@ -225,5 +197,9 @@ {% endblock %} diff --git a/templates/default/objects_list.html.twig b/templates/default/objects_list.html.twig index 7c7fd65..01a3416 100644 --- a/templates/default/objects_list.html.twig +++ b/templates/default/objects_list.html.twig @@ -6,9 +6,91 @@ {% extends 'elements/list.html.twig' %} {% import "macros.twig" as macros %} +{% import "@PluginGaletteObjectslend/macros.twig" as lend %} {% set nb = nb_objects %} +{% set columns = [] %} + +{% if login.isAdmin() or login.isStaff() %} + {% set columns = columns|merge([ + { + 'label': '#', + 'collapse': true + }, + ]) %} +{% endif %} + +{% if olendsprefs.imagesInLists() %} + {% set columns = columns|merge([ + { + 'label': _T("Picture"), + 'collapse': true + }, + ]) %} +{% endif %} + +{% set columns = columns|merge([ + {'label': _T("Name", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_NAME")}, +]) %} + +{% if lendsprefs.view_serial %} + {% set columns = columns|merge([ + {'label': _T("Serial", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_SERIAL")}, + ]) %} +{% endif %} + +{% if lendsprefs.view_price %} + {% set columns = columns|merge([ + {'label': _T("Price", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_PRICE")}, + ]) %} +{% endif %} + +{% if lendsprefs.view_lend_price %} + {% set columns = columns|merge([ + {'label': _T("Borrow price", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_RENTPRICE")}, + ]) %} +{% endif %} + +{% if lendsprefs.view_dimension %} + {% set columns = columns|merge([ + {'label': _T("Dimensions", "objectslend")}, + ]) %} +{% endif %} + +{% if lendsprefs.view_weight %} + {% set columns = columns|merge([ + {'label': _T("Weight", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_WEIGHT")}, + ]) %} +{% endif %} + +{% set columns = columns|merge([ + {'label': _T("Status", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_STATUS")}, + { + 'label': _T("Since", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_BDATE"), + 'collapse': true + }, + {'label': _T("By", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_MEMBER")}, +]) %} + +{% if lendsprefs.view_date_forecast %} + {% set columns = columns|merge([ + { + 'label': _T("Return", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_FDATE"), + 'collapse': true + }, + ]) %} +{% endif %} + +{% if login.isAdmin() or login.isStaff() %} + {% set columns = columns|merge([ + { + 'label': _T("Active", "objectslend"), + 'collapse': true + }, + ]) %} +{% endif %} + {% set form = { 'order': { 'name': "objectslend_objects" @@ -40,99 +122,11 @@ {% endif %} {% endblock %} -{% block header %} - {% set columns = [] %} - - {% if login.isAdmin() or login.isStaff() %} - {% set columns = columns|merge([ - { - 'label': '#', - 'collapse': true - }, - ]) %} - {% endif %} - - {% if olendsprefs.imagesInLists() %} - {% set columns = columns|merge([ - { - 'label': _T("Picture"), - 'collapse': true - }, - ]) %} - {% endif %} - - {% set columns = columns|merge([ - {'label': _T("Name", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_NAME")}, - ]) %} - - {% if lendsprefs.view_serial %} - {% set columns = columns|merge([ - {'label': _T("Serial", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_SERIAL")}, - ]) %} - {% endif %} - - {% if lendsprefs.view_price %} - {% set columns = columns|merge([ - {'label': _T("Price", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_PRICE")}, - ]) %} - {% endif %} - - {% if lendsprefs.view_lend_price %} - {% set columns = columns|merge([ - {'label': _T("Borrow price", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_RENTPRICE")}, - ]) %} - {% endif %} - - {% if lendsprefs.view_dimension %} - {% set columns = columns|merge([ - {'label': _T("Dimensions", "objectslend")}, - ]) %} - {% endif %} - - {% if lendsprefs.view_weight %} - {% set columns = columns|merge([ - {'label': _T("Weight", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_WEIGHT")}, - ]) %} - {% endif %} - - {% set columns = columns|merge([ - {'label': _T("Status", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_STATUS")}, - { - 'label': _T("Since", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_BDATE"), - 'collapse': true - }, - {'label': _T("By", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_MEMBER")}, - ]) %} - - {% if lendsprefs.view_date_forecast %} - {% set columns = columns|merge([ - { - 'label': _T("Return", "objectslend"), 'order': constant("GaletteObjectsLend\\Repository\\Objects::ORDERBY_FDATE"), - 'collapse': true - }, - ]) %} - {% endif %} - - {% if login.isAdmin() or login.isStaff() %} - {% set columns = columns|merge([ - { - 'label': _T("Active", "objectslend"), - 'collapse': true - }, - ]) %} - {% endif %} - - {{ parent() }} -{% endblock %} - {% block search %}
-
- - -
+ {{ lend.searchField(filters.filter_str) }}
- -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
- - -
+ {{ lend.triStateFilter('active_filter', 'active', _T("Active:", "objectslend"), filters.active_filter, {dc: constant('GaletteObjectsLend\\Repository\\Objects::ALL_OBJECTS'), yes: constant('GaletteObjectsLend\\Repository\\Objects::ACTIVE_OBJECTS'), no: constant('GaletteObjectsLend\\Repository\\Objects::INACTIVE_OBJECTS')}) }} + {{ lend.filterButtons() }}
@@ -212,17 +175,14 @@ {% if login.isAdmin() or login.isStaff() %} - + + {% endif %} {% if olendsprefs.imagesInLists() %} - {{ _T( + {{ lend.thumbnail("object", object.getId(), object.getPicture(), olendsprefs, _T("Object photo", "objectslend")) }} {% endif %} @@ -283,7 +243,8 @@ + title="{% if object.isActive() %}{{ _T("Object is active", "objectslend") }}{% else %}{{ _T("Object is inactive", "objectslend") }}{% endif %}" + aria-hidden="true"> {% if object.isActive() %}{{ _T("Active", "objectslend") }}{% else %}{{ _T("Inactive", "objectslend") }}{% endif %} @@ -375,9 +336,8 @@ {% else %} - {# FIXME: calculate colspan #} - {{ _T("No object has been found", "objectslend") }} + {{ _T("No object has been found", "objectslend") }} {% endfor %} {% endblock %} diff --git a/templates/default/preferences.html.twig b/templates/default/preferences.html.twig index c0c968a..8e10430 100644 --- a/templates/default/preferences.html.twig +++ b/templates/default/preferences.html.twig @@ -67,7 +67,7 @@