Browse Source

Melhorias na interface de convite de eventos

pull/159/head
Sesostris Vieira 3 years ago
parent
commit
eeb0974c29
  1. 25
      sigi/apps/eventos/templates/eventos/convida_casa.html
  2. 217
      sigi/apps/eventos/templates/eventos/evento.html
  3. 8
      sigi/apps/home/views.py
  4. 9
      sigi/static/js/search.js

25
sigi/apps/eventos/templates/eventos/convida_casa.html

@ -47,7 +47,13 @@
<div class="col s12"> <div class="col s12">
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<span class="card-title">{% trans "Dados do contato Interlegis" %}</span> <span class="card-title">
{% trans "Dados do contato Interlegis" %}
<a href="#" id="copiar-presidente" class="waves-effect waves-light btn-small light-green accent-1 right">
<i class="material-icons left">content_copy</i>
{% trans "Copiar dados do presidente" %}
</a>
</span>
{{ form_contato }} {{ form_contato }}
</div> </div>
</div> </div>
@ -72,4 +78,21 @@
</div> </div>
</div> </div>
</form> </form>
{% endblock %}
{% block footer %}
{{ block.super }}
<script>
$(document).ready(function() {
$("#copiar-presidente").click(function(event) {
event.preventDefault();
var dados = {{% for field in form_presidente %}
{{ field.name }}: $("#{{ field.id_for_label }}").val(),{% endfor %}
};
{% for field in form_contato %}
$("#{{ field.id_for_label }}").val(dados.{{ field.name }});
{% endfor %}
})
})
</script>
{% endblock %} {% endblock %}

217
sigi/apps/eventos/templates/eventos/evento.html

@ -10,111 +10,140 @@
padding-left: 15px; padding-left: 15px;
font-weight: bold; font-weight: bold;
} }
#content {
display: block !important;
}
.tab-panel {
background-color: #fff;
height: 100%;
}
.tab-content {
padding: 10px 24px;
height: 100%;
overflow-y: auto;
scrollbar-width: thin;
}
.tab-content::-webkit-scrollbar {
width: 3px;
background-color: #fff;
}
.tab-content::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 2px #fff;
background-color: #fff;
border-radius: 10px;
}
.tab-content::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 2px var(--main-hover-color);
background-color: var(--main-hover-color);
}
</style> </style>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{{ block.super }} {{ block.super }}
<div class=""> <div class="row">
<div class="row"> <div class="col s12">
<div class="col s12"> <h4>{{ evento.nome }}</h4>
<h4>{{ evento.nome }}</h4> </div>
</div> </div>
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s4"><a{% if not active %} class="active"{% endif %} href="#base">{% trans "Dados básicos" %}</a></li>
<li class="tab col s4"><a href="#convites">{% trans "Casas convidadas" %}</a></li>
<li class="tab col s4"><a{% if active %} class="active"{% endif %} href="#anexos">{% trans "Anexos" %}</a></li>
</ul>
</div> </div>
<div class="row"> <div id="base" class="col s12">
<div class="col s12"> <div class="tab-panel">
<ul class="tabs"> <div class="tab-content">
<li class="tab col s4"><a{% if not active %} class="active"{% endif %} href="#base">{% trans "Dados básicos" %}</a></li> <table class="responsive-table striped">
<li class="tab col s4"><a href="#convites">{% trans "Casas convidadas" %}</a></li> {% for field_name in fields %}
<li class="tab col s4"><a{% if active %} class="active"{% endif %} href="#anexos">{% trans "Anexos" %}</a></li> <tr>
</ul> <th>{{ evento|verbose_name:field_name|title }}</th>
<td>{{ evento|field_value:field_name }}</td>
</tr>
{% endfor %}
</table>
</div>
</div> </div>
<div id="base" class="col s12"> </div>
<div class="card"> <div id="convites" class="col s12">
<div class="card-content"> <div class="tab-panel">
<table class="responsive-table striped"> <div class="tab-content">
{% for field_name in fields %} <div class="input-field">
<input id="search-text" class="search-text" type="text" data-source="{% url 'openmapsearch' %}"
data-param="q" />
<label for="search">{% trans "Convidar" %}</label>
</div>
<div id="search-result" class="search-result" data-item-click="convida_casa"></div>
{% if evento.convite_set.count == 0 %}
<span class="card-title">{% trans "Nenhum convite registrado" %}</span>
{% else %}
<table class="responsive-table striped">
<thead>
<tr>
{% for field_name in convite_fields %}
<th>{{ evento.convite_set.first|verbose_name:field_name|title }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for convite in evento.convite_set.all %}
<tr> <tr>
<th>{{ evento|verbose_name:field_name|title }}</th> {% for field_name in convite_fields %}
<td>{{ evento|field_value:field_name }}</td> <td>{{ convite|field_value:field_name }}</td>
{% endfor %}
</tr> </tr>
{% endfor %} {% endfor %}
</table> </tbody>
</div> </table>
{% endif %}
</div> </div>
</div> </div>
<div id="convites" class="col s12"> </div>
<div class="card"> <div id="anexos" class="col s12">
<div class="card-content"> <div class="tab-panel">
<div class="input-field"> <div class="tab-content">
<input id="search-text" class="search-text" type="text" data-source="{% url 'openmapsearch' %}" {% if anexos.count == 0 %}
data-param="q" /> <span class="card-title">{% trans "Nenhum anexo registrado" %}</span>
<label for="search">{% trans "Convidar" %}</label> {% else %}
</div> {% if active %}
<div id="search-result" class="search-result" data-item-click="convida_casa"></div> <span class="card-title">
{% if evento.convite_set.count == 0 %} {% trans "Mostrando apenas anexos recem-criados" %}
<span class="card-title">{% trans "Nenhum convite registrado" %}</span> </span>
{% else %} <a href="{% url 'eventos-evento' evento.id %}#anexos">{% trans "Ver todos" %}</a>
<table class="responsive-table striped"> {% endif %}
<thead> <table class="responsive-table striped">
<tr> <thead>
{% for field_name in convite_fields %} <tr>
<th>{{ evento.convite_set.first|verbose_name:field_name|title }}</th> {% with anexos.first as anexo %}
{% endfor %} <th>{{ anexo|verbose_name:"descricao"|title }}</th>
</tr> <th>{{ anexo|verbose_name:"data_pub"|title }}</th>
</thead> <th>{{ anexo|verbose_name:"arquivo"|title }}</th>
<tbody> {% endwith %}
{% for convite in evento.convite_set.all %} </tr>
<tr> </thead>
{% for field_name in convite_fields %} <tbody>
<td>{{ convite|field_value:field_name }}</td> {% for anexo in anexos.all %}
{% endfor %} <tr>
</tr> <td>{{ anexo.descricao }}</td>
{% endfor %} <td>{{ anexo.data_pub|date:"SHORT_DATE_FORMAT" }}</td>
</tbody> <td>
</table> <a href="{{ anexo.arquivo.url }}" target="_blank">
{% endif %} <i class="material-icons">picture_as_pdf</i>
</div> </a>
</div> </td>
</div> </tr>
<div id="anexos" class="col s12"> {% endfor %}
<div class="card"> </tbody>
<div class="card-content"> </table>
{% if anexos.count == 0 %} {% endif %}
<span class="card-title">{% trans "Nenhum anexo registrado" %}</span> <div>
{% else %}
{% if active %}
<span class="card-title">
{% trans "Mostrando apenas anexos recem-criados" %}
</span>
<a href="{% url 'eventos-evento' evento.id %}#anexos">{% trans "Ver todos" %}</a>
{% endif %}
<table class="responsive-table striped">
<thead>
<tr>
{% with anexos.first as anexo %}
<th>{{ anexo|verbose_name:"descricao"|title }}</th>
<th>{{ anexo|verbose_name:"data_pub"|title }}</th>
<th>{{ anexo|verbose_name:"arquivo"|title }}</th>
{% endwith %}
</tr>
</thead>
<tbody>
{% for anexo in anexos.all %}
<tr>
<td>{{ anexo.descricao }}</td>
<td>{{ anexo.data_pub|date:"SHORT_DATE_FORMAT" }}</td>
<td>
<a href="{{ anexo.arquivo.url }}" target="_blank">
<i class="material-icons">picture_as_pdf</i>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

