Added channel quick enable/disable buttons.

This commit is contained in:
Martin Edenhofer 2016-12-12 15:54:41 +01:00
parent 81df51f274
commit fa8bf6e65f
6 changed files with 101 additions and 8 deletions

View file

@ -221,6 +221,8 @@ class App.ChannelEmailAccountOverview extends App.Controller
events: events:
'click .js-channelNew': 'wizard' 'click .js-channelNew': 'wizard'
'click .js-channelDelete': 'delete' 'click .js-channelDelete': 'delete'
'click .js-channelDisable': 'disable'
'click .js-channelEnable': 'enable'
'click .js-channelGroupChange': 'groupChange' 'click .js-channelGroupChange': 'groupChange'
'click .js-editInbound': 'editInbound' 'click .js-editInbound': 'editInbound'
'click .js-editOutbound': 'editOutbound' 'click .js-editOutbound': 'editOutbound'
@ -329,6 +331,30 @@ class App.ChannelEmailAccountOverview extends App.Controller
callback: @load callback: @load
) )
disable: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
item = App.Channel.find(id)
item.active = false
item.save(
done: =>
@load()
fail: =>
@load()
)
enable: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
item = App.Channel.find(id)
item.active = true
item.save(
done: =>
@load()
fail: =>
@load()
)
groupChange: (e) => groupChange: (e) =>
e.preventDefault() e.preventDefault()
id = $(e.target).closest('.action').data('id') id = $(e.target).closest('.action').data('id')

View file

@ -5,6 +5,8 @@ class Index extends App.ControllerSubContent
'click .js-new': 'new' 'click .js-new': 'new'
'click .js-edit': 'edit' 'click .js-edit': 'edit'
'click .js-delete': 'delete' 'click .js-delete': 'delete'
'click .js-disable': 'disable'
'click .js-enable': 'enable'
'click .js-configApp': 'configApp' 'click .js-configApp': 'configApp'
constructor: -> constructor: ->
@ -108,6 +110,30 @@ class Index extends App.ControllerSubContent
callback: @load callback: @load
) )
disable: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
item = App.Channel.find(id)
item.active = false
item.save(
done: =>
@load()
fail: =>
@load()
)
enable: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
item = App.Channel.find(id)
item.active = true
item.save(
done: =>
@load()
fail: =>
@load()
)
description: (e) => description: (e) =>
new App.ControllerGenericDescription( new App.ControllerGenericDescription(
description: App.Twitter.description description: App.Twitter.description

View file

@ -5,6 +5,8 @@ class Index extends App.ControllerSubContent
'click .js-edit': 'edit' 'click .js-edit': 'edit'
'click .js-delete': 'delete' 'click .js-delete': 'delete'
'click .js-configApp': 'configApp' 'click .js-configApp': 'configApp'
'click .js-disable': 'disable'
'click .js-enable': 'enable'
constructor: -> constructor: ->
super super
@ -107,6 +109,30 @@ class Index extends App.ControllerSubContent
callback: @load callback: @load
) )
disable: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
item = App.Channel.find(id)
item.active = false
item.save(
done: =>
@load()
fail: =>
@load()
)
enable: (e) =>
e.preventDefault()
id = $(e.target).closest('.action').data('id')
item = App.Channel.find(id)
item.active = true
item.save(
done: =>
@load()
fail: =>
@load()
)
description: (e) => description: (e) =>
new App.ControllerGenericDescription( new App.ControllerGenericDescription(
description: App.Twitter.description description: App.Twitter.description

View file

@ -41,7 +41,7 @@
<p><%- @T('You have no configured account right now.') %></p> <p><%- @T('You have no configured account right now.') %></p>
<% else: %> <% else: %>
<% for channel in @account_channels: %> <% for channel in @account_channels: %>
<div class="action" data-id="<%- channel.id %>"> <div class="action <% if channel.active isnt true: %>is-inactive<% end %>" data-id="<%- channel.id %>">
<div class="action-flow" style="width: 100%;"> <div class="action-flow" style="width: 100%;">
<div class="action-block action-block--flex"> <div class="action-block action-block--flex">
<div class="horizontal"> <div class="horizontal">
@ -135,7 +135,12 @@
</div> </div>
</div> </div>
<div class="action-controls"> <div class="action-controls">
<div class="sla-toggle btn btn--danger btn--secondary js-channelDelete"><%- @T('Delete') %></div> <% if channel.active is true: %>
<div class="btn btn--secondary js-channelDisable"><%- @T('Disable') %></div>
<% else: %>
<div class="btn btn--secondary js-channelEnable"><%- @T('Enable') %></div>
<% end %>
<div class="btn btn--danger btn--secondary js-channelDelete"><%- @T('Delete') %></div>
</div> </div>
</div> </div>
<% end %> <% end %>

View file

@ -11,7 +11,7 @@
<div class="page-content"> <div class="page-content">
<% for channel in @channels: %> <% for channel in @channels: %>
<div class="action" data-id="<%= channel.id %>"> <div class="action <% if channel.active isnt true: %>is-inactive<% end %>" data-id="<%= channel.id %>">
<div class="action-block action-row"> <div class="action-block action-row">
<h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.user.name %> <span class="text-muted"><%= channel.options.user.id %></span></h2> <h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.user.name %> <span class="text-muted"><%= channel.options.user.id %></span></h2>
</div> </div>
@ -33,8 +33,13 @@
</div> </div>
</div> </div>
<div class="action-controls"> <div class="action-controls">
<div class="sla-toggle btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div> <div class="btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div>
<div class="sla-edit btn js-edit"><%- @T('Edit') %></div> <% if channel.active is true: %>
<div class="btn btn--secondary js-disable"><%- @T('Disable') %></div>
<% else: %>
<div class="btn btn--secondary js-enable"><%- @T('Enable') %></div>
<% end %>
<div class="btn js-edit"><%- @T('Edit') %></div>
</div> </div>
</div> </div>
<% end %> <% end %>

View file

@ -11,7 +11,7 @@
<div class="page-content"> <div class="page-content">
<% for channel in @channels: %> <% for channel in @channels: %>
<div class="action" data-id="<%= channel.id %>"> <div class="action <% if channel.active isnt true: %>is-inactive<% end %>" data-id="<%= channel.id %>">
<div class="action-block action-row"> <div class="action-block action-row">
<h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.user.name %> <span class="text-muted">@<%= channel.options.user.screen_name %></span></h2> <h2><%- @Icon('status', 'supergood-color inline') %> <%= channel.options.user.name %> <span class="text-muted">@<%= channel.options.user.screen_name %></span></h2>
</div> </div>
@ -61,8 +61,13 @@
</div> </div>
</div> </div>
<div class="action-controls"> <div class="action-controls">
<div class="sla-toggle btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div> <div class="btn btn--danger btn--secondary js-delete"><%- @T('Delete') %></div>
<div class="sla-edit btn js-edit"><%- @T('Edit') %></div> <% if channel.active is true: %>
<div class="btn btn--secondary js-disable"><%- @T('Disable') %></div>
<% else: %>
<div class="btn btn--secondary js-enable"><%- @T('Enable') %></div>
<% end %>
<div class="btn js-edit"><%- @T('Edit') %></div>
</div> </div>
</div> </div>
<% end %> <% end %>