Anonymous
Как я могу исправить эту ошибку не распознавать метод зависимости?
Сообщение
Anonymous » 20 фев 2025, 16:15
Я создаю модельер BPMN на основе библиотеки BPMNJS и BPMnio. Мой проект состоит в том, чтобы построить его с помощью пользовательских элементов. Но я не могу заставить этот конкретный класс работать.
у меня есть этот класс < /p>
Код: Выделить всё
import { assign, bind } from 'min-dash';
import { is } from 'bpmn-js/lib/util/ModelUtil';
import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil';
import { myConnectionElements, aggreagatedElements } from './Types';
import { isDifferentType } from 'bpmn-js/lib/features/popup-menu/util/TypeUtil';
import PPINOTModeling from './PPINOTModeling';
export default class PPINOTContextPadProvider extends ContextPadProvider {
constructor(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate, appendPreview) {
// Call the base provider constructor with the full parameter list.
super(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate, appendPreview);
// Store injected services.
this._contextPad = contextPad;
this._popupMenu = popupMenu;
this._canvas = canvas;
this._modeling = modeling;
this._elementFactory = elementFactory;
this._connect = connect;
this._create = create;
this._translate = translate;
this._config = config;
// Register this provider on the contextPad.
contextPad.registerProvider(this);
// Determine autoPlace if enabled.
let autoPlace = config.autoPlace;
if (autoPlace !== false) {
autoPlace = injector.get('autoPlace', false);
}
this._autoPlace = autoPlace;
// Cache the original getContextPadEntries binding, if any.
this._cachedGetContextPadEntries = bind(this.getContextPadEntries, this);
}
appendAction(type, className, title, options) {
if (typeof title !== 'string') {
options = title;
title = this._translate('Append {type}', { type: type.replace(/^bpmn:/, '') });
}
const elementFactory = this._elementFactory;
const create = this._create;
const autoPlace = this._autoPlace;
const appendStart = (event, element) => {
const shape = elementFactory.createShape(assign({ type: type }, options));
create.start(event, shape, { source: element });
};
const append = autoPlace
? (event, element) => {
const shape = elementFactory.createShape(assign({ type: type }, options));
autoPlace.append(element, shape);
}
: appendStart;
return {
group: 'model',
className: className,
title: title,
action: {
dragstart: appendStart,
click: autoPlace ? append : appendStart
}
};
}
appendConnectAction(type, className, title) {
if (typeof title !== 'string') {
title = this._translate('Append {type}', { type: type.replace(/^PPINOT:/, '') });
}
const connect = this._connect;
const elementFactory = this._elementFactory;
const connectStart = (event, element, autoActivate) => {
connect.PPINOTStart(event, element, type, elementFactory, autoActivate);
};
return {
group: 'connect',
className: className,
title: title,
action: {
dragstart: connectStart,
click: connectStart
}
};
}
getContextPadEntries(element) {
let actions = this._cachedGetContextPadEntries ? this._cachedGetContextPadEntries(element) : {};
const businessObject = element.businessObject;
if (isAny(businessObject, aggreagatedElements) && element.type !== 'label') {
assign(actions, {
'connect1': this.appendConnectAction(
'PPINOT:AggregatedConnection',
'icon-aggregates',
'Connect using aggregates connection'
),
'connect2': this.appendConnectAction(
'PPINOT:IsGroupedBy',
'icon-isGroupedBy',
'Connect using isGroupedBy connection'
)
});
}
if (
is(businessObject, 'PPINOT:StateConditionAggregatedMeasure') ||
is(businessObject, 'PPINOT:StateCondAggMeasureNumber') ||
is(businessObject, 'PPINOT:StateCondAggMeasurePercentage') ||
is(businessObject, 'PPINOT:StateCondAggMeasureAll') ||
is(businessObject, 'PPINOT:StateCondAggMeasureAtLeastOne') ||
is(businessObject, 'PPINOT:StateCondAggMeasureNo') ||
is(businessObject, 'PPINOT:StateConditionMeasure') ||
is(businessObject, 'PPINOT:CountMeasure') ||
is(businessObject, 'PPINOT:CountAggregatedMeasure') ||
is(businessObject, 'PPINOT:TimeMeasure') ||
is(businessObject, 'PPINOT:TimeAggregatedMeasure') ||
is(businessObject, 'PPINOT:DataMeasure') ||
is(businessObject, 'PPINOT:DataAggregatedMeasure')
) {
if (element.type !== 'label') {
assign(actions, {
'connect3': this.appendConnectAction(
'PPINOT:DashedLine',
'icon-dashed-line',
'Connect using dashed line'
)
});
}
}
if (
is(businessObject, 'PPINOT:TimeMeasure') ||
is(businessObject, 'PPINOT:TimeAggregatedMeasure') ||
is(businessObject, 'PPINOT:CyclicTimeMeasure') ||
is(businessObject, 'PPINOT:CyclicTimeMeasureSUM') ||
is(businessObject, 'PPINOT:CyclicTimeMeasureMAX') ||
is(businessObject, 'PPINOT:CyclicTimeMeasureMIN') ||
is(businessObject, 'PPINOT:CyclicTimeMeasureAVG') ||
is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasure') ||
is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureSUM') ||
is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureMAX') ||
is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureMIN') ||
is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureAVG')
) {
if (element.type !== 'label') {
assign(actions, {
'connect7': this.appendConnectAction(
'PPINOT:ToConnection',
'icon-toConnector',
'Connect using To connection'
),
'connect8': this.appendConnectAction(
'PPINOT:FromConnection',
'icon-fromConnector',
'Connect using From connection'
)
});
}
}
if (
is(businessObject, 'PPINOT:CountMeasure') ||
is(businessObject, 'PPINOT:CountAggregatedMeasure') ||
is(businessObject, 'PPINOT:CountAggregatedMeasureSUM') ||
is(businessObject, 'PPINOT:CountAggregatedMeasureMAX') ||
is(businessObject, 'PPINOT:CountAggregatedMeasureMIN') ||
is(businessObject, 'PPINOT:CountAggregatedMeasureAVG')
) {
if (element.type !== 'label') {
assign(actions, {
'connect10': this.appendConnectAction(
'PPINOT:StartConnection',
'icon-startConnector',
'Connect using Start connection'
),
'connect11': this.appendConnectAction(
'PPINOT:EndConnection',
'icon-endConnector',
'Connect using End connection'
)
});
}
}
if (is(businessObject, 'bpmn:DataObjectReference') && element.type !== 'label') {
assign(actions, {
'connect12': this.appendConnectAction(
'PPINOT:RFCStateConnection',
'icon-dashed-line',
'Connect using RFC state connection'
)
});
}
if (isAny(businessObject, myConnectionElements) && element.type !== 'label') {
assign(actions, {
'connect13': this.appendConnectAction(
'PPINOT:MyConnection',
'bpmn-icon-connection',
'Connection between PPINOT elements'
)
});
}
return actions;
}
}
PPINOTContextPadProvider.$inject = [
'config.contextPad',
'injector',
'eventBus',
'contextPad',
'modeling',
'elementFactory',
'connect',
'create',
'popupMenu',
'canvas',
'rules',
'translate',
'appendPreview'
];
< /code>
Но я продолжаю получать эту ошибку
Введите описание изображения здесь
Функция определена и существует. Он наследует от < /p>
**
* BPMN-specific context pad provider.
*
* @implements {BaseContextPadProvider}
*
*/
export default class ContextPadProvider implements BaseContextPadProvider {
static $inject: string[];
/**
* @param config
* @param injector
* @param eventBus
* @param contextPad
* @param modeling
* @param elementFactory
* @param connect
* @param create
* @param popupMenu
* @param canvas
* @param rules
* @param translate
* @param appendPreview
*/
constructor(config: ContextPadConfig, injector: Injector, eventBus: EventBus, contextPad: ContextPad, modeling: Modeling, elementFactory: ElementFactory, connect: Connect, create: Create, popupMenu: PopupMenu, canvas: Canvas, rules: Rules, translate: Translate, appendPreview: AppendPreview);
/**
* @param elements
*
* @return
*/
getMultiElementContextPadEntries(elements: Element[]): ContextPadEntries;
/**
* @param element
*
* @return
*/
getContextPadEntries(element: Element): ContextPadEntries;
}
type Injector = import("didi").Injector;
type EventBus = import("diagram-js/lib/core/EventBus").default;
type ContextPad = import("diagram-js/lib/features/context-pad/ContextPad").default;
type Modeling = import("../modeling/Modeling").default;
type ElementFactory = import("../modeling/ElementFactory").default;
type AppendPreview = import("../append-preview/AppendPreview").default;
type Connect = import("diagram-js/lib/features/connect/Connect").default;
type Create = import("diagram-js/lib/features/create/Create").default;
type PopupMenu = import("diagram-js/lib/features/popup-menu/PopupMenu").default;
export type Canvas = any;
type Rules = import("diagram-js/lib/features/rules/Rules").default;
export type Translate = typeof import("diagram-js/lib/i18n/translate/translate").default;
type Element = import("../../model/Types").Element;
type ModdleElement = import("../../model/Types").ModdleElement;
type BaseContextPadProvider = import("diagram-js/lib/features/context-pad/ContextPadProvider").default;
type ContextPadEntries = import("diagram-js/lib/features/context-pad/ContextPadProvider").ContextPadEntries;
type ContextPadEntry = import("diagram-js/lib/features/context-pad/ContextPadProvider").ContextPadEntry;
export type ContextPadConfig = {
autoPlace?: boolean;
};
< /code>
и с диаграммы js < /p>
import type { Element } from '../../model/Types';
import type { ContextPadTarget } from './ContextPad';
export type ContextPadEntryAction = (
event: Event,
target: ContextPadTarget,
autoActivate: boolean
) => any;
export type ContextPadEntry = {
action:
| Record
| ContextPadEntryAction;
className?: string;
group?: string;
html?: string;
imageUrl?: string;
title?: string;
};
export type ContextPadEntries = Record<
string,
ContextPadEntry
>;
export type ContextPadEntriesCallback = (
entries: ContextPadEntries
) => ContextPadEntries;
/**
* An interface to be implemented by a context menu provider.
*/
export default interface ContextPadProvider<
ElementType extends Element = Element
> {
/**
* Returns a map of entries or a function that receives, modifies and returns
* a map of entries for one element.
*
* The following example shows how to replace any entries returned by previous
* providers with one entry which alerts the ID of the given element when
* clicking on the entry.
*
* @example
*
* ```javascript
* getPopupMenuEntries(element) {
* return function(entries) {
* return {
* alert: {
* action: (event, target, autoActivate) => {
* alert(element.id);
* },
* className: 'alert',
* title: 'Alert element ID'
* }
* };
* };
* }
* ```
*
* @param element
*/
getContextPadEntries?: (
element: ElementType
) => ContextPadEntriesCallback | ContextPadEntries;
/**
* Returns a map of entries or a function that receives, modifies and returns
* a map of entries for many elements.
*
* The following example shows how to replace any entries returned by previous
* providers with one entry which alerts the IDs of the given elements when
* clicking on the entry.
*
* @example
*
* ```javascript
* getMultiElementContextPadEntries(elements) {
* return function(entries) {
* return {
* alert: {
* action: (event, target, autoActivate) => {
* elements.forEach(element => alert(element.id));
* },
* className: 'alert',
* title: 'Alert element IDs'
* }
* };
* }
* ```
*
* @param elements
*/
getMultiElementContextPadEntries?: (
elements: ElementType[]
) => ContextPadEntriesCallback | ContextPadEntries;
}
Я попытался выполнять функцию вместо класса и исправить функциональность, но не могу ее исправить.
Подробнее здесь:
https://stackoverflow.com/questions/794 ... dependency
1740057302
Anonymous
Я создаю модельер BPMN на основе библиотеки BPMNJS и BPMnio. Мой проект состоит в том, чтобы построить его с помощью пользовательских элементов. Но я не могу заставить этот конкретный класс работать. у меня есть этот класс < /p> [code]import { assign, bind } from 'min-dash'; import { is } from 'bpmn-js/lib/util/ModelUtil'; import { isAny } from 'bpmn-js/lib/features/modeling/util/ModelingUtil'; import { myConnectionElements, aggreagatedElements } from './Types'; import { isDifferentType } from 'bpmn-js/lib/features/popup-menu/util/TypeUtil'; import PPINOTModeling from './PPINOTModeling'; export default class PPINOTContextPadProvider extends ContextPadProvider { constructor(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate, appendPreview) { // Call the base provider constructor with the full parameter list. super(config, injector, eventBus, contextPad, modeling, elementFactory, connect, create, popupMenu, canvas, rules, translate, appendPreview); // Store injected services. this._contextPad = contextPad; this._popupMenu = popupMenu; this._canvas = canvas; this._modeling = modeling; this._elementFactory = elementFactory; this._connect = connect; this._create = create; this._translate = translate; this._config = config; // Register this provider on the contextPad. contextPad.registerProvider(this); // Determine autoPlace if enabled. let autoPlace = config.autoPlace; if (autoPlace !== false) { autoPlace = injector.get('autoPlace', false); } this._autoPlace = autoPlace; // Cache the original getContextPadEntries binding, if any. this._cachedGetContextPadEntries = bind(this.getContextPadEntries, this); } appendAction(type, className, title, options) { if (typeof title !== 'string') { options = title; title = this._translate('Append {type}', { type: type.replace(/^bpmn:/, '') }); } const elementFactory = this._elementFactory; const create = this._create; const autoPlace = this._autoPlace; const appendStart = (event, element) => { const shape = elementFactory.createShape(assign({ type: type }, options)); create.start(event, shape, { source: element }); }; const append = autoPlace ? (event, element) => { const shape = elementFactory.createShape(assign({ type: type }, options)); autoPlace.append(element, shape); } : appendStart; return { group: 'model', className: className, title: title, action: { dragstart: appendStart, click: autoPlace ? append : appendStart } }; } appendConnectAction(type, className, title) { if (typeof title !== 'string') { title = this._translate('Append {type}', { type: type.replace(/^PPINOT:/, '') }); } const connect = this._connect; const elementFactory = this._elementFactory; const connectStart = (event, element, autoActivate) => { connect.PPINOTStart(event, element, type, elementFactory, autoActivate); }; return { group: 'connect', className: className, title: title, action: { dragstart: connectStart, click: connectStart } }; } getContextPadEntries(element) { let actions = this._cachedGetContextPadEntries ? this._cachedGetContextPadEntries(element) : {}; const businessObject = element.businessObject; if (isAny(businessObject, aggreagatedElements) && element.type !== 'label') { assign(actions, { 'connect1': this.appendConnectAction( 'PPINOT:AggregatedConnection', 'icon-aggregates', 'Connect using aggregates connection' ), 'connect2': this.appendConnectAction( 'PPINOT:IsGroupedBy', 'icon-isGroupedBy', 'Connect using isGroupedBy connection' ) }); } if ( is(businessObject, 'PPINOT:StateConditionAggregatedMeasure') || is(businessObject, 'PPINOT:StateCondAggMeasureNumber') || is(businessObject, 'PPINOT:StateCondAggMeasurePercentage') || is(businessObject, 'PPINOT:StateCondAggMeasureAll') || is(businessObject, 'PPINOT:StateCondAggMeasureAtLeastOne') || is(businessObject, 'PPINOT:StateCondAggMeasureNo') || is(businessObject, 'PPINOT:StateConditionMeasure') || is(businessObject, 'PPINOT:CountMeasure') || is(businessObject, 'PPINOT:CountAggregatedMeasure') || is(businessObject, 'PPINOT:TimeMeasure') || is(businessObject, 'PPINOT:TimeAggregatedMeasure') || is(businessObject, 'PPINOT:DataMeasure') || is(businessObject, 'PPINOT:DataAggregatedMeasure') ) { if (element.type !== 'label') { assign(actions, { 'connect3': this.appendConnectAction( 'PPINOT:DashedLine', 'icon-dashed-line', 'Connect using dashed line' ) }); } } if ( is(businessObject, 'PPINOT:TimeMeasure') || is(businessObject, 'PPINOT:TimeAggregatedMeasure') || is(businessObject, 'PPINOT:CyclicTimeMeasure') || is(businessObject, 'PPINOT:CyclicTimeMeasureSUM') || is(businessObject, 'PPINOT:CyclicTimeMeasureMAX') || is(businessObject, 'PPINOT:CyclicTimeMeasureMIN') || is(businessObject, 'PPINOT:CyclicTimeMeasureAVG') || is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasure') || is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureSUM') || is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureMAX') || is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureMIN') || is(businessObject, 'PPINOT:CyclicTimeAggregatedMeasureAVG') ) { if (element.type !== 'label') { assign(actions, { 'connect7': this.appendConnectAction( 'PPINOT:ToConnection', 'icon-toConnector', 'Connect using To connection' ), 'connect8': this.appendConnectAction( 'PPINOT:FromConnection', 'icon-fromConnector', 'Connect using From connection' ) }); } } if ( is(businessObject, 'PPINOT:CountMeasure') || is(businessObject, 'PPINOT:CountAggregatedMeasure') || is(businessObject, 'PPINOT:CountAggregatedMeasureSUM') || is(businessObject, 'PPINOT:CountAggregatedMeasureMAX') || is(businessObject, 'PPINOT:CountAggregatedMeasureMIN') || is(businessObject, 'PPINOT:CountAggregatedMeasureAVG') ) { if (element.type !== 'label') { assign(actions, { 'connect10': this.appendConnectAction( 'PPINOT:StartConnection', 'icon-startConnector', 'Connect using Start connection' ), 'connect11': this.appendConnectAction( 'PPINOT:EndConnection', 'icon-endConnector', 'Connect using End connection' ) }); } } if (is(businessObject, 'bpmn:DataObjectReference') && element.type !== 'label') { assign(actions, { 'connect12': this.appendConnectAction( 'PPINOT:RFCStateConnection', 'icon-dashed-line', 'Connect using RFC state connection' ) }); } if (isAny(businessObject, myConnectionElements) && element.type !== 'label') { assign(actions, { 'connect13': this.appendConnectAction( 'PPINOT:MyConnection', 'bpmn-icon-connection', 'Connection between PPINOT elements' ) }); } return actions; } } PPINOTContextPadProvider.$inject = [ 'config.contextPad', 'injector', 'eventBus', 'contextPad', 'modeling', 'elementFactory', 'connect', 'create', 'popupMenu', 'canvas', 'rules', 'translate', 'appendPreview' ]; < /code> Но я продолжаю получать эту ошибку Введите описание изображения здесь Функция определена и существует. Он наследует от < /p> ** * BPMN-specific context pad provider. * * @implements {BaseContextPadProvider} * */ export default class ContextPadProvider implements BaseContextPadProvider { static $inject: string[]; /** * @param config * @param injector * @param eventBus * @param contextPad * @param modeling * @param elementFactory * @param connect * @param create * @param popupMenu * @param canvas * @param rules * @param translate * @param appendPreview */ constructor(config: ContextPadConfig, injector: Injector, eventBus: EventBus, contextPad: ContextPad, modeling: Modeling, elementFactory: ElementFactory, connect: Connect, create: Create, popupMenu: PopupMenu, canvas: Canvas, rules: Rules, translate: Translate, appendPreview: AppendPreview); /** * @param elements * * @return */ getMultiElementContextPadEntries(elements: Element[]): ContextPadEntries; /** * @param element * * @return */ getContextPadEntries(element: Element): ContextPadEntries; } type Injector = import("didi").Injector; type EventBus = import("diagram-js/lib/core/EventBus").default; type ContextPad = import("diagram-js/lib/features/context-pad/ContextPad").default; type Modeling = import("../modeling/Modeling").default; type ElementFactory = import("../modeling/ElementFactory").default; type AppendPreview = import("../append-preview/AppendPreview").default; type Connect = import("diagram-js/lib/features/connect/Connect").default; type Create = import("diagram-js/lib/features/create/Create").default; type PopupMenu = import("diagram-js/lib/features/popup-menu/PopupMenu").default; export type Canvas = any; type Rules = import("diagram-js/lib/features/rules/Rules").default; export type Translate = typeof import("diagram-js/lib/i18n/translate/translate").default; type Element = import("../../model/Types").Element; type ModdleElement = import("../../model/Types").ModdleElement; type BaseContextPadProvider = import("diagram-js/lib/features/context-pad/ContextPadProvider").default; type ContextPadEntries = import("diagram-js/lib/features/context-pad/ContextPadProvider").ContextPadEntries; type ContextPadEntry = import("diagram-js/lib/features/context-pad/ContextPadProvider").ContextPadEntry; export type ContextPadConfig = { autoPlace?: boolean; }; < /code> и с диаграммы js < /p> import type { Element } from '../../model/Types'; import type { ContextPadTarget } from './ContextPad'; export type ContextPadEntryAction = ( event: Event, target: ContextPadTarget, autoActivate: boolean ) => any; export type ContextPadEntry = { action: | Record | ContextPadEntryAction; className?: string; group?: string; html?: string; imageUrl?: string; title?: string; }; export type ContextPadEntries = Record< string, ContextPadEntry >; export type ContextPadEntriesCallback = ( entries: ContextPadEntries ) => ContextPadEntries; /** * An interface to be implemented by a context menu provider. */ export default interface ContextPadProvider< ElementType extends Element = Element > { /** * Returns a map of entries or a function that receives, modifies and returns * a map of entries for one element. * * The following example shows how to replace any entries returned by previous * providers with one entry which alerts the ID of the given element when * clicking on the entry. * * @example * * ```javascript * getPopupMenuEntries(element) { * return function(entries) { * return { * alert: { * action: (event, target, autoActivate) => { * alert(element.id); * }, * className: 'alert', * title: 'Alert element ID' * } * }; * }; * } * ``` * * @param element */ getContextPadEntries?: ( element: ElementType ) => ContextPadEntriesCallback | ContextPadEntries; /** * Returns a map of entries or a function that receives, modifies and returns * a map of entries for many elements. * * The following example shows how to replace any entries returned by previous * providers with one entry which alerts the IDs of the given elements when * clicking on the entry. * * @example * * ```javascript * getMultiElementContextPadEntries(elements) { * return function(entries) { * return { * alert: { * action: (event, target, autoActivate) => { * elements.forEach(element => alert(element.id)); * }, * className: 'alert', * title: 'Alert element IDs' * } * }; * } * ``` * * @param elements */ getMultiElementContextPadEntries?: ( elements: ElementType[] ) => ContextPadEntriesCallback | ContextPadEntries; } [/code] Я попытался выполнять функцию вместо класса и исправить функциональность, но не могу ее исправить. Подробнее здесь: [url]https://stackoverflow.com/questions/79454637/how-can-i-fix-this-error-of-not-recognising-a-method-of-a-dependency[/url]