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
[32817] Disable advanced settings in project template (#8537)
Oliver Güntherebfd3ce0099b
diff --git a/app/views/projects/_form.html.erb b/app/views/projects/_form.html.erbindex 5f3fdd01f18..c1f98f6fd1c 100644--- a/app/views/projects/_form.html.erb+++ b/app/views/projects/_form.html.erb@@ -28,7 +28,7 @@ See docs/COPYRIGHT.rdoc for more details.++#%><% content_for :header_tags do %>- <meta name="required_script" content="project_identifier_listener" />+ <meta name="required_script" content="project_form_listener" /><% end %><%= error_messages_for_contract(project, errors) unless local_assigns[:no_error_messages] %>diff --git a/app/views/projects/form/_select_template.html.erb b/app/views/projects/form/_select_template.html.erbindex d945545c5c1..6ca5b14b6a3 100644--- a/app/views/projects/form/_select_template.html.erb+++ b/app/views/projects/form/_select_template.html.erb@@ -32,6 +32,7 @@ See docs/COPYRIGHT.rdoc for more details.<div class="form--field-container"><%= styled_select_tag :from_template,options_for_select(project_options_for_templated),+ id: 'project-select-template',prompt: "(#{t(:label_none)})",container_class: '-wide' %></div>diff --git a/frontend/src/app/modules/augmenting/dynamic-scripts/project_identifier_listener.js b/frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.jssimilarity index 95%rename from frontend/src/app/modules/augmenting/dynamic-scripts/project_identifier_listener.jsrename to frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.jsindex 9dfad32365c..1bf9e04d578 100644--- a/frontend/src/app/modules/augmenting/dynamic-scripts/project_identifier_listener.js+++ b/frontend/src/app/modules/augmenting/dynamic-scripts/project_form_listener.js@@ -104,7 +104,20 @@});}+ function observeTemplateChanges() {+ jQuery('#project-select-template').on('change', function() {+ let templateSelected = $(this).val() !== '';+ let settings = $('#advanced-settings');++ settings+ .toggle(!templateSelected)+ .find('input:not(#project_identifier), select, textarea')+ .prop('disabled', templateSelected);+ });+ }+observeProjectIdentifier();observeProjectName();+ observeTemplateChanges();});}(jQuery));diff --git a/spec/features/projects/template_spec.rb b/spec/features/projects/template_spec.rbindex de71a434250..a95a88bd411 100644--- a/spec/features/projects/template_spec.rb+++ b/spec/features/projects/template_spec.rb@@ -77,13 +77,12 @@ describe 'Project templates', type: :feature, js: true dovisit new_project_pathfill_in 'project[name]', with: 'Foo bar'- select 'My template', from: 'Use template'- click_on 'Advanced settings'- fill_in 'project[identifier]', with: 'foo'- # Fill status- select 'On track', from: 'Status'- status_description.click_and_type_slowly 'Status is OKAYDOKEY'+ expect(page).to have_selector('#advanced-settings', visible: true, text: 'ADVANCED SETTINGS')++ # Choosing template hides advanced settings+ select 'My template', from: 'project-select-template'+ expect(page).to have_no_selector('#advanced-settings', visible: true, text: 'ADVANCED SETTINGS')sleep 1click_on 'Create'@@ -101,15 +100,13 @@ describe 'Project templates', type: :feature, js: true doexpect(mail).not_to be_nil- expect(page).to have_current_path '/projects/foo/', wait: 20+ expect(page).to have_current_path '/projects/foo-bar/', wait: 20- project = Project.find_by identifier: 'foo'+ project = Project.find_by identifier: 'foo-bar'expect(project.name).to eq 'Foo bar'expect(project).not_to be_templatedexpect(project.users.first).to eq current_userexpect(project.enabled_module_names.sort).to eq(template.enabled_module_names.sort)- expect(project.status.code).to eq 'on_track'- expect(project.status.explanation).to eq 'Status is OKAYDOKEY'wp_source = template.work_packages.first.attributes.except(*%w[id author_id project_id updated_at created_at])wp_target = project.work_packages.first.attributes.except(*%w[id author_id project_id updated_at created_at])