Class: Admin::DocumentDataDictionaryEntriesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/document_data_dictionary_entries_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /document_data_dictionaries/1/entries or /document_data_dictionaries/1/entries.json



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 23

def create
  @document_data_dictionary_entry = DocumentDataDictionaryEntry.new(document_data_dictionary_entry_params)

  respond_to do |format|
    if @document_data_dictionary_entry.save
      format.html { redirect_to admin_document_document_data_dictionary_path(@document, @document_data_dictionary), notice: "Document data dictionary entry was successfully created." }
      format.json { render :show, status: :created, location: @document_data_dictionary_entry }
    else
      logger.debug("Document data dictionary entry could not be created. #{@document_data_dictionary_entry.errors.full_messages}")
      format.html { render :new, status: :unprocessable_entity }
      format.json { render json: @document_data_dictionary_entry.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /document_data_dictionaries/1/entries/1 or /document_data_dictionaries/1/entries/1.json



53
54
55
56
57
58
59
60
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 53

def destroy
  @document_data_dictionary_entry.destroy!

  respond_to do |format|
    format.html { redirect_to admin_document_document_data_dictionary_path(@document, @document_data_dictionary), status: :see_other, notice: "Document data dictionary entry was successfully destroyed." }
    format.json { head :no_content }
  end
end

#destroy_allObject

DELETE /admin/document_data_dictionaries/1/entries/destroy_all

Destroys all document data dictionaries provided in the file parameter. If successful, redirects with a success notice. Otherwise, redirects with an error notice.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 66

def destroy_all
  return if request.get?

  logger.debug("Destroy Data Dictionary Entries")

  respond_to do |format|
    if @document_data_dictionary.document_data_dictionary_entries.destroy_all
      format.html { redirect_to admin_document_document_data_dictionary_document_data_dictionary_entries_path(@document_data_dictionary.friendlier_id, @document_data_dictionary), notice: "Data dictionary entries were destroyed." }
    else
      format.html { redirect_to admin_document_document_data_dictionary_document_data_dictionary_entries_path(@document_data_dictionary.friendlier_id, @document_data_dictionary), notice: "Data dictionary entries could not be destroyed." }
    end
  rescue => e
    format.html { redirect_to admin_document_document_data_dictionary_document_data_dictionary_entries_path(@document_data_dictionary.friendlier_id, @document_data_dictionary), notice: "Data dictionary entries could not be destroyed. #{e}" }
  end
end

#editObject

GET /document_data_dictionaries/1/entries/1/edit



19
20
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 19

def edit
end

#newObject

GET /document_data_dictionaries/1/entries/new



14
15
16
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 14

def new
  @document_data_dictionary_entry = DocumentDataDictionaryEntry.new
end

#sortObject

POST /document_data_dictionaries/1/entries/sort Sorts document data dictionary entries based on the provided list of IDs. Renders an empty response body.



85
86
87
88
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 85

def sort
  DocumentDataDictionary.sort_entries(params[:id_list])
  render body: nil
end

#updateObject

PATCH/PUT /document_data_dictionaries/1/entries/1 or /document_data_dictionaries/1/entries/1.json



39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/admin/document_data_dictionary_entries_controller.rb', line 39

def update
  respond_to do |format|
    if @document_data_dictionary_entry.update(document_data_dictionary_entry_params)
      format.html { redirect_to admin_document_document_data_dictionary_path(@document, @document_data_dictionary), notice: "Document data dictionary entry was successfully updated." }
      format.json { render :show, status: :ok, location: @document_data_dictionary_entry }
    else
      logger.debug("Document data dictionary entry could not be updated. #{@document_data_dictionary_entry.errors.full_messages}")
      format.html { render :edit, status: :unprocessable_entity }
      format.json { render json: @document_data_dictionary_entry.errors, status: :unprocessable_entity }
    end
  end
end