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

43
sapl/static/js/compilacao_edit.js

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

64
sapl/static/styles/compilacao.scss

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

82
sapl/templates/compilacao/ajax_actions_dinamic_edit.html

@ -1,42 +1,66 @@
{% 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" >
{% 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">
<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>
</button>
<ul class="dropdown-menu">
<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>
<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>
<div class="btn-toolbar" role="toolbar" >
<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-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>

9
sapl/templates/compilacao/text_edit_bloco.html

@ -3,9 +3,12 @@
{% load common_tags %}
{% 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-actions-fixed btn-group">
<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>
<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">
<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%}
{% endif %}
</div>

Loading…
Cancel
Save