Class: Kaui::AccountTagsController
- Inherits:
-
EngineController
- Object
- EngineController
- Kaui::AccountTagsController
- Defined in:
- app/controllers/kaui/account_tags_controller.rb
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/kaui/account_tags_controller.rb', line 25 def edit @account_id = params.require(:account_id) = fetch_tag_names = promise { Kaui::Tag.all_for_account(@account_id, false, 'NONE', ).map(&:tag_definition_name).sort } = promise { Kaui::TagDefinition.all_for_account() } @tag_names = wait(fetch_tag_names) @available_tags = wait() end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/kaui/account_tags_controller.rb', line 5 def index = account = Kaui::Account.find_by_id_or_key(params.require(:account_id), true, true, ) = account.(nil, false, 'NONE', ) 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 = [] .each { |page| @tags_json << formatter.call(page) } @tags_json = @tags_json.to_json end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/kaui/account_tags_controller.rb', line 36 def update account_id = params.require(:account_id) = [] params.each_key do |tag| tag_info = tag.split('_') next if (tag_info.size != 2) || (tag_info[0] != 'tag') << tag_info[1] end Kaui::Tag.set_for_account(account_id, , current_user.kb_username, params[:reason], params[:comment], ) redirect_to kaui_engine.account_path(account_id), notice: 'Account tags successfully set' end |