diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index e082cb166..81918642e 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -1,5 +1,6 @@ class App.Controller extends Spine.Controller @include App.LogInclude + @include App.RenderScreen constructor: (params) -> @@ -358,22 +359,6 @@ class App.Controller extends Spine.Controller return if !@initLoadingDoneDelay @clearDelay(@initLoadingDoneDelay) - renderScreenSuccess: (data) -> - App.TaskManager.touch(@taskKey) if @taskKey - (data.el || @).html App.view('generic/error/success')(data) - - renderScreenError: (data) -> - App.TaskManager.touch(@taskKey) if @taskKey - (data.el || @).html App.view('generic/error/generic')(data) - - renderScreenNotFound: (data) -> - App.TaskManager.touch(@taskKey) if @taskKey - (data.el || @).html App.view('generic/error/not_found')(data) - - renderScreenUnauthorized: (data) -> - App.TaskManager.touch(@taskKey) if @taskKey - (data.el || @).html App.view('generic/error/unauthorized')(data) - locationVerify: (e) => newLocation = $(e.currentTarget).attr 'href' @log 'debug', "new location '#{newLocation}'" diff --git a/app/assets/javascripts/app/lib/mixins/render_screen.coffee b/app/assets/javascripts/app/lib/mixins/render_screen.coffee new file mode 100644 index 000000000..f60ce6cb5 --- /dev/null +++ b/app/assets/javascripts/app/lib/mixins/render_screen.coffee @@ -0,0 +1,25 @@ +# Methods for displaying a full-screen success or error message + +App.RenderScreen = + renderScreenSuccess: (data) -> + App.TaskManager.touch(@taskKey) if @taskKey + (data.el || @).html App.view('generic/error/success')(data) + + renderScreenError: (data) -> + App.TaskManager.touch(@taskKey) if @taskKey + (data.el || @).html App.view('generic/error/generic')(data) + + renderScreenNotFound: (data) -> + App.TaskManager.touch(@taskKey) if @taskKey + (data.el || @).html App.view('generic/error/not_found')(data) + + renderScreenUnauthorized: (data) -> + App.TaskManager.touch(@taskKey) if @taskKey + (data.el || @).html App.view('generic/error/unauthorized')(data) + + renderScreenPlaceholder: (data) -> + App.TaskManager.touch(@taskKey) if @taskKey + (data.el || @).html App.view('generic/error/placeholder')(data) + if data.action && data.actionCallback + (data.el || @.el).find('.js-action').click(data.actionCallback) + diff --git a/app/assets/javascripts/app/views/generic/error/placeholder.jst.eco b/app/assets/javascripts/app/views/generic/error/placeholder.jst.eco new file mode 100644 index 000000000..2627163d7 --- /dev/null +++ b/app/assets/javascripts/app/views/generic/error/placeholder.jst.eco @@ -0,0 +1,7 @@ +