From 1291275d09208f601d87e3a189c3fae60bcbc998 Mon Sep 17 00:00:00 2001 From: LeandroRoberto Date: Wed, 31 Aug 2016 16:53:09 -0300 Subject: [PATCH] Add bts de perfis e generaliza chmd de forms --- sapl/compilacao/views.py | 39 ++++----- sapl/static/js/compilacao_edit.js | 43 ++++++---- sapl/static/styles/compilacao.scss | 64 ++++++--------- .../compilacao/ajax_actions_dinamic_edit.html | 82 ++++++++++++------- .../templates/compilacao/text_edit_bloco.html | 9 +- 5 files changed, 132 insertions(+), 105 deletions(-) diff --git a/sapl/compilacao/views.py b/sapl/compilacao/views.py index e1eea02f4..1e88fc942 100644 --- a/sapl/compilacao/views.py +++ b/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_'): diff --git a/sapl/static/js/compilacao_edit.js b/sapl/static/js/compilacao_edit.js index a94a43f6c..c0c84d76d 100644 --- a/sapl/static/js/compilacao_edit.js +++ b/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(); } diff --git a/sapl/static/styles/compilacao.scss b/sapl/static/styles/compilacao.scss index 77ae12e84..553b0efb9 100644 --- a/sapl/static/styles/compilacao.scss +++ b/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 { diff --git a/sapl/templates/compilacao/ajax_actions_dinamic_edit.html b/sapl/templates/compilacao/ajax_actions_dinamic_edit.html index 96ddf65d6..be75c28e9 100644 --- a/sapl/templates/compilacao/ajax_actions_dinamic_edit.html +++ b/sapl/templates/compilacao/ajax_actions_dinamic_edit.html @@ -1,42 +1,66 @@ {% load i18n %} - - -
  • Construtor
  • -
  • Editor Simples
  • -
  • Editor tinymce
  • -
  • Editor Avançado
  • + diff --git a/sapl/templates/compilacao/text_edit_bloco.html b/sapl/templates/compilacao/text_edit_bloco.html index 1e399fb00..dd046108e 100644 --- a/sapl/templates/compilacao/text_edit_bloco.html +++ b/sapl/templates/compilacao/text_edit_bloco.html @@ -3,9 +3,12 @@ {% load common_tags %} {% dispositivotree dispositivos_list %} -
    -
    - {% trans 'Editar'%}{% trans 'Em Edição'%} {{ node.td.nome }} {{ node.dpt.rotulo }} +
    +
    + {% trans 'Editar'%}{% trans 'Em Edição'%} {{ node.td.nome }} {{ node.dpt.rotulo }} +
    + +
    {% if not node.dpt.rotulo and not node.dpt.texto and node.td.dispositivo_de_articulacao%} {% endif %}