Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mbritense committed Nov 20, 2024
1 parent 878b460 commit f30d461
Show file tree
Hide file tree
Showing 14 changed files with 750 additions and 121 deletions.
749 changes: 649 additions & 100 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions projects/valtimo/config/assets/core/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@
}
},
"processLink": {
"create": "Prozesslink erstellen",
"edit": "Prozesslink bearbeiten",
"saveChanges": "Änderungen speichern",
"unlink": "Verknüpfung aufheben",
Expand Down
1 change: 1 addition & 0 deletions projects/valtimo/config/assets/core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@
}
},
"processLink": {
"create": "Create process link",
"edit": "Edit process link",
"saveChanges": "Save changes",
"unlink": "Unlink",
Expand Down
1 change: 1 addition & 0 deletions projects/valtimo/config/assets/core/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,7 @@
}
},
"processLink": {
"create": "Proceskoppeling aanmaken",
"edit": "Proceskoppeling wijzigen",
"saveChanges": "Wijzigingen opslaan",
"unlink": "Ontkoppelen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const routes: Routes = [
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: [],
})
Expand Down
2 changes: 2 additions & 0 deletions projects/valtimo/process-link/src/lib/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export * from './process-link-state.service';
export * from './process-link-step.service';
export * from './process-link-button.service';
export * from './form-flow-component.service';
export * from './url-resolver.service';
export * from './url-validator.service';
6 changes: 1 addition & 5 deletions projects/valtimo/process-link/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
* Public API Surface of process-link
*/

export * from './lib/services/form-flow.service';
export * from './lib/services/process-link.service';
export * from './lib/services/process-link-state.service';
export * from './lib/services';
export * from './lib/services/valtimo-renderer';
export * from './lib/services/url-resolver.service';
export * from './lib/services/url-validator.service';
export * from './lib/components/select-plugin-configuration/select-plugin-configuration.component';
export * from './lib/components/select-plugin-action/select-plugin-action.component';
export * from './lib/components/select-url/select-url.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import {useService} from 'bpmn-js-properties-panel';
import {html} from 'htm/preact';
import {is} from 'bpmn-js/lib/util/ModelUtil';
import {ProcessManagementEditorService} from '../../../services';
import {ProcessManagementWindow} from '../../../models';
import {BpmnElement, ProcessManagementWindow} from '../../../models';
import {ProcessLink} from '@valtimo/process-link';
import {TranslateService} from '@ngx-translate/core';

