Class: Ld4lVirtualCollection::NotesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ld4l_virtual_collection/notes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /collections/1/items/1/notes



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 29

def create
  # puts("*** Entering CTRL: create note")
  @note = Note.new(@collection, @item, note_params)

  if @note.persist! == true
    redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Note was successfully created.'
  else
    # TODO How to add error message about what failed to persist???
    render :new
  end
end

#destroyObject

DELETE /notes/1



55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 55

def destroy
  # puts("*** Entering CTRL: destroy note")
  @note.destroy
  # if LD4L::OreRDF::DestroyProxy.call(@collection,@item.rdf_subject) == true
  redirect_to my_virtual_collection_path(@collection.id.to_s), notice: 'Note was successfully removed.'
  # else
  #   # TODO Should it redirect to edit???  OR list???  OR  where???
  #   # TODO How to add error message about what failed to be destroyed???
  #  render :edit
  # end
end

#editObject

GET /notes/1/edit



24
25
26
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 24

def edit
  # puts("*** Entering CTRL: edit note")
end

#indexObject

GET /collections/1/items/1/notes



9
10
11
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 9

def index
  @notes = Note.all(@collection,@item)
end

#newObject

GET /collections/1/items/1/notes/new



18
19
20
21
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 18

def new
  # puts("*** Entering CTRL: new note")
  @note = Note.new(@collection,@item)
end

#showObject

GET /notes/1



14
15
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 14

def show
end

#updateObject

PATCH/PUT /notes/1



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/ld4l_virtual_collection/notes_controller.rb', line 42

def update
  # puts("*** Entering CTRL: update note")
  @note = Note.update(@note, note_params)
  # TODO should check old and new values and only update if changed
  # TODO How to save only affected items & collection instead of all items & collection???
  if @note.persist! == true
    redirect_to my_virtual_collection_path(note_params[:collection_id]), notice: 'Note was successfully updated.'
  else
    render :edit
  end
end