Class: OtuPageLayoutsController

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

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#json_request?

Methods included from LogRecent

#log_user_recent_route

Methods included from Cookies

#digest_cookie, #digested_cookie_exists?

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#cumulative_gb_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs

Methods included from Api::Intercept

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#autocompleteObject



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

#createObject

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

#destroyObject

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

#editObject

GET /otu_page_layouts/1/edit



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

def edit
end

#indexObject

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

#listObject



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

#newObject

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

#otu_page_layout_paramsObject (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

#set_otu_page_layoutObject (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

#showObject

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

#updateObject

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