8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 08:32:26 +00:00

Merge branch 'collapse_from_url' into 'dev'

Make URL hash control Bootstrap collapse

See merge request federez/re2o!378
This commit is contained in:
klafyvel 2019-01-01 19:07:38 +01:00
commit f27f952143
5 changed files with 106 additions and 37 deletions

View file

@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div class="table-responsive">
{% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% include "pagination.html" with list=machines_list go_to_id="machines" %}
{% endif %}
<table class="table" id="machines_table">
@ -215,6 +215,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</script>
{% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %}
{% include "pagination.html" with list=machines_list go_to_id="machines" %}
{% endif %}
</div>

View file

@ -0,0 +1,33 @@
// Re2o est un logiciel d'administration développé initiallement au rezometz. Il
// se veut agnostique au réseau considéré, de manière à être installable en
// quelques clics.
//
// Copyright © 2018 Alexandre Iooss
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// This script makes URL hash controls Bootstrap collapse
// e.g. if there is #information in the URL
// then the collapse with id "information" will be open.
$(document).ready(function () {
if(location.hash != null && location.hash !== ""){
// Open the collapse corresponding to URL hash
$(location.hash + '.collapse').collapse('show');
} else {
// Open default collapse
$('.collapse-default.collapse').collapse('show');
}
});

View file

@ -45,6 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% bootstrap_javascript %}
<script src="/static/js/typeahead/typeahead.js"></script>
<script src="/static/js/bootstrap-tokenfield/bootstrap-tokenfield.js"></script>
<script src="{% static 'js/collapse-from-url.js' %}"></script>
{# Load CSS #}
{% bootstrap_css %}

View file

@ -23,23 +23,52 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %}
{% load url_insert_param %}
{% load i18n %}
{% if list.paginator.num_pages > 1 %}
<ul class="pagination nav navbar-nav">
{% if list.has_previous %}
<li><a href="{% url_insert_param request.get_full_path page=1 %}"> << </a></li>
<li><a href="{% url_insert_param request.get_full_path page=list.previous_page_number %}"> < </a></li>
{% endif %}
{% for page in list.paginator.page_range %}
{% if list.number <= page|add:"3" and list.number >= page|add:"-3" %}
<li class="{% if list.number == page %}active{% endif %}"><a href="{% url_insert_param request.get_full_path page=page %}">{{ page }}</a></li>
<ul class="pagination text-center">
{% if list.has_previous %}
<li>
<a href="{% url_insert_param request.get_full_path page=1 %}{% if go_to_id %}#{{ go_to_id }}{% endif %}">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">{% trans "First" %}</span>
</a>
</li>
<li>
<a href="{% url_insert_param request.get_full_path page=list.previous_page_number %}{% if go_to_id %}#{{ go_to_id }}{% endif %}">
<span aria-hidden="true">&lsaquo;</span>
<span class="sr-only">{% trans "Previous" %}</span>
</a>
</li>
{% else %}
<li class="disabled"><span aria-hidden="true">&laquo;</span></li>
<li class="disabled"><span aria-hidden="true">&lsaquo;</span></li>
{% endif %}
{% endfor %}
{% if list.has_next %}
<li><a href="{% url_insert_param request.get_full_path page=list.next_page_number %}"> > </a></li>
<li><a href="{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}"> >> </a></li>
{% endif %}
</ul>
{% for page in list.paginator.page_range %}
{% if list.number <= page|add:"3" and list.number >= page|add:"-3" %}
<li class="{% if list.number == page %}active{% endif %}">
<a href="{% url_insert_param request.get_full_path page=page %}{% if go_to_id %}#{{ go_to_id }}{% endif %}">{{ page }}</a>
</li>
{% endif %}
{% endfor %}
{% if list.has_next %}
<li>
<a href="{% url_insert_param request.get_full_path page=list.next_page_number %}{% if go_to_id %}#{{ go_to_id }}{% endif %}">
<span aria-hidden="true">&rsaquo;</span>
<span class="sr-only">{% trans "Next" %}</span>
</a>
</li>
<li>
<a href="{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}{% if go_to_id %}#{{ go_to_id }}{% endif %}">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">{% trans "Last" %}</span>
</a>
</li>
{% else %}
<li class="disabled"><span aria-hidden="true">&rsaquo;</span></li>
<li class="disabled"><span aria-hidden="true">&raquo;</span></li>
{% endif %}
</ul>
{% endif %}

View file

