Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from config import Config as C, Names as N 

2from control.html import HtmlElements as H 

3from control.utils import pick as G, E, NBSP 

4from control.typ.value import Value 

5 

6 

7CW = C.web 

8 

9Qq = H.icon(CW.unknown[N.generic], asChar=True) 

10QQ = H.icon(CW.unknown[N.generic]) 

11Qn = H.icon(CW.unknown[N.number], asChar=True) 

12Qc = H.icon(CW.unknown[N.country], asChar=True) 

13 

14 

15class Decision(Value): 

16 """Type class for decisions.""" 

17 

18 def __init__(self, context): 

19 super().__init__(context) 

20 

21 def titleStr(self, record, markup=True): 

22 """The title string is a suitable icon plus the participle field.""" 

23 decision = G(record, N.participle) 

24 if decision is None: 24 ↛ 25line 24 didn't jump to line 25, because the condition on line 24 was never true

25 return E if markup is None else Qq 

26 sign = G(record, N.sign) or E 

27 decision = ( 

28 f"""{sign} {decision}""" 

29 if markup is None 

30 else f"""{sign}{NBSP}{decision}""" 

31 ) 

32 return decision 

33 

34 def title( 

35 self, 

36 eid=None, 

37 record=None, 

38 markup=False, 

39 clickable=False, 

40 active=None, 

41 **kwargs, 

42 ): 

43 """Generate a custom title. 

44 

45 Parameters 

46 ---------- 

47 record: dict, optional, `None` 

48 eid: ObjectId, optional, `None` 

49 markup: boolean, optional, `False` 

50 clickable: boolean, optional, `False` 

51 If `True`, the title will be represented as a workflow task, 

52 otherwise as a workflow stage. 

53 active: string, optional, `None` 

54 **kwargs: dict 

55 Possible remaining parameters that might have been passed but are not 

56 relevant for this class. 

57 

58 Returns 

59 ------- 

60 string(html?) 

61 The title, possibly wrapped in HTML 

62 """ 

63 

64 if record is None and eid is None: 64 ↛ 65line 64 didn't jump to line 65, because the condition on line 64 was never true

65 return None if markup is None else (QQ, QQ) if markup else Qq 

66 

67 if record is None: 67 ↛ 68line 67 didn't jump to line 68, because the condition on line 67 was never true

68 context = self.context 

69 table = self.name 

70 record = context.getItem(table, eid) 

71 

72 titleStr = self.titleStr(record, markup=markup) 

73 titleHint = self.titleHint(record) 

74 

75 if markup: 75 ↛ 76line 75 didn't jump to line 76, because the condition on line 75 was never true

76 if eid is None: 

77 eid = G(record, N._id) 

78 

79 isActive = eid == active 

80 baseCls = "task" if clickable else "status" 

81 activeCls = "active " if isActive else E 

82 extraCls = G(record, N.acro) 

83 inActualCls = self.inActualCls(record) 

84 atts = dict(cls=f"{baseCls} {extraCls} {activeCls} large {inActualCls}") 

85 if clickable and eid is not None: 

86 atts[N.eid] = str(eid) 

87 

88 if titleHint: 

89 atts[N.title] = titleHint 

90 

91 titleFormatted = H.span(titleStr, lab=titleStr.lower(), **atts) 

92 return (titleStr, titleFormatted) 

93 else: 

94 return titleStr