Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/GaletteAuto/Filters/ModelsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ class ModelsList extends Pagination

/**
* Returns the field we want to default set order to
*
* @return string field name
*/
protected function getDefaultOrder(): string
protected function getDefaultOrder(): int
{
return 'model';
return self::ORDERBY_MODEL;
}
}
2 changes: 1 addition & 1 deletion templates/default/history.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% elseif owner.isWoman() %}
<i class="ui female icon tooltip"><span class="visually-hidden">{{ _T('Is a woman') }}</span></i>
{% else %}
<i class="ui icon"></i>
<i class="ui icon" aria-hidden="true"></i>
{% endif %}
{{ owner.sfullname }}
</td>
Expand Down
34 changes: 34 additions & 0 deletions templates/default/history_modal.js.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{#
# This file is part of Galette Auto plugin (https://galette.eu).
# SPDX-FileCopyrightText: Copyright © 2009-2026 The Galette Team
# SPDX-License-Identifier: GPL-3.0-or-later
#}

{# Open vehicle history in a modal from any `.vehicle-history` button #}
$(function() {
$('.vehicle-history').on('click', function() {
$.ajax({
url: $(this).data('url'),
success: function(res) {
{% include "elements/js/modal.js.twig" with {
modal_title_twig: _T("Car's history", "auto")|e("js"),
modal_content: "res",
modal_class: "large",
modal_content_class: "scrolling",
modal_deny_only: true,
modal_cancel_text: _T("Close")|e("js")
} %}
},
error: function() {
{% include "elements/js/modal.js.twig" with {
modal_title_twig: _T("An error occurred displaying history :(", "auto")|e("js"),
modal_without_content: true,
modal_class: "mini",
modal_deny_only: true,
modal_cancel_text: _T("Close")|e("js"),
modal_classname: "redalert",
} %}
}
});
});
});
4 changes: 2 additions & 2 deletions templates/default/model.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<form class="ui form" action="{% if mode == "new" %}{{ url_for("doModelAdd") }}{% else %}{{ url_for("doModelEdit", {"id": model.id}) }}{% endif %}" method="post" id="modifform">
<div class="ui styled fluid accordion field">
<div class="active title">
<i class="icon dropdown"></i>
<i class="icon dropdown" aria-hidden="true"></i>
{{ page_title }}
</div>
<div class="active content">
Expand Down Expand Up @@ -45,7 +45,7 @@

<div class="ui basic center aligned fitted segment">
<button type="submit" name="valid" class="action ui labeled icon primary button">
<i class="save icon"></i> {{ _T("Save") }}
<i class="save icon" aria-hidden="true"></i> {{ _T("Save") }}
</button>
<input type="hidden" name="{{ mode }}" value="1"/>
{% if mode != "new" %}
Expand Down
39 changes: 19 additions & 20 deletions templates/default/models_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,24 @@
#}

{% extends 'elements/list.html.twig' %}
{% import "macros.twig" as macros %}

{% set nb = count_models %}

{% set form = {
'route': {
'name': 'modelsFilter'
},
'order': {
'name': 'modelsList'
}
} %}

{% set columns = [
{'label': _T("Model", "auto"), 'order': constant('GaletteAuto\\Filters\\ModelsList::ORDERBY_MODEL')},
{'label': _T("Brand", "auto"), 'order': constant('GaletteAuto\\Filters\\ModelsList::ORDERBY_BRAND')}
] %}

{% block infoline %}
{% set infoline = {
'label': _Tn("%count model", "%count models", count_models, "auto")|replace({"%count": count_models}),
Expand All @@ -28,35 +43,19 @@
</a>
{% endblock %}

{% block header %}
{% set columns = [
{'label': _T("Model", "auto")},
{'label': _T("Brand", "auto")}
] %}
{{ parent() }}
{% endblock %}

{% block body %}
{% for m in models %}
{% set edit_link = url_for("modelEdit", {"id": m.id}) %}
<tr>
<td data-col-label="{{ _T("Model", "auto") }}"><a href="{{ edit_link }}">{{ m.model }}</a></td>
<td data-col-label="{{ _T("Brand", "auto") }}"><a href="{{ edit_link }}">{{ m.brand.getValue() }}</a></td>
<td class="center actions_row collapsing">
<a href="{{ edit_link }}" class="tooltip action">
<i class="ui edit icon"></i>
<span class="visually-hidden">{{ _T("Edit %property", "auto")|replace({"%property": m.brand.getValue() ~ ' ' ~ m.model}) }}</span>
</a>
<a
class="delete tooltip"
href="{{ url_for("removeModel", {"id": m.id}) }}"
>
<i class="ui red trash icon"></i>
<span class="visually-hidden">{{ _T("%property: remove from database", "auto")|replace({"%property": m.brand.getValue() ~ ' ' ~ m.model}) }}</span>
</a>
{% set label = m.brand.getValue() ~ ' ' ~ m.model %}
{{ macros.drawListAction(_T("Edit %property", "auto")|replace({"%property": label}), {'name': 'modelEdit', 'args': {'id': m.id}}, 'edit') }}
{{ macros.drawListAction(_T("%property: remove from database", "auto")|replace({"%property": label}), {'name': 'removeModel', 'args': {'id': m.id}}, 'red trash', 'delete') }}
</td>
</tr>
{% else %}
<tr><td colspan="4" class="emptylist">{{ _T("no record found", "auto") }}</td></tr>
<tr><td colspan="{{ columns_count }}" class="emptylist">{{ _T("no record found", "auto") }}</td></tr>
{% endfor %}
{% endblock %}
4 changes: 2 additions & 2 deletions templates/default/object.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<form class="ui form" action="{% if mode == "new" %}{{ url_for("doPropertyAdd", {"property": set}) }}{% else %}{{ url_for("doPropertyEdit", {"property": set, "id": obj.getId()}) }}{% endif %}" method="post" id="modifform">
<div class="ui styled fluid accordion field">
<div class="active title">
<i class="icon dropdown"></i>
<i class="icon dropdown" aria-hidden="true"></i>
{{ page_title }}
</div>
<div class="active content">
Expand All @@ -30,7 +30,7 @@

<div class="ui basic center aligned fitted segment">
<button type="submit" name="valid" class="action ui labeled icon primary button">
<i class="save icon"></i> {{ _T("Save") }}
<i class="save icon" aria-hidden="true"></i> {{ _T("Save") }}
</button>
<input type="hidden" name="set" value="{{ set }}"/>
<input type="hidden" name="{{ mode }}" value="1"/>
Expand Down
27 changes: 8 additions & 19 deletions templates/default/object_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
#}

{% extends 'elements/list.html.twig' %}
{% import "macros.twig" as macros %}

{% set field = obj.getField() %}

{% set nb = list|length %}

{% set columns = [
{'label': field_name}
] %}

{% block infoline %}
{% set infoline = {
'label': count_label,
Expand All @@ -31,13 +36,6 @@
</a>
{% endblock %}

{% block header %}
{% set columns = [
{'label': field_name}
] %}
{{ parent() }}
{% endblock %}

{% block body %}
{% for o in list %}
{% set edit_link = url_for("propertyEdit", {"property": obj.getRouteName(), "id": o.getId()}) %}
Expand All @@ -50,20 +48,11 @@
</a>
</td>
<td class="center actions_row collapsing">
<a href="{{ edit_link }}" class="tooltip action">
<i class="ui edit icon"></i>
<span class="visually-hidden">{{ _T("Edit %property", "auto")|replace({"%property": o.getValue()}) }}</span>
</a>
<a
class="delete tooltip"
href="{{ url_for("removeProperty", {"property": obj.getRouteName(), "id": o.getId()}) }}"
>
<i class="ui red trash icon"></i>
<span class="visually-hidden">{{ _T("%property: remove from database", "auto")|replace({"%property": o.getValue()}) }}</span>
</a>
{{ macros.drawListAction(_T("Edit %property", "auto")|replace({"%property": o.getValue()}), {'name': 'propertyEdit', 'args': {'property': obj.getRouteName(), 'id': o.getId()}}, 'edit') }}
{{ macros.drawListAction(_T("%property: remove from database", "auto")|replace({"%property": o.getValue()}), {'name': 'removeProperty', 'args': {'property': obj.getRouteName(), 'id': o.getId()}}, 'red trash', 'delete') }}
</td>
</tr>
{% else %}
<tr><td colspan="3" class="emptylist">{{ _T("no record found", "auto") }}</td></tr>
<tr><td colspan="{{ columns_count }}" class="emptylist">{{ _T("no record found", "auto") }}</td></tr>
{% endfor %}
{% endblock %}
11 changes: 5 additions & 6 deletions templates/default/object_show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@
{{ _T("Registered models for the brand '%s'", "auto")|replace({'%s': obj.getValue()}) }}
</div>
</h2>
<div class="ui relaxed divided list">
<ul class="ui relaxed divided list">
{% for model in models %}
<div class="item">
<li class="item">
<div class="content">
<div class="header">
<a href="{{ url_for("modelEdit", {"action": "edit", "id": model.id}) }}">{{ model.model }}</a>
<a href="{{ url_for("modelEdit", {"id": model.id}) }}">{{ model.model }}</a>
</div>
</div>
</div>
<li></li>
</li>
{% endfor %}
</div>
</ul>
{% else %}
<div class="ui info message">
<p>{{ _T("The brand '%s' does not have any registered model at this time.", "auto")|replace({'%s': obj.getValue()}) }}</p>
Expand Down
50 changes: 12 additions & 38 deletions templates/default/public_vehicles_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@

{% set nb = autos|length %}
{% set is_public = not login.isLogged() %}
{% set no_action = true %}

{% set columns = [
{'label': _T("Picture"), 'collapse': true},
{'label': _T("Name", "auto")},
{'label': _T("Owner", "auto")},
{'label': _T("Brand", "auto")},
{'label': _T("Model", "auto")},
{'label': _T("Description", "auto")},
] %}

{% set form = {
'route': {
Expand All @@ -22,19 +32,6 @@
{{ parent() }}
{% endblock %}

{% block header %}
{% set no_action = true %}
{% set columns = [
{'label': _T("Picture"), 'collapse': true},
{'label': _T("Name", "auto")},
{'label': _T("Owner", "auto")},
{'label': _T("Brand", "auto")},
{'label': _T("Model", "auto")},
{'label': _T("Description", "auto")},
] %}
{{ parent() }}
{% endblock %}

{% block body %}
{% for auto in autos %}
{% set brand = auto.getModel().getBrand() %}
Expand Down Expand Up @@ -86,36 +83,13 @@
</td>
</tr>
{% else %}
<tr><td colspan="6" class="emptylist">{{ _T("No car in the database", "auto") }}</td></tr>
<tr><td colspan="{{ columns_count }}" class="emptylist">{{ _T("No car in the database", "auto") }}</td></tr>
{% endfor %}
{% endblock %}

{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
$(function() {
$('.vehicle-history').on('click', function() {
$.ajax({
url: $(this).data('url'),
success: function(res) {
$('body').modal({
title: '{{ _T("Car's history", "auto")|e('js') }}',
content: res,
class: 'large'
}).modal('show');
},
error: function() {
{% include "elements/js/modal.js.twig" with {
modal_title_twig: _T("An error occurred displaying history :(", "auto")|e("js"),
modal_without_content: true,
modal_class: "mini",
modal_deny_only: true,
modal_cancel_text: _T("Close")|e("js"),
modal_classname: "redalert",
} %}
}
});
});
});
{% include "@PluginGaletteAuto/history_modal.js.twig" %}
</script>
{% endblock %}
10 changes: 10 additions & 0 deletions templates/default/scripts.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{#
# This file is part of Galette Auto plugin (https://galette.eu).
# SPDX-FileCopyrightText: Copyright © 2009-2026 The Galette Team
# SPDX-License-Identifier: GPL-3.0-or-later
#}

{# vehicle form only #}
{% if cur_route in ['vehicleAdd', 'vehicleEdit', 'doVehicleAdd', 'doVehicleEdit'] %}
<script type="text/javascript" src="{{ url_for("plugin_res", {"plugin": module_id, "path": "auto.js"}) }}"></script>
{% endif %}
Loading
Loading