Commit c1db190a authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Rename categories to types

parent cb4d0735
Pipeline #129697 failed with stages
in 7 minutes and 28 seconds
......@@ -61,9 +61,9 @@ import { DevelopmentMethodsComponent } from './development-methods/development-m
import { DevelopmentMethodComponent } from './development-method/development-method.component';
import { BmProcessesComponent } from './bm-processes/bm-processes.component';
import { BmProcessComponent } from './bm-process/bm-process.component';
import { CategoriesFormComponent } from './categories-form/categories-form.component';
import { TypesFormComponent } from './types-form/types-form.component';
import { FormArrayListComponent } from './form-array-list/form-array-list.component';
import { ProcessPatternCategoriesFormComponent } from './process-pattern-categories-form/process-pattern-categories-form.component';
import { ProcessPatternTypesFormComponent } from './process-pattern-types-form/process-pattern-types-form.component';
import { BmProcessDiagramComponent } from './bm-process-diagram/bm-process-diagram.component';
import { SelectProcessPatternFormComponent } from './select-process-pattern-form/select-process-pattern-form.component';
import { DescriptionFormComponent } from './description-form/description-form.component';
......@@ -127,9 +127,9 @@ import { NavbarComponent } from './navbar/navbar.component';
DevelopmentMethodComponent,
BmProcessesComponent,
BmProcessComponent,
CategoriesFormComponent,
TypesFormComponent,
FormArrayListComponent,
ProcessPatternCategoriesFormComponent,
ProcessPatternTypesFormComponent,
BmProcessDiagramComponent,
SelectProcessPatternFormComponent,
DescriptionFormComponent,
......
......@@ -13,29 +13,29 @@
</div>
</ng-template>
<ng-template #showCategoriesModal let-d="dismiss">
<ng-template #showTypesModal let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Show categories of {{modalElement.businessObject.name}}</h4>
<h4 class="modal-title">Show types of {{modalElement.businessObject.name}}</h4>
<button type="button" class="close" aria-label="Close" (click)="d()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<h5>Needed</h5>
<ul class="list-group" *ngIf="modalElement.businessObject.get('neededCategory').length > 0">
<ul class="list-group" *ngIf="modalElement.businessObject.get('neededType').length > 0">
<li class="list-group-item"
*ngFor="let category of modalElement.businessObject.get('neededCategory')">{{category}}</li>
*ngFor="let type of modalElement.businessObject.get('neededType')">{{type}}</li>
</ul>
<div class="alert alert-info" *ngIf="modalElement.businessObject.get('neededCategory').length === 0">
No needed categories defined for this task.
<div class="alert alert-info" *ngIf="modalElement.businessObject.get('neededType').length === 0">
No needed types defined for this task.
</div>
<h5 class="mt-3">Forbidden</h5>
<ul class="list-group" *ngIf="modalElement.businessObject.get('forbiddenCategory').length > 0">
<ul class="list-group" *ngIf="modalElement.businessObject.get('forbiddenType').length > 0">
<li class="list-group-item"
*ngFor="let category of modalElement.businessObject.get('forbiddenCategory')">{{category}}</li>
*ngFor="let type of modalElement.businessObject.get('forbiddenType')">{{type}}</li>
</ul>
<div class="alert alert-info" *ngIf="modalElement.businessObject.get('forbiddenCategory').length === 0">
No forbidden categories defined for this task.
<div class="alert alert-info" *ngIf="modalElement.businessObject.get('forbiddenType').length === 0">
No forbidden types defined for this task.
</div>
</div>
</ng-template>
......
......@@ -34,7 +34,7 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
@ViewChild('deleteProcessPatternModal', {static: true}) deleteProcessPatternModal: any;
@ViewChild('methodInfoModal', {static: true}) methodInfoModal: any;
@ViewChild('selectDevelopmentMethodModal', {static: true}) selectDevelopmentMethodModal: any;
@ViewChild('showCategoriesModal', {static: true}) showCategoriesModal: any;
@ViewChild('showTypesModal', {static: true}) showTypesModal: any;
constructor(
private bpmnService: BpmnService,
......@@ -51,7 +51,7 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
eventBus.on('bmp.deletePattern', (event, subProcessElement) => this.openDeleteProcessPatternModal(subProcessElement));
eventBus.on('bmp.processPatterns', (event, businessObject) => this.openAddProcessPatternModal(businessObject));
eventBus.on('bmp.selectMethod', (event, taskElement) => this.openSelectDevelopmentMethodModal(taskElement));
eventBus.on('bmp.showCategories', (event, taskElement) => this.openShowCategoriesModal(taskElement));
eventBus.on('bmp.showTypes', (event, taskElement) => this.openShowTypesModal(taskElement));
eventBus.on('bmp.showMethod', (event, methodElement) => this.openMethodInfoModal(methodElement));
if (this.bmProcess) {
this.loadBmProcess(this.bmProcess);
......@@ -97,9 +97,9 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
);
}
openShowCategoriesModal(taskElement) {
openShowTypesModal(taskElement) {
this.modalElement = taskElement;
this.modalReference = this.modalService.open(this.showCategoriesModal, {size: 'lg'});
this.modalReference = this.modalService.open(this.showTypesModal, {size: 'lg'});
}
openDeleteProcessPatternModal(subProcessElement) {
......@@ -117,7 +117,7 @@ export class BmProcessDiagramComponent implements OnInit, AfterContentInit, OnDe
this.modalElement = taskElement;
const businessObject = taskElement.businessObject;
this.developmentMethodService.getValidDevelopmentMethods(
businessObject.get('neededCategory'), businessObject.get('forbiddenCategory')
businessObject.get('neededType'), businessObject.get('forbiddenType')
).then((developmentMethods) => {
this.validDevelopmentMethods = developmentMethods.docs;
if (developmentMethods.docs.length > 0) {
......
export default class CategoriesContextPad {
export default class BmProcessPatternsContextPad {
static $inject = [
'contextPad',
......@@ -12,12 +12,12 @@ export default class CategoriesContextPad {
getContextPadEntries(element) {
if (element.type === 'bpmn:Task') {
return {
'bmdl.categories': {
'bmdl.types': {
group: 'edit',
className: 'bpmn-icon-service',
title: 'Manage Categories',
title: 'Manage types',
action: {
click: () => this.eventBus.fire('bmdl.categories', element.businessObject),
click: () => this.eventBus.fire('bmdl.types', element.businessObject),
}
}
};
......
import PaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';
export default class BmProcessPaletteProvider extends PaletteProvider {
export default class BmProcessPatternsPaletteProvider extends PaletteProvider {
getPaletteEntries(element) {
const actionNames = [
......
import ReplaceMenuProvider from 'bpmn-js/lib/features/popup-menu/ReplaceMenuProvider';
export default class CategoriesReplaceMenuProvider extends ReplaceMenuProvider {
export default class BmProcessPatternsReplaceMenuProvider extends ReplaceMenuProvider {
_createEntries(element, replaceOptions) {
replaceOptions = replaceOptions.filter((option) => option.target.type !== 'bpmn:SubProcess');
......
import CategoriesContextPad from './CategoriesContextPad';
import CategoriesPaletteProvider from './CategoriesPaletteProvider';
import CategoriesReplaceMenuProvider from './CategoriesReplaceMenuProvider';
import BmProcessPatternsContextPad from './BmProcessPatternsContextPad';
import BmProcessPatternsPaletteProvider from './BmProcessPatternsPaletteProvider';
import BmProcessPatternsReplaceMenuProvider from './BmProcessPatternsReplaceMenuProvider';
import ContextPadModule from 'diagram-js/lib/features/context-pad';
import CoreModule from 'bpmn-js/lib/core';
import ModelingModule from 'bpmn-js/lib/features/modeling';
......@@ -8,8 +8,8 @@ import PaletteModule from 'bpmn-js/lib/features/palette';
export default {
__depends__: [ContextPadModule, CoreModule, ModelingModule, PaletteModule],
__init__: ['categoriesContextPad', 'paletteProvider', 'replaceMenuProvider'],
categoriesContextPad: ['type', CategoriesContextPad],
paletteProvider: ['type', CategoriesPaletteProvider],
replaceMenuProvider: ['type', CategoriesReplaceMenuProvider],
__init__: ['bmProcessPatternsContextPad', 'paletteProvider', 'replaceMenuProvider'],
bmProcessPatternsContextPad: ['type', BmProcessPatternsContextPad],
paletteProvider: ['type', BmProcessPatternsPaletteProvider],
replaceMenuProvider: ['type', BmProcessPatternsReplaceMenuProvider],
};
......@@ -34,12 +34,12 @@ export default class BmProcessContextPadProvider {
};
}
if (is(element, 'bpmn:Task')) {
controls['bmp.showCategories'] = {
controls['bmp.showTypes'] = {
group: 'edit',
className: 'bpmn-icon-service',
title: 'Show categories',
title: 'Show types',
action: {
click: () => this.eventBus.fire('bmp.showCategories', element),
click: () => this.eventBus.fire('bmp.showTypes', element),
}
};
controls['bmp.selectMethod'] = {
......
......@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import BpmnModeler from 'bpmn-js/lib/Modeler';
import bmProcess from './bpmn-extensions/bm-process';
import categories from './bpmn-extensions/categories';
import bmProcessPatterns from './bpmn-extensions/bm-process-patterns';
import bmdl from '../assets/bpmn_bmdl.json';
import { is } from 'bpmn-js/lib/util/ModelUtil';
import { center } from 'diagram-js/lib/util/PositionUtil';
......@@ -22,7 +22,7 @@ export class BpmnService {
getBpmnModeler(): BpmnModeler {
return new BpmnModeler({
additionalModules: [
categories,
bmProcessPatterns,
],
moddleExtensions: {
bmdl,
......
......@@ -24,14 +24,17 @@ export class DevelopmentMethodService {
}
/**
* Get a list of development methods that have the needed categories, but not the forbidden ones.
* Get a list of development methods that have the needed types, but not the forbidden ones.
*
* @param needed needed types
* @param forbidden forbidden types
*/
getValidDevelopmentMethods(needed: string[], forbidden: string[]) {
return this.pouchdbService.find<DevelopmentMethod>(DevelopmentMethod.typeName, {
selector: {
$and: [
{
categories: {
types: {
$elemMatch: {
$in: needed,
}
......@@ -39,7 +42,7 @@ export class DevelopmentMethodService {
},
{
$not: {
categories: {
types: {
$elemMatch: {
$in: forbidden,
}
......
......@@ -7,10 +7,10 @@
<main *ngIf="developmentMethod" role="main" class="container">
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0">Development Method Categories</h6>
<h6 class="border-bottom border-gray pb-2 mb-0">Development Method Types</h6>
<div class="text-muted pt-3">
<app-categories-form [categories]="developmentMethod.categories"
(submitCategoriesForm)="updateDevelopmentMethod($event)"></app-categories-form>
<app-types-form [types]="developmentMethod.types"
(submitTypesForm)="updateDevelopmentMethod($event)"></app-types-form>
</div>
</div>
......
import { DevelopmentMethodComponent } from './development-method.component';
import { createRoutingFactory, Spectator } from '@ngneat/spectator';
import { MockComponent } from 'ng-mocks';
import { CategoriesFormComponent } from '../categories-form/categories-form.component';
import { TypesFormComponent } from '../types-form/types-form.component';
import { AuthorFormComponent } from '../author-form/author-form.component';
import { DescriptionFormComponent } from '../description-form/description-form.component';
......@@ -11,7 +11,7 @@ describe('DevelopmentMethodComponent', () => {
component: DevelopmentMethodComponent,
declarations: [
MockComponent(AuthorFormComponent),
MockComponent(CategoriesFormComponent),
MockComponent(TypesFormComponent),
MockComponent(DescriptionFormComponent),
],
});
......
......@@ -9,7 +9,7 @@ export class DevelopmentMethod extends PouchdbModel {
description: string;
author: Author;
categories: string[] = [];
types: string[] = [];
constructor(developmentMethod: Partial<DevelopmentMethod>) {
super(DevelopmentMethod.typeName);
......@@ -41,7 +41,7 @@ export class DevelopmentMethod extends PouchdbModel {
name: this.name,
description: this.description,
author: this.author.toPouchDb(),
categories: this.categories,
types: this.types,
};
}
......
<form [formGroup]="categoriesForm" (ngSubmit)="submitForm()">
<ng-container formArrayName="neededCategory">
<app-form-array-list elementName="Needed Category" [formArray]="neededCategoryFormArray"></app-form-array-list>
</ng-container>
<ng-container formArrayName="forbiddenCategory">
<app-form-array-list elementName="Forbidden Category"
[formArray]="forbiddenCategoryFormArray"></app-form-array-list>
</ng-container>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-dark btn-block" [disabled]="!categoriesForm.valid">
Update Categories
</button>
</div>
</div>
</form>
import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
import { FormArray, FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-process-pattern-categories-form',
templateUrl: './process-pattern-categories-form.component.html',
styleUrls: ['./process-pattern-categories-form.component.css']
})
export class ProcessPatternCategoriesFormComponent implements OnChanges {
@Input() categories: {
neededCategory: string[],
forbiddenCategory: string[],
};
@Output() submitCategoriesForm = new EventEmitter<FormGroup>();
categoriesForm: FormGroup = this.fb.group({
neededCategory: this.fb.array([]),
forbiddenCategory: this.fb.array([]),
});
constructor(
private fb: FormBuilder,
) {
}
ngOnChanges(changes: SimpleChanges) {
if (changes.categories) {
this.loadForm(changes.categories.currentValue);
}
}
submitForm() {
this.submitCategoriesForm.emit(this.categoriesForm);
}
get neededCategoryFormArray() {
return this.categoriesForm.get('neededCategory') as FormArray;
}
get forbiddenCategoryFormArray() {
return this.categoriesForm.get('forbiddenCategory') as FormArray;
}
private loadForm(categories: { neededCategory: string[], forbiddenCategory: string[] }) {
this.categoriesForm.setControl(
'neededCategory', this.fb.array(categories.neededCategory.map((category) => this.fb.control(category, Validators.required)))
);
this.categoriesForm.setControl(
'forbiddenCategory', this.fb.array(categories.forbiddenCategory.map((category) => this.fb.control(category, Validators.required)))
);
}
}
<ng-template #manageCategoriesModal let-d="dismiss">
<ng-template #manageTypesModal let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Manage categories of task {{ modalTask.name }}</h4>
<h4 class="modal-title">Manage types of task {{ modalTask.name }}</h4>
<button type="button" class="close" aria-label="Close" (click)="d()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="text-muted pt-3">
<app-process-pattern-categories-form [categories]="modalTask"
(submitCategoriesForm)="updateCategories($event)"></app-process-pattern-categories-form>
<app-process-pattern-types-form [types]="modalTask"
(submitTypesForm)="updateTypes($event)"></app-process-pattern-types-form>
</div>
</div>
</ng-template>
......
import { ProcessPatternDiagramComponent } from './process-pattern-diagram.component';
import { createComponentFactory, Spectator } from '@ngneat/spectator';
import { MockComponent } from 'ng-mocks';
import { ProcessPatternCategoriesFormComponent } from '../process-pattern-categories-form/process-pattern-categories-form.component';
import { ProcessPatternTypesFormComponent } from '../process-pattern-types-form/process-pattern-types-form.component';
import { ReactiveFormsModule } from '@angular/forms';
describe('ProcessPatternDiagramComponent', () => {
......@@ -9,7 +9,7 @@ describe('ProcessPatternDiagramComponent', () => {
const createComponent = createComponentFactory({
component: ProcessPatternDiagramComponent,
declarations: [
MockComponent(ProcessPatternCategoriesFormComponent),
MockComponent(ProcessPatternTypesFormComponent),
],
imports: [ReactiveFormsModule],
});
......
......@@ -34,13 +34,13 @@ export class ProcessPatternDiagramComponent implements OnInit, AfterContentInit,
modalTask: {
id: string,
name: string,
neededCategory: string[],
forbiddenCategory: string[],
neededType: string[],
forbiddenType: string[],
};
private modalReference: NgbModalRef;
@ViewChild('canvas', {static: true}) canvas: ElementRef<HTMLDivElement>;
@ViewChild('manageCategoriesModal', {static: true}) manageCategoriesModal: any;
@ViewChild('manageTypesModal', {static: true}) manageTypesModal: any;
constructor(
private bpmnService: BpmnService,
......@@ -51,7 +51,7 @@ export class ProcessPatternDiagramComponent implements OnInit, AfterContentInit,
ngOnInit() {
this.modeler = this.bpmnService.getBpmnModeler();
this.modeler.get('eventBus').on('bmdl.categories', (event, businessTask) => this.openManageCategoriesModal(businessTask));
this.modeler.get('eventBus').on('bmdl.types', (event, businessTask) => this.openManageTypesModal(businessTask));
if (this.processPattern) {
this.loadProcessPattern(this.processPattern);
}
......@@ -77,20 +77,20 @@ export class ProcessPatternDiagramComponent implements OnInit, AfterContentInit,
);
}
openManageCategoriesModal(businessTask) {
openManageTypesModal(businessTask) {
this.modalTask = {
id: businessTask.id,
name: businessTask.name,
neededCategory: businessTask.get('neededCategory') || [],
forbiddenCategory: businessTask.get('forbiddenCategory') || [],
neededType: businessTask.get('neededType') || [],
forbiddenType: businessTask.get('forbiddenType') || [],
};
this.modalReference = this.modalService.open(this.manageCategoriesModal, {size: 'lg'});
this.modalReference = this.modalService.open(this.manageTypesModal, {size: 'lg'});
}
updateCategories(categoriesForm: FormGroup) {
updateTypes(typesForm: FormGroup) {
const modeling = this.modeler.get('modeling');
const elementRegistry = this.modeler.get('elementRegistry');
modeling.updateProperties(elementRegistry.get(this.modalTask.id), categoriesForm.value);
modeling.updateProperties(elementRegistry.get(this.modalTask.id), typesForm.value);
this.modalReference.close();
this.save();
}
......
<form [formGroup]="typesForm" (ngSubmit)="submitForm()">
<ng-container formArrayName="neededType">
<app-form-array-list elementName="Needed Type" [formArray]="neededTypeFormArray"></app-form-array-list>
</ng-container>
<ng-container formArrayName="forbiddenType">
<app-form-array-list elementName="Forbidden Type"
[formArray]="forbiddenTypeFormArray"></app-form-array-list>
</ng-container>
<div class="form-group row">
<div class="col-sm-12">
<button type="submit" class="btn btn-dark btn-block" [disabled]="!typesForm.valid">
Update Types
</button>
</div>
</div>
</form>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment