Class: Kaui::TagDefinitionsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/tag_definitions_controller.rb

Constant Summary

Constants included from EngineControllerUtil

EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#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

#createObject


16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 16

def create
  params[:tag_definition][:applicable_object_types] = params[:tag_definition][:applicable_object_types].values unless params[:tag_definition][:applicable_object_types].blank?
  @tag_definition = Kaui::TagDefinition.new(params[:tag_definition])

  begin
    @tag_definition = @tag_definition.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
    redirect_to kaui_engine.tag_definitions_path, :notice => 'Tag definition successfully created'
  rescue => e
    flash.now[:error] = "Error while creating tag definition: #{as_string(e)}"
    render :action => :new
  end
end

#destroyObject


29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 29

def destroy
  @tag_definition = Kaui::TagDefinition.find_by_id(params[:id], 'NONE', options_for_klient)

  begin
    @tag_definition.delete(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
    redirect_to kaui_engine.tag_definitions_path, :notice => 'Tag definition successfully deleted'
  rescue => e
    flash.now[:error] = "Error while deleting tag definition: #{as_string(e)}"
    render :action => :index
  end
end

#indexObject


3
4
5
6
7
8
9
10
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 3

def index
  begin
    @tag_definitions = Kaui::TagDefinition.all('NONE', options_for_klient)
  rescue => e
    flash.now[:error] = "Error while retrieving tag definitions: #{as_string(e)}"
    @tag_definitions  = []
  end
end

#newObject


12
13
14
# File 'app/controllers/kaui/tag_definitions_controller.rb', line 12

def new
  @tag_definition = Kaui::TagDefinition.new
end