Class: AdditionalTagsController

Inherits:
ApplicationController
  • Object
show all
Includes:
AdditionalTagsHelper
Defined in:
app/controllers/additional_tags_controller.rb

Instance Method Summary collapse

Methods included from AdditionalTagsHelper

#additional_plain_tag_list, #additional_tag_link, #additional_tag_links, #additional_tag_sep, #additional_tags_from_params, #format_tags_json, #issue_tag_status_filter, #link_to_issue_tags_totals, #manageable_tag_column_values, #manageable_tag_columns, #manageable_tags, #render_tags_list, #sort_tags_for_list, #values_for_sort_direction, #wiki_tags_on_show?

Instance Method Details

#context_menuObject



62
63
64
65
66
# File 'app/controllers/additional_tags_controller.rb', line 62

def context_menu
  @tag = @tags.first if @tags.size == 1
  @back = back_url
  render layout: false
end

#destroyObject



53
54
55
56
57
58
59
60
# File 'app/controllers/additional_tags_controller.rb', line 53

def destroy
  @tags.each do |tag|
    tag.reload.destroy!
  rescue ::ActiveRecord::RecordNotFound, ::ActiveRecord::RecordNotDestroyed
    Rails.logger.warn "Tag #{tag} could not be deleted"
  end
  redirect_back_or_default @tag_list_path
end

#editObject



34
# File 'app/controllers/additional_tags_controller.rb', line 34

def edit; end

#indexObject

used by api calls



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/additional_tags_controller.rb', line 15

def index
  raise 'type is not provided' if params[:type].blank?

  type_info = manageable_tag_columns.detect { |m| m.first.to_s == params[:type] }
  raise 'type is not supported' unless type_info

  klass = type_info.first.to_s.camelize.constantize
  raise "#{klass.name} does not support tags" unless klass.respond_to? :available_tags

  @tags = klass.available_tags.to_a
  @count = @tags.count
  @tag_type = klass.name

  respond_to do |format|
    format.html { head :not_acceptable }
    format.api
  end
end

#mergeObject



68
69
70
71
72
73
74
75
# File 'app/controllers/additional_tags_controller.rb', line 68

def merge
  return unless request.post? &&
                params[:tag].present? &&
                params[:tag][:name].present?

  AdditionalTags::Tags.merge params[:tag][:name], @tags
  redirect_to @tag_list_path
end

#updateObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/additional_tags_controller.rb', line 36

def update
  @tag.name = params[:tag][:name] if params[:tag]
  if @tag.save
    flash[:notice] = flash_msg :update
    respond_to do |format|
      format.html do
        redirect_to @tag_list_path
      end
      format.xml
    end
  else
    respond_to do |format|
      format.html { render :edit }
    end
  end
end