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

deepClone payload source object to avoid side effects

ulferts5ecd0e06baf0
diff --git a/frontend/src/app/modules/fields/changeset/resource-changeset.ts b/frontend/src/app/modules/fields/changeset/resource-changeset.ts
index 1b8bc47cf4f..6777869c752 100644
--- a/frontend/src/app/modules/fields/changeset/resource-changeset.ts
+++ b/frontend/src/app/modules/fields/changeset/resource-changeset.ts
@@ -297,10 +297,11 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =
if (this.pristineResource.isNew) {
// If the resource is new, we need to pass the entire form payload
// to let all default values be transmitted (type, status, etc.)
+ // We clone the object to avoid later manipulations to affect the original resource.
if (this.form$.value) {
- payload = this.form$.value.payload.$source;
+ payload = _.cloneDeep(this.form$.value.payload.$source);
} else {
- payload = this.pristineResource.$source;
+ payload = _.cloneDeep(this.pristineResource.$source);
}
// Add attachments to be assigned.
diff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
index 4749e2c0e45..15a7d3c315d 100644
--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
@@ -86,7 +86,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
hours: 4
end
let!(:custom_field) do
- FactoryBot.create :time_entry_custom_field, field_format: 'string'
+ FactoryBot.create :time_entry_custom_field, field_format: 'text'
end
let(:other_user) do
FactoryBot.create(:user)
@@ -99,7 +99,7 @@ describe 'My page time entries current user widget spec', type: :feature, js: tr
let(:my_page) do
Pages::My::Page.new
end
- let(:cf_field) { ::EditField.new(page, "customField#{custom_field.id}") }
+ let(:cf_field) { ::TextEditorField.new(page, "customField#{custom_field.id}") }
let(:time_logging_modal) { ::Components::TimeLoggingModal.new }
before do