From 5e1f31ebdd3093453065cd770711839f49addee8 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 20 Feb 2020 09:32:47 +0100 Subject: [PATCH] hotfix #2135 - Don't enable inputs disabled by ACL directive --- front/core/components/button/index.js | 4 +++- front/core/directives/http-click.js | 7 +++++-- front/core/directives/http-submit.js | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/front/core/components/button/index.js b/front/core/components/button/index.js index 96d68c23b..e8c998801 100644 --- a/front/core/components/button/index.js +++ b/front/core/components/button/index.js @@ -29,8 +29,10 @@ export default class Button extends FormInput { } onClick(event) { - if (this.disabled) + if (this.disabled) { + event.preventDefault(); event.stopImmediatePropagation(); + } } } Button.$inject = ['$element', '$scope']; diff --git a/front/core/directives/http-click.js b/front/core/directives/http-click.js index 5e69d81d1..9f8426cef 100644 --- a/front/core/directives/http-click.js +++ b/front/core/directives/http-click.js @@ -14,10 +14,13 @@ export function directive($parse) { const cb = $parse($attrs.vnHttpClick); const element = $element[0]; $element.on('click', () => { - element.$ctrl.disabled = true; + const controller = element.$ctrl; + controller.$oldDisabled = field.$ctrl.disabled; + controller.disabled = true; cb($scope).finally(() => { - element.$ctrl.disabled = false; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); } diff --git a/front/core/directives/http-submit.js b/front/core/directives/http-submit.js index 0cf17866e..3d93f0220 100644 --- a/front/core/directives/http-submit.js +++ b/front/core/directives/http-submit.js @@ -19,12 +19,16 @@ export function directive($parse) { const fields = angular.element(elements); angular.forEach(fields, field => { - field.$ctrl.disabled = true; + const controller = field.$ctrl; + controller.$oldDisabled = controller.disabled; + controller.disabled = true; }); cb($scope).finally(() => { angular.forEach(fields, field => { - field.$ctrl.disabled = false; + const controller = field.$ctrl; + if (!controller.$oldDisabled) + controller.disabled = false; }); }); });