-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5ff290
commit 03f958e
Showing
4 changed files
with
52 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,65 @@ | ||
import { getExtensionElementsList } from '../../util/ExtensionElementsUtil'; | ||
|
||
import { createElement } from '../../util/ElementUtil'; | ||
|
||
import { | ||
getBusinessObject, | ||
is | ||
} from 'bpmn-js/lib/util/ModelUtil'; | ||
|
||
import { getPrefixedId } from '../../util/IdsUtil'; | ||
|
||
import { find } from 'min-dash'; | ||
import { getExtensionElementsList } from '../../util/ExtensionElementsUtil'; | ||
|
||
const USER_TASK_FORM_PREFIX = 'UserTaskForm_'; | ||
const FORM_KEY_PREFIX = 'camunda-forms:bpmn:', | ||
USER_TASK_FORM_ID_PREFIX = 'UserTaskForm_'; | ||
|
||
export function getFormDefinition(element) { | ||
const businessObject = getBusinessObject(element); | ||
|
||
export function createFormDefinition(properties, extensionElements, bpmnFactory) { | ||
return createElement( | ||
'zeebe:FormDefinition', | ||
properties, | ||
extensionElements, | ||
bpmnFactory | ||
); | ||
} | ||
const formDefinitions = getExtensionElementsList(businessObject, 'zeebe:FormDefinition'); | ||
|
||
export function createFormId() { | ||
return getPrefixedId(USER_TASK_FORM_PREFIX); | ||
return formDefinitions[ 0 ]; | ||
} | ||
|
||
export function createFormKey(formId) { | ||
return `camunda-forms:bpmn:${ formId }`; | ||
} | ||
export function getUserTaskForm(element, rootElement) { | ||
rootElement = rootElement || getRootElement(element); | ||
|
||
export function createUserTaskForm(properties, extensionElements, bpmnFactory) { | ||
return createElement( | ||
'zeebe:UserTaskForm', | ||
properties, | ||
extensionElements, | ||
bpmnFactory | ||
); | ||
} | ||
const formDefinition = getFormDefinition(element); | ||
|
||
function findUserTaskForm(formKey, rootElement) { | ||
const userTaskForms = getExtensionElementsList(rootElement, 'zeebe:UserTaskForm'); | ||
if (!formDefinition) { | ||
return; | ||
} | ||
|
||
const formKey = formDefinition.get('formKey'); | ||
|
||
return find(userTaskForms, (userTaskForm) => { | ||
const id = userTaskForm.get('zeebe:id'); | ||
const userTaskForms = getExtensionElementsList(rootElement, 'zeebe:UserTaskForm'); | ||
|
||
return createFormKey(id) === formKey; | ||
return userTaskForms.find(userTaskForm => { | ||
return userTaskFormIdToFormKey(userTaskForm.get('id')) === formKey; | ||
}); | ||
} | ||
|
||
export function getFormDefinition(element) { | ||
const businessObject = getBusinessObject(element); | ||
|
||
const formDefinitions = getExtensionElementsList(businessObject, 'zeebe:FormDefinition'); | ||
|
||
return formDefinitions[ 0 ]; | ||
export function userTaskFormIdToFormKey(userTaskFormId) { | ||
return `${ FORM_KEY_PREFIX }${ userTaskFormId }`; | ||
} | ||
|
||
function getRootElement(element) { | ||
var businessObject = getBusinessObject(element), | ||
parent = businessObject; | ||
export function formKeyToUserTaskFormId(formKey) { | ||
return formKey.replace(FORM_KEY_PREFIX, ''); | ||
} | ||
|
||
while (parent.$parent && !is(parent, 'bpmn:Process')) { | ||
parent = parent.$parent; | ||
} | ||
export function isUserTaskFormKey(formKey) { | ||
return formKey.startsWith(FORM_KEY_PREFIX); | ||
} | ||
|
||
return parent; | ||
export function createUserTaskFormId() { | ||
return getPrefixedId(USER_TASK_FORM_ID_PREFIX); | ||
} | ||
|
||
export function getUserTaskForm(element, parent) { | ||
const rootElement = parent || getRootElement(element); | ||
export function getRootElement(element) { | ||
const businessObject = getBusinessObject(element); | ||
|
||
const formDefinition = getFormDefinition(element); | ||
let parent = businessObject; | ||
|
||
if (!formDefinition) { | ||
return; | ||
while (parent.$parent && !is(parent, 'bpmn:Process')) { | ||
parent = parent.$parent; | ||
} | ||
|
||
const formKey = formDefinition.get('zeebe:formKey'); | ||
|
||
return findUserTaskForm(formKey, rootElement); | ||
return parent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters