meeting views
This commit is contained in:
@@ -8,7 +8,10 @@ class DocumentsController < ApplicationController
|
||||
end
|
||||
def new
|
||||
@document=Document.new
|
||||
@document.parent=params[:parent_typ].constantize.find(params[:parent_id])
|
||||
@parent=params[:parent_type].constantize.find(params[:parent_id])
|
||||
|
||||
@document.parent=@parent
|
||||
|
||||
@document.typ = 1
|
||||
respond_to do |format|
|
||||
format.js
|
||||
@@ -16,6 +19,7 @@ class DocumentsController < ApplicationController
|
||||
end
|
||||
def edit
|
||||
@document = Document.find(params[:id])
|
||||
@parent=@document.parent
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
@@ -24,7 +28,7 @@ class DocumentsController < ApplicationController
|
||||
|
||||
def create
|
||||
@document = Document.new(params[:document])
|
||||
|
||||
@parent=@document.parent
|
||||
respond_to do |format|
|
||||
if @document.save
|
||||
# format.html { redirect_to @document, notice: 'Document was successfully created.' }
|
||||
@@ -38,9 +42,9 @@ class DocumentsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
def update
|
||||
@document = Document.find(params[:id])
|
||||
|
||||
@parent=@document.parent
|
||||
respond_to do |format|
|
||||
if @document.update_attributes(params[:document])
|
||||
format.html { redirect_to @document, notice: 'Document was successfully updated.' }
|
||||
@@ -56,6 +60,7 @@ def update
|
||||
def destroy
|
||||
logger.info("-------------delete------------------")
|
||||
@document = Document.find(params[:id])
|
||||
@parent=@document.parent
|
||||
@document_id = params[:id]
|
||||
|
||||
@document.destroy
|
||||
|
||||
@@ -10,8 +10,10 @@ class MeetingsController < ApplicationController
|
||||
end
|
||||
def new
|
||||
@meeting=Meeting.new
|
||||
@meeting.parent=params[:parent_typ].constantize.find(params[:parent_id])
|
||||
@meeting.typ = 1
|
||||
@meeting.parent=params[:parent_type].constantize.find(params[:parent_id])
|
||||
@parent=@meeting.parent
|
||||
@meeting.calentry=Calentry.new
|
||||
# @meeting.typ = 1
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
@@ -35,7 +37,8 @@ class MeetingsController < ApplicationController
|
||||
end
|
||||
def edit
|
||||
@meeting = Meeting.find(params[:id])
|
||||
respond_to do |format|
|
||||
@parent=@meeting.parent
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
||||
@@ -43,6 +46,8 @@ class MeetingsController < ApplicationController
|
||||
|
||||
def create
|
||||
@meeting = Meeting.new(params[:meeting])
|
||||
@parent=@meeting.parent
|
||||
#@meeting.assign_attributes(params[:meeting])
|
||||
|
||||
respond_to do |format|
|
||||
if @meeting.save
|
||||
@@ -58,25 +63,25 @@ class MeetingsController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
@meeting = Meeting.find(params[:id])
|
||||
|
||||
@meeting = Meeting.find(params[:id])
|
||||
@parent=@meeting.parent
|
||||
respond_to do |format|
|
||||
if @meeting.update_attributes(params[:meeting])
|
||||
if @meeting.update_attributes(params[:meeting])
|
||||
format.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
format.js
|
||||
else
|
||||
# format.html { render action: "edit" }
|
||||
# format.html
|
||||
# format.json { render json: @meeting.errors, status: :unprocessable_entity }
|
||||
format.js { render action: "edit"}
|
||||
format.js { render action: "edit" }
|
||||
end
|
||||
end
|
||||
end
|
||||
def destroy
|
||||
logger.info("-------------delete------------------")
|
||||
@meeting = Meeting.find(params[:id])
|
||||
@parent=@meeting.parent
|
||||
@meeting_id = params[:id]
|
||||
@object=@meeting.object
|
||||
@meeting.destroy
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
class Document < ActiveRecord::Base
|
||||
attr_accessible :etherpadkey, :name, :parent, :text, :typ
|
||||
attr_accessible :etherpadkey, :name, :parent, :text, :typ, :parent_id, :parent_type
|
||||
belongs_to :parent, :polymorphic => true
|
||||
validate :name, :length=>{minimum:3}
|
||||
validate :text, :presence=>true
|
||||
validate :typ, :presence=>true
|
||||
validate :parent, :presence=>true
|
||||
|
||||
def self.new_divid_for(parent)
|
||||
"document_new_parent_" + parent.class.to_s + "_" + parent.id.to_s
|
||||
end
|
||||
def divid
|
||||
"document_"+self.id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
class Meeting < ActiveRecord::Base
|
||||
belongs_to :parent, :polymorphic=>true
|
||||
belongs_to :meetingtyp
|
||||
attr_accessible :desc, :intern, :name
|
||||
attr_accessible :desc, :intern, :name, :parent_id, :parent_type, :calentry,:calentry_attributes
|
||||
|
||||
|
||||
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
|
||||
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
|
||||
validate :agenda, :presence=>true
|
||||
validate :protocol, :presence=>true
|
||||
has_one :calentry, :as=>:object
|
||||
has_one :calentry, as: :object
|
||||
accepts_nested_attributes_for :calentry
|
||||
# validate :agenda, :presence=>true
|
||||
# validate :protocol, :presence=>true
|
||||
validate :parent, :presence=>true
|
||||
validate :calentry, :presence=>true
|
||||
before_validation :fix_calentry
|
||||
def fix_calentry
|
||||
self.calentry.object=self unless self.calentry.nil?
|
||||
end
|
||||
def public?
|
||||
! (self.intern)
|
||||
end
|
||||
@@ -29,4 +38,12 @@ class Meeting < ActiveRecord::Base
|
||||
self.agenda=d
|
||||
end
|
||||
end
|
||||
def self.new_divid_for(parent)
|
||||
"meeting_new_parent_" + parent.class.to_s + "_" + parent.id.to_s
|
||||
end
|
||||
def divid
|
||||
"meeting_"+self.id.to_s
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span1"></div><div class="span1">
|
||||
<%= fa_icon("calendar 2x") %>
|
||||
|
||||
<div class="span1"></div>
|
||||
<div class="span1">
|
||||
<%= fa_icon("calendar 2x") %>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<%= f.input :start, :as => :datetimepicker %></div><div class="span4">
|
||||
<%= f.input :dauer , :as => :string, :append=>"h" %></div><div class="span1">
|
||||
<% f.input :typ %>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<%= f.check_box :_destroy %>
|
||||
<%= I18n.t 'common.delete' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<%= f.input :start, :as => :datetimepicker %></div><div class="span4">
|
||||
<%= f.input :dauer , :as => :string, :append=>"h" %></div><div class="span1">
|
||||
<% f.input :typ %></div> <div class="span1"><%= f.check_box :_destroy %> <%= I18n.t 'common.delete' %></div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<div class="contentbox" id="document_<%= document.id%>">
|
||||
<% image_tag("/iconnavy/time.png") %>
|
||||
<%= fa_icon("file-text 2x") %>
|
||||
|
||||
<%= document.name %>
|
||||
<%= fa_icon("file-text") %>
|
||||
<%= link_to document.name, document %>
|
||||
<%= link_to "edit", edit_document_path(document),:remote=>true if can? :edit, document %>
|
||||
<%= link_to 'Delete', document, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, document %>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<%= semantic_form_for @document, :remote=>true, :html=>{:class=>""} do |f| %>
|
||||
|
||||
<%= f.input :name %>
|
||||
<%= f.input :parent_id, :as=>:hidden %>
|
||||
<%= f.input :parent_type, :as=>:hidden %>
|
||||
<%= f.action :submit, :as => :input_ %>
|
||||
|
||||
<% end %>
|
||||
|
||||
1
app/views/documents/create.js.erb
Normal file
1
app/views/documents/create.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#<%= Document.new_divid_for(@parent) %>").replaceWith("<div id=\"<%= Document.new_divid_for(@parent)%>\"></div><%=escape_javascript( render :partial=>"document", :object=>@document)%>");
|
||||
6
app/views/documents/edit.html.erb
Executable file
6
app/views/documents/edit.html.erb
Executable file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing Dokument</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @document %> |
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
$("#document_<%= @document.id %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@document)%>");
|
||||
$("#<%= @document.divid %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@document)%>");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
$("#document_new").replaceWith("<div id=\"document_new\"><%=escape_javascript( render :partial=>"nested_form" ,:object=>@document) %></div>");
|
||||
$("#<%= Document.new_divid_for(@parent) %>").replaceWith("<div id=\"<%= Document.new_divid_for(@parent) %>\"><%=escape_javascript( render :partial=>"nested_form" ,:object=>@document) %></div>");
|
||||
|
||||
|
||||
8
app/views/documents/show.html.erb
Normal file
8
app/views/documents/show.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<h2><%= @document.name %></h2>
|
||||
<%= raw(@document.text) %>
|
||||
<%= semantic_form_for @document, :html=>{:class=>""} do |f| %>
|
||||
<%= f.input :text, :as=>:tinymce_text %>
|
||||
<%= f.action :submit, :as => :input_ %>
|
||||
|
||||
<% end %>
|
||||
<%= tinymce %>
|
||||
@@ -1,8 +1,11 @@
|
||||
<div class="contentbox" id="meeting_<%= meeting.id%>">
|
||||
<h3>Meeting: <%= meeting.name %></h3>
|
||||
<%= render meeting.calentry %>
|
||||
<%= link_to "Agenda" , create_agenda_meeting_path(meeting), :remote=>true %>
|
||||
<%= link_to "Protokoll" , create_protocol_meeting_path(meeting),:remote=>true %>
|
||||
<%= link_to "edit", edit_meeting_path(meeting), remote: true %>
|
||||
<%= link_to 'Delete', meeting, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, meeting %>
|
||||
<%= render meeting.calentry unless meeting.calentry.nil? %>
|
||||
<%= link_to "Agenda" , create_agenda_meeting_path(meeting), :remote=>true if meeting.agenda.nil? %>
|
||||
<%= link_to "Protokoll" , create_protocol_meeting_path(meeting),:remote=>true if meeting.protocol.nil? %>
|
||||
<%= render meeting.agenda unless meeting.agenda.nil? %>
|
||||
<%= render meeting.protocol unless meeting.protocol.nil? %>
|
||||
</div>
|
||||
|
||||
|
||||
21
app/views/meetings/_nested_form.html.erb
Normal file
21
app/views/meetings/_nested_form.html.erb
Normal file
@@ -0,0 +1,21 @@
|
||||
<%= fa_icon("calendar 2x") %>
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= semantic_form_for @meeting, :remote=>true, :html=>{:class=>""} do |f| %>
|
||||
|
||||
<%= f.input :name %>
|
||||
<%= f.semantic_fields_for :calentry, @meeting.calentry do |ff| %>
|
||||
<%= ff.input :start, :as => :datetimepicker %>
|
||||
<%= ff.input :dauer , :as => :string, :append=>"h" %>
|
||||
<%= ff.input :typ %>
|
||||
<% ff.input :object_id %>
|
||||
<% ff.input :object_type %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<%= f.input :parent_id, :as=>:hidden %>
|
||||
<%= f.input :parent_type, :as=>:hidden %>
|
||||
<%= f.action :submit, :as => :input_ %>
|
||||
|
||||
<% end %>
|
||||
<%= @meeting.calentry.to_yaml %>
|
||||
1
app/views/meetings/create.js.erb
Normal file
1
app/views/meetings/create.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#<%= Meeting.new_divid_for(@parent) %>").replaceWith("<div id=\"<%= Meeting.new_divid_for(@parent)%>\"></div><%=escape_javascript( render :partial=>"meeting", :object=>@meeting)%>");
|
||||
1
app/views/meetings/destroy.js.erb
Normal file
1
app/views/meetings/destroy.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#meeting_<%= @meeting_id %>").remove();
|
||||
5
app/views/meetings/edit.js.erb
Normal file
5
app/views/meetings/edit.js.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
$("#<%= @meeting.divid %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting)%>");
|
||||
|
||||
|
||||
|
||||
|
||||
3
app/views/meetings/new.js.erb
Normal file
3
app/views/meetings/new.js.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
$("#<%= Meeting.new_divid_for(@parent) %>").replaceWith("<div id=\"<%= Meeting.new_divid_for(@parent) %>\"><%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting) %></div>");
|
||||
|
||||
|
||||
1
app/views/meetings/update.js.erb
Normal file
1
app/views/meetings/update.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
$("#meeting_<%= @meeting.id %>").replaceWith("<%=escape_javascript( render :partial=>"meeting", :object=>@meeting)%>");
|
||||
@@ -22,6 +22,9 @@
|
||||
<% end %>
|
||||
<% unless small.meetings.empty? %>
|
||||
<b>Treffen/Sitzungen</b>
|
||||
<%= link_to "Neues Meeting", new_meeting_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
|
||||
<div id="<%= Meeting.new_divid_for(small) %>"></div>
|
||||
|
||||
<% small.meetings.each do |m| %>
|
||||
<%= render m %>
|
||||
|
||||
@@ -31,6 +34,8 @@
|
||||
|
||||
<% unless small.documents.empty? %>
|
||||
<b>Dokumente</b>
|
||||
<%= link_to "Neues Dokument", new_document_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
|
||||
<div id="<%= Document.new_divid_for(small) %>"></div>
|
||||
<% small.documents.each do |d| %>
|
||||
<%= render d %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user