Skip to content

Commit

Permalink
Use custom element for kitten component
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Sep 2, 2024
1 parent cc663f3 commit 43ae411
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/views/kittens/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
These are the kittens:
</p>
<% @kittens.each do |kitten| %>
<%= tag 'kitten-component', data: { 'kitten-name': kitten.name } %>
<%= angular_component_tag 'opce-kitten', inputs: { 'kitten-name': kitten.name } %>
<% end %>
<% end %>
Expand Down
14 changes: 4 additions & 10 deletions frontend/module/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,12 @@ import { CommonModule } from '@angular/common';
import { KITTEN_ROUTES } from 'core-app/features/plugins/linked/openproject-proto_plugin/kitten.routes';
import { KittenPageComponent } from 'core-app/features/plugins/linked/openproject-proto_plugin/kitten-page/kitten-page.component';
import { kittenAction } from 'core-app/features/plugins/linked/openproject-proto_plugin/context-menu';
import { registerCustomElement } from 'core-app/shared/helpers/angular/custom-elements.helper';

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

// Explicitly bootstrap the kitten component in the DOM if it is found
// Angular would otherwise only bootstrap the global entry point bootstrap from the core
// preventing us from using components like this kitten component
hookService.register('openProjectAngularBootstrap', () => {
return [
{ selector: 'kitten-component', cls: KittenComponent },
];
});

// Register action menu
hookService.register('workPackageSingleContextMenu', () => kittenAction);
hookService.register('workPackageTableContextMenu', () => kittenAction);
};
Expand Down Expand Up @@ -90,4 +81,7 @@ export function initializeProtoPlugin(injector:Injector) {
],
})
export class PluginModule {
constructor(injector:Injector) {
registerCustomElement('opce-kitten', KittenComponent, { injector });
}
}

0 comments on commit 43ae411

Please sign in to comment.