Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please combined #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/controllers/meetings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def create_meeting
@meeting = Meeting.new(:project => @project, :start_date => DateTime.now, :end_date => DateTime.now + 3600, :author => User.current, :web => false)
@meeting.subject = params[:meeting][:subject]
@meeting.description = params[:meeting][:description]
@meeting.agenda = params[:meeting][:agenda]
@meeting.highlights = params[:meeting][:highlights]
@meeting.action = params[:meeting][:action]
@meeting.location = params[:meeting][:location]
@meeting.web = (params[:meeting][:web] == 'on')
tdate = Date.parse(params[:meeting][:start_date_date])
Expand All @@ -104,6 +107,12 @@ def create_meeting
@meeting.watcher_user_ids = params[:watchers]
@meeting.notify_participants = (params[:meeting][:notify_participants] == 'on')
if @meeting.save
if params[:contacts]
params[:contacts].each do |contact|
@meeting.meeting_contacts.create(easy_contact: @meeting.project.easy_contacts.find(contact))
end
end

attachments = Attachment.attach_files(@meeting, params[:attachments])
render_attachment_warning_if_needed(@meeting)
@meeting.deliver()
Expand All @@ -120,6 +129,9 @@ def edit_meeting
def update_meeting
@meeting.subject = params[:meeting][:subject]
@meeting.description = params[:meeting][:description]
@meeting.agenda = params[:meeting][:agenda]
@meeting.highlights = params[:meeting][:highlights]
@meeting.action = params[:meeting][:action]
@meeting.location = params[:meeting][:location]
@meeting.web = (params[:meeting][:web] == 'on')
tdate = Date.parse(params[:meeting][:start_date_date])
Expand All @@ -129,6 +141,16 @@ def update_meeting
@meeting.watcher_user_ids = params[:watchers]
@meeting.notify_participants = (params[:meeting][:notify_participants] == 'on')
if @meeting.save
# Clean meeting contacts
# Just rebuild the contacts list after the clean up
@meeting.meeting_contacts.delete_all

if params[:contacts]
params[:contacts].each do |contact|
@meeting.meeting_contacts.create(easy_contact: @meeting.project.easy_contacts.find(contact))
end
end

attachments = Attachment.attach_files(@meeting, params[:attachments])
render_attachment_warning_if_needed(@meeting)
@meeting.deliver()
Expand Down
13 changes: 13 additions & 0 deletions app/helpers/meetings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,19 @@ def meeting_style_time (meeting, day, min, max, ind)
"top: #{top}px; height: #{height}px; z-order: #{top}; position: absolute; left: #{ind * 10}px;"
end

def options_for_meeting_contacts
project_list = @project.easy_contacts.reject do |c|
@meeting.easy_contacts.include?(c)
end

project_list_options = project_list.empty? ? nil : options_from_collection_for_select(project_list, 'id', 'name')

{
project_contacts: project_list_options,
meeting_contacts: options_from_collection_for_select(@meeting.easy_contacts, 'id', 'name')
}
end

private

def each_xml_element(node, name)
Expand Down
38 changes: 36 additions & 2 deletions app/models/meeting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ class Meeting < ActiveRecord::Base
belongs_to :project
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'

has_many :meeting_contacts, dependent: :destroy
has_many :easy_contacts, through: :meeting_contacts

validates_presence_of :start_date, :end_date, :subject
validates_length_of :subject, :maximum => 255
validates_length_of :location, :maximum => 255
Expand Down Expand Up @@ -79,19 +82,32 @@ def deliver()
watcher_users.each do |w|
recipients[w.language] = update_recipients(recipients, w.language, w.mail)
end

easy_contacts.each do |c|
contact = get_contact_email_and_language(c)

recipients[contact[:language]] = update_recipients(recipients, contact[:language], contact[:email])
end
end

recipients.each do |language,rec|
MeetingMailer.send_meeting(self, rec, language).deliver
end
return true
end

def deliver_cancel()
recipients = { author.language => [ author.mail ] }
if notify_participants
watcher_users.each do |w|
recipients[w.language] = update_recipients(recipients, w.language, w.mail)
end

easy_contacts.each do |c|
contact = get_contact_email_and_language(c)

recipients[contact[:language]] = update_recipients(recipients, contact[:language], contact[:email])
end
end
recipients.each do |language,rec|
MeetingMailer.cancel_meeting(self, rec, language).deliver
Expand All @@ -114,7 +130,14 @@ def validate
if !valide
errors.add(:end_date_date, :greater_than_start_date)
end

end

def watched_by?(object)
if object.is_a?(EasyContact)
easy_contact_ids.include?(object.id)
else
super
end
end

private
Expand All @@ -125,4 +148,15 @@ def update_recipients (list, lang, mail)
mails << mail
end

def get_contact_email_and_language(object)
contact = {}

email_custom_field = object.custom_values.find{ |cv| cv.custom_field.name =~ /(E|e)(\-|)(M|m)ail/ }
contact[:email] = email_custom_field.value

language_custom_field = object.custom_values.find{ |cv| cv.custom_field.name =~ /(L|l)anguage/ }
contact[:language] = language_custom_field.nil? ? 'en' : language_custom_field.value