8
sigi/apps/home/views.py

@ -208,12 +208,16 @@ def openmapsearch(request):
tipo__legislativo=True, search_text__icontains=to_ascii(q) tipo__legislativo=True, search_text__icontains=to_ascii(q)
)[:10] )[:10]
dados = dados.values( dados = dados.values(
"id", "nome", "municipio__latitude", "municipio__longitude" "id",
"nome",
"municipio__uf__sigla",
"municipio__latitude",
"municipio__longitude",
) )
dados = [ dados = [
{ {
"id": d["id"], "id": d["id"],
"label": d["nome"], "label": f"{d['nome']} - {d['municipio__uf__sigla']}",
"lat": d["municipio__latitude"], "lat": d["municipio__latitude"],
"lng": d["municipio__longitude"], "lng": d["municipio__longitude"],
} }

9
sigi/static/js/search.js

@ -12,17 +12,16 @@ $(document).ready(function () {
query_param[param_name] = term; query_param[param_name] = term;
if (term.length < 3) { if (term.length < 3) {
$resultbox.html(""); $resultbox.empty();
$resultbox.addClass("hide"); $resultbox.addClass("hide");
return; return;
} }
$.get(url, query_param, function (data) { $.get(url, query_param, function (data) {
$resultbox.html(""); $resultbox.empty();
for (i in data) { for (i in data) {
var plain = JSON.stringify(data[i]); var plain = JSON.stringify(data[i]);
var $item = $(`<a href="#" class="search-result-item" data-retrieved='${plain}'></a>`); var $item = $(`<a href="#" class="search-result-item" data-retrieved='${plain}'>${data[i].label}</a>`);
$item.html(data[i].label);
$resultbox.append($item); $resultbox.append($item);
} }
$resultbox.removeClass("hide"); $resultbox.removeClass("hide");
@ -31,7 +30,7 @@ $(document).ready(function () {
var plain = $(this).attr("data-retrieved"); var plain = $(this).attr("data-retrieved");
var obj = JSON.parse(plain); var obj = JSON.parse(plain);
$this.val(obj.label); $this.val(obj.label);
$resultbox.html("").addClass("hide"); $resultbox.empty().addClass("hide");
callback(obj); callback(obj);
}); });
}); });

Loading…
Cancel
Save