import { domify, classes } from 'min-dom'; import { find } from 'min-dash'; import { escapeHTML } from 'diagram-js/lib/util/EscapeUtil'; import { getBusinessObject, is } from '../../util/ModelUtil'; import { isPlane, planeId, primaryShape } from '../../util/DrilldownUtil'; var OPEN_CLASS = 'bjs-breadcrumbs-shown'; /** * Adds Overlays that allow switching planes on collapsed subprocesses. * * @param {eventBus} eventBus * @param {elementRegistry} elementRegistry * @param {overlays} overlays * @param {canvas} canvas */ export default function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays, canvas) { var breadcrumbs = domify('
'); var container = canvas.getContainer(); var containerClasses = classes(container); container.appendChild(breadcrumbs); var boParents = []; // Update primary shape if Name or ID of the plane changes eventBus.on('element.changed', function(e) { var shape = e.element; if (!isPlane(shape)) { return; } var primary = elementRegistry.get(primaryShape(shape)); primary && eventBus.fire('element.changed', { element: primary }); }); // update breadcrumbs if name/id of the primary shape changes eventBus.on('element.changed', function(e) { var shape = e.element, bo = getBusinessObject(shape); var isPresent = find(boParents, function(el) { return el === bo; }); if (!isPresent) { return; } updateBreadcrumbs(); }); /** * Updates the displayed breadcrumbs. If no element is provided, only the * labels are updated. * * @param {djs.model.Base} [element] */ function updateBreadcrumbs(element) { if (element) { boParents = getBoParentChain(element); } var path = boParents.map(function(parent) { var title = escapeHTML(parent.name || parent.id); var link = domify('