-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblocks.py
149 lines (144 loc) · 4.25 KB
/
blocks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Slack block kit - https://api.slack.com/block-kit
from datetime import datetime
# Get current date for time logging form
def currentDate():
return datetime.now()
# Time logging form blocks
def timelog_form():
output = [
{
# Horizontal line
"type": "divider"
},
{
# Date picker
"type": "input",
"block_id": "date_select_block",
"element": {
"type": "datepicker",
# YYYY-MM-DD format needs to be used here because SQL doesn't have a date data type so these are stored as strings - in this format lexicographical order is identical to chronological order.
"initial_date": currentDate().strftime("%Y-%m-%d"),
"placeholder": {
"type": "plain_text",
"text": "Select a date",
},
"action_id": "date_select_input"
},
"label": {
"type": "plain_text",
"text": "Date to log",
}
},
{
# Hours input
"type": "input",
"block_id": "hours_block",
"element": {
"type": "plain_text_input",
"action_id": "hours_input"
},
"label": {
"type": "plain_text",
"text": "Time logged (e.g. 2h, 25m)",
}
},
{
# Submit button
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Click to submit and log hours"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Submit",
},
"value": "placeholder",
"action_id": "timelog_response"
}
}
]
return output
# User selection form for hour sum
def gethours_form():
output = [
{
"type": "input",
"block_id": "user_select_block",
"element": {
"type": "multi_users_select",
"placeholder": {
"type": "plain_text",
"text": "Select users",
},
"action_id": "user_select_input"
},
"label": {
"type": "plain_text",
"text": "Select users to view their total time logged",
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Confirm Selection",
},
"action_id": "gethours_response"
}
]
}
]
return output
# User selection form for table
def getusertables_form():
output = [
{
"type": "input",
"block_id": "user_select_block",
"element": {
"type": "multi_users_select",
"placeholder": {
"type": "plain_text",
"text": "Select users",
},
"action_id": "user_select_input"
},
"label": {
"type": "plain_text",
"text": "Select users to their last n entries as a table",
}
},
{
# Number of entries
"type": "input",
"block_id": "num_entries_block",
"element": {
"type": "plain_text_input",
"action_id": "num_entries_input"
},
"label": {
"type": "plain_text",
"text": "Number of entries to return for each user",
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Confirm Selection",
},
"action_id": "getusertables_response"
},
]
}
]
return output