Class: Kaui::AccountTagsController
Constant Summary
EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD
Instance Method Summary
collapse
#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user
Instance Method Details
#edit ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/kaui/account_tags_controller.rb', line 24
def edit
@account_id = params.require(:account_id)
cached_options_for_klient = options_for_klient
fetch_tag_names = promise { (Kaui::Tag.all_for_account(@account_id, false, 'NONE', cached_options_for_klient).map { |tag| tag.tag_definition_name }).sort }
fetch_available_tags = promise { Kaui::TagDefinition.all_for_account(cached_options_for_klient) }
@tag_names = wait(fetch_tag_names)
@available_tags = wait(fetch_available_tags)
end
|
#index ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/kaui/account_tags_controller.rb', line 3
def index
cached_options_for_klient = options_for_klient
account = Kaui::Account::find_by_id_or_key(params.require(:account_id), true, true, cached_options_for_klient)
tags = account.all_tags(nil, false, 'NONE', cached_options_for_klient)
formatter = lambda do |tag|
url_for_object = view_context.url_for_object(tag.object_id, tag.object_type)
[
tag.tag_id,
url_for_object ? view_context.link_to(tag.object_id, url_for_object) : tag.object_id,
tag.object_type,
tag.tag_definition_name
]
end
@tags_json = []
tags.each { |page| @tags_json << formatter.call(page) }
@tags_json = @tags_json.to_json
end
|
#update ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/kaui/account_tags_controller.rb', line 35
def update
account_id = params.require(:account_id)
tags = []
params.each do |tag, tag_name|
tag_info = tag.split('_')
next if tag_info.size != 2 or tag_info[0] != 'tag'
tags << tag_info[1]
end
Kaui::Tag.set_for_account(account_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
redirect_to kaui_engine.account_path(account_id), :notice => 'Account tags successfully set'
end
|