meeting ix

This commit is contained in:
Andreas Stephanides
2014-12-12 15:24:20 +01:00
parent e411a98b4e
commit a9ef5c14ba
4 changed files with 18 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
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, :parent_id, :parent_type, :calentry,:calentry_attributes attr_accessible :desc, :intern, :name, :parent_id, :parent_type, :calentry,:calentry_attributes, :meetingtyp_id
has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent has_one :protocol, :class_name=>'Document', :conditions=>{:typ=>10}, :as=>:parent
@@ -13,6 +13,16 @@ class Meeting < ActiveRecord::Base
validate :parent, :presence=>true validate :parent, :presence=>true
validate :calentry, :presence=>true validate :calentry, :presence=>true
before_validation :fix_calentry before_validation :fix_calentry
def text
unless self.meetingtyp.try(:name).to_s.empty?
t = self.meetingtyp.name.to_s+", "
else
t = parent.title", " if self.name.empty?
end
t= t+ self.name
t = t + " " + I18n.l(self .calentry.start)
t
end
def fix_calentry def fix_calentry
self.calentry.object=self unless self.calentry.nil? self.calentry.object=self unless self.calentry.nil?
end end

View File

@@ -1,5 +1,5 @@
<div class="contentbox" id="meeting_<%= meeting.id%>"> <div class="contentbox" id="meeting_<%= meeting.id%>">
<h3>Meeting: <%= meeting.name %></h3> <b><%= meeting.text %></b>
<%= link_to "edit", edit_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 %> <%= link_to 'Delete', meeting, method: :delete, data: { confirm: 'Are you sure?' } , remote: true if can? :delete, meeting %>
<%= render meeting.calentry unless meeting.calentry.nil? %> <%= render meeting.calentry unless meeting.calentry.nil? %>

View File

@@ -4,6 +4,8 @@
<%= semantic_form_for @meeting, :remote=>true, :html=>{:class=>""} do |f| %> <%= semantic_form_for @meeting, :remote=>true, :html=>{:class=>""} do |f| %>
<%= f.input :name %> <%= f.input :name %>
<%= f.input :meetingtyp %>
<%= f.semantic_fields_for :calentry, @meeting.calentry do |ff| %> <%= f.semantic_fields_for :calentry, @meeting.calentry do |ff| %>
<%= ff.input :start, :as => :datetimepicker %> <%= ff.input :start, :as => :datetimepicker %>
<%= ff.input :dauer , :as => :string, :append=>"h" %> <%= ff.input :dauer , :as => :string, :append=>"h" %>

View File

@@ -20,16 +20,17 @@
<%= raw(frage.text) %> <%= raw(frage.text) %>
</p> </p>
<% end %> <% end %>
<% if can?(:edit,small) || !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 %> <%= link_to "Neues Meeting", new_meeting_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
<div id="<%= Meeting.new_divid_for(small) %>"></div> <div id="<%= Meeting.new_divid_for(small) %>"></div>
<% unless small.meetings.empty? %> <% unless small.meetings.empty? %>
<% small.meetings.each do |m| %> <% small.meetings.each do |m| %>
<%= render m %> <%= render m %>
<% end%> <% end%>
<% end%> <% end%>
<% end %>
<% if can?(:edit,small)|| ! 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 %> <%= link_to "Neues Dokument", new_document_path(:parent_id=>small.id, :parent_type=>"Thema"), :remote=>true %>
<div id="<%= Document.new_divid_for(small) %>"></div> <div id="<%= Document.new_divid_for(small) %>"></div>
@@ -40,7 +41,7 @@
<% end%> <% end%>
<% end%> <% end%>
<% end %>
<% unless small.hideattachment %> <% unless small.hideattachment %>
<%= render partial: "themen/attachment_list", object: small.attachments, locals:{editor: false} unless small.attachments.empty? %> <%= render partial: "themen/attachment_list", object: small.attachments, locals:{editor: false} unless small.attachments.empty? %>
<% end %> <% end %>