Improved error handling.

This commit is contained in:
Martin Edenhofer 2016-05-18 00:27:05 +02:00
parent dff4a03208
commit dc263fb92a
2 changed files with 29 additions and 17 deletions

View file

@ -38,18 +38,23 @@ class Index extends App.ControllerContent
channel = App.Channel.find(channel_id) channel = App.Channel.find(channel_id)
if channel && channel.options && channel.options.sync if channel && channel.options && channel.options.sync
displayName = '-' displayName = '-'
if channel.options.sync.wall.group_id if channel.options.sync.wall && channel.options.sync.wall.group_id
group = App.Group.find(channel.options.sync.wall.group_id) group = App.Group.find(channel.options.sync.wall.group_id)
displayName = group.displayName() displayName = group.displayName()
if !channel.options.sync
channel.options.sync = {}
if !channel.options.sync.wall
channel.options.sync.wall = {}
channel.options.sync.wall.groupName = displayName channel.options.sync.wall.groupName = displayName
for page in channel.options.pages if channel.options && channel.options.pages
displayName = '-' for page in channel.options.pages
for page_id, pageParams of channel.options.sync.pages displayName = '-'
if page.id is page_id for page_id, pageParams of channel.options.sync.pages
if pageParams.group_id if page.id is page_id
group = App.Group.find(pageParams.group_id) if pageParams.group_id
displayName = group.displayName() group = App.Group.find(pageParams.group_id)
page.groupName = displayName displayName = group.displayName()
page.groupName = displayName
channels.push channel channels.push channel
@html App.view('facebook/list')( @html App.view('facebook/list')(
channels: channels channels: channels
@ -114,6 +119,9 @@ class Index extends App.ControllerContent
e.preventDefault() e.preventDefault()
id = $(e.target).closest('.action').data('id') id = $(e.target).closest('.action').data('id')
channel = App.Channel.find(id) channel = App.Channel.find(id)
if !channel
@navigate '#channels/facebook'
return
if !channel.options.sync if !channel.options.sync
channel.options.sync = {} channel.options.sync = {}
if !channel.options.sync.wall if !channel.options.sync.wall
@ -136,14 +144,15 @@ class Index extends App.ControllerContent
el.html(selection) el.html(selection)
groupSelection(channel.options.sync.wall.group_id, content.find('.js-wall .js-groups'), 'wall') groupSelection(channel.options.sync.wall.group_id, content.find('.js-wall .js-groups'), 'wall')
for page in channel.options.pages if channel.options.pages
pageConfigured = false for page in channel.options.pages
for page_id, pageParams of channel.options.sync.pages pageConfigured = false
if page.id is page_id for page_id, pageParams of channel.options.sync.pages
pageConfigured = true if page.id is page_id
groupSelection(pageParams.group_id, content.find(".js-groups[data-page-id=#{page.id}]"), "pages::#{page.id}") pageConfigured = true
if !pageConfigured groupSelection(pageParams.group_id, content.find(".js-groups[data-page-id=#{page.id}]"), "pages::#{page.id}")
groupSelection('', content.find(".js-groups[data-page-id=#{page.id}]"), "pages::#{page.id}") if !pageConfigured
groupSelection('', content.find(".js-groups[data-page-id=#{page.id}]"), "pages::#{page.id}")
modal = new App.ControllerModal( modal = new App.ControllerModal(
head: 'Facebook Account' head: 'Facebook Account'

View file

@ -119,6 +119,9 @@ class Index extends App.ControllerContent
e.preventDefault() e.preventDefault()
id = $(e.target).closest('.action').data('id') id = $(e.target).closest('.action').data('id')
channel = App.Channel.find(id) channel = App.Channel.find(id)
if !channel
@navigate '#channels/twitter'
return
content = $( App.view('twitter/account_edit')(channel: channel) ) content = $( App.view('twitter/account_edit')(channel: channel) )
createGroupSelection = (selected_id, prefix) -> createGroupSelection = (selected_id, prefix) ->