contact
end
end
6 changes: 6 additions & 0 deletions app/models/meeting_contact.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class MeetingContact < ActiveRecord::Base
unloadable

belongs_to :meeting
belongs_to :easy_contact
end
35 changes: 34 additions & 1 deletion app/views/meetings/_form_meeting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@
<p><%= f.text_field :location, :size => 80 %><br/><%= check_box_tag 'meeting[web]', 'on', @meeting.web %><%= l(:field_meeting_web) %></p>
<p><%= f.text_field :start_date_date, :required => true, :size => 10, :onchange => "sync_date('meeting_start_date_date','meeting_end_date_date')" %><%= calendar_for('meeting_start_date_date') %>&nbsp;&nbsp;-&nbsp;&nbsp;<%= select_time @meeting_tz.utc_to_local(@meeting.start_date_time), {:prefix => 'start_time', :minute_step => 5, :time_separator => ':' }, { :onchange => "sync_time(this,'start_time','end_time')" } %>&nbsp;&nbsp;&nbsp;<%= l(:field_time_zone) %>: <%= User.current.time_zone ? User.current.time_zone : ActiveSupport::TimeZone[Setting.plugin_redmine_meetings['meeting_timezone']] %></p>
<p><%= f.text_field :end_date_date, :required => true, :size => 10 %><%= calendar_for('meeting_end_date_date') %>&nbsp;&nbsp;-&nbsp;&nbsp;<%= select_time @meeting_tz.utc_to_local(@meeting.end_date_time), :prefix => 'end_time', :minute_step => 5, :time_separator => ':' %></p>
<p><%= link_to l('easy_pages.modules.issues_create_new'), new_project_issue_path(@project) %></p>

<p><%= f.text_area :description, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
<% if @meeting.id %>
<p><%= submit_tag l(:button_save) %> <strong>NOTE: This will submit the form</strong> </p>
<% else %>
<p><%= submit_tag l(:button_create) %> <strong>NOTE: This will submit the form</strong> </p>
<% end %>

<p>
<%= f.text_area :description, :cols => 60, :rows => 10, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'meeting_description' %>
</p>
<p><%= f.text_area :agenda, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
<% unless @meeting.new_record? %>
<p><%= f.text_area :highlights, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
<p><%= f.text_area :action, :cols => 60, :rows => 10, :class => 'wiki-edit' %></p>
<% end %>
<p id="attachments_form"><%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %></p>
</div>

Expand All @@ -21,6 +34,26 @@
<label class="floating"><%= check_box_tag 'watchers[]', user.id, @meeting.watched_by?(user) %> <%=h user %></label>
<% end -%>
<% end -%>

<hr />

<label>Contacts</label>

<table id="meeting-form-contacts-table">
<tr>
<td class="select-box">
<%= select_tag 'project_contacts_list', options_for_meeting_contacts[:project_contacts], { multiple: true, size: 10 } %>
</td>
<td class="buttons">
<%= button_tag '→', type: 'button', onclick: "moveOptions($(this.form).find('#project_contacts_list')[0], $(this.form).find('#selected_meeting_contacts')[0]);" %>
<%= button_tag '←', type: 'button', onclick: "moveOptions($(this.form).find('#selected_meeting_contacts')[0], $(this.form).find('#project_contacts_list')[0]);" %>
</td>
<td class="select-box">
<%= select_tag 'contacts[]', options_for_meeting_contacts[:meeting_contacts], { multiple: true, size: 10, id: 'selected_meeting_contacts' } %>
</td>
</tr>
</table>

</p>
</div>

Expand Down
1 change: 1 addition & 0 deletions app/views/meetings/edit_meeting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<div id="preview" class="wiki"></div>

<% content_for :header_tags do %>
<%= javascript_include_tag 'pmgov_customs.js', :plugin => "redmine_meetings" %>
<%= stylesheet_link_tag 'redmine_meetings.css', :plugin => "redmine_meetings" %>
<%= javascript_include_tag 'redmine_meetings.js', :plugin => "redmine_meetings" %>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions app/views/meetings/new_meeting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<div id="preview" class="wiki"></div>

<% content_for :header_tags do %>
<%= javascript_include_tag 'pmgov_customs.js', :plugin => "redmine_meetings" %>
<%= stylesheet_link_tag 'redmine_meetings.css', :plugin => "redmine_meetings" %>
<%= javascript_include_tag 'redmine_meetings.js', :plugin => "redmine_meetings" %>
<% end %>
Expand Down
16 changes: 16 additions & 0 deletions app/views/meetings/show_meeting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,29 @@
<div class="wiki">
<%= textilizable @meeting, :description, :attachments => @meeting.attachments %>
</div>
<p><strong><%=l(:field_agenda)%></strong></p>
<div class="wiki">
<%= textilizable @meeting, :agenda %>
</div>
<p><strong><%=l(:field_highlights)%></strong></p>
<div class="wiki">
<%= textilizable @meeting, :highlights %>
</div>
<p><strong><%=l(:field_action)%></strong></p>
<div class="wiki">
<%= textilizable @meeting, :action %>
</div>

