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
Clear attachments store on finishing creation
Oliver Günther7610dd798999
diff --git a/frontend/src/app/core/state/resource-collection.service.ts b/frontend/src/app/core/state/resource-collection.service.tsindex 4f56cca6c4c..7b9a16b4966 100644--- a/frontend/src/app/core/state/resource-collection.service.ts+++ b/frontend/src/app/core/state/resource-collection.service.ts@@ -38,6 +38,7 @@ import {switchMap,} from 'rxjs/operators';import { CollectionState } from 'core-app/core/state/collection-store';+import { omit } from 'lodash';export type CollectionStore<T> = EntityStore<CollectionState<T>>;@@ -96,6 +97,20 @@ export abstract class ResourceCollectionService<T> {) as Observable<T>;}+ /**+ * Clear a collection key+ * @param key Collection key to clear+ */+ clear(key:string):void {+ this+ .store+ .update(+ ({ collections }) => ({+ collections: omit(collections, key),+ }),+ );+ }+/*** Update a single entity in the store*diff --git a/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts b/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.tsindex 94a50dbf2b2..fbb930c45b2 100644--- a/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts+++ b/frontend/src/app/features/work-packages/components/wp-new/wp-create.service.ts@@ -59,6 +59,7 @@ import { SchemaResource } from 'core-app/features/hal/resources/schema-resource'import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';import { HalResourceService } from 'core-app/features/hal/services/hal-resource.service';import { ResourceChangeset } from 'core-app/shared/components/fields/changeset/resource-changeset';+import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service';export const newWorkPackageHref = '/api/v3/work_packages/new';@@ -79,6 +80,7 @@ export class WorkPackageCreateService extends UntilDestroyedMixin {protected halEditing:HalResourceEditingService,protected schemaCache:SchemaCacheService,protected halEvents:HalEventsService,+ protected attachmentsService:AttachmentsResourceService,) {super();@@ -215,6 +217,11 @@ export class WorkPackageCreateService extends UntilDestroyedMixin {.work_packages.cache.clearSome('new');++ this+ .attachmentsService+ .clear('new');+this.form = undefined;}diff --git a/spec/features/work_packages/attachments/attachment_upload_spec.rb b/spec/features/work_packages/attachments/attachment_upload_spec.rbindex a02e36c39a1..03cb7fd43f1 100644--- a/spec/features/work_packages/attachments/attachment_upload_spec.rb+++ b/spec/features/work_packages/attachments/attachment_upload_spec.rb@@ -104,6 +104,69 @@ describe 'Upload attachment to work package', js: true doendend+ context 'when on a split page' do+ let!(:type) { create(:type_task) }+ let!(:status) { create(:status, is_default: true) }+ let!(:priority) { create(:priority, is_default: true) }+ let!(:project) do+ create(:project, types: [type])+ end+ let!(:table) { ::Pages::WorkPackagesTable.new project }++ it 'can add two work packages in a row when uploading (Regression #42933)' do+ table.visit!+ new_page = table.create_wp_by_button type+ subject = new_page.edit_field :subject+ subject.set_value 'My subject'++ target = find('.ck-content')+ attachments.drag_and_drop_file(target, image_fixture.path)++ sleep 2+ expect(page).not_to have_selector('op-toasters-upload-progress')++ editor.in_editor do |_container, editable|+ expect(editable).to have_selector('img[src*="/api/v3/attachments/"]', wait: 20)+ expect(editable).not_to have_selector('.ck-upload-placeholder-loader')+ end++ sleep 2++ scroll_to_and_click find('#work-packages--edit-actions-save')++ new_page.expect_toast(+ message: 'Successful creation.'+ )++ split_view = ::Pages::SplitWorkPackage.new(WorkPackage.last)++ field = split_view.edit_field :description+ expect(field.display_element).to have_selector('img')++ wp = WorkPackage.last+ expect(wp.subject).to eq('My subject')+ expect(wp.attachments.count).to eq(1)++ # create another one+ new_page = table.create_wp_by_button type+ subject = new_page.edit_field :subject+ subject.set_value 'A second task'++ scroll_to_and_click find('#work-packages--edit-actions-save')++ new_page.expect_toast(+ message: 'Successful creation.'+ )++ last = WorkPackage.last+ expect(last.subject).to eq('A second task')+ expect(last.attachments.count).to eq(0)++ wp.reload+ expect(wp.attachments.count).to eq(1)+ end+ end+context 'when on a new page' doshared_examples 'it supports image uploads via drag & drop' dolet!(:new_page) { Pages::FullWorkPackageCreate.new }