removing more logic from templates + simpler coffeescript
This commit is contained in:
parent
8232aa2a21
commit
e1d38ebb89
|
@ -9,10 +9,10 @@
|
|||
if data.success
|
||||
($ "div#entries").prepend(data.render) # TODO: slideDown or something
|
||||
# GitHub issue #26:
|
||||
if document.getElementById('ib-delete-all') == undefined
|
||||
del_all_btn = ($ "button#ib-delete-all-author")
|
||||
else
|
||||
if document.getElementById('ib-delete-all')?
|
||||
del_all_btn = ($ "button#ib-delete-all")
|
||||
else
|
||||
del_all_btn = ($ "button#ib-delete-all-author")
|
||||
del_all_btn.removeAttr 'disabled'
|
||||
del_all_btn[0].dataset.ibCount = (Number del_all_btn[0].dataset.ibCount) + 1
|
||||
error: (jqxhr, status, error) ->
|
||||
|
@ -163,10 +163,10 @@ $(document).on "click", "button[name=ib-destroy]", ->
|
|||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
$("div.inbox-box[data-id=#{iid}]").slideUp()
|
||||
if document.getElementById('ib-delete-all') == undefined
|
||||
del_all_btn = ($ "button#ib-delete-all-author")
|
||||
else
|
||||
if document.getElementById('ib-delete-all')?
|
||||
del_all_btn = ($ "button#ib-delete-all")
|
||||
else
|
||||
del_all_btn = ($ "button#ib-delete-all-author")
|
||||
del_all_btn.removeAttr 'disabled'
|
||||
del_all_btn[0].dataset.ibCount = (Number del_all_btn[0].dataset.ibCount) - 1
|
||||
showNotification data.message, data.success
|
||||
|
|
|
@ -26,10 +26,13 @@ class InboxController < ApplicationController
|
|||
end
|
||||
rescue
|
||||
flash.now[:error] = "No user with the name @#{params[:author]} found, showing default entries instead!"
|
||||
@not_found = true
|
||||
@inbox
|
||||
@inbox_count
|
||||
end
|
||||
end
|
||||
|
||||
@disabled = true if @inbox.empty? or @not_found
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
|
|
|
@ -25,5 +25,5 @@
|
|||
.panel-heading
|
||||
%h3.panel-title= t 'views.inbox.sidebar.actions.title'
|
||||
.panel-body
|
||||
%button.btn.btn-block.btn-danger{type: :button, id: @author ? 'ib-delete-all-author' : 'ib-delete-all', disabled: (Inbox.where(user: current_user).empty? ? 'disabled' : nil), data: { ib_count: @inbox_count }}= t 'views.inbox.sidebar.actions.button'
|
||||
%button.btn.btn-block.btn-danger{type: :button, id: @author ? 'ib-delete-all-author' : 'ib-delete-all', disabled: (@disabled ? 'disabled' : nil), data: { ib_count: @inbox_count }}= t 'views.inbox.sidebar.actions.button'
|
||||
|
||||
|
|
Loading…
Reference in New Issue