-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRowTemplate1
More file actions
66 lines (58 loc) · 2.64 KB
/
RowTemplate1
File metadata and controls
66 lines (58 loc) · 2.64 KB
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
from ._anvil_designer import RowTemplate1Template
from anvil import *
import anvil.server
import anvil.users
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import datetime
#from ..Log import Log
#### GOES UNDER LOG, TEMPLATE FOR DATA TABLE ROW #####
class RowTemplate1(RowTemplate1Template):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run before the form opens.
current_row_id = self.item.get_id()
current_row = app_tables.requests.get_by_id(current_row_id)
if(current_row['Time_to_Completion'] != None):
self.check_box_complete.checked = 1
def check_box_complete_change(self, **event_args):
"""This method is called when this checkbox is checked or unchecked"""
#get current row of data
current_row_id = self.item.get_id()
current_row = app_tables.requests.get_by_id(current_row_id)
current_date = datetime.date.today()
#add parent form Log to RowTemplate1 class scope
Log = get_open_form()
Log.dd=None
Log.ttc=None
#self.check_box_complete.checked = not self.check_box_complete.checked
if(self.check_box_complete.checked):
elapsed_time = current_date - current_row['Date_Requested']
Log.dd = current_date
Log.ttc = elapsed_time.days
print('Checkbox has been checked.')
print('Log.dd: {}'.format(Log.dd))
print('Log.ttc: {}'.format(Log.ttc))
else:
print('Checkbox has been unchecked.')
current_date = None
print('Checkbox has been toggled to {} in {} Mode.'.format(self.check_box_complete.checked,Log.ui_mode))
if Log.ui_mode == 'Edit':#Log.search_button.text == 'Confirm Edit':
#if completion box is unchecked (no self.ttc, self.dd), remove text from time_to_completion field in row
#(and date_delivered later once get first condition working)
if not Log.dd:
Log.deliv_date_picker.date = None
#current_row.update(Time_to_Completion=None)
else:
Log.deliv_date_picker.date = Log.dd
#print('Checkbox has been checked in Edit Mode.')
#print('Checkbox has been toggled to {} in Edit Mode.'.format(self.check_box_complete.checked))
elif Log.ui_mode == 'Search':#Log.search_button.text != 'Confirm Edit':
#print('Checkbox has been toggled to {} in Search Mode.'.format(self.check_box_complete.checked))
current_row.update(Date_Delivered=Log.dd,Time_to_Completion=Log.ttc)
print('Current row updated with dd: {} and ttc: {}.'.format(Log.dd,Log.ttc))
Log.reset_interface()
Log.refresh_table(mode=None)
pass