Class: Atrium::ShowcasesController
Instance Method Summary
collapse
#atrium_config
#facet_element, #get_parent_path, #get_showcase_parent_edit_path, #get_showcase_parent_show_path, #render_showcase_facet_selection
#application_name
#get_saved_items, #get_saved_search, #saved_searches_for_select
Instance Method Details
#add_or_update ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'app/controllers/atrium/showcases_controller.rb', line 53
def add_or_update
@parent=parent
@showcase= Atrium::Showcase.with_selected_facets(
@parent.id,
@parent.class.name,
params[:facet_selection]
).first
logger.debug("Showcase: #{@showcase.inspect}")
unless @showcase
@showcase = @parent.showcases.build(
{
showcases_id:@parent.id,
showcases_type:@parent.class.name
}
)
@showcase.save!
if(params[:facet_selection])
params[:facet_selection].collect {|key,value|
@showcase.facet_selections.create(
{solr_facet_name:key,value:value.first}
)
}
@showcase.save!
end
end
render action: "edit"
end
|
#create ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/atrium/showcases_controller.rb', line 11
def create
@showcase=parent.showcases.build(params[:showcase])
if @showcase.save!
flash[:notice] = 'Showcase was successfully created.'
render action: "edit"
else
render action: "new"
end
end
|
#destroy ⇒ Object
46
47
48
49
50
51
|
# File 'app/controllers/atrium/showcases_controller.rb', line 46
def destroy
redirect_url=parent_url
@showcase.destroy
flash[:notice] = 'Showcase '+params[:id] +' was deleted successfully.'
redirect_to redirect_url
end
|
#edit ⇒ Object
40
41
|
# File 'app/controllers/atrium/showcases_controller.rb', line 40
def edit
end
|
#index ⇒ Object
21
22
23
|
# File 'app/controllers/atrium/showcases_controller.rb', line 21
def index
@showcases=parent.showcases
end
|
#new ⇒ Object
7
8
9
|
# File 'app/controllers/atrium/showcases_controller.rb', line 7
def new
@showcase=parent.showcases.build(params[:showcase])
end
|
#show ⇒ Object
43
44
|
# File 'app/controllers/atrium/showcases_controller.rb', line 43
def show
end
|
#update ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/atrium/showcases_controller.rb', line 25
def update
if (params[:showcase])
params[:showcase][:showcase_items] ||= []
if params[:showcase][:showcase_items].length > 0
params[:showcase][:showcase_items].delete_if { |elem| elem.empty? }
end
end
if @showcase.update_attributes(params[:showcase])
flash[:notice] = 'Showcase was successfully updated.'
else
flash.now.alert = 'Showcase Not updated'
end
render action: "edit"
end
|