Sha256: ae2135b7e549cfce48d8f29bcf2b83b3b272a43938d04f5981a24256d934d539

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Kaui
  class BundleTagsController < Kaui::EngineController
    def edit
      @bundle_id = params.require(:bundle_id)

      cached_options_for_klient = options_for_klient
      fetch_tag_names = promise { Kaui::Tag.all_for_bundle(@bundle_id, false, 'NONE', cached_options_for_klient).map(&:tag_definition_name).sort }
      fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }

      @tag_names = wait(fetch_tag_names)
      @available_tags = wait(fetch_available_tags)
    end

    def update
      account_id = params.require(:account_id)
      bundle_id = params.require(:bundle_id)

      tags = []
      params.each_key do |tag|
        tag_info = tag.split('_')
        next if (tag_info.size != 2) || (tag_info[0] != 'tag')

        tags << tag_info[1]
      end

      Kaui::Tag.set_for_bundle(bundle_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
      redirect_to kaui_engine.account_bundles_path(account_id), notice: 'Bundle tags successfully set'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kaui-3.0.5 app/controllers/kaui/bundle_tags_controller.rb
kaui-3.0.4 app/controllers/kaui/bundle_tags_controller.rb
kaui-3.0.2 app/controllers/kaui/bundle_tags_controller.rb