-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
|
||
# 1) Phone | ||
|
||
```py | ||
phone = PhoneBone( | ||
descr="Telefon", | ||
default_country_code="+49", | ||
params={ | ||
"visibleIf": """ category == "service" """, | ||
}, | ||
) | ||
``` | ||
|
||
|
||
# 2) View | ||
|
||
```py | ||
"views": [ | ||
{ | ||
"name": "Service - Neu", | ||
"icon": "hammer", | ||
"filter": { | ||
"category": "service", | ||
"status": "new", | ||
}, | ||
} | ||
], | ||
``` | ||
|
||
# 3) Assign | ||
|
||
```py | ||
"views": [ | ||
{ | ||
"name": "Service - Neu", | ||
"icon": "hammer", | ||
"filter": { | ||
"category": "service", | ||
"status": "new", | ||
}, | ||
"actions": ["assign"], | ||
"customActions": { | ||
"assign": { | ||
"name": "Zuweisen", | ||
"access": ["todo-edit", "root"], | ||
"icon": "person-plus-fill", | ||
"variant": "success", | ||
"outline": True, | ||
"action": "action", | ||
"url": "/{{module}}/assign", | ||
"enabled": "True", | ||
"show_label": True, | ||
"target": "popup", | ||
}, | ||
}, | ||
} | ||
], | ||
|
||
|
||
@exposed | ||
@skey(allow_empty=True) | ||
@access("todo-edit") | ||
def assign(self, **kwargs): | ||
|
||
# ActionSkel for assigning multiple todos to one user | ||
class TodoAssignSkel(ActionSkel): | ||
todo = RelationalBone( | ||
kind="todo", | ||
descr="Todos", | ||
multiple=True, | ||
required=True, | ||
format="$(dest.lastname) - $(dest.message)", | ||
refKeys={ | ||
"lastname", | ||
"message", | ||
} | ||
) | ||
|
||
user = UserBone( | ||
descr="Zuweisen an", | ||
required=True, | ||
) | ||
|
||
action_skel = TodoAssignSkel() | ||
|
||
if selected_keys := current.request.get().context.get("viur_selected_keys"): | ||
if isinstance(selected_keys, str): | ||
selected_keys = selected_keys, | ||
|
||
for key in selected_keys: | ||
action_skel.setBoneValue("todo", key, append=True) | ||
|
||
if not kwargs or not action_skel.fromClient(kwargs): | ||
return self.render.render("assign", action_skel) | ||
|
||
for todo in action_skel["todo"]: | ||
self.editSkel().update( | ||
values={ | ||
"status": "open", | ||
"user": action_skel["user"]["dest"]["key"], | ||
}, | ||
key=todo["dest"]["key"], | ||
) | ||
|
||
return self.render.render("assignSuccess", action_skel) | ||
|
||
|
||
``` |