Skip to content

Commit 9278603

Browse files
committed
Fixes from today's meeting
1 parent 1e3bc61 commit 9278603

File tree

4 files changed

+72
-29
lines changed

4 files changed

+72
-29
lines changed

deploy/index.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ indexes:
2626
- direction: desc
2727
name: creationdate
2828

29+
- kind: todo
30+
properties:
31+
- name: category
32+
- name: creationdate
33+
direction: desc
34+
35+
- kind: todo
36+
properties:
37+
- name: user.dest.__key__
38+
- name: creationdate
39+
direction: desc
40+
2941
- kind: viur-emails
3042
properties:
3143
- name: isSend

deploy/modules/todo.py

+45-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from viur.core.prototypes import List
2-
from viur.core import exposed, skey, access
2+
from viur.core import current, utils, exposed, skey, access
33
from viur.core.skeleton import RelSkel as ActionSkel # TODO: ActionSkel
44
from viur.core.bones import *
55

@@ -11,24 +11,36 @@ class Todo(List):
1111
"creationdate",
1212
"lastname",
1313
"firstname",
14+
"phone",
15+
"message",
1416
"user",
15-
"subject",
1617
),
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+
]
3244
}
3345

3446
default_order = {
@@ -65,7 +77,7 @@ class TodoAssignSkel(ActionSkel):
6577
descr="Todos",
6678
multiple=True,
6779
required=True,
68-
format="$(dest.lastname) - $(dest.subject)",
80+
format="$(dest.lastname) - $(dest.message)",
6981
refKeys={
7082
"lastname",
7183
"subject",
@@ -79,6 +91,10 @@ class TodoAssignSkel(ActionSkel):
7991

8092
action_skel = TodoAssignSkel()
8193

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+
8298
if not kwargs or not action_skel.fromClient(kwargs):
8399
# TODO: Provide generic render action skel
84100
return self.render.edit(action_skel, "assign")
@@ -88,12 +104,23 @@ class TodoAssignSkel(ActionSkel):
88104
for todo in action_skel["todo"]:
89105
skel = self.editSkel()
90106
skel.fromDB(todo["dest"]["key"])
107+
skel["status"] = "open"
91108
skel.setBoneValue("user", action_skel["user"]["dest"]["key"])
92109
skel.toDB()
93110

94111
# TODO: Provide generic render action success
95112
return self.render.editSuccess(action_skel, "assignSuccess")
96113

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+
97124

98125
Todo.html = True
99126
Todo.json = True

deploy/modules/user.py

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ class User(User):
1717
"orderby": "lastname",
1818
},
1919
}
20+
21+
22+
User.json = True

deploy/skeletons/todo.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class TodoSkel(skeleton.Skeleton):
88
"add": ["subject"],
99
}
1010

11+
# FIXME: viur-core
1112
creationdate = DateBone(
1213
descr="Erstellt am",
1314
readOnly=True,
@@ -25,25 +26,24 @@ class TodoSkel(skeleton.Skeleton):
2526
required=True,
2627
)
2728

28-
phone = PhoneBone(
29-
descr="Telefon",
30-
default_country_code="+49",
31-
)
32-
3329
category = SelectBone(
34-
descr="Kategorie",
30+
descr="Thema",
3531
defaultValue="question",
3632
required=True,
3733
values={
38-
"question": "Anfrage",
34+
"question": "Frage",
3935
"billing": "Abrechnung",
4036
"service": "Service",
4137
},
4238
)
4339

44-
subject = StringBone(
45-
descr="Thema",
46-
required=True,
40+
# LIVE (1)
41+
phone = PhoneBone(
42+
descr="Telefon",
43+
default_country_code="+49",
44+
params={
45+
"visibleIf": """ category == "service" """ # LIVE(2)
46+
}
4747
)
4848

4949
message = TextBone(
@@ -57,7 +57,8 @@ class TodoSkel(skeleton.Skeleton):
5757
required=True,
5858
defaultValue="open",
5959
values={
60-
"open": "Offen",
60+
"new": "Neu",
61+
"open": "Zugewiesen",
6162
"pending": "In Bearbeitung",
6263
"closed": "Geschlossen",
6364
},

0 commit comments

Comments
 (0)