From e05c0f6064e8195335ef399bc2ba8acef163bcfd Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 7 Mar 2018 16:04:36 +0100 Subject: [PATCH] Added probing for modal dialog to prevent conflicts of more modal dialogs at same time. --- .../controllers/_application_controller.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index b30d0683f..95d242233 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -676,6 +676,8 @@ class App.ControllerModal extends App.Controller closeOnAnyClick: false initalFormParams: {} initalFormParamsIgnore: false + showTryMax: 10 + showTrydelay: 1000 events: 'submit form': 'submit' @@ -687,6 +689,7 @@ class App.ControllerModal extends App.Controller constructor: -> super + @showTryCount = 0 if @authenticateRequired return if !@authenticateCheckRedirect() @@ -699,6 +702,16 @@ class App.ControllerModal extends App.Controller if @shown @render() + showDelayed: => + delay = => + @showTryCount += 1 + @render() + @delay(delay, @showTrydelay) + + modalAlreadyExists: -> + return true if $('.modal').length > 0 + false + content: -> 'You need to implement a one @content()!' @@ -737,6 +750,10 @@ class App.ControllerModal extends App.Controller @el render: => + if @modalAlreadyExists() && @showTryCount <= @showTryMax + @showDelayed() + return + @initalFormParamsIgnore = false if @buttonSubmit is true