diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index 03309976..98c2db80 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -17,6 +17,7 @@ class InboxController < ApplicationController .where(questions: { user_id: @target_user.id, author_is_anonymous: false }) .count if @inbox_author.empty? + @empty = true flash.now[:info] = "No questions from @#{params[:author]} found, showing default entries instead!" else @inbox = @inbox_author @@ -28,7 +29,15 @@ class InboxController < ApplicationController end end - @disabled = true if @inbox.empty? or @not_found + if @empty or @not_found + @delete_id = "ib-delete-all" + elsif @author + @delete_id = "ib-delete-all-author" + else + @delete_id = "ib-delete-all" + end + + @disabled = true if @inbox.empty? respond_to do |format| format.html format.js diff --git a/app/views/inbox/_sidebar.html.haml b/app/views/inbox/_sidebar.html.haml index 39994ce6..9da5bd77 100644 --- a/app/views/inbox/_sidebar.html.haml +++ b/app/views/inbox/_sidebar.html.haml @@ -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: (@disabled ? 'disabled' : nil), data: { ib_count: @inbox_count }}= t 'views.inbox.sidebar.actions.button' + %button.btn.btn-block.btn-danger{type: :button, id: @delete_id , disabled: (@disabled ? 'disabled' : nil), data: { ib_count: @inbox_count }}= t 'views.inbox.sidebar.actions.button'