OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/frontend/app/components/wp-fast-table/builders/context-link-icon-builder.ts

58 lines
2.0 KiB

import {$injectFields} from '../../angular/angular-injector-bridge.functions';
import {opIconElement} from '../../../helpers/op-icon-builder';
import {wpCellTdClassName} from './cell-builder';
import {UiStateLinkBuilder} from './ui-state-link-builder';
import {WorkPackageResourceInterface} from '../../api/api-v3/hal-resources/work-package-resource.service';
export const contextMenuTdClassName = 'wp-table--context-menu-td';
export const contextMenuSpanClassName = 'wp-table--context-menu-span';
export const contextMenuLinkClassName = 'wp-table-context-menu-link';
export const contextColumnIcon = 'wp-table-context-menu-icon';
export const detailsLinkClassName = 'wp-table--details-link';
export class ContextLinkIconBuilder {
// Injections
public I18n:op.I18n;
public text:any;
public uiStatebuilder = new UiStateLinkBuilder();
constructor() {
$injectFields(this, 'I18n');
this.text = {
button: this.I18n.t('js.button_open_details')
};
}
public build(workPackage:WorkPackageResourceInterface):HTMLElement {
// Append details button
let td = document.createElement('td');
td.classList.add(wpCellTdClassName, contextMenuTdClassName, 'hide-when-print');
let detailsLink = this.uiStatebuilder.linkToDetails(
workPackage.id,
this.text.button,
''
);
detailsLink.classList.add(detailsLinkClassName, contextColumnIcon);
detailsLink.appendChild(opIconElement('icon', 'icon-info2'));
// Enter the context menu arrow
let contextMenu = document.createElement('a');
contextMenu.href = 'javascript:';
contextMenu.classList.add(contextMenuLinkClassName, contextColumnIcon);
contextMenu.appendChild(opIconElement('icon', 'icon-show-more-horizontal'));
// Wrap both icons in a span
let span = document.createElement('span');
span.classList.add(contextMenuSpanClassName);
span.appendChild(detailsLink);
span.appendChild(contextMenu);
td.appendChild(span);
return td;
}
}