store search in session (#2735)

* allow to detect used query filters
* allow to set label in action buttons
* allow to reset last search from session
* migrate invoice archive to new search system
* display number of used search filters
This commit is contained in:
Kevin Papst
2021-08-26 01:37:40 +02:00
committed by GitHub
parent 56524a9773
commit 98a3fc99a2
55 changed files with 365 additions and 81 deletions

View File

@@ -1,6 +1,6 @@
{% macro activities(view) %}
{% macro activities(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'activities', view) %}
{% set event = actions(app.user, 'activities', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -26,7 +26,7 @@
{% block page_title %}{{ 'admin_activity.title'|trans }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.activities('index') }}{% endblock %}
{% block page_actions %}{{ actions.activities('index', query) }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}

View File

@@ -1,6 +1,6 @@
{% macro customers(view) %}
{% macro customers(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'customers', view) %}
{% set event = actions(app.user, 'customers', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -37,7 +37,7 @@
{% block page_title %}{{ 'admin_customer.title'|trans }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.customers('index') }}{% endblock %}
{% block page_actions %}{{ actions.customers('index', query) }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}

View File

@@ -10,9 +10,9 @@
{{ widgets.table_actions(event.actions) }}
{% endmacro %}
{% macro invoice_listing(view) %}
{% macro invoice_listing(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'invoice_details', view) %}
{% set event = actions(app.user, 'invoice_details', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -1,12 +1,12 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/search.html.twig" as search %}
{% import "macros/datatables.html.twig" as tables %}
{% import "invoice/actions.html.twig" as actions %}
{% import "invoice/macros.html.twig" as macros %}
{% set columns = {
'date': {'class': 'alwaysVisible', 'orderBy': false},
'date': {'class': 'alwaysVisible'},
'user': {'class': 'hidden-xs hidden-sm text-nowrap hidden', 'orderBy': false},
'customer': {'class': 'hidden-xs hidden-sm text-nowrap', 'orderBy': false},
'invoice_number': {'class': 'hidden-xs hidden-sm w-min', 'title': 'invoice.number'|trans, 'orderBy': false},
@@ -14,16 +14,16 @@
'payment_date': {'class': 'hidden-xs hidden w-min', 'title': 'invoice.payment_date'|trans, 'orderBy': false},
'status': {'class': 'alwaysVisible w-min', 'orderBy': false},
'subtotal': {'class': 'hidden-xs text-right w-min hidden', 'title': 'invoice.subtotal'|trans, 'orderBy': false},
'tax': {'class': 'hidden-xs text-right w-min hidden', 'title': 'invoice.tax'|trans, 'orderBy': false},
'total_rate': {'class': 'hidden-xs text-right w-min', 'orderBy': false},
'tax': {'class': 'hidden-xs text-right w-min hidden', 'title': 'invoice.tax'|trans},
'total_rate': {'class': 'hidden-xs text-right w-min'},
'actions': {'class': 'actions alwaysVisible', 'orderBy': false},
} %}
{% set tableName = 'invoices' %}
{% block page_title %}{{ 'invoice.title'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoice_listing('index') }}{% endblock %}
{% block page_search %}{{ toolbar.dropDownSearch(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.invoice_listing('index', query) }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}

View File

@@ -43,6 +43,11 @@
<div class="btn-group">
<button type="submit" name="performSearch" value="performSearch" class="btn btn-primary pull-left" data-type="submit">{{ 'search'|trans }}</button>
</div>
{% if form.vars.data.countFilter() > 0 and not form.vars.data.isBookmarkSearch() %}
<div class="btn-group">
<button type="submit" id="resetSearchFilter" name="resetSearchFilter" class="btn btn-warning" title="{{ 'action.reset'|trans }}">{{ 'action.reset'|trans }}</button>
</div>
{% endif %}
<div class="btn-group">
{% if form.vars.data.bookmark %}
<button type="submit" id="setDefaultQuery" name="setDefaultQuery" class="btn btn-default" title="{{ 'label.set_as_default'|trans }}"><i class="{{ 'bookmarked'|icon }}"></i></button>

View File

@@ -359,6 +359,7 @@
{% set title = null %}
{% set disabled = false %}
{% set attr = {} %}
{% set label = null %}
{% set translation_domain = 'messages' %}
{% if type is same as (false) %}
{% set class = "" %}
@@ -369,6 +370,7 @@
{% endif %}
{% if values is not iterable %}
{% deprecated 'Passing a non iterable action_button is deprecated since 1.15 and will be removed with 2.0' %}
{% set url = values %}
{% if 'onclick:' in url %}
{% set onclick = url|replace({'onclick:': ''}) %}
@@ -393,6 +395,7 @@
{% set title = values.title ?? null %}
{% set class = class ~ ( values.class | default("")) %}
{% set attr = values.attr ?? {} %}
{% set label = values.label ?? null %}
{% set translation_domain = values.translation_domain ?? translation_domain %}
{% endif %}
@@ -412,7 +415,7 @@
{{ ' ' ~ name }}={% if '"' in value %}'{{ value|raw }}'{% else %}"{{ value|raw }}"{% endif %}
{% endfor %}
{% endif %}
>{% if title is not null %}{{ title|trans({}, translation_domain) }}{% else %}{{ _self.icon(icon) }}{% endif %}</a>
>{% if title is not null %}{{ title|trans({}, translation_domain) }}{% else %}{{ _self.icon(icon) }}{% endif %}{% if label is not null %}<span class="label bg-yellow">{{ label }}</span>{% endif %}</a>
{% endapply %}
{% endmacro %}

View File

@@ -1,6 +1,6 @@
{% macro projects(view) %}
{% macro projects(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'projects', view) %}
{% set event = actions(app.user, 'projects', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -30,7 +30,7 @@
{% block page_title %}{{ 'admin_project.title'|trans }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.projects('index') }}{% endblock %}
{% block page_actions %}{{ actions.projects('index', query) }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}

View File

@@ -1,6 +1,6 @@
{% macro tags(view) %}
{% macro tags(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'tags', view) %}
{% set event = actions(app.user, 'tags', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -6,7 +6,7 @@
{% block page_title %}{{ 'menu.tags'|trans }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.tags('index') }}{% endblock %}
{% block page_actions %}{{ actions.tags('index', query) }}{% endblock %}
{% block main %}

View File

@@ -1,6 +1,6 @@
{% macro teams(view) %}
{% macro teams(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'teams', view) %}
{% set event = actions(app.user, 'teams', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -6,7 +6,7 @@
{% block page_title %}{{ 'teams.title'|trans({}, 'teams') }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.teams('index') }}{% endblock %}
{% block page_actions %}{{ actions.teams('index', query) }}{% endblock %}
{% block main %}

View File

@@ -1,6 +1,6 @@
{% macro timesheets_team(view) %}
{% macro timesheets_team(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'timesheets_team', view) %}
{% set event = actions(app.user, 'timesheets_team', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -9,7 +9,7 @@
{% set allowMarkdown = false %}
{% block page_title %}{{ 'admin_timesheet.title'|trans }}{% endblock %}
{% block page_actions %}{{ actions.timesheets_team('index') }}{% endblock %}
{% block page_actions %}{{ actions.timesheets_team('index', query) }}{% endblock %}
{% block row_action %}
{{- actions.timesheet_team(entry, 'index') -}}

View File

@@ -1,6 +1,6 @@
{% macro timesheets(view) %}
{% macro timesheets(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'timesheets', view) %}
{% set event = actions(app.user, 'timesheets', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -9,7 +9,7 @@
{% set allowMarkdown = true %}
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
{% block page_actions %}{{ actions.timesheets('index') }}{% endblock %}
{% block page_actions %}{{ actions.timesheets('index', query) }}{% endblock %}
{% block row_action %}
{{- actions.timesheet(entry, 'index') -}}

View File

@@ -1,6 +1,6 @@
{% macro users(view) %}
{% macro users(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'users', view) %}
{% set event = actions(app.user, 'users', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}

View File

@@ -28,7 +28,7 @@
{% block page_title %}{{ 'admin_user.title'|trans }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.users('index') }}{% endblock %}
{% block page_actions %}{{ actions.users('index', query) }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns, 'kimai.userUpdate') }}