Show error message when editor fails to initiate.

This commit is contained in:
Ting-Kuan 2014-03-27 14:35:20 -04:00
parent a811086918
commit 6012a3ce9e
7 changed files with 53 additions and 5 deletions

View file

@ -18,10 +18,12 @@ block content
h3(data-i18n="article.edit_article_title") Edit Article h3(data-i18n="article.edit_article_title") Edit Article
span span
|: "#{article.attributes.name}" |: "#{article.attributes.name}"
#article-treema #article-treema
#article-view #article-view
hr hr
div#error-view

View file

@ -75,4 +75,6 @@ block outer_content
div.tab-pane#editor-level-systems-tab-view div.tab-pane#editor-level-systems-tab-view
div#error-view
block footer block footer

View file

@ -84,4 +84,6 @@ block content
div#spritesheets div#spritesheets
div#error-view
.clearfix .clearfix

View file

@ -1,5 +1,6 @@
View = require 'views/kinds/RootView' View = require 'views/kinds/RootView'
VersionHistoryView = require './versions_view' VersionHistoryView = require './versions_view'
ErrorView = require '../../error_view'
template = require 'templates/editor/article/edit' template = require 'templates/editor/article/edit'
Article = require 'models/Article' Article = require 'models/Article'
@ -19,6 +20,18 @@ module.exports = class ArticleEditView extends View
super options super options
@article = new Article(_id: @articleID) @article = new Article(_id: @articleID)
@article.saveBackups = true @article.saveBackups = true
@listenToOnce(@article, 'error',
() =>
@hideLoading()
# Hack: editor components appear after calling insertSubView.
# So we need to hide them first.
$(@$el).find('.main-content-area').children('*').not('#error-view').remove()
@insertSubView(new ErrorView())
)
@article.fetch() @article.fetch()
@listenToOnce(@article, 'sync', @onArticleSync) @listenToOnce(@article, 'sync', @onArticleSync)
@listenTo(@article, 'schema-loaded', @buildTreema) @listenTo(@article, 'schema-loaded', @buildTreema)

View file

@ -13,6 +13,7 @@ SystemsTabView = require './systems_tab_view'
LevelSaveView = require './save_view' LevelSaveView = require './save_view'
LevelForkView = require './fork_view' LevelForkView = require './fork_view'
VersionHistoryView = require './versions_view' VersionHistoryView = require './versions_view'
ErrorView = require '../../error_view'
module.exports = class EditorLevelView extends View module.exports = class EditorLevelView extends View
id: "editor-level-view" id: "editor-level-view"
@ -43,6 +44,12 @@ module.exports = class EditorLevelView extends View
@level = new Level _id: @levelID @level = new Level _id: @levelID
@listenToOnce(@level, 'sync', @onLevelLoaded) @listenToOnce(@level, 'sync', @onLevelLoaded)
@listenToOnce(@supermodel, 'error',
() =>
@hideLoading()
@insertSubView(new ErrorView())
)
@supermodel.populateModel @level @supermodel.populateModel @level
showLoading: ($el) -> showLoading: ($el) ->

View file

@ -1,15 +1,16 @@
View = require 'views/kinds/RootView'
template = require 'templates/editor/thang/edit'
ThangType = require 'models/ThangType' ThangType = require 'models/ThangType'
SpriteParser = require 'lib/sprites/SpriteParser' SpriteParser = require 'lib/sprites/SpriteParser'
SpriteBuilder = require 'lib/sprites/SpriteBuilder' SpriteBuilder = require 'lib/sprites/SpriteBuilder'
CocoSprite = require 'lib/surface/CocoSprite' CocoSprite = require 'lib/surface/CocoSprite'
Camera = require 'lib/surface/Camera' Camera = require 'lib/surface/Camera'
ThangComponentEditView = require 'views/editor/components/main'
VersionHistoryView = require './versions_view'
DocumentFiles = require 'collections/DocumentFiles' DocumentFiles = require 'collections/DocumentFiles'
View = require 'views/kinds/RootView'
ThangComponentEditView = require 'views/editor/components/main'
VersionHistoryView = require './versions_view'
ColorsTabView = require './colors_tab_view' ColorsTabView = require './colors_tab_view'
ErrorView = require '../../error_view'
template = require 'templates/editor/thang/edit'
CENTER = {x:200, y:300} CENTER = {x:200, y:300}
@ -43,6 +44,18 @@ module.exports = class ThangTypeEditView extends View
@mockThang = $.extend(true, {}, @mockThang) @mockThang = $.extend(true, {}, @mockThang)
@thangType = new ThangType(_id: @thangTypeID) @thangType = new ThangType(_id: @thangTypeID)
@thangType.saveBackups = true @thangType.saveBackups = true
@listenToOnce(@thangType, 'error',
() =>
@hideLoading()
# Hack: editor components appear after calling insertSubView.
# So we need to hide them first.
$(@$el).find('.main-content-area').children('*').not('#error-view').remove()
@insertSubView(new ErrorView())
)
@thangType.fetch() @thangType.fetch()
@thangType.loadSchema() @thangType.loadSchema()
@thangType.schema().once 'sync', @onThangTypeSync, @ @thangType.schema().once 'sync', @onThangTypeSync, @

View file

@ -0,0 +1,9 @@
View = require 'views/kinds/RootView'
module.exports = class ErrorView extends View
id: "error-view"
el: "<div class='alert alert-warning'></div>"
render: ()->
super()
@$el.append("<h2><span>Error: Failed to process request.</span></h2>")