Extract renderScreen* methods into their own mixin

This commit is contained in:
Ryan Lue 2019-02-26 11:27:48 +01:00
parent c9f3641cad
commit 4f494b57ac
3 changed files with 33 additions and 16 deletions

View file

@ -1,5 +1,6 @@
class App.Controller extends Spine.Controller class App.Controller extends Spine.Controller
@include App.LogInclude @include App.LogInclude
@include App.RenderScreen
constructor: (params) -> constructor: (params) ->
@ -358,22 +359,6 @@ class App.Controller extends Spine.Controller
return if !@initLoadingDoneDelay return if !@initLoadingDoneDelay
@clearDelay(@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) => locationVerify: (e) =>
newLocation = $(e.currentTarget).attr 'href' newLocation = $(e.currentTarget).attr 'href'
@log 'debug', "new location '#{newLocation}'" @log 'debug', "new location '#{newLocation}'"

View file

@ -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)

View file

@ -0,0 +1,7 @@
<div class="fullscreenMessage fullscreenMessage--placeholder">
<%- @icon %>
<h2><% if @status isnt undefined: %><%- @T('Status Code') %>: <%= @status %>. <% end %><%- @T(@detail) %></h2>
<% if @action: %>
<div class="btn btn--action js-action"><%= @T(@action) %></div>
<% end %>
</div>