1
1
from viur .core .prototypes import List
2
- from viur .core import exposed , skey , access
2
+ from viur .core import current , utils , exposed , skey , access
3
3
from viur .core .skeleton import RelSkel as ActionSkel # TODO: ActionSkel
4
4
from viur .core .bones import *
5
5
@@ -11,24 +11,36 @@ class Todo(List):
11
11
"creationdate" ,
12
12
"lastname" ,
13
13
"firstname" ,
14
+ "phone" ,
15
+ "message" ,
14
16
"user" ,
15
- "subject" ,
16
17
),
17
- "actions" : ["assign" ],
18
- "customActions" : {
19
- "assign" : {
20
- "name" : "Zuweisen" , # button name
21
- "access" : ["todo-edit" , "root" ], # Who may trigger?
22
- "icon" : "person-plus-fill" , # button icon
23
- "variant" : "success" , # button color
24
- "outline" : True , # button outline style
25
- "action" : "action" , # ActionSkel
26
- "url" : "/{{module}}/assign" , # actionSkel initial url
27
- "enabled" : 'True' , # regel wann button aktiv "TRUE" === immer
28
- "show_label" : True , # button ohne label
29
- "target" : "popup" , # popup, tab
30
- },
31
- }
18
+ # LIVE (3)
19
+ "views" : [
20
+ {
21
+ "icon" : "chat-dots-fill" , # LIVE (4)
22
+ "name" : "Service - Neu" ,
23
+ "filter" : {
24
+ "category" : "service" ,
25
+ "status" : "new" ,
26
+ },
27
+ "actions" : ["assign" ],
28
+ "customActions" : { # LIVE(5)
29
+ "assign" : {
30
+ "name" : "Zuweisen" , # button name
31
+ "access" : ["todo-edit" , "root" ], # Who may trigger?
32
+ "icon" : "person-plus-fill" , # button icon
33
+ "variant" : "success" , # button color
34
+ "outline" : True , # button outline style
35
+ "action" : "action" , # ActionSkel
36
+ "url" : "/{{module}}/assign" , # actionSkel initial url
37
+ "enabled" : 'True' , # regel wann button aktiv "TRUE" === immer
38
+ "show_label" : True , # button ohne label
39
+ "target" : "popup" , # popup, tab
40
+ },
41
+ },
42
+ }
43
+ ]
32
44
}
33
45
34
46
default_order = {
@@ -65,7 +77,7 @@ class TodoAssignSkel(ActionSkel):
65
77
descr = "Todos" ,
66
78
multiple = True ,
67
79
required = True ,
68
- format = "$(dest.lastname) - $(dest.subject )" ,
80
+ format = "$(dest.lastname) - $(dest.message )" ,
69
81
refKeys = {
70
82
"lastname" ,
71
83
"subject" ,
@@ -79,6 +91,10 @@ class TodoAssignSkel(ActionSkel):
79
91
80
92
action_skel = TodoAssignSkel ()
81
93
94
+ if selected_keys := current .request .get ().context .get ("viur_selected_keys" ):
95
+ for key in selected_keys :
96
+ action_skel .setBoneValue ("todo" , key , append = True )
97
+
82
98
if not kwargs or not action_skel .fromClient (kwargs ):
83
99
# TODO: Provide generic render action skel
84
100
return self .render .edit (action_skel , "assign" )
@@ -88,12 +104,23 @@ class TodoAssignSkel(ActionSkel):
88
104
for todo in action_skel ["todo" ]:
89
105
skel = self .editSkel ()
90
106
skel .fromDB (todo ["dest" ]["key" ])
107
+ skel ["status" ] = "open"
91
108
skel .setBoneValue ("user" , action_skel ["user" ]["dest" ]["key" ])
92
109
skel .toDB ()
93
110
94
111
# TODO: Provide generic render action success
95
112
return self .render .editSuccess (action_skel , "assignSuccess" )
96
113
114
+ def listFilter (self , query ):
115
+ if query := super ().listFilter (query ):
116
+ if not utils .string .is_prefix (self .render .kind , "json.vi" ):
117
+ cuser = current .user .get ()
118
+ query .mergeExternalFilter ({
119
+ "user.dest.key" : cuser ["key" ],
120
+ })
121
+
122
+ return query
123
+
97
124
98
125
Todo .html = True
99
126
Todo .json = True
0 commit comments