fix invoice preview (#1129)

This commit is contained in:
Kevin Papst
2019-09-20 16:00:03 +02:00
committed by GitHub
parent 5aa422dde1
commit e45e782e7d
9 changed files with 39 additions and 31 deletions

View File

@@ -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

View File

@@ -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';
}

View File

@@ -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;
}
/**

View File

@@ -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);
}
}

View File

@@ -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 %}

View File

@@ -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 %}

View File

@@ -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);
}
}

View File

@@ -736,10 +736,6 @@
<source>invoice.filter</source>
<target>Rechnungsdaten filtern</target>
</trans-unit>
<trans-unit id="limited_entries">
<source>limited_entries</source>
<target>Limitiert auf %max% Einträge</target>
</trans-unit>
<trans-unit id="button.preview">
<source>button.preview</source>
<target>Vorschau</target>

View File

@@ -736,10 +736,6 @@
<source>invoice.filter</source>
<target>Filter invoice data</target>
</trans-unit>
<trans-unit id="limited_entries">
<source>limited_entries</source>
<target>Limited to %max% entries</target>
</trans-unit>
<trans-unit id="button.preview">
<source>button.preview</source>
<target>Preview</target>