From e45e782e7d8bd622a14dc41db7e75fe555f304c0 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Fri, 20 Sep 2019 16:00:03 +0200 Subject: [PATCH] fix invoice preview (#1129) --- UPGRADING.md | 4 ++++ src/Constants.php | 20 ++++++++++---------- src/Controller/InvoiceController.php | 7 ++----- src/Event/UserPreferenceEvent.php | 14 ++++++++++++-- templates/invoice/actions.html.twig | 3 ++- templates/invoice/index.html.twig | 8 ++++++-- tests/Event/UserPreferenceEventTest.php | 6 +++--- translations/messages.de.xliff | 4 ---- translations/messages.en.xliff | 4 ---- 9 files changed, 39 insertions(+), 31 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index f340c1d15..f6fa35a36 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -8,6 +8,10 @@ you can upgrade your Kimai installation to the latest stable release. Check below if there are more version specific steps required, which need to be executed after the normal update process. Perform EACH version specific task between your version and the new one, otherwise you risk data inconsistency or a broken installation. +## [1.4](https://github.com/kevinpapst/kimai2/releases/tag/1.4) + +[Update as usual](https://www.kimai.org/documentation/updates.html), nothing special for this release if you upgrade from 1.0 / 1.0.1. + ## [1.3](https://github.com/kevinpapst/kimai2/releases/tag/1.3) ### Possible BC breaks diff --git a/src/Constants.php b/src/Constants.php index b5d2f93b9..45f17eced 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -10,32 +10,32 @@ namespace App; /** - * Some very global constants for Kimai. + * Some "very" global constants for Kimai. */ class Constants { + /** + * The current release version + */ + public const VERSION = '1.4'; + /** + * The current release status, either "stable" or "dev" + */ + public const STATUS = 'dev'; /** * The software name */ public const SOFTWARE = 'Kimai 2'; - /** - * The current release version - */ - public const VERSION = '1.3'; /** * The release name, will only change for new major version */ public const NAME = 'Ayumi'; - /** - * The current release status, either "stable" or "dev" - */ - public const STATUS = 'stable'; /** * Used in multiple views */ public const GITHUB = 'https://github.com/kevinpapst/kimai2/'; /** - * Used in multiple views + * Homepage, used in multiple views */ public const HOMEPAGE = 'https://www.kimai.org'; } diff --git a/src/Controller/InvoiceController.php b/src/Controller/InvoiceController.php index 4739eec32..85d574ef9 100644 --- a/src/Controller/InvoiceController.php +++ b/src/Controller/InvoiceController.php @@ -68,7 +68,6 @@ class InvoiceController extends AbstractController } $showPreview = false; - $maxItemsPreview = 500; $entries = []; $query = $this->getDefaultQuery(); @@ -88,7 +87,6 @@ class InvoiceController extends AbstractController $previewButton = $form->get('preview'); if ($previewButton->isClicked()) { $showPreview = true; - $query->setPageSize($maxItemsPreview); $entries = $this->getPreviewEntries($query); } } @@ -102,8 +100,7 @@ class InvoiceController extends AbstractController return $this->render('invoice/index.html.twig', [ 'model' => $model, 'form' => $form->createView(), - 'preview_max' => $maxItemsPreview, - 'preview_show' => $showPreview, + 'preview' => $showPreview, ]); } @@ -209,7 +206,7 @@ class InvoiceController extends AbstractController $entries = array_merge($entries, $items); } - return array_slice($entries, 0, $query->getPageSize()); + return $entries; } /** diff --git a/src/Event/UserPreferenceEvent.php b/src/Event/UserPreferenceEvent.php index ad3564d01..8b42f197d 100644 --- a/src/Event/UserPreferenceEvent.php +++ b/src/Event/UserPreferenceEvent.php @@ -40,7 +40,7 @@ final class UserPreferenceEvent extends Event } /** - * Do not set the preferences directly to the user object, but ONLY via addUserPreference() + * Do not set the preferences directly to the user object, but ONLY via addPreference() * @return User */ public function getUser() @@ -59,7 +59,7 @@ final class UserPreferenceEvent extends Event /** * @param UserPreference $preference */ - public function addUserPreference(UserPreference $preference) + public function addPreference(UserPreference $preference) { foreach ($this->preferences as $pref) { if (strtolower($pref->getName()) === strtolower($preference->getName())) { @@ -70,4 +70,14 @@ final class UserPreferenceEvent extends Event } $this->preferences[] = $preference; } + + /** + * @param UserPreference $preference + * @deprecated since 1.4, will be removed with 2.0 + */ + public function addUserPreference(UserPreference $preference) + { + @trigger_error('addUserPreference() is deprecated and will be removed with 2.0', E_USER_DEPRECATED); + $this->addPreference($preference); + } } diff --git a/templates/invoice/actions.html.twig b/templates/invoice/actions.html.twig index e8f4ddf14..26d2ca51d 100644 --- a/templates/invoice/actions.html.twig +++ b/templates/invoice/actions.html.twig @@ -2,7 +2,8 @@ {% macro invoices(view) %} {% import "macros/widgets.html.twig" as widgets %} - {% set actions = {} %} + {% set actions = {'visibility': '#modal_invoice'} %} + {% if is_granted('manage_invoice_template') %} {% set actions = actions|merge({'list': path('admin_invoice_template')}) %} {% endif %} diff --git a/templates/invoice/index.html.twig b/templates/invoice/index.html.twig index 8680629ba..5071b0d10 100644 --- a/templates/invoice/index.html.twig +++ b/templates/invoice/index.html.twig @@ -20,6 +20,10 @@ {% block page_subtitle %}{{ 'invoice.subtitle'|trans }}{% endblock %} {% block page_actions %}{{ actions.invoices('index') }}{% endblock %} +{% block main_before %} + {{ tables.data_table_column_modal(tableName, columns) }} +{% endblock %} + {% block main %} {% if is_granted('create_invoice') %} @@ -41,7 +45,7 @@ {% endblock %} {% block box_footer%} {{ form_widget(form.create, {'attr': {'class': 'btn btn-success'}}) }} - {{ form_widget(form.preview, {'attr': {'data-toggle': 'tooltip', 'title': 'limited_entries'|trans({'%max%': preview_max})}}) }} + {{ form_widget(form.preview) }} {% endblock %} {% block box_after %}{{ form_end(form) }}{% endblock %} {% endembed %} @@ -49,7 +53,7 @@ {{ widgets.callout('danger', 'http_error_403.suggestion'|trans({}, 'exceptions')) }} {% endif %} - {% if preview_show %} + {% if preview %} {% if model.calculator is empty or model.calculator.entries is empty %} {{ widgets.callout('warning', 'error.no_entries_found') }} {% else %} diff --git a/tests/Event/UserPreferenceEventTest.php b/tests/Event/UserPreferenceEventTest.php index e006fe103..9815cae39 100644 --- a/tests/Event/UserPreferenceEventTest.php +++ b/tests/Event/UserPreferenceEventTest.php @@ -31,7 +31,7 @@ class UserPreferenceEventTest extends TestCase $this->assertEquals($user, $sut->getUser()); $this->assertEquals([], $sut->getPreferences()); - $sut->addUserPreference($pref); + $sut->addPreference($pref); $this->assertEquals([$pref], $sut->getPreferences()); } @@ -51,7 +51,7 @@ class UserPreferenceEventTest extends TestCase $sut = new UserPreferenceEvent($user, []); - $sut->addUserPreference($pref); - $sut->addUserPreference($pref2); + $sut->addUserPreference($pref); // change me, once the deprecated method will be deleted + $sut->addPreference($pref2); } } diff --git a/translations/messages.de.xliff b/translations/messages.de.xliff index 4a1044162..5c6ebd720 100644 --- a/translations/messages.de.xliff +++ b/translations/messages.de.xliff @@ -736,10 +736,6 @@ invoice.filter Rechnungsdaten filtern - - limited_entries - Limitiert auf %max% Einträge - button.preview Vorschau diff --git a/translations/messages.en.xliff b/translations/messages.en.xliff index 1523cca38..c616f3ffe 100644 --- a/translations/messages.en.xliff +++ b/translations/messages.en.xliff @@ -736,10 +736,6 @@ invoice.filter Filter invoice data - - limited_entries - Limited to %max% entries - button.preview Preview