[英]Is it possible to have custom connectors in AlloyUI
AlloyUI newbie here and I guess am having trouble with something very basic of the YUI framework. AlloyUI新手在这里,我想在使用YUI框架的一些基本知识时会遇到麻烦。 Am using AlloyUI 3.0.1, which still uses YUI and AngularJS.
我正在使用AlloyUI 3.0.1,但仍使用YUI和AngularJS。
Question is: Is there a way to create custom connectors on a 'per-custom-node' basis in AlloyUI? 问题是:是否有一种方法可以在AlloyUI中基于“每个自定义节点”创建自定义连接器?
The goal is to be able to have different custom connectors (with set of separate custom attributes) for each custom nodes. 目标是能够为每个定制节点具有不同的定制连接器(具有一组单独的定制属性)。 For example, lets say I have 2 custom nodes A and B and I want nodes A - A to be connected using one type of custom connecter and B - B using another.
例如,假设我有2个自定义节点A和B,并且我希望节点A-A使用一种类型的自定义连接器进行连接,而B-B使用另一种类型的连接器进行连接。 Is this possible?
这可能吗?
I am able to create custom nodes with custom properties etc. like so: 我能够使用自定义属性等创建自定义节点,如下所示:
service.getScriptContainer = function(Y) {
var scriptContainer = Y.Component.create({
NAME: 'diagram-node',
ATTRS: {
//..custom properies,
connectors : {
valueFn : function(){
return ConnectorFactory.getScriptConnector(Y);
}
}
},
EXTENDS: Y.DiagramNodeTask,
prototype: {
.....
}
where ConnectorFactory is an AngularJS factory that returns an object of type: 'A.Connector'. 其中ConnectorFactory是AngularJS工厂,它返回类型为'A.Connector'的对象。
When I use this, I am able to drag and drop the custom node on the canvas, but as soon as I try to use a connector on it to connect to another node, I get an error in the console saying: 使用此功能时,我可以将自定义节点拖放到画布上,但是当我尝试在其上使用连接器连接到另一个节点时,控制台中出现错误:
Uncaught TypeError: undefined is not a function at line 920: aui-diagram-node.js
which is: 这是:
return instance.get('connectors').has(transition.uid);
.. and this is where am getting lost. ..这就是迷路的地方。
Can I extend 'A.connector' and use it on a 'per-custom-node' basis? 我可以扩展“ A.connector”并在“每个自定义节点”的基础上使用它吗? If so, how?
如果是这样,怎么办?
Any help is appreciated! 任何帮助表示赞赏!
Thanks. 谢谢。
I think I have at least direction you should investigate (if not the answer): 我认为至少我应该指导您进行调查(如果没有答案):
you can (re)write your own aui-diagram-builder-connector.js and "replace/hijack old one" via applyConfig - something like this: 您可以(重新)编写自己的aui-diagram-builder-connector.js并通过applyConfig“替换/劫持旧版本”-类似这样:
YUI().use('aui-diagram-builder', function(Y) {
/* your code */
}).applyConfig({ /* her we "hijack" default aui-diagram-builder-connector file */
modules: {
"aui-diagram-builder-connector": {
fullpath: '/js/aui-diagram-builder-connector-mine.js' /* use relative path and minified version if possible */
}
}
});
This will load new file for built-in required module, so you have maximum freedom while keeping old file untouched :) 这将为内置的必需模块加载新文件,因此您在保持旧文件不变的同时拥有最大的自由度:)
This one saved me once and I hope it will save somebody else too :D 这一次救了我一次,我希望它也可以救别人:D
Took me whole day to find it :( 花了我一整天才找到它:(
I tested this but the cpied /js/aui-diagram-builder-connector-mine.js is never loaded or used in the DiagramBuilder. 我对此进行了测试,但是在DiagramBuilder中从未加载或使用cpied /js/aui-diagram-builder-connector-mine.js。
best regards 最好的祝福
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.