feat: use Object.assign
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { assign, forEach, isArray } from '@vben/utils';
|
import { forEach, isArray } from '@vben/utils';
|
||||||
|
|
||||||
import { getChildLanes } from 'bpmn-js/lib/features/modeling/util/LaneUtil';
|
import { getChildLanes } from 'bpmn-js/lib/features/modeling/util/LaneUtil';
|
||||||
import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil';
|
import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil';
|
||||||
@@ -140,7 +140,9 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function appendStart(event, element) {
|
function appendStart(event, element) {
|
||||||
const shape = elementFactory.createShape(assign({ type }, options));
|
const shape = elementFactory.createShape(
|
||||||
|
Object.assign({ type }, options),
|
||||||
|
);
|
||||||
create.start(event, shape, {
|
create.start(event, shape, {
|
||||||
source: element,
|
source: element,
|
||||||
});
|
});
|
||||||
@@ -148,7 +150,9 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
|
|
||||||
const append = autoPlace
|
const append = autoPlace
|
||||||
? function (event, element) {
|
? function (event, element) {
|
||||||
const shape = elementFactory.createShape(assign({ type }, options));
|
const shape = elementFactory.createShape(
|
||||||
|
Object.assign({ type }, options),
|
||||||
|
);
|
||||||
|
|
||||||
autoPlace.append(element, shape);
|
autoPlace.append(element, shape);
|
||||||
}
|
}
|
||||||
@@ -182,7 +186,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
) {
|
) {
|
||||||
const childLanes = getChildLanes(element);
|
const childLanes = getChildLanes(element);
|
||||||
|
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'lane-insert-above': {
|
'lane-insert-above': {
|
||||||
group: 'lane-insert-above',
|
group: 'lane-insert-above',
|
||||||
className: 'bpmn-icon-lane-insert-above',
|
className: 'bpmn-icon-lane-insert-above',
|
||||||
@@ -197,7 +201,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
|
|
||||||
if (childLanes.length < 2) {
|
if (childLanes.length < 2) {
|
||||||
if (element.height >= 120) {
|
if (element.height >= 120) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'lane-divide-two': {
|
'lane-divide-two': {
|
||||||
group: 'lane-divide',
|
group: 'lane-divide',
|
||||||
className: 'bpmn-icon-lane-divide-two',
|
className: 'bpmn-icon-lane-divide-two',
|
||||||
@@ -210,7 +214,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (element.height >= 180) {
|
if (element.height >= 180) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'lane-divide-three': {
|
'lane-divide-three': {
|
||||||
group: 'lane-divide',
|
group: 'lane-divide',
|
||||||
className: 'bpmn-icon-lane-divide-three',
|
className: 'bpmn-icon-lane-divide-three',
|
||||||
@@ -223,7 +227,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'lane-insert-below': {
|
'lane-insert-below': {
|
||||||
group: 'lane-insert-below',
|
group: 'lane-insert-below',
|
||||||
className: 'bpmn-icon-lane-insert-below',
|
className: 'bpmn-icon-lane-insert-below',
|
||||||
@@ -239,7 +243,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
|
|
||||||
if (is(businessObject, 'bpmn:FlowNode')) {
|
if (is(businessObject, 'bpmn:FlowNode')) {
|
||||||
if (is(businessObject, 'bpmn:EventBasedGateway')) {
|
if (is(businessObject, 'bpmn:EventBasedGateway')) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'append.receive-task': appendAction(
|
'append.receive-task': appendAction(
|
||||||
'bpmn:ReceiveTask',
|
'bpmn:ReceiveTask',
|
||||||
'bpmn-icon-receive-task',
|
'bpmn-icon-receive-task',
|
||||||
@@ -277,7 +281,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
'bpmn:CompensateEventDefinition',
|
'bpmn:CompensateEventDefinition',
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'append.compensation-activity': appendAction(
|
'append.compensation-activity': appendAction(
|
||||||
'bpmn:Task',
|
'bpmn:Task',
|
||||||
'bpmn-icon-task',
|
'bpmn-icon-task',
|
||||||
@@ -297,7 +301,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
) &&
|
) &&
|
||||||
!isEventSubProcess(businessObject)
|
!isEventSubProcess(businessObject)
|
||||||
) {
|
) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'append.end-event': appendAction(
|
'append.end-event': appendAction(
|
||||||
'bpmn:EndEvent',
|
'bpmn:EndEvent',
|
||||||
'bpmn-icon-end-event-none',
|
'bpmn-icon-end-event-none',
|
||||||
@@ -324,14 +328,14 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
|
|
||||||
if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
|
if (!popupMenu.isEmpty(element, 'bpmn-replace')) {
|
||||||
// Replace menu entry
|
// Replace menu entry
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
replace: {
|
replace: {
|
||||||
group: 'edit',
|
group: 'edit',
|
||||||
className: 'bpmn-icon-screw-wrench',
|
className: 'bpmn-icon-screw-wrench',
|
||||||
title: '修改类型',
|
title: '修改类型',
|
||||||
action: {
|
action: {
|
||||||
click(event, element) {
|
click(event, element) {
|
||||||
const position = assign(getReplaceMenuPosition(element), {
|
const position = Object.assign(getReplaceMenuPosition(element), {
|
||||||
cursor: { x: event.x, y: event.y },
|
cursor: { x: event.x, y: event.y },
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -350,7 +354,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
'bpmn:DataStoreReference',
|
'bpmn:DataStoreReference',
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'append.text-annotation': appendAction(
|
'append.text-annotation': appendAction(
|
||||||
'bpmn:TextAnnotation',
|
'bpmn:TextAnnotation',
|
||||||
'bpmn-icon-text-annotation',
|
'bpmn-icon-text-annotation',
|
||||||
@@ -378,7 +382,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
'bpmn:DataStoreReference',
|
'bpmn:DataStoreReference',
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
connect: {
|
connect: {
|
||||||
group: 'connect',
|
group: 'connect',
|
||||||
className: 'bpmn-icon-connection-multi',
|
className: 'bpmn-icon-connection-multi',
|
||||||
@@ -392,7 +396,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is(businessObject, 'bpmn:Group')) {
|
if (is(businessObject, 'bpmn:Group')) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'append.text-annotation': appendAction(
|
'append.text-annotation': appendAction(
|
||||||
'bpmn:TextAnnotation',
|
'bpmn:TextAnnotation',
|
||||||
'bpmn-icon-text-annotation',
|
'bpmn-icon-text-annotation',
|
||||||
@@ -409,7 +413,7 @@ ContextPadProvider.prototype.getContextPadEntries = function (element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deleteAllowed) {
|
if (deleteAllowed) {
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
delete: {
|
delete: {
|
||||||
group: 'edit',
|
group: 'edit',
|
||||||
className: 'bpmn-icon-trash',
|
className: 'bpmn-icon-trash',
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { assign } from '@vben/utils';
|
|
||||||
|
|
||||||
import PaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';
|
import PaletteProvider from 'bpmn-js/lib/features/palette/PaletteProvider';
|
||||||
|
|
||||||
export default function CustomPalette(
|
export default function CustomPalette(
|
||||||
@@ -42,7 +40,9 @@ F.prototype.getPaletteEntries = function () {
|
|||||||
|
|
||||||
function createAction(type, group, className, title, options) {
|
function createAction(type, group, className, title, options) {
|
||||||
function createListener(event) {
|
function createListener(event) {
|
||||||
const shape = elementFactory.createShape(assign({ type }, options));
|
const shape = Object.assign(
|
||||||
|
elementFactory.createShape({ type }, options),
|
||||||
|
);
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
shape.businessObject.di.isExpanded = options.isExpanded;
|
shape.businessObject.di.isExpanded = options.isExpanded;
|
||||||
@@ -90,7 +90,7 @@ F.prototype.getPaletteEntries = function () {
|
|||||||
create.start(event, elementFactory.createParticipantShape());
|
create.start(event, elementFactory.createParticipantShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'hand-tool': {
|
'hand-tool': {
|
||||||
group: 'tools',
|
group: 'tools',
|
||||||
className: 'bpmn-icon-hand-tool',
|
className: 'bpmn-icon-hand-tool',
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { assign } from '@vben/utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A palette provider for BPMN 2.0 elements.
|
* A palette provider for BPMN 2.0 elements.
|
||||||
*/
|
*/
|
||||||
@@ -48,7 +46,9 @@ PaletteProvider.prototype.getPaletteEntries = function () {
|
|||||||
|
|
||||||
function createAction(type, group, className, title, options) {
|
function createAction(type, group, className, title, options) {
|
||||||
function createListener(event) {
|
function createListener(event) {
|
||||||
const shape = elementFactory.createShape(assign({ type }, options));
|
const shape = elementFactory.createShape(
|
||||||
|
Object.assign({ type }, options),
|
||||||
|
);
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
shape.businessObject.di.isExpanded = options.isExpanded;
|
shape.businessObject.di.isExpanded = options.isExpanded;
|
||||||
@@ -96,7 +96,7 @@ PaletteProvider.prototype.getPaletteEntries = function () {
|
|||||||
create.start(event, elementFactory.createParticipantShape());
|
create.start(event, elementFactory.createParticipantShape());
|
||||||
}
|
}
|
||||||
|
|
||||||
assign(actions, {
|
Object.assign(actions, {
|
||||||
'hand-tool': {
|
'hand-tool': {
|
||||||
group: 'tools',
|
group: 'tools',
|
||||||
className: 'bpmn-icon-hand-tool',
|
className: 'bpmn-icon-hand-tool',
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Button } from 'ant-design-vue';
|
import { Button } from 'ant-design-vue';
|
||||||
import { assign } from 'min-dash';
|
|
||||||
|
|
||||||
defineOptions({ name: 'MyProcessPalette' });
|
defineOptions({ name: 'MyProcessPalette' });
|
||||||
|
|
||||||
@@ -11,7 +10,7 @@ const addTask = (event: MouseEvent, options: any = {}) => {
|
|||||||
const create = bpmnInstances().modeler.get('create');
|
const create = bpmnInstances().modeler.get('create');
|
||||||
|
|
||||||
const shape = ElementFactory.createShape(
|
const shape = ElementFactory.createShape(
|
||||||
assign({ type: 'bpmn:UserTask' }, options),
|
Object.assign({ type: 'bpmn:UserTask' }, options),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
@@ -26,12 +25,6 @@ const addTask = (event: MouseEvent, options: any = {}) => {
|
|||||||
<Button type="primary" @click="addTask" @mousedown="addTask">
|
<Button type="primary" @click="addTask" @mousedown="addTask">
|
||||||
测试任务
|
测试任务
|
||||||
</Button>
|
</Button>
|
||||||
<div class="test-container" id="palette-container">1</div>
|
<div class="mt-4" id="palette-container">1</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.test-container {
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user