Class: ActiveMetadata::NotesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/active_metadata/notes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
# File 'app/controllers/active_metadata/notes_controller.rb', line 26

def create
  @document = eval(params[:model_name]).find params[:model_id]
  @document.create_note_for(params[:field_name], params[:note])
  respond_to do |format|
    # TODO redirect to edit
    format.js       
  end
end

#destroyObject



50
51
52
53
54
55
56
57
# File 'app/controllers/active_metadata/notes_controller.rb', line 50

def destroy
  @document = eval(params[:model_name]).find params[:model_id]
  @document.delete_note_for(params[:field_name],params[:id])
  respond_to do |format|
    # TODO redirect to index
    format.js
  end
end

#editObject



16
17
18
19
# File 'app/controllers/active_metadata/notes_controller.rb', line 16

def edit
  @document = eval(params[:model_name]).find params[:model_id] 
  @note = @document.note_for params[:field_name],params[:id]     
end

#indexObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/active_metadata/notes_controller.rb', line 6

def index
  @document = eval(params[:model_name]).find params[:model_id] 
  @notes = @document.notes_for params[:field_name]      
  respond_to do |format|
    format.html { render :layout => false}
    format.xml  { render :xml => @notes }
    format.xls { send_data @notes.to_xls_data(:columns => [:note,:created_at], :headers => [:nota,'inserita']), :filename => 'notes.xls' }        
  end
end

#showObject



21
22
23
24
# File 'app/controllers/active_metadata/notes_controller.rb', line 21

def show
  @document = eval(params[:model_name]).find params[:model_id] 
  @note = @document.note_for params[:field_name],params[:id]     
end

#updateObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/active_metadata/notes_controller.rb', line 35

def update
  @document = eval(params[:model_name]).find params[:model_id]
  @note = @document.note_for params[:field_name],params[:id]     
        
  respond_to do |format|
    if @document.update_note(params[:id],params[:note][:note])
      format.html { redirect_to((@document.class,@document.id,@note.label,@note.id), :notice => 'Note was successfully updated.') }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @note.errors, :status => :unprocessable_entity }
    end
  end
end