meeting views

This commit is contained in:
Andreas Stephanides
2014-12-04 00:00:57 +01:00
parent b259c1080a
commit ab396c002e
20 changed files with 129 additions and 37 deletions

View File

@@ -8,7 +8,10 @@ class DocumentsController < ApplicationController
end end
def new def new
@document=Document.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 @document.typ = 1
respond_to do |format| respond_to do |format|
format.js format.js
@@ -16,6 +19,7 @@ class DocumentsController < ApplicationController
end end
def edit def edit
@document = Document.find(params[:id]) @document = Document.find(params[:id])
@parent=@document.parent
respond_to do |format| respond_to do |format|
format.js format.js
end end
@@ -24,7 +28,7 @@ class DocumentsController < ApplicationController
def create def create
@document = Document.new(params[:document]) @document = Document.new(params[:document])
@parent=@document.parent
respond_to do |format| respond_to do |format|
if @document.save if @document.save
# format.html { redirect_to @document, notice: 'Document was successfully created.' } # format.html { redirect_to @document, notice: 'Document was successfully created.' }
@@ -38,9 +42,9 @@ class DocumentsController < ApplicationController
end end
end end
def update def update
@document = Document.find(params[:id]) @document = Document.find(params[:id])
@parent=@document.parent
respond_to do |format| respond_to do |format|
if @document.update_attributes(params[:document]) if @document.update_attributes(params[:document])
format.html { redirect_to @document, notice: 'Document was successfully updated.' } format.html { redirect_to @document, notice: 'Document was successfully updated.' }
@@ -56,6 +60,7 @@ def update
def destroy def destroy
logger.info("-------------delete------------------") logger.info("-------------delete------------------")
@document = Document.find(params[:id]) @document = Document.find(params[:id])
@parent=@document.parent
@document_id = params[:id] @document_id = params[:id]
@document.destroy @document.destroy

View File

@@ -10,8 +10,10 @@ class MeetingsController < ApplicationController
end end
def new def new
@meeting=Meeting.new @meeting=Meeting.new
@meeting.parent=params[:parent_typ].constantize.find(params[:parent_id]) @meeting.parent=params[:parent_type].constantize.find(params[:parent_id])
@meeting.typ = 1 @parent=@meeting.parent
@meeting.calentry=Calentry.new
# @meeting.typ = 1
respond_to do |format| respond_to do |format|
format.js format.js
end end
@@ -35,7 +37,8 @@ class MeetingsController < ApplicationController
end end
def edit def edit
@meeting = Meeting.find(params[:id]) @meeting = Meeting.find(params[:id])
respond_to do |format| @parent=@meeting.parent
respond_to do |format|
format.js format.js
end end
@@ -43,6 +46,8 @@ class MeetingsController < ApplicationController
def create def create
@meeting = Meeting.new(params[:meeting]) @meeting = Meeting.new(params[:meeting])
@parent=@meeting.parent
#@meeting.assign_attributes(params[:meeting])
respond_to do |format| respond_to do |format|
if @meeting.save if @meeting.save
@@ -58,25 +63,25 @@ class MeetingsController < ApplicationController
end end
def update def update
@meeting = Meeting.find(params[:id]) @meeting = Meeting.find(params[:id])
@parent=@meeting.parent
respond_to do |format| 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.html { redirect_to @meeting, notice: 'Meeting was successfully updated.' }
format.json { head :no_content } format.json { head :no_content }
format.js format.js
else else
# format.html { render action: "edit" } # format.html
# format.json { render json: @meeting.errors, status: :unprocessable_entity } # format.json { render json: @meeting.errors, status: :unprocessable_entity }
format.js { render action: "edit"} format.js { render action: "edit" }
end end
end end
end end
def destroy def destroy
logger.info("-------------delete------------------") logger.info("-------------delete------------------")
@meeting = Meeting.find(params[:id]) @meeting = Meeting.find(params[:id])
@parent=@meeting.parent
@meeting_id = params[:id] @meeting_id = params[:id]
@object=@meeting.object
@meeting.destroy @meeting.destroy
respond_to do |format| respond_to do |format|

View File

@@ -1,9 +1,14 @@
class Document < ActiveRecord::Base 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 belongs_to :parent, :polymorphic => true
validate :name, :length=>{minimum:3} validate :name, :length=>{minimum:3}
validate :text, :presence=>true validate :text, :presence=>true
validate :typ, :presence=>true validate :typ, :presence=>true
validate :parent, :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 end

