Browse Source

Add bts de perfis e generaliza chmd de forms

pull/590/head
LeandroRoberto 8 years ago
parent
commit
1291275d09
  1. 39
      sapl/compilacao/views.py
  2. 43
      sapl/static/js/compilacao_edit.js
  3. 64
      sapl/static/styles/compilacao.scss
  4. 82
      sapl/templates/compilacao/ajax_actions_dinamic_edit.html
  5. 9
      sapl/templates/compilacao/text_edit_bloco.html

39
sapl/compilacao/views.py

@ -1198,8 +1198,8 @@ class ActionDeleteDispositivoMixin(ActionsCommonsMixin):
# print(p.id, p) # print(p.id, p)
p.dispositivo_subsequente = n p.dispositivo_subsequente = n
if n: if n:
p.fim_vigencia = n.ini_vigencia - timedelta(days=1) p.fim_vigencia = n.inicio_vigencia - timedelta(days=1)
p.fim_eficacia = n.ini_eficacia - timedelta(days=1) p.fim_eficacia = n.inicio_eficacia - timedelta(days=1)
else: else:
p.fim_vigencia = None p.fim_vigencia = None
p.fim_eficacia = None p.fim_eficacia = None
@ -2021,25 +2021,16 @@ class ActionsEditMixin(ActionDragAndMoveDispositivoAlteradoMixin,
def json_get_perfis(self, context): def json_get_perfis(self, context):
try: if 'perfil_pk' in self.request.GET:
if 'perfil_pk' in self.request.GET: self.set_perfil_in_session(
self.set_perfil_in_session( self.request, self.request.GET['perfil_pk'])
self.request, self.request.GET['perfil_pk']) elif 'perfil_estrutural' not in self.request.session:
elif 'perfil_estrutural' not in self.request.session: self.set_perfil_in_session(request=self.request)
self.set_perfil_in_session(request=self.request)
self.object_list = self.get_queryset()
self.perfil_estrutural_list = self.get_queryset_perfil_estrutural()
context = self.get_context_data( data = {'pk': self.kwargs['dispositivo_id'],
object_list=self.object_list, 'pai': [self.kwargs['dispositivo_id'], ]}
perfil_estrutural_list=self.perfil_estrutural_list
)
except Exception as e:
print(e)
return self.render_to_response(context) return data
def set_perfil_in_session(self, request=None, perfil_id=0): def set_perfil_in_session(self, request=None, perfil_id=0):
if not request: if not request:
@ -2098,6 +2089,16 @@ class DispositivoDinamicEditView(
context = {} context = {}
context['object'] = self.object context['object'] = self.object
context['allowed_inserts'] = self.allowed_inserts() context['allowed_inserts'] = self.allowed_inserts()
if 'perfil_pk' in request.GET:
self.set_perfil_in_session(
request, request.GET['perfil_pk'])
elif 'perfil_estrutural' not in request.session:
self.set_perfil_in_session(request=request)
context['perfil_estrutural_list'
] = PerfilEstruturalTextoArticulado.objects.all()
return self.render_to_response(context) return self.render_to_response(context)
elif action.startswith('json_'): elif action.startswith('json_'):

43
sapl/static/js/compilacao_edit.js

@ -31,6 +31,7 @@ function DispositivoEdit() {
var form_data = { var form_data = {
'action' : this.getAttribute('action'), 'action' : this.getAttribute('action'),
'tipo_pk' : this.getAttribute('tipo_pk'), 'tipo_pk' : this.getAttribute('tipo_pk'),
'perfil_pk' : this.getAttribute('perfil_pk'),
'variacao' : this.getAttribute('variacao'), 'variacao' : this.getAttribute('variacao'),
}; };
@ -72,29 +73,40 @@ function DispositivoEdit() {
var dpt = $(this).closest('.dpt'); var dpt = $(this).closest('.dpt');
if (dpt.hasClass('dpt-selected')) { if (dpt.hasClass('dpt-selected')) {
instance.clearEditSelected(); if (this.getAttribute('action') == 'editor-close')
instance.clearEditSelected();
return; return;
} }
instance.clearEditSelected(); instance.clearEditSelected();
instance.loadActionsEdit(dpt); instance.loadActionsEdit(dpt);
dpt.on('get_form_base', function () { var formtype = dpt.attr('formtype');
var _this = $(this);
_this.addClass('dpt-selected');
instance.scrollTo(_this);
_this.off('get_form_base')
var btn_fechar = _this.find('.btn-fechar');
btn_fechar.on('click', function() {
instance.clearEditSelected();
});
var btns_excluir = _this.find('.btns-excluir'); dpt.on(formtype, instance[formtype]);
_this.find('.dpt-actions-bottom').last().append(btns_excluir);
instance.loadForm(dpt, formtype);
}
instance.get_form_base = function () {
var _this = $(this);
_this.addClass('dpt-selected');
btns_excluir.find('.btn-excluir').on('click', instance.bindActionsClick); var dpt_form = _this.children().filter('.dpt-form');
dpt_form.find('form').submit(instance.onSubmitEditFormBase);
instance.scrollTo(_this);
_this.off('get_form_base')
var btn_fechar = _this.find('.btn-fechar');
btn_fechar.on('click', function() {
instance.clearEditSelected();
}); });
instance.loadForm(dpt, 'get_form_base');
var btns_excluir = _this.find('.btns-excluir');
_this.find('.dpt-actions-bottom').last().append(btns_excluir);
btns_excluir.find('.btn-excluir').on('click', instance.bindActionsClick);
} }
instance.loadActionsEdit = function(dpt) { instance.loadActionsEdit = function(dpt) {
@ -103,6 +115,7 @@ function DispositivoEdit() {
$.get(url).done(function(data) { $.get(url).done(function(data) {
dpt.find('.dpt-actions').first().html(data); dpt.find('.dpt-actions').first().html(data);
dpt.find('.btn-inserts').on('click', instance.bindActionsClick); dpt.find('.btn-inserts').on('click', instance.bindActionsClick);
dpt.find('.btn-perfis').on('click', instance.bindActionsClick);
dpt.find('.btn-editor-type').on('click', instance.bindActionsEditorType); dpt.find('.btn-editor-type').on('click', instance.bindActionsEditorType);
if (editortype == 'construct') if (editortype == 'construct')
@ -112,14 +125,12 @@ function DispositivoEdit() {
} }
instance.loadForm = function(dpt, trigger) { instance.loadForm = function(dpt, trigger) {
var pk = dpt.attr('pk'); var pk = dpt.attr('pk');
var dpt_form = dpt.children().filter('.dpt-form'); var dpt_form = dpt.children().filter('.dpt-form');
if (dpt_form.length == 1) { if (dpt_form.length == 1) {
var url = pk+'/refresh?action='+trigger; var url = pk+'/refresh?action='+trigger;
$.get(url).done(function(data) { $.get(url).done(function(data) {
if (editortype != "construct") { if (editortype != "construct") {
dpt_form.html(data); dpt_form.html(data);
dpt_form.find('form').submit(instance.onSubmitEditFormBase);
if (editortype == 'tinymce' ) { if (editortype == 'tinymce' ) {
initTinymce(); initTinymce();
} }

64
sapl/static/styles/compilacao.scss

@ -389,7 +389,6 @@ a:link:after, a:visited:after {
} }
} }
} }
} }
.dptt { .dptt {
@ -442,7 +441,6 @@ a:link:after, a:visited:after {
} }
} }
} }
.dne-nota { .dne-nota {
position: relative; position: relative;
transform: scaleX(1); transform: scaleX(1);
@ -526,7 +524,8 @@ a:link:after, a:visited:after {
display: block; display: block;
& > .dpt-actions-fixed { & > .dpt-actions-fixed {
position: absolute; position: absolute;
right: 0px; right: -0.25em;
top: 0px;
z-index: 3; z-index: 3;
opacity: 0; opacity: 0;
@ -536,15 +535,20 @@ a:link:after, a:visited:after {
.deactivate { .deactivate {
display:inline; display:inline;
} }
.btn-dpt-edit.btn-default {
color: #333;
}
} }
& > .dpt-actions, & > .dpt-actions-bottom { & > .dpt-actions, & > .dpt-actions-bottom {
display: none; display: none;
} }
& > .dpt-text { & > .dpt-text {
cursor: pointer; cursor: pointer;
min-height: 31px; min-height: 30px;
&:hover { &:hover {
background-color: rgba(0, 0, 0, 0.01);
color: $color_buttons; color: $color_buttons;
border: 1px solid #eee;
transition: color 0.3s ease; transition: color 0.3s ease;
} }
&.artigo { &.artigo {
@ -558,9 +562,11 @@ a:link:after, a:visited:after {
} }
&:hover { &:hover {
background-color: rgba(0, 0, 0, 0.01);
& > .dpt-actions-fixed { & > .dpt-actions-fixed {
opacity: 1; opacity: 0.8;
&:hover {
opacity: 1;
}
} }
} }
@ -609,7 +615,6 @@ a:link:after, a:visited:after {
padding: 0.3em 1em; padding: 0.3em 1em;
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: 0;
a { a {
&.link-rotulo { &.link-rotulo {
text-decoration: underline; text-decoration: underline;
@ -632,27 +637,11 @@ a:link:after, a:visited:after {
padding: 0; padding: 0;
background-color: #fafafa; background-color: #fafafa;
border-radius: 3px; border-radius: 3px;
z-index: 2; z-index: 4;
& > .dpt-text1 { & > .dpt-text {
opacity: 1; &:hover {
border: 0px solid #e0e0e0 !important; background-color: rgba(0, 0, 0, 0.0);
margin: 1em; border: 0px solid #eee;
padding: 0.3em;
position: relative;
background-color: white;
min-height: 2em;
&:before {
border-width: 1rem;
border-style: solid;
border-color: transparent transparent #e0e0e0 #e0e0e0 ;
content: "";
display: block;
height: 0px;
width: 0px;
position: absolute;
bottom: 0rem;
left: 0rem;
} }
} }
& > .dpt-form { & > .dpt-form {
@ -712,8 +701,8 @@ a:link:after, a:visited:after {
} }
& > .dpt-actions-fixed { & > .dpt-actions-fixed {
opacity: 1; opacity: 1;
margin-top: -1em; top: -12px;
margin-right: -0.5em; right: 0.5em;
.activate { .activate {
display:inline; display:inline;
} }
@ -721,10 +710,11 @@ a:link:after, a:visited:after {
display:none; display:none;
} }
.btn-dpt-edit { .btn-dpt-edit {
background-color: #02baf2; padding-top: 2px;
color: white; padding-bottom: 1px;
border: 0; &.btn-default {
font-weight: bold; background-color: #fad46b;
}
} }
} }
@ -753,14 +743,12 @@ a:link:after, a:visited:after {
} }
} }
&:hover { &:hover {
.dpt-actions-fixed { & > .dpt-actions-fixed {
opacity: 1;
} }
} }
} }
} }
.cp.cpe1 { .cp.cpe1 {

82
sapl/templates/compilacao/ajax_actions_dinamic_edit.html

@ -1,42 +1,66 @@
{% load i18n %} {% load i18n %}
<div class="btn-group dropdown" role="group">
{% if object.dispositivo_subsequente == None %}
{% for inserts in allowed_inserts %}
{% if inserts.itens %}
<div class="btn-group btn-group-inserts" role="group">
<button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{inserts.icone|safe}}<span>{{inserts.tipo_insert}}</span>
</button>
<ul class="dropdown-menu dropdown-menu-left">
<div class="arrow top"></div>
{% for item in inserts.itens %}
<li><a class="btn-inserts btn-action " action="{{inserts.action}}" pk="{{item.dispositivo_base}}" variacao="{{item.variacao}}" tipo_pk="{{item.tipo_pk}}">{{item.provavel|safe}}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endfor %}
{%endif%}
</div>
<div class="btn-toolbar pull-right" role="toolbar" > <div class="btn-toolbar pull-right" role="toolbar" >
{% if object.tipo_dispositivo.dispositivo_de_articulacao and object.tipo_dispositivo.dispositivo_de_alteracao %}
<div class="btn-group " role="group">
<button type="button" class="btn btn-default btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Registrar Revogação
</button>
<button type="button" class="btn btn-default btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Registrar Alteração
</button>
<button type="button" class="btn btn-default btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Registrar Inclusão
</button>
</div>
{%endif%}
<div class="btn-group " role="group"> <div class="btn-group " role="group">
<button type="button" class="btn btn-primary btn-sm radius-right" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> <button type="button" class="btn btn-default btn-sm radius-right" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-edit fa-lg"></i> <i class="fa fa-edit fa-lg"></i>
</button> </button>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<div class="arrow top"></div> <div class="arrow top"></div>
<li><a class="btn-editor-type" editortype="construct">Construtor</a></li>
<li><a class="btn-editor-type" editortype="textarea">Editor Simples</a></li>
<li><a class="btn-editor-type" editortype="tinymce">Editor Tinymce</a></li>
<li><a class="btn-editor-avancado" href="{% url 'sapl.compilacao:dispositivo_edit' object.ta_id object.pk %}" >Editor Avançado</a></li>
</ul>
</div>
</div>
<li><a class="btn-editor-type" editortype="construct">Construtor</a></li> <div class="btn-toolbar" role="toolbar" >
<li><a class="btn-editor-type" editortype="textarea">Editor Simples</a></li>
<li><a class="btn-editor-type" editortype="tinymce">Editor tinymce</a></li> <div class="btn-group dropdown" role="group">
<li><a class="btn-editor-avancado" href="{% url 'sapl.compilacao:dispositivo_edit' object.ta_id object.pk %}" >Editor Avançado</a></li> {% if object.dispositivo_subsequente == None %}
{% for inserts in allowed_inserts %}
{% if inserts.itens %}
<div class="btn-group btn-group-inserts" role="group">
<button type="button" class="btn btn-success btn-sm {% if forloop.last %}radius-right{%endif%}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
{{inserts.icone|safe}}<span>{{inserts.tipo_insert}}</span>
</button>
<ul class="dropdown-menu dropdown-menu-left">
<div class="arrow top"></div>
{% for item in inserts.itens %}
<li><a class="btn-inserts btn-action " action="{{inserts.action}}" pk="{{item.dispositivo_base}}" variacao="{{item.variacao}}" tipo_pk="{{item.tipo_pk}}">{{item.provavel|safe}}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>
<div class="btn-group " role="group">
{% if object.dispositivo_subsequente == None %}
{% for perfil in perfil_estrutural_list%}
<button type="button" class="btn-perfis btn btn-xs {%if request.session.perfil_estrutural == perfil.pk%}btn-success{%else%}btn-default{%endif%}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" pk="{{object.pk}}" perfil_pk="{{perfil.pk}}" action="json_get_perfis" title="{{perfil.nome}}">
{{perfil.sigla}}
</button>
{% endfor %}
{%endif%}
</ul>
</div> </div>
</div> </div>

9
sapl/templates/compilacao/text_edit_bloco.html

@ -3,9 +3,12 @@
{% load common_tags %} {% load common_tags %}
{% dispositivotree dispositivos_list %} {% dispositivotree dispositivos_list %}
<div class="dpt" id="id{{node.dpt.id}}" pk="{{node.dpt.pk}}" ordem="{{node.dpt.ordem}}" name="{{node.dpt.pk}}" title="{{node.dpt.pk}} - {{node.dpt.ordem}}"> <div class="dpt" id="id{{node.dpt.id}}" pk="{{node.dpt.pk}}" ordem="{{node.dpt.ordem}}" name="{{node.dpt.pk}}" title="{{node.dpt.pk}} - {{node.dpt.ordem}}" formtype="get_form_base">
<div class="dpt-actions-fixed btn-group"> <div class="dpt-actions-fixed">
<a class="btn-action btn-dpt-edit btn btn-default btn-sm" pk="{{node.dpt.pk}}"><span class="deactivate">{% trans 'Editar'%}</span><span class="activate">{% trans 'Em Edição'%}</span> {{ node.td.nome }} {{ node.dpt.rotulo }}</a> <a class="btn-action btn-dpt-edit btn btn-default btn-sm" pk="{{node.dpt.pk}}" title=""><span class="deactivate">{% trans 'Editar'%}</span><span class="activate">{% trans 'Em Edição'%}</span> {{ node.td.nome }} {{ node.dpt.rotulo }}</a>
<div class="btn-group">
<a class="btn-action btn-dpt-edit btn btn-info btn-sm activate" pk="{{node.dpt.pk}}" action="editor-close" title="{% trans 'Fechar Edição' %}"><span class="deactivate"></span><span class="activate"><i class="fa fa-times" aria-hidden="true"></i></span></a>
</div>
{% if not node.dpt.rotulo and not node.dpt.texto and node.td.dispositivo_de_articulacao%} {% if not node.dpt.rotulo and not node.dpt.texto and node.td.dispositivo_de_articulacao%}
{% endif %} {% endif %}
</div> </div>

Loading…
Cancel
Save