Coverage for gws-app/gws/plugin/model_widget/feature_select/__init__.py: 92%

12 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Feature select widget. 

2 

3Drop-down list for choosing the related feature of a ``relatedFeature`` 

4field, optionally with a search field. This is the default widget of 

5``relatedFeature`` fields. 

6 

7Example:: 

8 

9 fields+ { 

10 name "category" 

11 type "relatedFeature" 

12 fromColumn "category_id" 

13 toModel "model_category" 

14 widget { type "featureSelect" withSearch true } 

15 } 

16""" 

17 

18import gws 

19import gws.base.model.widget 

20 

21 

22@gws.ext.config.modelWidget('featureSelect') 

23class Config(gws.base.model.widget.Config): 

24 """Drop-down list for choosing a related feature.""" 

25 

26 withSearch: bool = False 

27 """Show a search field to filter the list.""" 

28 

29 

30@gws.ext.props.modelWidget('featureSelect') 

31class Props(gws.base.model.widget.Props): 

32 withSearch: bool 

33 

34 

35@gws.ext.object.modelWidget('featureSelect') 

36class Object(gws.base.model.widget.Object): 

37 """Feature select widget object.""" 

38 

39 def props(self, user): 

40 return gws.u.merge( 

41 super().props(user), 

42 withSearch=self.cfg('withSearch', default=False), 

43 )