Coverage for gws-app/gws/plugin/select_tool/action.py: 0%

26 statements  

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

1"""The ``select`` action.""" 

2 

3from typing import Optional 

4 

5import gws 

6import gws.base.action 

7import gws.base.web 

8import gws.base.storage 

9import gws.lib.uom 

10 

11 

12@gws.ext.config.action('select') 

13class Config(gws.base.action.Config): 

14 """Action for selecting features on the map.""" 

15 

16 storage: Optional[gws.base.storage.Config] 

17 """Storage for saving and loading selections.""" 

18 tolerance: Optional[gws.UomValueStr] 

19 """Click tolerance for feature selection.""" 

20 

21 

22@gws.ext.props.action('select') 

23class Props(gws.base.action.Props): 

24 storage: gws.base.storage.Props 

25 tolerance: str 

26 

27 

28@gws.ext.object.action('select') 

29class Object(gws.base.action.Object): 

30 """Action for the feature selection tool.""" 

31 

32 storage: Optional[gws.base.storage.Object] 

33 """Storage for saved selections, if configured.""" 

34 tolerance: Optional[gws.UomValue] 

35 """Click tolerance for feature selection.""" 

36 

37 def configure(self): 

38 self.storage = self.create_child_if_configured( 

39 gws.base.storage.Object, self.cfg('storage'), categoryName='Select') 

40 self.tolerance = self.cfg('tolerance') 

41 

42 def props(self, user): 

43 return gws.u.merge( 

44 super().props(user), 

45 storage=self.storage, 

46 tolerance=gws.lib.uom.to_str(self.tolerance) if self.tolerance else None, 

47 ) 

48 

49 @gws.ext.command.api('selectStorage') 

50 def handle_storage(self, req: gws.WebRequester, p: gws.base.storage.Request) -> gws.base.storage.Response: 

51 """Read or write saved selections.""" 

52 if not self.storage: 

53 raise gws.NotFoundError('no storage configured') 

54 return self.storage.handle_request(req, p)