View File

@@ -1,12 +1,21 @@
class Meeting < ActiveRecord::Base class Meeting < ActiveRecord::Base
belongs_to :parent, :polymorphic=>true belongs_to :parent, :polymorphic=>true
belongs_to :meetingtyp 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 :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document' has_one :agenda , :as=>:parent,:conditions=>{:typ=>11}, :class_name=>'Document'
validate :agenda, :presence=>true has_one :calentry, as: :object
validate :protocol, :presence=>true accepts_nested_attributes_for :calentry
has_one :calentry, :as=>:object # 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? def public?
! (self.intern) ! (self.intern)
end end
@@ -29,4 +38,12 @@ class Meeting < ActiveRecord::Base
self.agenda=d self.agenda=d
end end
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 end

View File

@@ -1,10 +1,15 @@
<div class="row-fluid"> <div class="row-fluid">
<div class="span1"></div><div class="span1"> <div class="span1"></div>
<%= fa_icon("calendar 2x") %> <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>
<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>

View File

@@ -1,8 +1,7 @@
<div class="contentbox" id="document_<%= document.id%>"> <div class="contentbox" id="document_<%= document.id%>">
<% image_tag("/iconnavy/time.png") %> <% image_tag("/iconnavy/time.png") %>
<%= fa_icon("file-text 2x") %> <%= fa_icon("file-text") %>
<%= link_to document.name, document %>
<%= document.name %>
<%= link_to "edit", edit_document_path(document),:remote=>true if can? :edit, 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 %> <%= link_to 'Delete', document, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, document %>
</div> </div>

View File

@@ -4,6 +4,8 @@
<%= semantic_form_for @document, :remote=>true, :html=>{:class=>""} do |f| %> <%= semantic_form_for @document, :remote=>true, :html=>{:class=>""} do |f| %>
<%= f.input :name %> <%= f.input :name %>
<%= f.input :parent_id, :as=>:hidden %>
<%= f.input :parent_type, :as=>:hidden %>
<%= f.action :submit, :as => :input_ %> <%= f.action :submit, :as => :input_ %>
<% end %> <% end %>

View 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)%>");

View File

@@ -0,0 +1,6 @@
<h1>Editing Dokument</h1>
<%= render 'form' %>
<%= link_to 'Show', @document %> |

View File

@@ -1,5 +1,4 @@
$("#<%= @document.divid %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@document)%>");
$("#document_<%= @document.id %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@document)%>");

View File

@@ -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>");

View 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 %>

View File

@@ -1,8 +1,11 @@
<div class="contentbox" id="meeting_<%= meeting.id%>"> <div class="contentbox" id="meeting_<%= meeting.id%>">
<h3>Meeting: <%= meeting.name %></h3> <h3>Meeting: <%= meeting.name %></h3>
<%= render meeting.calentry %> <%= link_to "edit", edit_meeting_path(meeting), remote: true %>
<%= link_to "Agenda" , create_agenda_meeting_path(meeting), :remote=>true %> <%= link_to 'Delete', meeting, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, meeting %>
<%= link_to "Protokoll" , create_protocol_meeting_path(meeting),:remote=>true %> <%= 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.agenda unless meeting.agenda.nil? %>
<%= render meeting.protocol unless meeting.protocol.nil? %> <%= render meeting.protocol unless meeting.protocol.nil? %>
</div> </div>

View 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 %>

View 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)%>");

View File

@@ -0,0 +1 @@
$("#meeting_<%= @meeting_id %>").remove();

View File

@@ -0,0 +1,5 @@
$("#<%= @meeting.divid %>").html("<%=escape_javascript( render :partial=>"nested_form" ,:object=>@meeting)%>");

View 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>");

View File

@@ -0,0 +1 @@
$("#meeting_<%= @meeting.id %>").replaceWith("<%=escape_javascript( render :partial=>"meeting", :object=>@meeting)%>");

View File

@@ -22,6 +22,9 @@
<% end %> <% end %>
<% unless small.meetings.empty? %> <% unless small.meetings.empty? %>
<b>Treffen/Sitzungen</b> <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| %> <% small.meetings.each do |m| %>
<%= render m %> <%= render m %>
@@ -31,6 +34,8 @@
<% unless small.documents.empty? %> <% unless small.documents.empty? %>
<b>Dokumente</b> <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| %> <% small.documents.each do |d| %>
<%= render d %> <%= render d %>