8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02: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"> <div class="table-responsive">
{% if machines_list.paginator %} {% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %} {% include "pagination.html" with list=machines_list go_to_id="machines" %}
{% endif %} {% endif %}
<table class="table" id="machines_table"> <table class="table" id="machines_table">
@ -215,6 +215,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</script> </script>
{% if machines_list.paginator %} {% if machines_list.paginator %}
{% include "pagination.html" with list=machines_list %} {% include "pagination.html" with list=machines_list go_to_id="machines" %}
{% endif %} {% endif %}
</div> </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 %} {% bootstrap_javascript %}
<script src="/static/js/typeahead/typeahead.js"></script> <script src="/static/js/typeahead/typeahead.js"></script>
<script src="/static/js/bootstrap-tokenfield/bootstrap-tokenfield.js"></script> <script src="/static/js/bootstrap-tokenfield/bootstrap-tokenfield.js"></script>
<script src="{% static 'js/collapse-from-url.js' %}"></script>
{# Load CSS #} {# Load CSS #}
{% bootstrap_css %} {% bootstrap_css %}

View file

@ -23,23 +23,52 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endcomment %} {% endcomment %}
{% load url_insert_param %} {% load url_insert_param %}
{% load i18n %}
{% if list.paginator.num_pages > 1 %} {% if list.paginator.num_pages > 1 %}
<ul class="pagination nav navbar-nav"> <ul class="pagination text-center">
{% if list.has_previous %} {% if list.has_previous %}
<li><a href="{% url_insert_param request.get_full_path page=1 %}"> << </a></li> <li>
<li><a href="{% url_insert_param request.get_full_path page=list.previous_page_number %}"> < </a></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 %} {% endif %}
{% for page in list.paginator.page_range %} {% for page in list.paginator.page_range %}
{% if list.number <= page|add:"3" and list.number >= page|add:"-3" %} {% 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> <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 %} {% endif %}
{% endfor %} {% endfor %}
{% if list.has_next %} {% if list.has_next %}
<li><a href="{% url_insert_param request.get_full_path page=list.next_page_number %}"> > </a></li> <li>
<li><a href="{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}"> >> </a></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 %} {% endif %}
</ul> </ul>
{% endif %} {% 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. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
{% endcomment %} {% endcomment %}
{% load bootstrap3 %}
{% load acl %} {% load acl %}
{% load logs_extra %} {% load logs_extra %}
{% load design %} {% load design %}
@ -78,7 +77,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if solde_activated %} {% if solde_activated %}
<div class="col-sm-6 col-md-4"> <div class="col-sm-6 col-md-4">
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse" data-target="#collapse4"> <div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse"
data-target="#subscriptions">
{{ users.solde }} <i class="fa fa-eur"></i> {{ users.solde }} <i class="fa fa-eur"></i>
</div> </div>
<div class="panel-body dashboard"> <div class="panel-body dashboard">
@ -92,7 +92,8 @@ 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 %}"> <div class="col-sm-6 {% if solde_activated %}col-md-4{% else %}col-md-6{% endif %}">
{% if nb_machines %} {% if nb_machines %}
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading dashboard" data-parent="#accordion" data-toggle="collapse" data-target="#collapse3"> <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> <i class="fa fa-desktop"></i>{% trans " Machines" %} <span class="badge"> {{ nb_machines }}</span>
</div> </div>
<div class="panel-body dashboard"> <div class="panel-body dashboard">
@ -103,7 +104,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div> </div>
{% else %} {% else %}
<div class="panel panel-warning"> <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"> <div class="panel-body dashboard">
<a class="btn btn-warning btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}"> <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" %} <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-group" id="accordion">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse" <div class="panel-heading clearfix profil" data-parent="#accordion" data-toggle="collapse"
data-target="#collapse1"> data-target="#information">
<h3 class="panel-title pull-left"> <h3 class="panel-title pull-left">
<i class="fa fa-user"></i>{% trans " Detailed information" %} <i class="fa fa-user"></i>{% trans " Detailed information" %}
</h3> </h3>
</div> </div>
<div class="panel-collapse collapse in" id="collapse1"> <div class="panel-collapse collapse collapse-default" id="information">
<div class="panel-body"> <div class="panel-body">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' users.id %}"> <a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-info' users.id %}">
<i class="fa fa-edit"></i> <i class="fa fa-edit"></i>
@ -305,12 +309,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div> </div>
{% if users.is_class_club %} {% if users.is_class_club %}
<div class="panel panel-default"> <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"> <h3 class="panel-title pull-left">
<i class="fa fa-users"></i>{% trans " Manage the club" %} <i class="fa fa-users"></i>{% trans " Manage the club" %}
</h3> </h3>
</div> </div>
<div class="panel-collapse collapse" id="collapse2"> <div class="panel-collapse collapse" id="club">
<div class="panel-body"> <div class="panel-body">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-club-admin-members' users.club.id %}"> <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> <i class="fa fa-lock"></i>
@ -361,14 +365,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</div> </div>
{% endif %} {% endif %}
<div class="panel panel-default"> <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"> <h3 class="panel-title pull-left">
<i class="fa fa-desktop"></i> <i class="fa fa-desktop"></i>
{% trans "Machines" %} {% trans "Machines" %}
<span class="badge">{{nb_machines}}</span> <span class="badge">{{nb_machines}}</span>
</h3> </h3>
</div> </div>
<div id="collapse3" class="panel-collapse collapse"> <div id="machines" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}"> <a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:new-machine' users.id %}">
<i class="fa fa-desktop"></i> <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> </div>
<div class="panel panel-default"> <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"> <h3 class="panel-title pull-left">
<i class="fa fa-eur"></i> <i class="fa fa-eur"></i>
{% trans "Subscriptions" %} {% trans "Subscriptions" %}
</h3> </h3>
</div> </div>
<div id="collapse4" class="panel-collapse collapse"> <div id="subscriptions" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
{% can_create Facture %} {% can_create Facture %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'cotisations:new-facture' users.id %}"> <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> </div>
<div class="panel panel-default"> <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"> <h3 class="panel-title pull-left">
<i class="fa fa-ban"></i> <i class="fa fa-ban"></i>
{% trans "Bans" %} {% trans "Bans" %}
</h3> </h3>
</div> </div>
<div id="collapse5" class="panel-collapse collapse"> <div id="bans" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
{% can_create Ban %} {% can_create Ban %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-ban' users.id %}"> <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> </div>
<div class="panel panel-default"> <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"> <h3 class="panel-title pull-left">
<i class="fa fa-check-circle"></i> <i class="fa fa-check-circle"></i>
{% trans "Whitelists" %} {% trans "Whitelists" %}
</h3> </h3>
</div> </div>
<div id="collapse6" class="panel-collapse collapse"> <div id="whitelists" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
{% can_create Whitelist %} {% can_create Whitelist %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:add-whitelist' users.id %}"> <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> </div>
<div class="panel panel-default"> <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"> <h3 class="panel-title pull-left">
<i class="fa fa-envelope"></i>{% trans " Email settings" %} <i class="fa fa-envelope"></i>{% trans " Email settings" %}
</h3> </h3>
</div> </div>
<div id="collapse7" class="panel-collapse collapse"> <div id="email" class="panel-collapse collapse">
<div class="panel-body"> <div class="panel-body">
{% can_edit users %} {% can_edit users %}
<a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-email-settings' users.id %}"> <a class="btn btn-primary btn-sm" role="button" href="{% url 'users:edit-email-settings' users.id %}">