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
allows selecting items to copy from a template project
ulfertsa2caedcdb703
diff --git a/frontend/src/app/features/projects/components/copy-project/copy-project.component.ts b/frontend/src/app/features/projects/components/copy-project/copy-project.component.tsindex c53ce0aed62..dc36d1ecd4e 100644--- a/frontend/src/app/features/projects/components/copy-project/copy-project.component.ts+++ b/frontend/src/app/features/projects/components/copy-project/copy-project.component.ts@@ -84,6 +84,6 @@ export class CopyProjectComponent extends UntilDestroyedMixin implements OnInit}private isMeta(property:string|undefined):boolean {- return !!property && (property.startsWith('copy') || property == 'sendNotifications');+ return !!property && (property.startsWith('copy') || property === 'sendNotifications');}}diff --git a/frontend/src/app/features/projects/components/new-project/new-project.component.ts b/frontend/src/app/features/projects/components/new-project/new-project.component.tsindex 4c7e2a76171..c59618750b3 100644--- a/frontend/src/app/features/projects/components/new-project/new-project.component.ts+++ b/frontend/src/app/features/projects/components/new-project/new-project.component.ts@@ -39,6 +39,7 @@ export class NewProjectComponent extends UntilDestroyedMixin implements OnInit {use_template: this.I18n.t('js.project.use_template'),no_template_selected: this.I18n.t('js.project.no_template_selected'),advancedSettingsLabel: this.I18n.t('js.forms.advanced_settings'),+ copySettingsLabel: this.I18n.t('js.project.copy.copy_options'),};hiddenFields:string[] = [@@ -88,10 +89,15 @@ export class NewProjectComponent extends UntilDestroyedMixin implements OnInit {this.resourcePath = this.apiV3Service.projects.path;this.fieldGroups = [{name: this.text.advancedSettingsLabel,- fieldsFilter: (field) => !['name', 'parent', 'sendNotifications'].includes(field.templateOptions?.property as string)+ fieldsFilter: (field) => !['name', 'parent'].includes(field.templateOptions?.property as string)+ && !this.isMeta(field.templateOptions?.property)&& !(field.templateOptions?.required&& !field.templateOptions.hasDefault&& field.templateOptions.payloadValue == null),+ },+ {+ name: this.text.copySettingsLabel,+ fieldsFilter: (field:IOPFormlyFieldSettings) => this.isMeta(field.templateOptions?.property),}];if (this.uIRouterGlobals.params.parent_id) {@@ -128,8 +134,8 @@ export class NewProjectComponent extends UntilDestroyedMixin implements OnInit {return !!key && (this.hiddenFields.includes(key) || this.isMeta(key));}- private isMeta(key:string):boolean {- return key.startsWith('_meta.');+ private isMeta(property:string|undefined):boolean {+ return !!property && (property.startsWith('copy') || property === 'sendNotifications');}private setParentAsPayload(parentId:string) {diff --git a/spec/features/projects/template_spec.rb b/spec/features/projects/template_spec.rbindex 214a6b311a7..5bbc1b427ef 100644--- a/spec/features/projects/template_spec.rb+++ b/spec/features/projects/template_spec.rb@@ -72,6 +72,10 @@ describe 'Project templates', type: :feature, js: true dolet(:status_field_selector) { 'ckeditor-augmented-textarea[textarea-selector="#project_status_explanation"]' }let(:status_description) { ::Components::WysiwygEditor.new status_field_selector }+ let!(:other_user) do+ create(:user, member_in_project: template, member_through_role: role)+ end+let(:name_field) { ::FormFields::InputFormField.new :name }let(:template_field) { ::FormFields::SelectFormField.new :use_template }let(:status_field) { ::FormFields::SelectFormField.new :status }@@ -86,9 +90,15 @@ describe 'Project templates', type: :feature, js: true doname_field.set_value 'Foo bar'+ expect(page)+ .not_to have_content('COPY OPTIONS')+template_field.select_option 'My template'- sleep 1+ # Only when a template is selected, the options are displayed.+ # Using this to know when the copy form has been fetched from the backend.+ expect(page)+ .to have_content('COPY OPTIONS')# It keeps the namename_field.expect_value 'Foo bar'@@ -98,16 +108,19 @@ describe 'Project templates', type: :feature, js: true dopage.find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').clickstatus_field.expect_selected 'ON TRACK'- # It does not show the copy meta flags- expect(page).to have_no_selector('[data-qa-field-name="copyMembers"]')-- # But shows the send notifications field- expect(page).to have_selector('[data-qa-field-name="sendNotifications"]')# Update status to off trackstatus_field.select_option 'Off track'parent_field.select_option other_project.name+ page.find('.op-fieldset--toggle', text: 'COPY OPTIONS').click++ # Now shows the send notifications field.+ expect(page).to have_selector('[data-qa-field-name="sendNotifications"]')++ # And allows to deselect copying the members.+ uncheck 'Members'+page.find('button:not([disabled])', text: 'Save').clickexpect(page).to have_content I18n.t(:label_copy_project)@@ -127,7 +140,8 @@ describe 'Project templates', type: :feature, js: true doproject = Project.find_by identifier: 'foo-bar'expect(project.name).to eq 'Foo bar'expect(project).not_to be_templated- expect(project.users.first).to eq current_user+ # Does not include the member excluded from being copied but sets the copying user as member.+ expect(project.users).to match_array(current_user)expect(project.enabled_module_names.sort).to eq(template.enabled_module_names.sort)wp_source = template.work_packages.first.attributes.except(*%w[id author_id project_id updated_at created_at])