Skip to content

Commit f9e40ca

Browse files
authored
Merge pull request #24641 from opf/feature/meet-185-activity-tab-journalise-and-add-information-about-when-a-work-package-is-added-or-discussed-in-a-meeting
[MEET-185] Activity tab: Journalise and add information about when a work package is added or discussed in a meeting
2 parents 0ae4d09 + 1ada408 commit f9e40ca

41 files changed

Lines changed: 1679 additions & 10 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/components/work_packages/activities_tab/journals/filter_and_sorting_component.html.erb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@
4444
},
4545
active: show_only_comments?
4646
)
47+
if show_hide_meetings_filter?
48+
menu.with_item(
49+
label: t("activities.work_packages.activity_tab.label_activity_hide_meetings"),
50+
href: update_filter_work_package_activities_path(work_package, filter: WorkPackages::ActivitiesTab::Filters::HIDE_MEETINGS),
51+
content_arguments: {
52+
data: {
53+
turbo_stream: true, action: "click->work-packages--activities-tab--index#setFilterToHideMeetings",
54+
test_selector: "op-wp-journals-filter-hide-meetings"
55+
}
56+
},
57+
active: hide_meetings?
58+
)
59+
end
4760
end
4861
end
4962
container.with_column do

app/components/work_packages/activities_tab/journals/filter_and_sorting_component.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ def show_only_comments?
5959
def show_only_changes?
6060
filter == Filters::ONLY_CHANGES
6161
end
62+
63+
def hide_meetings?
64+
filter == Filters::HIDE_MEETINGS
65+
end
66+
67+
# Only offer "hide meetings" to users who would see the work package
68+
# meetings tab (the same condition used for the WP meetings tab)
69+
def show_hide_meetings_filter?
70+
User.current.allowed_in_any_project?(:view_meetings)
71+
end
6272
end
6373
end
6474
end

app/controllers/work_packages/activities_tab_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ def find_journal
236236
@journal = @work_package
237237
.journals
238238
.internal_visible
239+
.without_meeting_causes
239240
.find(params[:id])
240241
rescue ActiveRecord::RecordNotFound
241242
respond_with_error(I18n.t("label_not_found"))

app/controllers/work_packages_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def journals
268268
work_package
269269
.journals
270270
.internal_visible
271+
.without_meeting_causes
271272
.changing
272273
.includes(:user)
273274
.order(order).to_a

app/models/activities/base_activity_provider.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def event_selection_query(user, from, to, options)
142142
query = journals_with_data_query
143143
query = extend_event_query(query)
144144
query = filter_for_visibility(query, user)
145+
query = exclude_meeting_causes(query)
145146
query = filter_for_event_datetime(query, from, to)
146147
query = restrict_user(query, options)
147148
restrict_projects(query, user, options)
@@ -170,6 +171,15 @@ def filter_for_visibility(query, user)
170171
)
171172
end
172173

174+
def exclude_meeting_causes(query)
175+
query.where(cause_type_expression.eq(nil).or(cause_type_expression.not_in(Journal::MEETING_CAUSE_TYPES)))
176+
end
177+
178+
def cause_type_expression
179+
@cause_type_expression ||=
180+
Arel::Nodes::InfixOperation.new("->>", journals_table[:cause], Arel::Nodes.build_quoted("type"))
181+
end
182+
173183
def filter_for_event_datetime(query, from, to)
174184
query = query.where(journals_table[:created_at].gteq(from)) if from
175185
query = query.where(journals_table[:created_at].lteq(to)) if to

app/models/journal.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,20 @@ class Journal < ApplicationRecord
8888
status_name
8989
status_id
9090
status_changes
91+
meeting_id
92+
source_meeting_id
9193
],
9294
prefix: true
93-
VALID_CAUSE_TYPES = %w[
95+
96+
MEETING_CAUSE_TYPES = %w[
97+
meeting_agenda_item_added
98+
meeting_agenda_item_removed
99+
meeting_agenda_item_moved
100+
meeting_agenda_item_discussed
101+
meeting_outcome_recorded
102+
].freeze
103+
104+
VALID_CAUSE_TYPES = (%w[
94105
default_attribute_written
95106
import
96107
progress_mode_changed_to_status_based
@@ -104,7 +115,7 @@ class Journal < ApplicationRecord
104115
work_package_related_changed_times
105116
work_package_duplicate_closed
106117
working_days_changed
107-
].freeze
118+
] + MEETING_CAUSE_TYPES).freeze
108119

109120
# Make sure each journaled model instance only has unique version ids
110121
validates :version, uniqueness: { scope: %i[journable_id journable_type] }
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
class Journal::CausedByMeetingAgendaItemAdded < CauseOfChange::Base
32+
def initialize(meeting)
33+
super("meeting_agenda_item_added", "meeting_id" => meeting.id)
34+
end
35+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
class Journal::CausedByMeetingAgendaItemDiscussed < CauseOfChange::Base
32+
def initialize(meeting)
33+
super("meeting_agenda_item_discussed", "meeting_id" => meeting.id)
34+
end
35+
end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
class Journal::CausedByMeetingAgendaItemMoved < CauseOfChange::Base
32+
def initialize(meeting, source_meeting: nil)
33+
attributes = { "meeting_id" => meeting.id }
34+
attributes["source_meeting_id"] = source_meeting.id if source_meeting
35+
36+
super("meeting_agenda_item_moved", attributes)
37+
end
38+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
class Journal::CausedByMeetingAgendaItemRemoved < CauseOfChange::Base
32+
def initialize(meeting)
33+
super("meeting_agenda_item_removed", "meeting_id" => meeting.id)
34+
end
35+
end

0 commit comments

Comments
 (0)