-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskView.bbj
More file actions
231 lines (203 loc) · 8.74 KB
/
TaskView.bbj
File metadata and controls
231 lines (203 loc) · 8.74 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
REM /**
REM * TaskView.bbj
REM * @author gosteen
REM */
REM package TaskApp
REM /**
REM * The view controller for tasks that are displayed by the Task App. Serves as the basis for TaskListView and TaskCardView
REM */
class public TaskView
field public BBjChildWindow Win!
field protected Task task!
field protected BBjString uuid!
field protected BBjPopupMenu flagPopupMenu!
field protected BBjSysGui sysgui!
field protected BBjStaticText title!
field protected BBjStaticText description!
field protected BBjCheckBox checkbox!
field protected BBjStaticText dueNotice!
field protected BBjStaticText priorityFlag!
field protected BBjString flagIcon! = "<html><dwc-icon pool='tabler' name='filled-flag-2'></dwc-icon>"
field protected BBjButton btnDeleteTask!
REM /**
REM * Constructor for the TaskView object
REM *
REM * @param BBjWindow parent! The parent BBjWindow that this TaskView will be added to
REM * @param Task t! The Task object containing the task information that will be displayed
REM * @return TaskView The newly created TaskView
REM *
REM */
method public TaskView(BBjWindow parent!, Task t!)
#sysgui! = BBjAPI().getSysGui()
#task! = t!
#uuid! = #task!.getUuid()
#Win! = parent!.addChildWindow("", $00108000$, #sysgui!.getAvailableContext())
#Win!.setAttribute("id", #uuid!)
#Win!.addClass("task clickable")
#title! = #Win!.addStaticText("")
#title!.addClass("textTitle")
#description! = #Win!.addStaticText("")
#description!.addClass("textDescription")
#checkbox! = #Win!.addCheckBox("Mark as Complete")
#checkbox!.setCallback(BBjControl.ON_CHECK_CHANGE, #this!, "onTaskCheck")
#dueNotice! = #Win!.addStaticText("")
#dueNotice!.addClass("dueNotice")
#priorityFlag! = #Win!.addStaticText(#flagIcon!)
#priorityFlag!.addClass("priorityFlag")
#priorityFlag!.setCallback(BBjControl.ON_POPUP_REQUEST, #this!, "OnShowPriorityPopup")
trashIcon! = "<html><dwc-icon pool='tabler' name='trash' style='width: 25px; height: 25px'></dwc-icon>"
#btnDeleteTask! = #Win!.addButton(trashIcon!)
#btnDeleteTask!.addClass("btnDelete")
#btnDeleteTask!.setCallback(BBjControl.ON_BUTTON_PUSH, #this!, "onDelete")
#setPriorityFlag()
#refresh()
methodend
REM /**
REM * Refresh the TaskView with the latest information from its Task object.
REM * This is called from the TaskApp class when a TASK_UPDATE event is posted.
REM */
method public void refresh()
if (#task!.getDeleted()) then
#setVisible(0)
endif
#clearStyles()
#title!.setText(#task!.getTitle())
#description!.setText(#task!.getDescription())
#checkbox!.setSelected(#task!.getComplete())
label! = "Mark as Complete"
if (#task!.getComplete()) then
#Win!.addClass("complete")
label! = "Mark as Incomplete"
endif
#checkbox!.setAttribute("label",label!)
#setPriorityFlag()
#setDueNotice()
if (#flagPopupMenu! <> null()) then
for i = Task.PRIORITY_HIGH() to Task.PRIORITY_LOW()
menuItem! = #flagPopupMenu!.getMenuItem(i)
menuItem!.setVisible(1)
REM Hide the flag that matches the task's current priority
if (#task!.getPriority() = i) then
menuItem!.setVisible(0)
endif
next i
endif
#description!.setToolTipText(#task!.getDescription())
#title!.setToolTipText(#task!.getTitle())
methodend
REM /**
REM * Sets the visibility of the ChildWindow of the TaskView
REM * Calls setVisible on #Win!
REM *
REM * @param BBjNumber visible! BBjNumber acting as a boolean specifying the visibility
REM */
method public void setVisible(BBjNumber visible!)
#Win!.setVisible(visible!)
methodend
REM /**
REM * Removes the style classes for all possible statuses.
REM */
method public void clearStyles()
#Win!.removeClass("complete incomplete")
#Win!.removeClass("status-complete")
methodend
REM /**
REM * Sets the label for when the task is due. If the due date of the task is ahead of the current date,
REM * the label will be set to the current date. If the due date of the task is equal to the current date,
REM * the label will be set to "Due Today!" If the due date of the task has already passed, the label will be set
REM * to "Past Due!"
REM */
method public void setDueNotice()
#dueNotice!.removeClass("dueToday pastDue complete")
dueNotice! = ""
dueDate! = #task!.getDueDate()
formattedDueDate! = date(#task!.getDueDate():"%Dl, %Ml %D")
#dueNotice!.addClass("dueNotice")
if (#task!.getComplete()) then
dueNotice! = "<html><dwc-icon pool='tabler' name='check'></dwc-icon> Complete"
#dueNotice!.addClass("complete")
else
if (dueDate! > -1) then
dueNotice! = "Due " + formattedDueDate!
#dueNotice!.setToolTipText("Due " + formattedDueDate!)
if (dueDate! < jul(date(0))) then
dueNotice! = "Past Due!"
#dueNotice!.addClass("pastDue")
endif
if (dueDate! = jul(date(0))) then
dueNotice! = "Due Today!"
#dueNotice!.addClass("dueToday")
endif
endif
endif
#dueNotice!.setText(dueNotice!)
methodend
REM /**
REM * Adds a priority flag icon which represents the task's priority level.
REM */
method public void setPriorityFlag()
flagText! = "Priority " + STR(#task!.getPriority())
#priorityFlag!.removeClass("priority-1 priority-2 priority-3 priority-4 priority-5 priority-0 priority-transparent")
#priorityFlag!.addClass("priority-" + STR(#task!.getPriority()))
#priorityFlag!.setToolTipText(flagText!)
if (#task!.getComplete()) then
#priorityFlag!.addClass("priority-transparent")
endif
methodend
REM /**
REM * Creates a BBjPopupMenu that contains flag icons representing every priority level except for
REM * the task's priority level.
REM */
method public void createPopupMenu()
#flagPopupMenu! = #sysgui!.addPopupMenu()
for i = Task.PRIORITY_HIGH() to Task.PRIORITY_LOW()
flagItem! = #flagPopupMenu!.addMenuItem(-i, #flagIcon!)
if (#task!.getPriority() = i) then flagItem!.setVisible(0)
flagItem!.addClass("priority-flag priority-" + str(i))
flagItem!.setCallback(flagItem!.ON_POPUP_ITEM_SELECT, #this!, "changePriority")
next i
methodend
REM /**
REM * Method to run when a task's checkbox is changed
REM *
REM * @param BBjCheckChangeEvent e! The BBjCheckChangeEvent that invoked this method
REM */
method public void onTaskCheck(BBjCheckChangeEvent e!)
#clearStyles()
if (#task!.getComplete()) then
#task!.setComplete(0)
else
#task!.setComplete(1)
endif
BBjAPI().postCustomEvent("TASK_UPDATE",#task!)
methodend
REM /**
REM * Triggers message box which prompts user for confirmation before deleting a task
REM *
REM * @param BBjButtonPushEvent e! The BBjButtonPushEvent that causes this method to be executed
REM */
method public void onDelete(BBjButtonPushEvent e!)
confirmDeleteTask! = msgbox("Are you sure you want to delete this task?", BBjSysGui.MSGBOX_BUTTONS_YES_NO + BBjSysGui.MSGBOX_ICON_EXCLAMATION, "Delete Task")
if (confirmDeleteTask! = 6) then
#task!.setDeleted(1)
BBjAPI().postCustomEvent("TASK_UPDATE",#task!)
endif
methodend
method public void OnShowPriorityPopup(BBjPopupRequestEvent event!)
if (#flagPopupMenu! = null()) then #createPopupMenu()
#flagPopupMenu!.show(event!.getControl(), 0, 0)
methodend
REM /**
REM * -Changes task priority level to priority level selected from the #flagPopupMenu!
REM *
REM * @param BBjPopupSelectEvent e! The BBjPopupSelectEvent that causes this method to be executed
REM */
method public void changePriority(BBjPopupSelectEvent e!)
newPriority! = ABS(e!.getMenuItem().getID())
#task!.setPriority(newPriority!)
BBjAPI().postCustomEvent("TASK_UPDATE", #task!)
methodend
classend
REM BBj USE Statements
use ::Task.bbj::Task
use ::Utils.bbj::Utils