Coverage for gws-app/gws/plugin/model_widget/feature_list/__init__.py: 95%
20 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Feature list widget.
3Shows the related features of a ``relatedFeatureList``,
4``relatedMultiFeatureList`` or ``relatedLinkedFeatureList`` field as a list.
5Buttons to create a new related feature, link an existing one, edit, unlink
6or delete the selected one can be turned on and off. This is the default
7widget of feature list fields.
9Example::
11 fields+ {
12 name "pois"
13 type "relatedFeatureList"
14 toModel "model_poi"
15 toColumn "category_id"
16 widget { type "featureList" withDeleteButton true }
17 }
18"""
20import gws
21import gws.base.model.widget
24@gws.ext.config.modelWidget('featureList')
25class Config(gws.base.model.widget.Config):
26 """List of related features."""
28 withNewButton: bool = True
29 """Show a button to create a new related feature."""
30 withLinkButton: bool = True
31 """Show a button to link an existing feature."""
32 withEditButton: bool = True
33 """Show a button to edit the selected feature."""
34 withUnlinkButton: bool = False
35 """Show a button to unlink the selected feature without deleting it."""
36 withDeleteButton: bool = False
37 """Show a button to delete the selected feature."""
40@gws.ext.props.modelWidget('featureList')
41class Props(gws.base.model.widget.Props):
42 withNewButton: bool
43 withLinkButton: bool
44 withEditButton: bool
45 withUnlinkButton: bool
46 withDeleteButton: bool
49@gws.ext.object.modelWidget('featureList')
50class Object(gws.base.model.widget.Object):
51 """Feature list widget object."""
53 def props(self, user):
54 return gws.u.merge(
55 super().props(user),
56 withNewButton=self.cfg('withNewButton', default=True),
57 withLinkButton=self.cfg('withLinkButton', default=True),
58 withEditButton=self.cfg('withEditButton', default=True),
59 withUnlinkButton=self.cfg('withUnlinkButton', default=False),
60 withDeleteButton=self.cfg('withDeleteButton', default=False),
61 )