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
extract save into create form
ulfertsda5c46c2fc0a
diff --git a/app/components/projects/index_page_header_component.html.erb b/app/components/projects/index_page_header_component.html.erbindex 3b3c9538862..ca34e8eaa3c 100644--- a/app/components/projects/index_page_header_component.html.erb+++ b/app/components/projects/index_page_header_component.html.erb@@ -85,50 +85,11 @@%><% end %><% else %>- <% header.with_title(font_size: :small, mt: 2, mb: 2, data: { 'test-selector': 'project-query-name'}) do %>- <%= primer_form_with(url: projects_queries_path, id: 'project-save-form') do %>- <%= hidden_field_tag :filters, params[:filters] %>-- <%= render(- Primer::Alpha::TextField.new(- visually_hide_label: true,- autofocus: true,- required: true,- name: 'name',- label: Queries::Projects::ProjectQuery.human_attribute_name(:name),- placeholder: t(:'projects.lists.new.placeholder')))- %>- <% end %>-- <% header.with_actions do %>- <%= render(- Primer::Beta::Button.new(- type: :submit,- scheme: :primary,- size: :medium,- form: 'project-save-form',- aria: { label: I18n.t(:button_save) },- mr: BUTTON_MARGIN_RIGHT,- ml: 1- )- ) do- I18n.t(:button_save)- end- %>-- <%= render(- Primer::Beta::Button.new(- tag: :a,- href: projects_path(filters: params[:filters]),- size: :medium,- aria: { label: I18n.t(:button_cancel) }- )- ) do- I18n.t(:button_cancel)- end- %>- <% end %>- <% end %>+ <% header.with_title(mt: 2, mb: 2, data: { 'test-selector': 'project-query-name'}) do+ primer_form_with(url: projects_queries_path, id: 'project-save-form') do |f|+ render(Queries::Projects::Create.new(f, params:))+ end+ end %><% end %><% end %>diff --git a/app/forms/queries/projects/create.rb b/app/forms/queries/projects/create.rbnew file mode 100644index 00000000000..6a01b1f9b15--- /dev/null+++ b/app/forms/queries/projects/create.rb@@ -0,0 +1,73 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-2024 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 Queries::Projects::Create < ApplicationForm+ include OpenProject::StaticRouting::UrlHelpers++ attr_accessor :params++ def initialize(params:, **options)+ super(**options)++ self.params = params+ end++ form do |query_form|+ query_form.group(layout: :horizontal) do |group|+ # TODO: rather then relying on the params, serialize the query filters+ group.hidden(+ name: :filters,+ value: params[:filters]+ )++ group.text_field(+ visually_hide_label: true,+ required: true,+ autofocus: true,+ name: 'name',+ label: Queries::Projects::ProjectQuery.human_attribute_name(:name),+ placeholder: I18n.t(:'projects.lists.new.placeholder')+ )++ group.submit(+ name: :submit,+ label: I18n.t(:button_save),+ scheme: :primary+ )++ group.button(+ name: :cancel,+ scheme: :secondary,+ label: I18n.t(:button_cancel),+ tag: :a,+ # TODO: rather then relying on the params, serialize the query filters+ href: OpenProject::StaticRouting::StaticUrlHelpers.new.projects_path(filters: params[:filters])+ )+ end+ end+end