@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %}
{% load bootstrap3 %}
{% load acl %}
{% load logs_extra %}
{% load design %}
@ -78,8 +77,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if solde_activated %}
<div class="col-sm-6 col-md-4">
<div class="panel panel-info">
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse" data-target="#collapse4">
{{ users.solde }} <i class="fa fa-eur"></i>
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse"
data-target="#subscriptions">
{{ users.solde }} <i class="fa fa-eur"></i>
</div>
<div class="panel-body dashboard">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:credit-solde' users.id %}">
@ -92,8 +92,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div class="col-sm-6 {% if solde_activated %}col-md-4{% else %}col-md-6{% endif %}">
{% if nb_machines %}
<div class="panel panel-info">
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse" data-target="#collapse3">
<i class="fa fa-desktop"></i>{% trans " Machines" %} <span class="badge"> {{ nb_machines }}</span>
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse"
data-target="#machines">
<i class="fa fa-desktop"></i>{% trans " Machines" %} <span class="badge"> {{ nb_machines }}</span>
</div>
<div class="panel-body dashboard">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
@ -103,7 +104,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
{% else %}
<div class="panel panel-warning">
<div class="panel-heading dashboard">{% trans "No machine" %}</div>
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse"
data-target="#machines">
{% trans "No machine" %}
</div>
<div class="panel-body dashboard">
<a class="btn btn-warning btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
<i class="fa fa-desktop"></i>{% trans " Add a machine" %}
@ -118,12 +122,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
data-target="#collapse1">
data-target="#information">
<h3 class="panel-title pull-left">
<i class="fa fa-user"></i>{% trans " Detailed information" %}
</h3>
</div>
<div class="panel-collapse collapse in" id="collapse1">
<div class="panel-collapse collapse collapse-default" id="information">
<div class="panel-body">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' users.id %}">
<i class="fa fa-edit"></i>
@ -305,12 +309,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
{% if users.is_class_club %}
<div class="panel panel-default">
<div class="panel-heading clearfix" data-parent="#accordion" data-toggle="collapse" data-target="#collapse2">
<div class="panel-heading clearfix" data-parent="#accordion" data-toggle="collapse" data-target="#club">
<h3 class="panel-title pull-left">
<i class="fa fa-users"></i>{% trans " Manage the club" %}
</h3>
</div>
<div class="panel-collapse collapse" id="collapse2">
<div class="panel-collapse collapse" id="club">
<div class="panel-body">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-club-admin-members' users.club.id %}">
<i class="fa fa-lock"></i>
@ -361,14 +365,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
{% endif %}
<div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#collapse3">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
data-target="#machines">
<h3 class="panel-title pull-left">
<i class="fa fa-desktop"></i>
{% trans "Machines" %}
<span class="badge">{{nb_machines}}</span>
</h3>
</div>
<div id="collapse3" class="panel-collapse collapse">
<div id="machines" class="panel-collapse collapse">
<div class="panel-body">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
<i class="fa fa-desktop"></i>
@ -385,13 +390,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#collapse4">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
data-target="#subscriptions">
<h3 class="panel-title pull-left">
<i class="fa fa-eur"></i>
{% trans "Subscriptions" %}
</h3>
</div>
<div id="collapse4" class="panel-collapse collapse">
<div id="subscriptions" class="panel-collapse collapse">
<div class="panel-body">
{% can_create Facture %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:new-facture' users.id %}">
@ -416,13 +422,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#collapse5">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#bans">
<h3 class="panel-title pull-left">
<i class="fa fa-ban"></i>
{% trans "Bans" %}
</h3>
</div>
<div id="collapse5" class="panel-collapse collapse">
<div id="bans" class="panel-collapse collapse">
<div class="panel-body">
{% can_create Ban %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-ban' users.id %}">
@ -441,13 +447,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#collapse6">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#whitelists">
<h3 class="panel-title pull-left">
<i class="fa fa-check-circle"></i>
{% trans "Whitelists" %}
</h3>
</div>
<div id="collapse6" class="panel-collapse collapse">
<div id="whitelists" class="panel-collapse collapse">
<div class="panel-body">
{% can_create Whitelist %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-whitelist' users.id %}">
@ -466,12 +472,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#collapse7">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" data-target="#email">
<h3 class="panel-title pull-left">
<i class="fa fa-envelope"></i>{% trans " Email settings" %}
</h3>
</div>
<div id="collapse7" class="panel-collapse collapse">
<div id="email" class="panel-collapse collapse">
<div class="panel-body">
{% can_edit users %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-email-settings' users.id %}">