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

Render required custom fields

Oliver Günther81cba3fecbfb
diff --git a/app/components/work_packages/dialogs/create_form_component.html.erb b/app/components/work_packages/dialogs/create_form_component.html.erb
index 1e46b743da5..3c31646a691 100644
--- a/app/components/work_packages/dialogs/create_form_component.html.erb
+++ b/app/components/work_packages/dialogs/create_form_component.html.erb
@@ -4,7 +4,10 @@
scope: :work_package,
model: @work_package,
html: {
- id: 'create-work-package-form'
+ id: 'create-work-package-form',
+ data: {
+ controller: "work-packages--create-dialog"
+ }
}
) do |f|
flex_layout(mb: 3) do |modal_body|
diff --git a/app/forms/work_packages/dialogs/create_form.rb b/app/forms/work_packages/dialogs/create_form.rb
index 9841bbd3ce5..3d18939e87d 100644
--- a/app/forms/work_packages/dialogs/create_form.rb
+++ b/app/forms/work_packages/dialogs/create_form.rb
@@ -28,6 +28,8 @@
module WorkPackages::Dialogs
class CreateForm < ApplicationForm
+ include CustomFields::CustomFieldRendering
+
attr_reader :work_package, :wrapper_id, :contract
def initialize(work_package:, wrapper_id:)
@@ -49,7 +51,7 @@ module WorkPackages::Dialogs
autocomplete_options: {
multiple: false,
decorated: true,
- append_to: "##{wrapper_id}"
+ append_to: wrapper_id
}
) do |select|
contract
@@ -74,9 +76,21 @@ module WorkPackages::Dialogs
}
)
+ render_custom_fields(form: f)
+
work_package.changes.each do |attribute, value|
f.hidden(name: attribute, value:)
end
end
+
+ def additional_custom_field_input_arguments
+ { wrapper_id: }
+ end
+
+ private
+
+ def custom_fields
+ @custom_fields ||= work_package.available_custom_fields.required
+ end
end
end
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/create-dialog.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/create-dialog.controller.ts
new file mode 100644
index 00000000000..0507587ce51
--- /dev/null
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/create-dialog.controller.ts
@@ -0,0 +1,36 @@
+/*
+ * -- 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.
+ * ++
+ */
+
+import { Controller } from '@hotwired/stimulus';
+
+export default class CreateDialogController extends Controller {
+ connect() {
+ }
+}