Class: ClassificationsController
  
  
  
  
    - Inherits:
 
    - 
      ApplicationController
      
        
        show all
      
      
 
    
  
  
    
  
    
  
  
  
    - Defined in:
 
    - frontend/app/controllers/classifications_controller.rb
 
  
  
    
      Instance Method Summary
      (collapse)
    
    
  
  
  
  
  
  
  
  
  
  
  can_access?, permission_mappings, set_access_control
  
  
    Instance Method Details
    
      
  
  
    - (Object) accept_children 
  
  
  
  
    
      
122
123
124 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 122
def accept_children
  handle_accept_children(JSONModel(:classification))
end
 
     | 
  
 
    
      
  
  
    - (Object) create 
  
  
  
  
    
      
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 49
def create
  flash.keep(:spawned_from_accession)
  handle_crud(:instance => :classification,
              :on_invalid => ->(){
    render action: "new"
  },
    :on_valid => ->(id){
    redirect_to({
                  :controller => :classifications,
                  :action => :edit,
                  :id => id
                },
                :flash => {:success => I18n.t("classification._frontend.messages.created", JSONModelI18nWrapper.new(:classification => @classification))})
  })
end
     | 
  
 
    
      
  
  
    - (Object) defaults 
  
  
  
  
    
      
90
91
92
93
94
95
96
97
98
99 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 90
def defaults
  defaults = DefaultValues.get 'classification'
  values = defaults ? defaults.form_values : {}
  @classification = JSONModel(:classification).new(values)._always_valid!
  @form_title = I18n.t("default_values.form_title.classification")
  render "defaults"
end
     | 
  
 
    
      
  
  
    - (Object) delete 
  
  
  
  
    
      
81
82
83
84
85
86
87 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 81
def delete
  classification = JSONModel(:classification).find(params[:id])
  classification.delete
  flash[:success] = I18n.t("classification._frontend.messages.deleted", JSONModelI18nWrapper.new(:classification => classification))
  redirect_to(:controller => :classifications, :action => :index, :deleted_uri => classification.uri)
end
     | 
  
 
    
      
  
  
    - (Object) edit 
  
  
  
  
    
      
37
38
39
40
41
42
43
44
45
46 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 37
def edit
  flash.keep if not flash.empty? 
  if params[:inline]
    @classification = JSONModel(:classification).find(params[:id], find_opts)
    return render_aspace_partial :partial => "classifications/edit_inline"
  end
  @classification = JSONModel(:classification).find(params[:id])
end
     | 
  
 
    
      
  
  
    - (Object) index 
  
  
  
  
    
      
9
10
11 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 9
def index
  @search_data = Search.for_type(session[:repo_id], "classification", params_for_backend_search.merge({"facet[]" => SearchResultData.CLASSIFICATION_FACETS}))
end
     | 
  
 
    
      
  
  
    - (Object) new 
  
  
  
  
    
      
24
25
26
27
28
29
30
31
32
33
34 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 24
def new
  @classification = JSONModel(:classification).new(:title => I18n.t("classification.title_default", :default => ""))._always_valid!
  if user_prefs['default_values']
    defaults = DefaultValues.get 'classification'
    @classification.update(defaults.values) if defaults
  end
  return render_aspace_partial :partial => "classifications/new_inline" if params[:inline]
end
     | 
  
 
    
      
  
  
    - (Object) show 
  
  
  
  
    
      
13
14
15
16
17
18
19
20
21
22 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 13
def show
  flash.keep
  if params[:inline]
    @classification = JSONModel(:classification).find(params[:id], find_opts)
    return render_aspace_partial :partial => "classifications/show_inline"
  end
  @classification = JSONModel(:classification).find(params[:id])
end
     | 
  
 
    
      
  
  
    - (Object) tree 
  
  
  
  
    
      
127
128
129
130
131 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 127
def tree
  flash.keep 
  render :json => fetch_tree
end
 
     | 
  
 
    
      
  
  
    - (Object) update 
  
  
  
  
    
      
67
68
69
70
71
72
73
74
75
76
77
78 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 67
def update
  handle_crud(:instance => :classification,
              :obj => JSONModel(:classification).find(params[:id], find_opts),
              :on_invalid => ->(){
    render_aspace_partial :partial => "edit_inline"
  },
    :on_valid => ->(id){
    @refresh_tree_node = true
  flash.now[:success] = I18n.t("classification._frontend.messages.updated", JSONModelI18nWrapper.new(:classification => @classification))
  render_aspace_partial :partial => "edit_inline"
  })
end
     | 
  
 
    
      
  
  
    - (Object) update_defaults 
  
  
  
  
    
      
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 
     | 
    
      # File 'frontend/app/controllers/classifications_controller.rb', line 101
def update_defaults
  begin
    DefaultValues.from_hash({
                              "record_type" => "classification",
                              "lock_version" => params[:classification].delete('lock_version'),
                              "defaults" => cleanup_params_for_schema(
                                                                      params[:classification],
                                                                      JSONModel(:classification).schema)
                            }).save
    flash[:success] = I18n.t("default_values.messages.defaults_updated")
    redirect_to :controller => :classifications, :action => :defaults
  rescue Exception => e
    flash[:error] = e.message
    redirect_to :controller => :classifications, :action => :defaults
  end
end
     |