Skip to content

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

Add destroy methods

Mir Bhatiae3ce73ca217e
diff --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.erb
index 6652f2d8424..a60dfcb8056 100644
--- 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.erb
@@ -10,7 +10,7 @@
unless @hide_notes
grid.with_area(:notes) do
if @state == :edit
- render(MeetingAgendaItems::Outcomes::NewComponent.new(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item, meeting_outcome: @meeting_outcome, hidden: false))
+ render(MeetingAgendaItems::Outcomes::InputComponent.new(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item, meeting_outcome: @meeting_outcome, hidden: false))
elsif @state == :show
render(MeetingAgendaItems::Outcomes::ShowNotesComponent.new(meeting_outcome: @meeting_outcome))
end
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/outcomes/input_component.html.erb
similarity index 100%
rename from modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.html.erb
rename to modules/meeting/app/components/meeting_agenda_items/outcomes/input_component.html.erb
diff --git a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.rb b/modules/meeting/app/components/meeting_agenda_items/outcomes/input_component.rb
similarity index 98%
rename from modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.rb
rename to modules/meeting/app/components/meeting_agenda_items/outcomes/input_component.rb
index 392b3e81565..7e07794999c 100644
--- a/modules/meeting/app/components/meeting_agenda_items/outcomes/new_component.rb
+++ b/modules/meeting/app/components/meeting_agenda_items/outcomes/input_component.rb
@@ -27,7 +27,7 @@
#++
module MeetingAgendaItems::Outcomes
- class NewComponent < ApplicationComponent
+ class InputComponent < ApplicationComponent
include ApplicationHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
diff --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.rb
index a8c266de56a..5dba3613efc 100644
--- 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.rb
@@ -69,7 +69,7 @@ module MeetingAgendaItems
def delete_action_item(menu)
menu.with_item(label: t("label_agenda_outcome_delete"),
scheme: :danger,
- href: "",
+ href: meeting_outcome_path(@meeting, @meeting_outcome),
form_arguments: {
method: :delete, data: { confirm: t("text_are_you_sure"), "turbo-stream": true }
}) do |item|
diff --git a/modules/meeting/app/contracts/meeting_outcomes/delete_contract.rb b/modules/meeting/app/contracts/meeting_outcomes/delete_contract.rb
new file mode 100644
index 00000000000..99f4a1202fb
--- /dev/null
+++ b/modules/meeting/app/contracts/meeting_outcomes/delete_contract.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 DeleteContract < ::DeleteContract
+ include ModifiableItem
+
+ delete_permission -> {
+ user.allowed_in_project?(:create_meeting_minutes, model.meeting_agenda_item.project)
+ }
+ end
+end
diff --git a/modules/meeting/app/controllers/meeting_outcomes_controller.rb b/modules/meeting/app/controllers/meeting_outcomes_controller.rb
index ee081910b5f..00770beb64a 100644
--- a/modules/meeting/app/controllers/meeting_outcomes_controller.rb
+++ b/modules/meeting/app/controllers/meeting_outcomes_controller.rb
@@ -34,7 +34,7 @@ class MeetingOutcomesController < ApplicationController
include Meetings::AgendaComponentStreams
before_action :set_meeting
- before_action :set_meeting_agenda_item, except: %i[edit cancel_edit update]
+ before_action :set_meeting_agenda_item, except: %i[edit cancel_edit update destroy]
before_action :set_meeting_outcome, except: %i[new cancel_new create]
before_action :authorize_global, only: %i[new create]
before_action :authorize, except: %i[new create]
@@ -120,6 +120,20 @@ class MeetingOutcomesController < ApplicationController
respond_with_turbo_streams
end
+ def destroy
+ @meeting_agenda_item = @meeting_outcome.meeting_agenda_item
+ call = ::MeetingOutcomes::DeleteService
+ .new(user: current_user, model: @meeting_outcome)
+ .call
+
+ if call.success?
+ render_base_outcome_component_via_turbo_stream(meeting: @meeting, meeting_agenda_item: @meeting_agenda_item, hide_notes: true)
+ # else
+ end
+
+ respond_with_turbo_streams
+ end
+
private
def set_meeting
diff --git a/modules/meeting/app/services/meeting_outcomes/delete_service.rb b/modules/meeting/app/services/meeting_outcomes/delete_service.rb
new file mode 100644
index 00000000000..a1e840d2674
--- /dev/null
+++ b/modules/meeting/app/services/meeting_outcomes/delete_service.rb
@@ -0,0 +1,32 @@
+#-- 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 DeleteService < ::BaseServices::Delete
+ end
+end