Class: Workarea::Admin::HelpController

Inherits:
ApplicationController show all
Includes:
HelpAuthorization
Defined in:
app/controllers/workarea/admin/help_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model

Methods included from Publishing

#allow_publishing!, #allow_publishing?, #set_publishing_options

Methods included from Visiting

#most_visited

Instance Method Details

#createObject



35
36
37
38
39
40
41
42
43
# File 'app/controllers/workarea/admin/help_controller.rb', line 35

def create
  if @help_article.save
    flash[:success] = t('workarea.admin.help.flash_messages.created')
    redirect_to help_index_path
  else
    flash[:error] = t('workarea.admin.help.flash_messages.save_error')
    render :new
  end
end

#destroyObject



58
59
60
61
62
# File 'app/controllers/workarea/admin/help_controller.rb', line 58

def destroy
  @help_article.destroy
  flash[:success] = t('workarea.admin.help.flash_messages.removed')
  redirect_to help_index_path
end

#editObject



45
46
# File 'app/controllers/workarea/admin/help_controller.rb', line 45

def edit
end

#indexObject

TODO remove related help in v4



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/workarea/admin/help_controller.rb', line 11

def index
  related_help = params[:like_text].present? || params[:for_url].present?

  if request.xhr? && related_help
    search = Search::RelatedHelp.new(params)
    @search = Admin::HelpSearchViewModel.new(search, view_model_options)
    render :takeover
  else
    search = Search::HelpSearch.new(params)
    @search = Admin::HelpSearchViewModel.new(search, view_model_options)
  end
end

#newObject



32
33
# File 'app/controllers/workarea/admin/help_controller.rb', line 32

def new
end

#showObject



24
25
26
27
28
29
30
# File 'app/controllers/workarea/admin/help_controller.rb', line 24

def show
  search = Search::RelatedHelp.new(ids: [@help_article.id])
  @related = Admin::HelpSearchViewModel.new(search, view_model_options)
  @article_body = Redcarpet::Markdown.new(
    Redcarpet::Render::HTML.new(hard_wrap: true)
  ).render(@help_article.body.html_safe)
end

#updateObject



48
49
50
51
52
53
54
55
56
# File 'app/controllers/workarea/admin/help_controller.rb', line 48

def update
  if @help_article.update_attributes(params[:help_article])
    flash[:success] = t('workarea.admin.help.flash_messages.updated')
    redirect_to help_path(@help_article)
  else
    flash[:error] = t('workarea.admin.help.flash_messages.save_error')
    render :edit
  end
end