Skip to content

Commit 43ae411

Browse files
Use custom element for kitten component
1 parent cc663f3 commit 43ae411

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

app/views/kittens/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
These are the kittens:
2020
</p>
2121
<% @kittens.each do |kitten| %>
22-
<%= tag 'kitten-component', data: { 'kitten-name': kitten.name } %>
22+
<%= angular_component_tag 'opce-kitten', inputs: { 'kitten-name': kitten.name } %>
2323
<% end %>
2424
<% end %>
2525

frontend/module/main.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,12 @@ import { CommonModule } from '@angular/common';
4848
import { KITTEN_ROUTES } from 'core-app/features/plugins/linked/openproject-proto_plugin/kitten.routes';
4949
import { KittenPageComponent } from 'core-app/features/plugins/linked/openproject-proto_plugin/kitten-page/kitten-page.component';
5050
import { kittenAction } from 'core-app/features/plugins/linked/openproject-proto_plugin/context-menu';
51+
import { registerCustomElement } from 'core-app/shared/helpers/angular/custom-elements.helper';
5152

5253
export function initializeProtoPlugin(injector:Injector) {
5354
return () => {
5455
const hookService = injector.get(HookService);
5556

56-
// Explicitly bootstrap the kitten component in the DOM if it is found
57-
// Angular would otherwise only bootstrap the global entry point bootstrap from the core
58-
// preventing us from using components like this kitten component
59-
hookService.register('openProjectAngularBootstrap', () => {
60-
return [
61-
{ selector: 'kitten-component', cls: KittenComponent },
62-
];
63-
});
64-
65-
// Register action menu
6657
hookService.register('workPackageSingleContextMenu', () => kittenAction);
6758
hookService.register('workPackageTableContextMenu', () => kittenAction);
6859
};
@@ -90,4 +81,7 @@ export function initializeProtoPlugin(injector:Injector) {
9081
],
9182
})
9283
export class PluginModule {
84+
constructor(injector:Injector) {
85+
registerCustomElement('opce-kitten', KittenComponent, { injector });
86+
}
9387
}

0 commit comments

Comments
 (0)