class ValtimoPropertiesProvider {
static $inject = ['propertiesPanel', 'translate'];
Expand All @@ -11,12 +13,20 @@ class ValtimoPropertiesProvider {
return (window as any as ProcessManagementWindow).processManagementEditorService;
}

constructor(propertiesPanel: any, translate: any) {
private get translateService(): TranslateService {
return (window as any as ProcessManagementWindow).translateService;
}

constructor(propertiesPanel: any) {
propertiesPanel.registerProvider(500, this);
}

public getGroups(element: any): (groups: any[]) => any[] {
console.log('x', this.processManagementEditorService.processLinksForSelectedDefinition);
public getGroups(element: BpmnElement): (groups: any[]) => any[] {
const processLink: ProcessLink | null =
this.processManagementEditorService.processLinksForSelectedDefinition.find(
processLink => processLink.activityId === element.id
) || null;


return (groups: any[]) => {
if (
Expand All @@ -27,7 +37,7 @@ class ValtimoPropertiesProvider {
const customGroup = {
id: 'customRootGroup',
label: 'Process link',
entries: [this.createCustomButton(element)],
entries: [this.createCustomRootElement(element, processLink)],
groupType: 'root', // Mark this group as root level
};
groups.unshift(customGroup); // Add to the top of the panel
Expand All @@ -36,27 +46,39 @@ class ValtimoPropertiesProvider {
};
}

public createCustomButton(element: any): any {
public createCustomRootElement(element: any, processLink: ProcessLink | null): any {
return {
id: 'customRootButton',
translateService: this.translateService,
id: 'customRootElement',
processLink,
element,
component: CustomButton,
component: CustomRootElement,
isEdited: () => false,
};
}
}

function CustomButton(props: any): any {
const {element} = props;
const CustomRootElement = (props: any): any => {
const {element, processLink, translateService} = props;
const modeling = useService('modeling');
const translate = useService('translate');
const editProcessLinkText = translateService.instant('interface.edit')
const unlinkText = translateService.instant('processLink.unlink')
const createText = translateService.instant('processLink.create')
console.log("process link", processLink)

const handleClick = () => {
console.log(`Custom action triggered for element: ${element.id}`);
modeling.updateProperties(element, {customProperty: 'newValue'});
// trigger update
modeling.updateProperties(element, {});
};

return html`<button id="customRootButton" onClick=${handleClick}>test</button> `;
return processLink ? html`
<div class="process-link-properties-panel">
<button class="cds--btn cds--btn--primary cds--btn--md cds--layout--size-md" onClick=${handleClick}>${editProcessLinkText}</button>
<button class="cds--btn cds--btn--danger cds--btn--md cds--layout--side-md" onClick=${handleClick}>${unlinkText}</button>
</div>` : html`
<div class="process-link-properties-panel">
<button class="cds--btn cds--btn--primary cds--btn--md cds--layout--size-md" onClick=${handleClick}>${createText}</button>
</div>`
}

const valtimoPropertiesProviderModule = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<div #viewer class="bpmn__viewer" [style.display]="obs.isReadOnlyProcess ? 'flex' : 'none'"></div>
</div>

<valtimo-process-link-modal></valtimo-process-link-modal>

<ng-container renderInPageHeader [fullWidth]="true">
<ng-template>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,18 @@
width: 150px;
}
}

::ng-deep .process-link-properties-panel {
padding: 8px 12px 16px 12px;
width: 100%;
display: flex;
flex-direction: row;
gap: 16px;

.cds--btn {
flex-shrink: 1;
width: 100%;
display: flex;
align-items: center;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ import {distinctUntilChanged} from 'rxjs/operators';
import {isEqual} from 'lodash';
import {ProcessManagementEditorService} from '../../services';
import {ProcessManagementWindow} from '../../models';
import {
ProcessLinkButtonService,
ProcessLinkModule,
ProcessLinkStateService,
ProcessLinkStepService,
} from '@valtimo/process-link';

@Component({
selector: 'valtimo-process-management-editor',
Expand All @@ -82,8 +88,15 @@ import {ProcessManagementWindow} from '../../models';
IconModule,
TranslateModule,
TagModule,
ProcessLinkModule,
ProcessLinkModule,
],
providers: [
ProcessManagementEditorService,
ProcessLinkStateService,
ProcessLinkStepService,
ProcessLinkButtonService,
],
providers: [ProcessManagementEditorService],
})
export class ProcessManagementEditorComponent implements AfterViewInit, OnDestroy {
@ViewChild('modeler', {static: false}) modelerElementRef!: ElementRef;
Expand Down Expand Up @@ -171,6 +184,7 @@ export class ProcessManagementEditorComponent implements AfterViewInit, OnDestro
this.iconService.registerAll([Deploy16]);
(window as any as ProcessManagementWindow).processManagementEditorService =
processManagementEditorService;
(window as any as ProcessManagementWindow).translateService = translateService;
}

public ngAfterViewInit(): void {
Expand Down
23 changes: 23 additions & 0 deletions projects/valtimo/process-management/src/lib/models/bpmn.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2015-2024 Ritense BV, the Netherlands.
*
* Licensed under EUPL, Version 1.2 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

interface BpmnElement {
type: string;
id: string;
di: {id: string};
}

export {BpmnElement};
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
*/

export * from './window.model';
export * from './bpmn.model';
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

import {ValtimoWindow} from '@valtimo/config';
import {ProcessManagementEditorService} from '../services';
import {TranslateService} from '@ngx-translate/core';

interface ProcessManagementWindow extends ValtimoWindow {
processManagementEditorService: ProcessManagementEditorService;
translateService: TranslateService;
}

export {ProcessManagementWindow};

0 comments on commit f30d461

Please sign in to comment.