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

Rewrite quickinfo with custom element

Oliver Güntherd1e55891f438
diff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.ts
index 29646f35b2d..2afe03addc3 100644
--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts
+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts
@@ -102,10 +102,6 @@ import {
AttributeHelpTextComponent,
attributeHelpTextSelector,
} from 'core-app/shared/components/attribute-help-texts/attribute-help-text.component';
-import {
- quickInfoMacroSelector,
- WorkPackageQuickinfoMacroComponent,
-} from 'core-app/shared/components/fields/macros/work-package-quickinfo-macro.component';
import { SpotSwitchComponent, spotSwitchSelector } from 'core-app/spot/components/switch/switch.component';
import { BackupComponent, backupSelector } from 'core-app/core/setup/globals/components/admin/backup.component';
import {
@@ -234,7 +230,6 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [
{ selector: opCalendarSidemenuSelector, cls: CalendarSidemenuComponent },
{ selector: triggerActionsEntryComponentSelector, cls: TriggerActionsEntryComponent, embeddable: true },
{ selector: backlogsPageComponentSelector, cls: BacklogsPageComponent },
- { selector: quickInfoMacroSelector, cls: WorkPackageQuickinfoMacroComponent, embeddable: true },
{ selector: editableQueryPropsSelector, cls: EditableQueryPropsComponent },
{ selector: backupSelector, cls: BackupComponent },
{ selector: opInAppNotificationBellSelector, cls: InAppNotificationBellComponent },
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.ts
index 3d3367dd488..c222bffb81a 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
@@ -38,17 +38,18 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';
-import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
+import {
+ HalResourceEditingService,
+} from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
import { DisplayFieldService } from 'core-app/shared/components/fields/display/display-field.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
-import { CombinedDateDisplayField } from 'core-app/shared/components/fields/display/field-types/combined-date-display.field';
+import {
+ CombinedDateDisplayField,
+} from 'core-app/shared/components/fields/display/field-types/combined-date-display.field';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
-export const quickInfoMacroSelector = 'macro.macro--wp-quickinfo';
-
@Component({
- selector: quickInfoMacroSelector,
templateUrl: './work-package-quickinfo-macro.html',
styleUrls: ['./work-package-quickinfo-macro.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -83,8 +84,8 @@ export class WorkPackageQuickinfoMacroComponent {
readonly displayField:DisplayFieldService,
readonly pathHelper:PathHelperService,
readonly I18n:I18nService,
- readonly cdRef:ChangeDetectorRef) {
-
+ readonly cdRef:ChangeDetectorRef,
+ ) {
}
ngOnInit() {
diff --git a/frontend/src/app/shared/components/fields/openproject-fields.module.ts b/frontend/src/app/shared/components/fields/openproject-fields.module.ts
index 8374b6770ee..39af27a23b1 100644
--- a/frontend/src/app/shared/components/fields/openproject-fields.module.ts
+++ b/frontend/src/app/shared/components/fields/openproject-fields.module.ts
@@ -173,5 +173,6 @@ export class OpenprojectFieldsModule {
constructor(injector:Injector) {
registerCustomElement('opce-macro-attribute-value', AttributeValueMacroComponent, { injector });
registerCustomElement('opce-macro-attribute-label', AttributeLabelMacroComponent, { injector });
+ registerCustomElement('opce-macro-wp-quickinfo', WorkPackageQuickinfoMacroComponent, { injector });
}
}
diff --git a/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb b/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb
index e1ce8a3544f..298df6a8817 100644
--- a/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb
+++ b/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb
@@ -58,9 +58,8 @@ module OpenProject::TextFormatting::Matchers
private
def render_work_package_macro(wp_id, detailed: false)
- ApplicationController.helpers.content_tag :macro,
+ ApplicationController.helpers.content_tag 'opce-macro-wp-quickinfo',
'',
- class: "macro--wp-quickinfo",
data: { id: wp_id, detailed: }
end
diff --git a/spec/features/work_packages/details/markdown/activity_comments_spec.rb b/spec/features/work_packages/details/markdown/activity_comments_spec.rb
index 05e015a2961..d87fc7ea6a5 100644
--- a/spec/features/work_packages/details/markdown/activity_comments_spec.rb
+++ b/spec/features/work_packages/details/markdown/activity_comments_spec.rb
@@ -246,7 +246,7 @@ RSpec.describe 'activity comments', js: true do
comment_field.submit_by_click
wp_page.expect_comment text: "Single ##{work_package2.id}"
- expect(page).to have_selector('.user-comment .macro--wp-quickinfo', count: 2)
+ expect(page).to have_selector('.user-comment opce-macro-wp-quickinfo', count: 2)
expect(page).to have_selector('.user-comment .work-package--quickinfo.preview-trigger', count: 2)
end
end
diff --git a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb
index 2228ee625e2..3187382b0bd 100644
--- a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb
+++ b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb
@@ -71,7 +71,7 @@ RSpec.describe 'Wysiwyg work package quicklink macros', js: true do
# 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('opce-macro-wp-quickinfo', 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')
@@ -93,7 +93,7 @@ RSpec.describe 'Wysiwyg work package quicklink macros', js: true do
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('opce-macro-wp-quickinfo', 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}")
@@ -162,12 +162,12 @@ RSpec.describe 'Wysiwyg work package quicklink macros', js: true do
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$/)
+ expect(page).to have_selector('opce-macro-wp-quickinfo', text: /No dates$/)
+ expect(page).to have_selector('opce-macro-wp-quickinfo', text: 'Start date only (01/01/2020 - no finish date)')
+ expect(page).to have_selector('opce-macro-wp-quickinfo', text: 'End date only (no start date - 12/31/2020)')
+ expect(page).to have_selector('opce-macro-wp-quickinfo', text: 'Both dates (01/01/2020 - 12/31/2020)')
+ expect(page).to have_selector('opce-macro-wp-quickinfo', text: 'Milestone with date (01/01/2020)')
+ expect(page).to have_selector('opce-macro-wp-quickinfo', text: /Milestone without date$/)
end
end
end
diff --git a/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb b/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb
index f78665fe342..97dafaa8d62 100644
--- a/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb
@@ -295,9 +295,8 @@ RSpec.describe OpenProject::TextFormatting,
describe 'double hash work_package link' do
let(:work_package_link) do
- content_tag :macro,
+ content_tag 'opce-macro-wp-quickinfo',
'',
- class: "macro--wp-quickinfo",
data: { id: '1234', detailed: 'false' }
end
@@ -308,9 +307,8 @@ RSpec.describe OpenProject::TextFormatting,
describe 'triple hash work_package link' do
let(:work_package_link) do
- content_tag :macro,
+ content_tag 'opce-macro-wp-quickinfo',
'',
- class: "macro--wp-quickinfo",
data: { id: '1234', detailed: 'true' }
end
diff --git a/spec/requests/api/v3/work_packages/show_resource_spec.rb b/spec/requests/api/v3/work_packages/show_resource_spec.rb
index 7b34239060f..ec8c0d2a2a3 100644
--- a/spec/requests/api/v3/work_packages/show_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/show_resource_spec.rb
@@ -123,7 +123,7 @@ RSpec.describe 'API v3 Work package resource',
# resolves links
expect(subject['html'])
- .to have_selector("macro.macro--wp-quickinfo[data-id='#{other_wp.id}']")
+ .to have_selector("opce-macro-wp-quickinfo[data-id='#{other_wp.id}']")
# resolves macros, e.g. toc
expect(subject['html'])
.to have_selector('.op-uc-toc--list-item', text: "OpenProject Masterplan for 2015")