<fieldset class="collapsible" style="padding: 0pt;">
<legend onclick="toggleFieldset(this);"><%= l(:field_doodle_users) %></legend>
<div id="list_doodle_users" style="margin: 0.5em 0pt; overflow: visible;">
<% @meeting.watcher_users.collect.sort.each do |user| %>
<br/>&nbsp;&nbsp;&nbsp;<%=h user %>
<% end %>

<% @meeting.easy_contacts.collect.sort.each do |contact| %>
<br/>&nbsp;&nbsp;&nbsp;<%=h contact %>
<% end %>
</div></fieldset>

<% if @meeting.attachments.any? -%>
Expand Down
7 changes: 7 additions & 0 deletions assets/javascripts/pmgov_customs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$(document).ready(function() {
$('#meeting-form').submit(function(e) {
$(this).find('#selected_meeting_contacts option').each(function(i, v){
$(v).attr('selected', true);
});
});
});
17 changes: 9 additions & 8 deletions assets/javascripts/redmine_meetings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function SetAllCheckBoxes(CheckValue) {
objCheckBoxes[i].checked = CheckValue;
}


function sync_date(from, to) {
document.getElementById(to).value = document.getElementById(from).value;
}
Expand All @@ -29,18 +30,18 @@ function sync_time(obj, from, to) {
}

function setAutoPreview(url, form, field) {
new Field.Observer(field,2, function(){
new Ajax.Updater('preview', url, {
asynchronous:true,
evalScripts:true,
method:'post',
parameters:Form.serialize(form)
});
new Field.Observer(field,2, function(){
new Ajax.Updater('preview', url, {
asynchronous:true,
evalScripts:true,
method:'post',
parameters:Form.serialize(form)
});
});
}

function start_meeting(url) {
var wihe = "width="+screen.availWidth+",height="+screen.availHeight;
open(url, "Meeting","directories=no,location=no,resizable=yes,scrollbars=yes,status=no,toolbar=no," + wihe);
return false;
}
}
26 changes: 25 additions & 1 deletion assets/stylesheets/redmine_meetings.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,28 @@ div.meeting { background-color: #F7A95A; display:block; border: 1px solid black;
div.webmeeting { background-color: #A7FAA0; display:block; border: 1px solid black; }

div.meeting.day.tooltip { background-color: #F7A95A; display:block; width: 49%; border: 1px solid black; }
div.webmeeting.day.tooltip { background-color: #A7FAA0; display:block; width: 49%; border: 1px solid black; }
div.webmeeting.day.tooltip { background-color: #A7FAA0; display:block; width: 49%; border: 1px solid black; }

select#start_time_hour, select#start_time_minute, select#end_time_hour, select#end_time_minute{ width: 4%; }

table#meeting-form-contacts-table {
width: 35%;
}

table#meeting-form-contacts-table td {
text-align: center;
vertical-align: middle;
}

table#meeting-form-contacts-table td.select-box {
width: 45%;
}


table#meeting-form-contacts-table td.select-box select {
width: 100%;
}

table#meeting-form-contacts-table td.buttons {
width: 10%;
}
5 changes: 4 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ en:
field_end_date_date: End
field_location: Location
field_meeting_web: Use the conference room dedicated to the project
field_agenda: Agenda
field_highlights: Highlights
field_action: Action

label_doodle_plural: "Doodles"
label_title_doodle: "Doodle"
Expand Down Expand Up @@ -77,4 +80,4 @@ en:
cancel_meeting_email1: "The following meeting has been cancelled/deleted"
cancel_meeting_email2: "This meeting can be removed from your calendar using the attached file, meeting.ics (instructions depend from the software you are using)."

download_ics: "ICS (ICalendar)"
download_ics: "ICS (ICalendar)"
11 changes: 11 additions & 0 deletions db/migrate/004_additional_fields.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class AdditionalFields < ActiveRecord::Migration
def up
add_column :meetings, :agenda, :text
add_column :meetings, :highlights, :text
end

def down
remove_column :meetings, :agenda
remove_column :meetings, :highlights
end
end
10 changes: 10 additions & 0 deletions db/migrate/005_create_meeting_contacts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateMeetingContacts < ActiveRecord::Migration
def change
create_table :meeting_contacts do |t|
t.references :meeting
t.references :easy_contact
end
add_index :meeting_contacts, :meeting_id
add_index :meeting_contacts, :easy_contact_id
end
end
9 changes: 9 additions & 0 deletions db/migrate/006_add_action_field.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddActionField < ActiveRecord::Migration
def up
add_column :meetings, :action, :text
end

def down
remove_column :meetings, :action
end
end
9 changes: 9 additions & 0 deletions test/unit/meeting_contact_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path('../../test_helper', __FILE__)

class MeetingContactTest < ActiveSupport::TestCase

# Replace this with your real tests.
def test_truth
assert true
end
end
9 changes: 9 additions & 0 deletions test/unit/meeting_contacts_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require File.expand_path('../../test_helper', __FILE__)

class MeetingContactsTest < ActiveSupport::TestCase

# Replace this with your real tests.
def test_truth
assert true
end
end