Class: OtuPageLayoutsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/otu_page_layouts_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#polymorphic_filter_params

Methods inherited from ApplicationController

#clear_project_and_user_variables, #digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #intercept_api, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #notice_user, #project_matches, #record_not_found, #set_project_and_user_variables, #set_project_from_params, #token_authenticate

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Instance Method Details

- (Object) autocomplete



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/controllers/otu_page_layouts_controller.rb', line 75

def autocomplete
  @otu_page_layouts = OtuPageLayout.find_for_autocomplete(params)

  data = @otu_page_layouts.collect do |t|
    {id: t.id,
     label: ApplicationController.helpers.otu_page_layout_tag(t),
     response_values: {
       params[:method] => t.id
     },
     label_html: ApplicationController.helpers.otu_page_layout_tag(t)
    }

    render :json => data
  end
end

- (Object) create

POST /otu_page_layouts POST /otu_page_layouts.json



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/otu_page_layouts_controller.rb', line 31

def create
  @otu_page_layout = OtuPageLayout.new(otu_page_layout_params)

  respond_to do |format|
    if @otu_page_layout.save
      format.html { redirect_to @otu_page_layout, notice: 'Otu page layout was successfully created.' }
      format.json { render :show, status: :created, location: @otu_page_layout }
    else
      format.html { render :new }
      format.json { render json: @otu_page_layout.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /otu_page_layouts/1 DELETE /otu_page_layouts/1.json



61
62
63
64
65
66
67
# File 'app/controllers/otu_page_layouts_controller.rb', line 61

def destroy
  @otu_page_layout.destroy
  respond_to do |format|
    format.html { redirect_to otu_page_layouts_url }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /otu_page_layouts/1/edit



26
27
# File 'app/controllers/otu_page_layouts_controller.rb', line 26

def edit
end

- (Object) index

GET /otu_page_layouts GET /otu_page_layouts.json



8
9
10
11
# File 'app/controllers/otu_page_layouts_controller.rb', line 8

def index
  @recent_objects = OtuPageLayout.where(project_id: sessions_current_project_id).order(updated_at: :desc).limit(10)
  render '/shared/data/all/index'
end

- (Object) list



69
70
71
# File 'app/controllers/otu_page_layouts_controller.rb', line 69

def list
  @otu_page_layouts = OtuPageLayout.with_project_id(sessions_current_project_id).order(:name).page(params[:page]) #.per(10) 
end

- (Object) new

GET /otu_page_layouts/new



19
20
21
22
23
# File 'app/controllers/otu_page_layouts_controller.rb', line 19

def new
  @otu_page_layout = OtuPageLayout.new
  # generate an empty ActiveRecord::Relation
  @topics = ControlledVocabularyTerm.where(type: 'Topic', name: nil)
end

- (Object) otu_page_layout_params (private)

Never trust parameters from the scary internet, only allow the white list through.



99
100
101
102
103
104
# File 'app/controllers/otu_page_layouts_controller.rb', line 99

def otu_page_layout_params
  params.require(:otu_page_layout).permit(
    :name,
    standard_sections_attributes: [:topic_id, :_destroy, :type, :id, :position]
  )
end

- (Object) set_otu_page_layout (private)



93
94
95
96
# File 'app/controllers/otu_page_layouts_controller.rb', line 93

def set_otu_page_layout
  @otu_page_layout = OtuPageLayout.with_project_id(sessions_current_project_id).find(params[:id])
  @recent_object = @otu_page_layout
end

- (Object) show

GET /otu_page_layouts/1 GET /otu_page_layouts/1.json



15
16
# File 'app/controllers/otu_page_layouts_controller.rb', line 15

def show
end

- (Object) update

PATCH/PUT /otu_page_layouts/1 PATCH/PUT /otu_page_layouts/1.json



47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/otu_page_layouts_controller.rb', line 47

def update
  respond_to do |format|
    if @otu_page_layout.update(otu_page_layout_params)
      format.html { redirect_to @otu_page_layout, notice: 'Otu page layout was successfully updated.' }
      format.json { render :show, status: :ok, location: @otu_page_layout }
    else
      format.html { render :edit }
      format.json { render json: @otu_page_layout.errors, status: :unprocessable_entity }
    end
  end
end