OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add outcome components and new/create methods
Mir Bhatia82987747291a
diff --git a/modules/meeting/app/components/meeting_agenda_items/form_component.sass b/modules/meeting/app/components/meeting_agenda_items/form_component.sassindex 0e1a9d4b59a..02aab89d971 100644--- a/modules/meeting/app/components/meeting_agenda_items/form_component.sass+++ b/modules/meeting/app/components/meeting_agenda_items/form_component.sass@@ -5,8 +5,9 @@grid-template-columns: minmax(0, 100%) 100px minmax(200px, 1fr)grid-template-areas: "title duration presenter" "notes notes notes" "add_note actions actions"grid-gap: 8px- // Do not remove easily. The hidden labels of the form inputs are positioned absolutely,- // and thus breaking the whole layout if there is no container around them+ // Do not remove easily!+ // The hidden labels of the form inputs are positioned absolutely,+ // and thus break the whole layout if there is no container around themposition: relative&--actionsdiff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erbindex e8329f22cc7..712336161ff 100644--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb@@ -90,7 +90,7 @@grid.with_area(:outcomes, tag: :div) doflex_layout do |flex|flex.with_row do- render(MeetingAgendaItems::Outcomes::NewButtonComponent.new(meeting: @meeting))+ render(MeetingAgendaItems::Outcomes::BaseComponent.new(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item))endendenddiff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/base_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/base_component.html.erbnew file mode 100644index 00000000000..256ed9538e1--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/base_component.html.erb@@ -0,0 +1,19 @@+<%=+ component_wrapper do+ grid_layout("op-meeting-outcome", tag: :div, id: "outcome-#{@meeting_agenda_item.id}") do |grid|+ grid.with_area(:button) do+ render(MeetingAgendaItems::Outcomes::NewButtonComponent.new(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item))+ end if @hide_notes++ unless @hide_notes+ grid.with_area(:notes) do+ if @state == :edit+ render(MeetingAgendaItems::Outcomes::NewComponent.new(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item, hidden: false))+ elsif @state == :show+ render(MeetingAgendaItems::Outcomes::ShowNotesComponent.new(meeting_outcome: @meeting_outcome))+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/base_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/base_component.rbnew file mode 100644index 00000000000..2a195bb7647--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/base_component.rb@@ -0,0 +1,62 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingAgendaItems+ class Outcomes::BaseComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:, meeting_agenda_item:, meeting_outcome: nil, state: :edit, hide_notes: true)+ super++ @meeting = meeting+ @meeting_agenda_item = meeting_agenda_item+ @meeting_outcome = meeting_outcome+ @state = state+ @hide_notes = hide_notes++ override+ # binding.pry+ end++ def wrapper_uniq_by+ @meeting_agenda_item.id+ end++ private++ def override+ if @meeting_agenda_item&.outcomes&.information_kind&.first&.notes.present?+ @meeting_outcome = @meeting_agenda_item&.outcomes&.information_kind&.first+ @state = :show+ @hide_notes = false+ end+ end+ end+enddiff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erbnew file mode 100644index 00000000000..5e1e69e9e94--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.html.erb@@ -0,0 +1,39 @@+<%=+ component_wrapper(data: wrapper_data_attributes) do+ primer_form_with(+ model: @meeting_outcome,+ method: @method,+ url: @submit_path+ ) do |f|+ grid_layout("op-meeting-outcome-form", tag: :div) do |grid|+ grid.with_area(+ :notes,+ display: display_notes_input_value,+ data: { "meeting-agenda-item-form-target": "notesInput" }+ ) do+ render(MeetingAgendaItem::Outcome::Notes.new(f))+ end++ grid.with_area(:actions) do+ flex_layout do |flex|+ flex.with_column(mr: 2) do+ render(+ Primer::Beta::Button.new(+ scheme: :secondary,+ tag: :a,+ href: @cancel_path,+ data: { "turbo-stream": true }+ )+ ) do |_c|+ t("button_cancel")+ end+ end+ flex.with_column do+ render(MeetingAgendaItem::Outcome::Submit.new(f))+ end+ end+ end+ end+ end+ end+%>diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rbnew file mode 100644index 00000000000..a0e5d139886--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.rb@@ -0,0 +1,90 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingAgendaItems::Outcomes+ class FormComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:, meeting_agenda_item:, meeting_outcome:, method:, submit_path:, cancel_path:,+ display_notes_input: nil)+ super+ # binding.pry+ @meeting = meeting+ @meeting_agenda_item = meeting_agenda_item+ @meeting_outcome = meeting_outcome+ @method = method+ @submit_path = submit_path+ @cancel_path = cancel_path+ @display_notes_input = display_notes_input+ end++ def wrapper_uniq_by+ @meeting_outcome.id+ end++ def render?+ # User.current.allowed_in_project?(:manage_agendas, @meeting.project)+ true+ end++ private++ def wrapper_data_attributes+ # {+ # controller: "meeting-agenda-item-form",+ # "application-target": "dynamic",+ # "meeting-agenda-item-form-cancel-url-value": @cancel_path+ # }+ nil+ end++ def display_notes_input_value+ :block+ # if @display_notes_input+ # :block+ # elsif @meeting_agenda_item.notes.blank?+ # :none+ # else+ # :block+ # end+ end++ def display_notes_add_button_value+ :block+ # if @display_notes_input+ # :none+ # elsif @meeting_agenda_item.notes.blank?+ # :block+ # else+ # :none+ # end+ end+ end+enddiff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.sass b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.sassnew file mode 100644index 00000000000..dcc9f21735e--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/form_component.sass@@ -0,0 +1,18 @@+@import 'helpers'++.op-meeting-outcome-form+ display: grid+ grid-template-columns: minmax(0, 100%) 100px minmax(200px, 1fr)+ grid-template-areas: "title . ." "notes notes notes" ". actions actions"+ grid-gap: 8px+ // Do not remove easily!+ // The hidden labels of the form inputs are positioned absolutely,+ // and thus break the whole layout if there is no container around them+ position: relative++ &--actions+ justify-self: end++ @media screen and (max-width: $breakpoint-md)+ grid-template-columns: 100px minmax(0, 100%)+ grid-template-areas: "title title" "duration presenter" "notes notes" "add_note actions"diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.html.erbindex 2d864c3e88a..3cf8b04d153 100644--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.html.erb@@ -9,7 +9,7 @@label: t("outcome.add_button"),tag: :a,content_arguments: {- # href: new_outcome_meeting_agenda_item_path(@meeting, type: "simple", meeting_section_id: @meeting_section&.id),+ href: new_meeting_outcome_path(@meeting, meeting_agenda_item_id: @meeting_agenda_item&.id),data: { "turbo-stream": true }})diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.rbindex 46eb069acb7..80883097e2d 100644--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_button_component.rb@@ -36,7 +36,7 @@ module MeetingAgendaItems::Outcomesdef initialize(meeting:, meeting_agenda_item: nil, disabled: false)super-+ # binding.pry@meeting = meeting@meeting_agenda_item = meeting_agenda_item@disabled = @meeting.closed? || disableddiff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.html.erbnew file mode 100644index 00000000000..30fb17002a6--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.html.erb@@ -0,0 +1,16 @@+<%=+ component_wrapper do+ unless @hidden+ render(+ MeetingAgendaItems::Outcomes::FormComponent.new(+ meeting: @meeting,+ meeting_agenda_item: @meeting_agenda_item,+ meeting_outcome: @meeting_outcome,+ method: :post,+ submit_path: meeting_outcomes_path(@meeting, meeting_agenda_item_id: @meeting_agenda_item&.id, format: :turbo_stream),+ cancel_path: cancel_new_meeting_outcomes_path(@meeting, meeting_agenda_item_id: @meeting_agenda_item&.id)+ )+ )+ end+ end+%>diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.rbnew file mode 100644index 00000000000..fab3a63f556--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.rb@@ -0,0 +1,58 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingAgendaItems::Outcomes+ class NewComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:, meeting_agenda_item:, meeting_outcome: nil, hidden: true)+ super+ @meeting = meeting+ @meeting_agenda_item = meeting_agenda_item+ @meeting_outcome = meeting_outcome || build_meeting_outcome+ @hidden = hidden++ # binding.pry+ end++ private++ def wrapper_uniq_by+ @meeting_agenda_item&.id+ end++ def build_meeting_outcome+ MeetingOutcome.new(+ meeting_agenda_item: @meeting_agenda_item,+ kind: 0+ )+ end+ end+enddiff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rbnew file mode 100644index 00000000000..d866185a5d1--- /dev/null+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/show_notes_component.rb@@ -0,0 +1,56 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingAgendaItems+ class Outcomes::ShowNotesComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers++ def initialize(meeting_outcome:)+ super++ @meeting_outcome = meeting_outcome+ end++ def call+ render(Primer::Box.new(m: 3)) do+ component_collection do |collection|+ collection.with_component(Primer::Beta::Heading.new(tag: :h5)) do+ "Outcome"+ end++ collection.with_component(Primer::Box.new(classes: "op-uc-container", mt: 1)) do+ format_text(@meeting_outcome, :notes)+ end+ end+ end+ end+ end+enddiff --git a/modules/meeting/app/contracts/meeting_outcomes/base_contract.rb b/modules/meeting/app/contracts/meeting_outcomes/base_contract.rbnew file mode 100644index 00000000000..46bd4f98a50--- /dev/null+++ b/modules/meeting/app/contracts/meeting_outcomes/base_contract.rb@@ -0,0 +1,43 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingOutcomes+ class BaseContract < ::ModelContract+ include ModifiableItem++ def self.model+ MeetingOutcome+ end++ attribute :work_package+ attribute :meeting_agenda_item++ attribute :notes+ attribute :kind+ end+enddiff --git a/modules/meeting/app/contracts/meeting_outcomes/create_contract.rb b/modules/meeting/app/contracts/meeting_outcomes/create_contract.rbnew file mode 100644index 00000000000..f198db6bdad--- /dev/null+++ b/modules/meeting/app/contracts/meeting_outcomes/create_contract.rb@@ -0,0 +1,79 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingOutcomes+ class CreateContract < BaseContract++ validate :user_allowed_to_add, :validate_meeting_existence++ # def self.assignable_meetings(user)+ # StructuredMeeting+ # .open+ # .not_templated+ # .not_cancelled+ # .visible(user)+ # end++ ##+ # Meeting agenda items can currently be only created+ # through the project permission :manage_agendas+ # When MeetingRole becomes available, agenda items will+ # be created through meeting permissions :manage_agendas+ def user_allowed_to_add+ binding.pry+ # when creating a meeting agenda item from the work package tab and not selecting a meeting+ # the meeting and therefore the project is not set+ # in this case we only want to show the "Meeting can't be blank" error instead of a misleading permission base error+ # the error is added by the models presence validation+ return unless visible?++ unless user.allowed_in_project?(:create_meeting_minutes, model.meeting_agenda_item.project)+ errors.add :base, :error_unauthorized+ end+ end++ ##+ # A stale browser window might provide an already deleted meeting as an option when creating an agenda item from the+ # work package tab. This would lead to an 500 server error when trying to save the agenda item.+ def validate_meeting_existence+ # when creating a meeting agenda item from the work package tab and not selecting a meeting+ # the meeting and therefore the project is not set+ # in this case we only want to show the "Meeting can't be blank" error instead of a misleading not existance error+ # the error is added by the models presence validation+ return if model.meeting_agenda_item.meeting.nil?++ errors.add :base, :does_not_exist unless visible?+ end++ private++ def visible?+ @visible ||= model.meeting_agenda_item.meeting&.visible?(user)+ end+ end+enddiff --git a/modules/meeting/app/contracts/meeting_outcomes/modifiable_item.rb b/modules/meeting/app/contracts/meeting_outcomes/modifiable_item.rbnew file mode 100644index 00000000000..5c4964425c4--- /dev/null+++ b/modules/meeting/app/contracts/meeting_outcomes/modifiable_item.rb@@ -0,0 +1,45 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingOutcomes+ module ModifiableItem+ extend ActiveSupport::Concern++ # included do+ # validate :validate_modifiable+ # end+ #+ # protected+ #+ # def validate_modifiable+ # unless model.modifiable?+ # errors.add :base, I18n.t(:text_agenda_item_not_editable_anymore)+ # end+ # end+ end+enddiff --git a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rbindex 489d4db2e4e..421fc9c5167 100644--- a/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb+++ b/modules/meeting/app/controllers/concerns/meetings/agenda_component_streams.rb@@ -1,4 +1,5 @@# frozen_string_literal: true+#-- copyright# OpenProject is an open source project management software.# Copyright (C) the OpenProject GmbH@@ -173,6 +174,49 @@ module Meetingsendend+ def render_outcome_form_via_turbo_stream(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item)+ # binding.pry+ render_base_outcome_component_via_turbo_stream(meeting:, meeting_agenda_item:, hide_notes: false, meeting_outcome: nil,+ state: :edit)++ # update_new_outcome_button_via_turbo_stream(disabled: true)+ end++ def render_base_outcome_component_via_turbo_stream(meeting_outcome:, state:, hide_notes:, meeting: @meeting,+ meeting_agenda_item: @meeting_agenda_item)+ # binding.pry+ update_via_turbo_stream(+ component: MeetingAgendaItems::Outcomes::BaseComponent.new(+ hide_notes:,+ meeting:,+ meeting_agenda_item:,+ meeting_outcome:,+ state:+ )+ )+ end++ # def update_new_outcome_component_via_turbo_stream(hidden: false, meeting_agenda_item: @meeting_agenda_item, meeting: @meeting)+ # update_via_turbo_stream(+ # component: MeetingAgendaItems::Outcomes::BaseComponent.new(+ # hide_notes:+ # meeting:,+ # meeting_agenda_item:+ # )+ # )+ # end++ def update_new_outcome_button_via_turbo_stream(disabled: false, meeting: @meeting,+ meeting_agenda_item: @meeting_agenda_item)+ update_via_turbo_stream(+ component: MeetingAgendaItems::Outcomes::NewButtonComponent.new(+ disabled:,+ meeting:,+ meeting_agenda_item:+ )+ )+ end+def update_list_via_turbo_stream(meeting: @meeting, form_hidden: true, form_type: :simple)# replace needs to be called in order to mount the drag and drop handlers again# update would not do that and drag and drop would stop working after the first updatediff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rbindex 6a9547f4dd0..ca2fa51cb43 100644--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb@@ -80,6 +80,7 @@ class MeetingAgendaItemsController < ApplicationController@meeting_agenda_item = call.result+ binding.pryif call.success?reset_meeting_from_agenda_item# enable continue editingdiff --git a/modules/meeting/app/controllers/meeting_outcomes_controller.rb b/modules/meeting/app/controllers/meeting_outcomes_controller.rbnew file mode 100644index 00000000000..3726893f553--- /dev/null+++ b/modules/meeting/app/controllers/meeting_outcomes_controller.rb@@ -0,0 +1,210 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++class MeetingOutcomesController < ApplicationController+ # include AttachableServiceCall+ include OpTurbo::ComponentStream+ include Meetings::AgendaComponentStreams++ before_action :set_meeting+ before_action :set_meeting_agenda_item+ before_action :authorize_global, only: %i[new create]+ before_action :authorize, except: %i[new create]++ def new+ # binding.pry+ if @meeting.open?+ render_outcome_form_via_turbo_stream(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item)+ else+ update_all_via_turbo_stream+ render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))+ end++ respond_with_turbo_streams+ end++ def cancel_new+ render_base_outcome_component_via_turbo_stream(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item, hide_notes: true)+ # update_new_button_via_turbo_stream(disabled: false)++ respond_with_turbo_streams+ end++ def create # rubocop:disable Metrics/AbcSize+ call = ::MeetingOutcomes::CreateService+ .new(user: current_user)+ .call(+ meeting_agenda_item: @meeting_agenda_item,+ notes: params[:meeting_outcome][:outcome]+ )++ @meeting_outcome = call.result+ # binding.pry+ if call.success?+ render_base_outcome_component_via_turbo_stream(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item, meeting_outcome: @meeting_outcome, hide_notes: false, state: :show)+ else+ # show errors+ update_new_component_via_turbo_stream(+ hidden: false, meeting_agenda_item: @meeting_agenda_item, type: @agenda_item_type+ )+ render_base_error_in_flash_message_via_turbo_stream(call.errors)+ end++ respond_with_turbo_streams+ end++ def edit+ if @meeting_agenda_item.editable?+ update_item_via_turbo_stream(state: :edit, display_notes_input: params[:display_notes_input])+ else+ update_all_via_turbo_stream+ render_error_flash_message_via_turbo_stream(message: t("text_meeting_not_editable_anymore"))+ end++ respond_with_turbo_streams+ end++ def cancel_edit+ update_item_via_turbo_stream(state: :show)++ respond_with_turbo_streams+ end++ def update+ call = ::MeetingAgendaItems::UpdateService+ .new(user: current_user, model: @meeting_agenda_item)+ .call(meeting_agenda_item_params)++ if call.success?+ reset_meeting_from_agenda_item+ update_item_via_turbo_stream+ update_section_header_via_turbo_stream(meeting_section: @meeting_agenda_item.meeting_section)+ update_header_component_via_turbo_stream+ update_sidebar_details_component_via_turbo_stream+ else+ # show errors+ update_item_via_turbo_stream(state: :edit)+ render_base_error_in_flash_message_via_turbo_stream(call.errors)+ end++ respond_with_turbo_streams+ end++ def destroy+ section = @meeting_agenda_item.meeting_section++ call = ::MeetingAgendaItems::DeleteService+ .new(user: current_user, model: @meeting_agenda_item)+ .call++ if call.success?+ reset_meeting_from_agenda_item+ remove_item_via_turbo_stream(clear_slate: @meeting.agenda_items.empty?)+ update_header_component_via_turbo_stream+ update_section_header_via_turbo_stream(meeting_section: section) if section&.reload.present?+ update_sidebar_details_component_via_turbo_stream+ else+ generic_call_failure_response(call)+ end++ respond_with_turbo_streams+ end++ def drop+ call = ::MeetingAgendaItems::DropService.new(+ user: current_user, meeting_agenda_item: @meeting_agenda_item+ ).call(+ target_id: params[:target_id],+ position: params[:position]+ )++ if call.success?+ if call.result[:section_changed]+ move_item_to_other_section_via_turbo_stream(+ old_section: call.result[:old_section],+ current_section: call.result[:current_section]+ )+ else+ move_item_within_section_via_turbo_stream+ end+ else+ generic_call_failure_response(call)+ end++ respond_with_turbo_streams+ end++ def move+ call = ::MeetingAgendaItems::UpdateService+ .new(user: current_user, model: @meeting_agenda_item)+ .call(move_to: params[:move_to]&.to_sym)++ if call.success?+ move_item_within_section_via_turbo_stream+ else+ generic_call_failure_response(call)+ end++ respond_with_turbo_streams+ end++ private++ def set_meeting+ # binding.pry+ @meeting = Meeting.find(params[:meeting_id])+ @project = @meeting.project # required for authorization via before_action+ end++ # In case we updated the meeting as part of the service flow+ # it needs to be reassigned for the controller in order to get correct timestamps+ def reset_meeting_from_agenda_item+ @meeting = @meeting_agenda_item.meeting+ end++ def set_agenda_item_type+ @agenda_item_type = params[:type]&.to_sym+ end++ def set_meeting_agenda_item+ # binding.pry+ @meeting_agenda_item = MeetingAgendaItem.find(params[:meeting_agenda_item_id])+ end++ def set_agenda_item_outcome+ #TODO+ end++ def generic_call_failure_response(call)+ # A failure might imply that the meeting was already closed and the action was triggered from a stale browser window+ # updating all components resolves the stale state of that window+ update_all_via_turbo_stream+ # show additional base error message+ render_base_error_in_flash_message_via_turbo_stream(call.errors)+ end+enddiff --git a/modules/meeting/app/forms/meeting_agenda_item/notes.rb b/modules/meeting/app/forms/meeting_agenda_item/notes.rbindex 3114a81659f..a5c5f76dbbf 100644--- a/modules/meeting/app/forms/meeting_agenda_item/notes.rb+++ b/modules/meeting/app/forms/meeting_agenda_item/notes.rb@@ -37,7 +37,7 @@ class MeetingAgendaItem::Notes < ApplicationFormdisabled: @disabled,classes: "ck-editor-primer-adjusted",rich_text_options: {- resource:,+ # resource:,showAttachments: false})diff --git a/modules/meeting/app/forms/meeting_agenda_item/outcome/notes.rb b/modules/meeting/app/forms/meeting_agenda_item/outcome/notes.rbnew file mode 100644index 00000000000..de32d28210e--- /dev/null+++ b/modules/meeting/app/forms/meeting_agenda_item/outcome/notes.rb@@ -0,0 +1,57 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++class MeetingAgendaItem::Outcome::Notes < ApplicationForm+ delegate :object, to: :@builder++ form do |outcome_form|+ outcome_form.rich_text_area(+ name: :outcome,+ label: "Outcome",+ disabled: @disabled,+ classes: "ck-editor-primer-adjusted",+ rich_text_options: {+ resource:,+ editor_type: "constrained",+ showAttachments: false+ }+ )+ end++ def initialize(disabled: false)+ @disabled = disabled+ # binding.pry+ end++ def resource+ return unless object&.meeting_agenda_item++ API::V3::Meetings::MeetingRepresenter+ .new(object.meeting_agenda_item.meeting, current_user: User.current, embed_links: false)+ end+enddiff --git a/modules/meeting/app/forms/meeting_agenda_item/outcome/submit.rb b/modules/meeting/app/forms/meeting_agenda_item/outcome/submit.rbnew file mode 100644index 00000000000..ca157962ab4--- /dev/null+++ b/modules/meeting/app/forms/meeting_agenda_item/outcome/submit.rb@@ -0,0 +1,41 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++class MeetingAgendaItem::Outcome::Submit < ApplicationForm+ form do |outcome_form|+ outcome_form.group(layout: :horizontal) do |button_group|+ # button_group.hidden(name: :lock_version)+ # button_group.hidden(name: :type, value: @type, scope_name_to_model: false)+ button_group.submit(name: :submit_button, label: I18n.t("button_save"), scheme: :primary)+ end+ end++ # def initialize(type: :simple)+ # @type = type+ # end+enddiff --git a/modules/meeting/app/models/meeting_outcome.rb b/modules/meeting/app/models/meeting_outcome.rbindex 05119640237..f284043a366 100644--- a/modules/meeting/app/models/meeting_outcome.rb+++ b/modules/meeting/app/models/meeting_outcome.rb@@ -35,7 +35,7 @@ class MeetingOutcome < ApplicationRecordinformation: 0,decision: 1,work_package: 2- }.freeze, suffix: true, default: "information"+ }.freeze, _suffix: true, _default: "information"validates_presence_of :meeting_agenda_itemvalidates_presence_of :notes, if: -> { information_kind? }diff --git a/modules/meeting/app/services/meeting_outcomes/create_service.rb b/modules/meeting/app/services/meeting_outcomes/create_service.rbnew file mode 100644index 00000000000..1673ea7976d--- /dev/null+++ b/modules/meeting/app/services/meeting_outcomes/create_service.rb@@ -0,0 +1,42 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingOutcomes+ class CreateService < ::BaseServices::Create+ # include AfterPerformHook+ #+ # alias_method :original_after_perform, :after_perform+ #+ # def after_perform(call)+ # # The reload is required because, the time slot calculations are changing the+ # # `start_time`, `end_time` attributes and they should be available for rendering.+ # call.result.reload+ # original_after_perform(call)+ # end+ end+enddiff --git a/modules/meeting/app/services/meeting_outcomes/set_attributes_service.rb b/modules/meeting/app/services/meeting_outcomes/set_attributes_service.rbnew file mode 100644index 00000000000..3be23f9883f--- /dev/null+++ b/modules/meeting/app/services/meeting_outcomes/set_attributes_service.rb@@ -0,0 +1,37 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# 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 COPYRIGHT and LICENSE files for more details.+#++++module MeetingOutcomes+ class SetAttributesService < ::BaseServices::SetAttributes+ # def set_default_attributes(_params)+ # model.change_by_system do+ # model.author = user+ # end+ # end+ end+enddiff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rbindex f277ef1fc9a..dbb6b42ad8f 100644--- a/modules/meeting/config/routes.rb+++ b/modules/meeting/config/routes.rb@@ -118,6 +118,17 @@ Rails.application.routes.draw doput :moveendend+ resources :outcomes, controller: "meeting_outcomes" do+ collection do+ get :new, action: :new, as: :new+ get :cancel_new+ end+ member do+ # get :cancel_edit+ # put :drop+ # put :move+ end+ endresource :agenda, controller: "meeting_agendas", only: [:update] domember dodiff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rbindex ae136fed098..8fe457f6496 100644--- a/modules/meeting/lib/open_project/meeting/engine.rb+++ b/modules/meeting/lib/open_project/meeting/engine.rb@@ -112,7 +112,10 @@ module OpenProject::Meetingpermissible_on: :project,require: :memberpermission :create_meeting_minutes,- { meeting_minutes: %i[update preview] },+ {+ meeting_minutes: %i[update preview],+ meeting_outcomes: %i[new cancel_new create edit cancel_edit update destroy drop move] #TODO+ },permissible_on: :project,require: :memberpermission :send_meeting_minutes_notification,