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
Display date range in quicklink macro when no start date
Christophe Bliarda087f31ebf02
diff --git a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.tsindex 69d35ba249c..8473e6761c1 100644--- a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts+++ b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts@@ -70,7 +70,7 @@ export class WorkPackageQuickinfoMacroComponent {/** Work package to be shown */workPackage$:Observable<WorkPackageResource>;- dateDisplayField = CombinedDateDisplayField;+ combinedDateDisplayField = CombinedDateDisplayField;workPackageLink:string;@@ -99,7 +99,7 @@ export class WorkPackageQuickinfoMacroComponent {.id(id).get().pipe(- tap({ error: (e) => this.markError(this.text.not_found) }),+ tap({ error: (_e) => this.markError(this.text.not_found) }),);}diff --git a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.htmlindex 18d14d416db..39328b4b808 100644--- a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html+++ b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html@@ -18,7 +18,7 @@[displayFieldOptions]="{ writable: false }"fieldName="subject"></display-field>- <ng-container *ngIf="detailed && (!!workPackage.startDate || !!workPackage.date)">+ <ng-container *ngIf="detailed && (!!workPackage.startDate || !!workPackage.dueDate || !!workPackage.date)">(<display-field *ngIf="!!workPackage.date"[resource]="workPackage"[displayFieldOptions]="{ writable: false }"@@ -28,9 +28,16 @@<display-field *ngIf="!!workPackage.startDate"[resource]="workPackage"[displayFieldOptions]="{ writable: false }"- [displayClass]="dateDisplayField"+ [displayClass]="combinedDateDisplayField"fieldName="startDate"containerType="single-view">+ </display-field>+ <display-field *ngIf="!workPackage.startDate && !!workPackage.dueDate"+ [resource]="workPackage"+ [displayFieldOptions]="{ writable: false }"+ [displayClass]="combinedDateDisplayField"+ fieldName="dueDate"+ containerType="single-view"></display-field>)</ng-container></ng-container>@@ -38,4 +45,3 @@<i class="icon icon-error"></i><em [textContent]="error"></em></span>-diff --git a/spec/factories/type_factory.rb b/spec/factories/type_factory.rbindex c4d4985560a..63986abe5bb 100644--- a/spec/factories/type_factory.rb+++ b/spec/factories/type_factory.rb@@ -53,11 +53,6 @@ FactoryBot.define do["query_#{query.id}".to_sym]]]endend-- factory :type_milestone, class: 'Type' do- name { 'Milestone' }- is_milestone { true }- endendfactory :type_standard, class: '::Type' do@@ -93,5 +88,11 @@ FactoryBot.define doname { 'Task' }position { 4 }end++ factory :type_milestone do+ name { 'Milestone' }+ position { 5 }+ is_milestone { true }+ endendenddiff --git a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb b/spec/features/wysiwyg/macros/quicklink_macros_spec.rbindex 92f389408eb..c38a91a4545 100644--- a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb+++ b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb@@ -28,70 +28,151 @@require 'spec_helper'-describe 'Wysiwyg work package quicklink macros', type: :feature, js: true do- shared_let(:admin) { create :admin }- let(:user) { admin }- let!(:project) { create(:project, identifier: 'some-project', enabled_module_names: %w[wiki work_package_tracking]) }+describe 'Wysiwyg work package quicklink macros', js: true do+ shared_let(:user) { create(:admin) }+ shared_let(:project) { create(:project_with_types) }let!(:work_package) docreate(:work_package,- subject: "Foo Bar",+ subject: "My subject",project:,start_date: Date.parse('2020-01-01'),due_date: Date.parse('2020-02-01'))end- let(:editor) { ::Components::WysiwygEditor.new }+ let(:editor) { Components::WysiwygEditor.new }- let(:markdown) do- <<~MD- # My headline+ before do+ login_as(user)+ visit project_wiki_path(project, :wiki)+ end- ###{work_package.id}+ it 'renders work package quicklink macro # with id linking to work package' do+ editor.set_markdown "##{work_package.id}"+ click_on 'Save'- ####{work_package.id}- MD+ # Expect output widget+ within('#content') do+ expect(page).to have_link("##{work_package.id}")+ expect(page).not_to have_selector('.work-package--quickinfo.preview-trigger')+ end++ # Edit page again+ click_on 'Edit'++ editor.in_editor do |container,|+ expect(container).to have_selector('p', text: "##{work_package.id}")+ endend- before do- login_as(user)+ it 'renders work package quicklink macro ## with id link, subject and type' do+ editor.set_markdown "###{work_package.id}"+ click_on 'Save'++ # Expect output widget+ within('#content') do+ expected_macro_text = "#{work_package.type.name.upcase} ##{work_package.id}: My subject"+ expect(page).to have_selector('macro', text: expected_macro_text)+ expect(page).to have_selector('span', text: work_package.type.name.upcase)+ expect(page).to have_selector('.work-package--quickinfo.preview-trigger', text: "##{work_package.id}")+ expect(page).to have_selector('span', text: 'My subject')+ end++ # Edit page again+ click_on 'Edit'++ editor.in_editor do |container,|+ expect(container).to have_selector('p', text: "###{work_package.id}")+ endend- describe 'in wikis' do- describe 'creating a wiki page' do- before do- visit project_wiki_path(project, :wiki)- end-- it 'can add and save multiple code blocks (Regression #28350)' do- editor.in_editor do |container,|- editor.set_markdown markdown- expect(container).to have_selector('p', text: "###{work_package.id}")- expect(container).to have_selector('p', text: "####{work_package.id}")- end-- click_on 'Save'-- expect(page).to have_selector('.flash.notice')-- # Expect output widget- within('#content') do- expect(page).to have_selector('macro', count: 2)- expect(page).to have_selector('span', text: 'Foo Bar', count: 2)- expect(page).to have_selector('span', text: work_package.type.name.upcase, count: 2)- expect(page).to have_selector('span', text: work_package.status.name, count: 1)- # Dates are being rendered in two nested spans- expect(page).to have_selector('span', text: '01/01/2020', count: 2)- expect(page).to have_selector('span', text: '02/01/2020', count: 2)- expect(page).to have_selector('.work-package--quickinfo.preview-trigger', text: "##{work_package.id}", count: 2)- end-- # Edit page again- click_on 'Edit'-- editor.in_editor do |container,|- expect(container).to have_selector('p', text: "###{work_package.id}")- expect(container).to have_selector('p', text: "####{work_package.id}")- end- end+ it 'renders work package quicklink macro ### with id link, subject, type, status, and dates' do+ editor.set_markdown "####{work_package.id}"+ click_on 'Save'++ # Expect output widget+ within('#content') do+ expected_macro_text = "#{work_package.status.name}#{work_package.type.name.upcase} " \+ "##{work_package.id}: My subject (01/01/2020 - 02/01/2020)"+ expect(page).to have_selector('macro', text: expected_macro_text)+ expect(page).to have_selector('span', text: work_package.status.name)+ expect(page).to have_selector('span', text: work_package.type.name.upcase)+ expect(page).to have_selector('.work-package--quickinfo.preview-trigger', text: "##{work_package.id}")+ expect(page).to have_selector('span', text: 'My subject')+ # Dates are being rendered in two nested spans+ expect(page).to have_selector('span', text: '01/01/2020', count: 2)+ expect(page).to have_selector('span', text: '02/01/2020', count: 2)+ end++ # Edit page again+ click_on 'Edit'++ editor.in_editor do |container,|+ expect(container).to have_selector('p', text: "####{work_package.id}")+ end+ end++ it 'displays dates with work package detailed link macro only if a date is present' do+ wp_no_dates =+ create(:work_package,+ subject: "No dates",+ project:,+ start_date: nil,+ due_date: nil)+ wp_start_date_only =+ create(:work_package,+ subject: "Start date only",+ project:,+ start_date: Date.parse('2020-01-01'),+ due_date: nil)+ wp_end_date_only =+ create(:work_package,+ subject: "End date only",+ project:,+ start_date: nil,+ due_date: Date.parse('2020-12-31'))+ wp_both_dates =+ create(:work_package,+ subject: "Both dates",+ project:,+ start_date: Date.parse('2020-01-01'),+ due_date: Date.parse('2020-12-31'))+ wp_milestone_with_date =+ create(:work_package,+ :is_milestone,+ subject: "Milestone with date",+ project:,+ start_date: Date.parse('2020-01-01'),+ due_date: Date.parse('2020-01-01'))+ wp_milestone_without_date =+ create(:work_package,+ :is_milestone,+ subject: "Milestone without date",+ project:,+ start_date: nil,+ due_date: nil)++ editor.set_markdown <<~MD+ ####{wp_no_dates.id}++ ####{wp_start_date_only.id}++ ####{wp_end_date_only.id}++ ####{wp_both_dates.id}++ ####{wp_milestone_with_date.id}++ ####{wp_milestone_without_date.id}+ MD++ click_on 'Save'++ within('#content') do+ expect(page).to have_selector('macro', text: /No dates$/)+ expect(page).to have_selector('macro', text: 'Start date only (01/01/2020 - no finish date)')+ expect(page).to have_selector('macro', text: 'End date only (no start date - 12/31/2020)')+ expect(page).to have_selector('macro', text: 'Both dates (01/01/2020 - 12/31/2020)')+ expect(page).to have_selector('macro', text: 'Milestone with date (01/01/2020)')+ expect(page).to have_selector('macro', text: /Milestone without date$/)endendend