kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
4.3 KiB
140 lines
4.3 KiB
11 years ago
|
#-- encoding: UTF-8
|
||
|
#-- copyright
|
||
11 years ago
|
# OpenProject Meeting Plugin
|
||
|
#
|
||
|
# Copyright (C) 2011-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.md for more details.
|
||
|
#++
|
||
|
|
||
11 years ago
|
class Activity::MeetingActivityProvider < Activity::BaseActivityProvider
|
||
11 years ago
|
acts_as_activity_provider type: 'meetings',
|
||
10 years ago
|
activities: [:meeting, :meeting_content],
|
||
11 years ago
|
permission: :view_meetings
|
||
|
|
||
11 years ago
|
def extend_event_query(query, activity)
|
||
|
case activity
|
||
|
when :meeting_content
|
||
|
query.join(meetings_table).on(activity_journals_table(activity)[:meeting_id].eq(meetings_table[:id]))
|
||
10 years ago
|
join_cond = journal_table[:journable_type].eq('MeetingContent')
|
||
11 years ago
|
query.join(meeting_contents_table).on(journal_table[:journable_id].eq(meeting_contents_table[:id]).and(join_cond))
|
||
11 years ago
|
end
|
||
|
end
|
||
|
|
||
11 years ago
|
def event_query_projection(activity)
|
||
|
case activity
|
||
|
when :meeting
|
||
11 years ago
|
[
|
||
11 years ago
|
activity_journal_projection_statement(:title, 'meeting_title', activity),
|
||
|
activity_journal_projection_statement(:start_time, 'meeting_start_time', activity),
|
||
|
activity_journal_projection_statement(:duration, 'meeting_duration', activity),
|
||
|
activity_journal_projection_statement(:project_id, 'project_id', activity)
|
||
11 years ago
|
]
|
||
|
else
|
||
|
[
|
||
11 years ago
|
projection_statement(meeting_contents_table, :type, 'meeting_content_type'),
|
||
|
projection_statement(meetings_table, :id, 'meeting_id'),
|
||
|
projection_statement(meetings_table, :title, 'meeting_title'),
|
||
6 years ago
|
projection_statement(meetings_table, :project_id, 'project_id')
|
||
11 years ago
|
]
|
||
|
end
|
||
|
end
|
||
|
|
||
11 years ago
|
def activitied_type(activity)
|
||
|
(activity == :meeting) ? Meeting : MeetingContent
|
||
|
end
|
||
|
|
||
11 years ago
|
def projects_reference_table(activity)
|
||
|
case activity
|
||
|
when :meeting
|
||
|
activity_journals_table(activity)
|
||
11 years ago
|
else
|
||
11 years ago
|
meetings_table
|
||
11 years ago
|
end
|
||
|
end
|
||
|
|
||
11 years ago
|
def activity_journals_table(activity)
|
||
|
case activity
|
||
|
when :meeting
|
||
8 years ago
|
@activity_journals_table = JournalManager.journal_class(Meeting).arel_table
|
||
11 years ago
|
else
|
||
8 years ago
|
@activity_journals_table = JournalManager.journal_class(MeetingContent).arel_table
|
||
11 years ago
|
end
|
||
11 years ago
|
end
|
||
|
|
||
11 years ago
|
protected
|
||
|
|
||
11 years ago
|
def event_name(event, activity)
|
||
|
case event['event_description']
|
||
|
when 'Agenda closed'
|
||
|
I18n.t('meeting_agenda_closed', scope: 'events')
|
||
|
when 'Agenda opened'
|
||
|
I18n.t('meeting_agenda_opened', scope: 'events')
|
||
|
when 'Minutes created'
|
||
|
I18n.t('meeting_minutes_created', scope: 'events')
|
||
|
else
|
||
|
super
|
||
|
end
|
||
|
end
|
||
|
|
||
11 years ago
|
def event_title(event, activity)
|
||
|
case activity
|
||
|
when :meeting
|
||
|
start_time = event['meeting_start_time'].is_a?(String) ? DateTime.parse(event['meeting_start_time'])
|
||
|
: event['meeting_start_time']
|
||
|
end_time = start_time + event['meeting_duration'].to_f.hours
|
||
11 years ago
|
|
||
11 years ago
|
"#{l :label_meeting}: #{event['meeting_title']} (#{format_date start_time} #{format_time start_time, false}-#{format_time end_time, false})"
|
||
11 years ago
|
else
|
||
|
"#{event['meeting_content_type'].constantize.model_name.human}: #{event['meeting_title']}"
|
||
|
end
|
||
11 years ago
|
end
|
||
|
|
||
11 years ago
|
def event_type(event, activity)
|
||
|
case activity
|
||
|
when :meeting
|
||
|
'meeting'
|
||
|
else
|
||
|
(event['meeting_content_type'].include?('Agenda')) ? 'meeting-agenda' : 'meeting-minutes'
|
||
|
end
|
||
|
end
|
||
|
|
||
11 years ago
|
def event_path(event, activity)
|
||
|
id = activity_id(event, activity)
|
||
|
|
||
11 years ago
|
url_helpers.meeting_path(id)
|
||
11 years ago
|
end
|
||
|
|
||
11 years ago
|
def event_url(event, activity)
|
||
|
id = activity_id(event, activity)
|
||
|
|
||
11 years ago
|
url_helpers.meeting_url(id)
|
||
11 years ago
|
end
|
||
|
|
||
11 years ago
|
private
|
||
|
|
||
|
def meetings_table
|
||
8 years ago
|
@meetings_table ||= Meeting.arel_table
|
||
11 years ago
|
end
|
||
|
|
||
|
def meeting_contents_table
|
||
8 years ago
|
@meeting_contents_table ||= MeetingContent.arel_table
|
||
11 years ago
|
end
|
||
|
|
||
|
def activity_id(event, activity)
|
||
|
(activity == :meeting) ? event['journable_id'] : event['meeting_id']
|
||
11 years ago
|
end
|
||
|
end
|