提供一种通用且易用的关系小部件
项目描述
摘要
此立方体提供了一个通用但易用的小部件,可以将编辑的实体链接到多个其他实体,以执行特定的关系。它提供
一个可复选(取消复选)的关联实体列表
触发显示弹出窗口的机制,以显示关系的每个可能的目标实体类型
在弹出窗口中,最终用户可以
搜索(使用属性)要链接到编辑的实体
显示(在分页表中)并选择它们(使用每行表上的复选框)
创建一个要链接的新实体(可以禁用)
使用方法
为您的关系选择关系小部件
您可以使用以下两种机制之一来配置用户界面
要么 cubicweb.web.uihelper.FormConfig
from cubicweb.web import uihelper from cubes.relationwidget.views import RelationFacetWidget class MyEntityConfig(uihelper.FormConfig): etype = 'MyEntity' # Move `my_relation` into the attribute section: rels_as_attrs = ('my_relation', ) # Edit `my_relation` using RelationFacetWidget: widgets = dict( my_relation=RelationFacetWidget, )
或者直接通过 uicfg.autoform_field_kwarg
from cubicweb.web.views import uicfg from cubes.relationwidget.views import RelationFacetWidget # edit the relation as attribute. uicfg.autoform_section.tag_subject_of( ('MyEntity', 'my_relation', '*'), formtype=('main', 'muledit'), section='attributes') # add the RelationFacetWidget for `my_relation` uicfg.autoform_field_kwargs.tag_subject_of( ('MyEntity', 'my_relation', '*'), {'widget': RelationFacetWidget})
配置它(可选)
如果您想禁用将新实体链接到编辑实体的功能,您可以使用uicfg再次进行操作
对于单个关系,使用uicfg
uicfg.autoform_field_kwargs.tag_subject_of( ('MyEntity', 'my_relation', '*'), {'widget': RelationFacetWidget(no_creation_form=True)})
全局覆盖 SearchForRelatedEntitiesView.has_creation_form 以始终返回False
from cubes.relationwidget.view import SearchForRelatedEntitiesView class MySearchForRelatedEntitiesView(SearchForRelatedEntitiesView): @property def has_creation_from(self): return False def registration_callback(vreg): vreg.register_and_register(MySearchForRelatedEntitiesView, SearchForRelatedEntitiesView)
还有一个可用的 dialog_options 字典,可用于配置bootstrap模态窗口(请参阅https://bootstrap.ac.cn/javascript/#modals-options)
uicfg.autoform_field_kwargs.tag_subject_of( ('MyEntity', 'my_relation', '*'), {'widget': RelationFacetWidget(dialog_options={'keyboard': False})})
项目详情
下载文件
下载您平台对应的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
cubicweb-relationwidget-0.10.0.tar.gz (20.5 kB 查看哈希值)
构建分布
关闭
cubicweb-relationwidget-0.10.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9f30abcc42d1537eb360cbc20956d6a68b69ff82505ce0d033e0fccfd11557a7 |
|
MD5 | ee26f0a50c08fb287e13391f2318128c |
|
BLAKE2b-256 | b0cec0c0476b2670e4f78018253ac87631a67729ab739d4000ef487218d22012 |
关闭
cubicweb_relationwidget-0.10.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | a582903af208459b69355ea29750b3148a6fe62ae34ceeb5775f0363176b9776 |
|
MD5 | 0fcdea0f3407f7eff1984f1a3dc1cb86 |
|
BLAKE2b-256 | 8ede791768ede9a84daba9dd3cefcd3e1cec620b79a1a01966240abae0bcff2e |