Browse Source

WIP

mesa-vuejs
Edward Ribeiro 5 years ago
parent
commit
3b5d5fd5d5
  1. 5
      sapl/parlamentares/urls.py
  2. 67
      sapl/parlamentares/views.py
  3. 61
      sapl/templates/parlamentares/composicaomesa_form.html
  4. 2
      sapl/webpack-stats.json

5
sapl/parlamentares/urls.py

@ -20,7 +20,7 @@ from sapl.parlamentares.views import (CargoMesaCrud, ColigacaoCrud,
remove_parlamentar_composicao,
parlamentares_filiados, BlocoCrud,
PesquisarParlamentarView, VincularParlamentarView,
get_sessoes_legislatura)
get_sessoes_legislatura, get_mesa_diretora)
from .apps import AppConfig
@ -80,6 +80,9 @@ urlpatterns = [
url(r'^mesa-diretora/$',
MesaDiretoraView.as_view(), name='mesa_diretora'),
url(r'^mesa-diretora/dados/$',
get_mesa_diretora, name='dados_mesa'),
url(r'^mesa-diretora/altera-field-mesa/$',
altera_field_mesa, name='altera_field_mesa'),

67
sapl/parlamentares/views.py

@ -864,6 +864,73 @@ class MesaDiretoraView(FormView):
})
def get_mesa_diretora(request):
if not Legislatura.objects.exists() or \
not SessaoLegislativa.objects.exists():
return JsonResponse([])
leg_atual = True
legislaturas = []
for leg in Legislatura.objects\
.prefetch_related('sessaolegislativa_set')\
.all()\
.order_by('-numero'):
sessoes = leg.sessaolegislativa_set.all().order_by('-numero')
sessao_list = []
sessao_atual = True
for s in sessoes:
mesa = ComposicaoMesa.objects\
.select_related('parlamentar', 'cargo')\
.filter(sessao_legislativa=s)\
.values_list('id',
'parlamentar_id',
'parlamentar__nome_parlamentar',
'cargo_id',
'cargo__descricao',)\
.order_by('cargo_id')
keys = ['mesa_cargo_id',
'parlamentar_id',
'nome_parlamentar',
'cargo_id',
'cargo_descricao']
mesas = []
for m in mesa:
mesas.append({k: v for k, v in zip(keys, m)})
sessao = {
"id": s.id,
"descricao": str(s),
"atual": sessao_atual,
"parlamentares_mesa": mesas,
}
sessao_list.append(sessao)
sessao_atual = False
legislaturas.append({
"id": leg.id,
"atual": leg_atual,
"descricao": str(leg).strip(),
"sessoes": sessao_list,
})
leg_atual = False
data = {
"legislaturas": legislaturas,
"cargos_mesa": list(CargoMesa.objects.all().values_list('id',
'descricao',
'unico'
).order_by('id'
))
}
return JsonResponse(data, safe=False)
def altera_field_mesa(request):
"""
Essa função lida com qualquer alteração nos campos

61
sapl/templates/parlamentares/composicaomesa_form.html

@ -1,8 +1,64 @@
{% extends "crud/detail.html" %}
{% load i18n staticfiles menus %}
{% load i18n %}
{% load common_tags %}
{% load render_bundle from webpack_loader %}
{% load webpack_static from webpack_loader %}
{% block actions %} {% endblock %}
{% block detail_content %}
<div id="mesa-diretora">
<fieldset class="form-group">
<legend>Escolha da Legislatura e da Sessão Legislativa</legend>
<div class="row">
<div class="col-md-6">
<label>Escolha uma Legislatura</label>
<select v-if="legislaturas" class="form-control" v-model="legislatura_selecionada">
<option v-for="l in legislaturas" v-bind:value="l.id">
[[ l.descricao ]]
</option>
</select>
</div>
<div class="col-md-6">
<label>Escolha uma Sessão Legislativa</label>
<select v-if="sessoes" class="form-control" v-model="sessao_selecionada">
<option v-for="s in sessoes" v-bind:value="s.id">
[[ s.descricao ]]
</option>
</select>
</div>
</div>
</fieldset>
<fieldset class="form-group">
<legend>Escolha da Composição da Mesa Diretora</legend>
<div class="row">
<div class="col-md-4">
<label>Composição da Mesa Diretora</label>
<select v-if="parlamentares_mesa" multiple size="5" class="form-control" v-model="parlamentares_selecionados">
<option v-for="pm in parlamentares_mesa" v-bind:value="{id:pm.mesa_cargo_id, nome:pm.nome_parlamentar}">
[[ pm.nome_parlamentar ]] || [[ pm.cargo_descricao ]]
</option>
</select>
</div>
<div class="col-md-4" align="center">
<br/><br/>
{% if perms.parlamentares.add_composicaomesa %}
<button v-on:click="excluir" name="excluir" title="Remove parlamentar da mesa" class="btn btn-danger">
Excluir
</button>
{% endif %}
<br/>
<br/>
{% if perms.parlamentares.add_cargomesa %}
<input type="submit" style="display: none" name="Incluir" id="id_incluir" Value="Incluir" class="btn btn-primary" />
{% endif %}
</div>
</div>
</fieldset>
</div>
{% if sessoes|length == 0 %}
<div class="alert alert-danger alert-dismissible" role="alert">
<b>{{legislatura_selecionada}}</b> não possui nenhuma Sessão Legislativa cadastrada.<br />
@ -306,3 +362,8 @@
</script>
{% endblock %}
{% block webpack_loader_js %}
{% render_chunk_vendors 'js' %}
{% render_bundle 'global' 'js' %}
{% render_bundle 'parlamentares' 'js' %}
{% endblock webpack_loader_js %}

2
sapl/webpack-stats.json

@ -1 +1 @@
{"status":"done","publicPath":"/static/sapl/frontend/","chunks":{"chunk-vendors":[{"name":"css/chunk-vendors.aa0d128d.css","publicPath":"/static/sapl/frontend/css/chunk-vendors.aa0d128d.css","path":"../sapl/sapl/static/sapl/frontend/css/chunk-vendors.aa0d128d.css"},{"name":"js/chunk-vendors.a29ef83d.js","publicPath":"/static/sapl/frontend/js/chunk-vendors.a29ef83d.js","path":"../sapl/sapl/static/sapl/frontend/js/chunk-vendors.a29ef83d.js"},{"name":"css/chunk-vendors.aa0d128d.css.map","publicPath":"/static/sapl/frontend/css/chunk-vendors.aa0d128d.css.map","path":"../sapl/sapl/static/sapl/frontend/css/chunk-vendors.aa0d128d.css.map"}],"compilacao":[{"name":"css/compilacao.eff62463.css","publicPath":"/static/sapl/frontend/css/compilacao.eff62463.css","path":"../sapl/sapl/static/sapl/frontend/css/compilacao.eff62463.css"},{"name":"js/compilacao.0684a9a9.js","publicPath":"/static/sapl/frontend/js/compilacao.0684a9a9.js","path":"../sapl/sapl/static/sapl/frontend/js/compilacao.0684a9a9.js"},{"name":"css/compilacao.eff62463.css.map","publicPath":"/static/sapl/frontend/css/compilacao.eff62463.css.map","path":"../sapl/sapl/static/sapl/frontend/css/compilacao.eff62463.css.map"}],"global":[{"name":"css/global.3b8f6afb.css","publicPath":"/static/sapl/frontend/css/global.3b8f6afb.css","path":"../sapl/sapl/static/sapl/frontend/css/global.3b8f6afb.css"},{"name":"js/global.7291511d.js","publicPath":"/static/sapl/frontend/js/global.7291511d.js","path":"../sapl/sapl/static/sapl/frontend/js/global.7291511d.js"},{"name":"css/global.3b8f6afb.css.map","publicPath":"/static/sapl/frontend/css/global.3b8f6afb.css.map","path":"../sapl/sapl/static/sapl/frontend/css/global.3b8f6afb.css.map"}],"painel":[{"name":"css/painel.5d957a9b.css","publicPath":"/static/sapl/frontend/css/painel.5d957a9b.css","path":"../sapl/sapl/static/sapl/frontend/css/painel.5d957a9b.css"},{"name":"js/painel.f7b68b0b.js","publicPath":"/static/sapl/frontend/js/painel.f7b68b0b.js","path":"../sapl/sapl/static/sapl/frontend/js/painel.f7b68b0b.js"},{"name":"css/painel.5d957a9b.css.map","publicPath":"/static/sapl/frontend/css/painel.5d957a9b.css.map","path":"../sapl/sapl/static/sapl/frontend/css/painel.5d957a9b.css.map"}],"parlamentar":[{"name":"css/parlamentar.0e433876.css","publicPath":"/static/sapl/frontend/css/parlamentar.0e433876.css","path":"../sapl/sapl/static/sapl/frontend/css/parlamentar.0e433876.css"},{"name":"js/parlamentar.a2666491.js","publicPath":"/static/sapl/frontend/js/parlamentar.a2666491.js","path":"../sapl/sapl/static/sapl/frontend/js/parlamentar.a2666491.js"},{"name":"css/parlamentar.0e433876.css.map","publicPath":"/static/sapl/frontend/css/parlamentar.0e433876.css.map","path":"../sapl/sapl/static/sapl/frontend/css/parlamentar.0e433876.css.map"}]}}
{"status":"done","publicPath":"http://localhost:8080/","chunks":{"undefined":[{"name":"0.js","publicPath":"http://localhost:8080/0.js","path":"../sapl/sapl/static/sapl/frontend/0.js"},{"name":"0.js.map","publicPath":"http://localhost:8080/0.js.map","path":"../sapl/sapl/static/sapl/frontend/0.js.map"}],"null":[{"name":"5.js","publicPath":"http://localhost:8080/5.js","path":"../sapl/sapl/static/sapl/frontend/5.js"},{"name":"5.js.map","publicPath":"http://localhost:8080/5.js.map","path":"../sapl/sapl/static/sapl/frontend/5.js.map"}],"compilacao":[{"name":"compilacao.js","publicPath":"http://localhost:8080/compilacao.js","path":"../sapl/sapl/static/sapl/frontend/compilacao.js"},{"name":"compilacao.js.map","publicPath":"http://localhost:8080/compilacao.js.map","path":"../sapl/sapl/static/sapl/frontend/compilacao.js.map"}],"global":[{"name":"global.js","publicPath":"http://localhost:8080/global.js","path":"../sapl/sapl/static/sapl/frontend/global.js"},{"name":"global.js.map","publicPath":"http://localhost:8080/global.js.map","path":"../sapl/sapl/static/sapl/frontend/global.js.map"}],"online":[{"name":"online.js","publicPath":"http://localhost:8080/online.js","path":"../sapl/sapl/static/sapl/frontend/online.js"},{"name":"online.js.map","publicPath":"http://localhost:8080/online.js.map","path":"../sapl/sapl/static/sapl/frontend/online.js.map"}],"painel":[{"name":"painel.js","publicPath":"http://localhost:8080/painel.js","path":"../sapl/sapl/static/sapl/frontend/painel.js"},{"name":"painel.js.map","publicPath":"http://localhost:8080/painel.js.map","path":"../sapl/sapl/static/sapl/frontend/painel.js.map"}],"parlamentares":[{"name":"parlamentares.js","publicPath":"http://localhost:8080/parlamentares.js","path":"../sapl/sapl/static/sapl/frontend/parlamentares.js"},{"name":"parlamentares.56f4c27ebcae0f287335.hot-update.js","publicPath":"http://localhost:8080/parlamentares.56f4c27ebcae0f287335.hot-update.js","path":"../sapl/sapl/static/sapl/frontend/parlamentares.56f4c27ebcae0f287335.hot-update.js"},{"name":"parlamentares.js.map","publicPath":"http://localhost:8080/parlamentares.js.map","path":"../sapl/sapl/static/sapl/frontend/parlamentares.js.map"},{"name":"parlamentares.56f4c27ebcae0f287335.hot-update.js.map","publicPath":"http://localhost:8080/parlamentares.56f4c27ebcae0f287335.hot-update.js.map","path":"../sapl/sapl/static/sapl/frontend/parlamentares.56f4c27ebcae0f287335.hot-update.js.map"}]},"error":"ModuleBuildError","message":"Module build failed (from ./node_modules/@vue/cli-plugin-babel/node_modules/babel-loader/lib/index.js):\nSyntaxError: /home/eribeiro/projects/sapl-frontend/src/__apps/parlamentares/main.js: Unexpected character '#' (53:12)\n\n 51 | console.log(this.parlamentares_selecionados)\n 52 | \n> 53 | # Remove todos os parlamentares selecionados\n | ^\n 54 | var nova_lista = this.parlamentares_mesa.filter( p => this.parlamentares_selecionados.find( o => o.id === p.mesa_cargo_id ) === undefined);\n 55 | \n 56 | this.parlamentares_mesa = nova_lista\n at Object.raise (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:3831:17)\n at Object.readToken_numberSign (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:4164:12)\n at Object.getTokenFromCode (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:4510:14)\n at Object.getTokenFromCode (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:3584:18)\n at Object.nextToken (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:4034:12)\n at Object.next (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:3974:10)\n at Object.eat (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:3979:12)\n at Object.parseCallExpressionArguments (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:6051:18)\n at Object.parseSubscript (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5965:29)\n at Object.parseSubscripts (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5882:19)\n at Object.parseExprSubscripts (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5872:17)\n at Object.parseMaybeUnary (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5842:21)\n at Object.parseExprOps (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5729:23)\n at Object.parseMaybeConditional (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5702:23)\n at Object.parseMaybeAssign (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5647:21)\n at Object.parseExpression (/home/eribeiro/projects/sapl-frontend/node_modules/@babel/parser/lib/index.js:5595:23)"}
Loading…
Cancel
Save