Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
emT3web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mac Stephens
emT3web
Commits
33f30507
Commit
33f30507
authored
Nov 06, 2026
by
Daniel Barker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save and Cancel buttons now persist when editing a rows date
parent
e3026c77
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
607 additions
and
103 deletions
+607
-103
View.TimeEntries.html
emT3Web/View.TimeEntries.html
+5
-1
View.TimeEntries.pas
emT3Web/View.TimeEntries.pas
+211
-35
time-entries.css
emT3Web/css/time-entries.css
+15
-0
uTaskPickerOffCanvas.pas
emT3Web/uTaskPickerOffCanvas.pas
+284
-59
Api.Database.dfm
emT3XDataServer/Source/Api.Database.dfm
+1
-1
TimeEntry.Service.pas
emT3XDataServer/Source/TimeEntry.Service.pas
+9
-1
TimeEntry.ServiceImpl.pas
emT3XDataServer/Source/TimeEntry.ServiceImpl.pas
+79
-3
emT3XDataServer.ini
emT3XDataServer/bin/emT3XDataServer.ini
+1
-1
emT3XDataServer.dproj
emT3XDataServer/emT3XDataServer.dproj
+2
-2
No files found.
emT3Web/View.TimeEntries.html
View file @
33f30507
...
@@ -85,9 +85,13 @@
...
@@ -85,9 +85,13 @@
Cancel
Cancel
</button>
</button>
<button
type=
"button"
class=
"btn btn-
primary
btn-sm"
id=
"btn_task_picker_save"
disabled
>
<button
type=
"button"
class=
"btn btn-
outline-success
btn-sm"
id=
"btn_task_picker_save"
disabled
>
Save
Save
</button>
</button>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
id=
"btn_task_picker_select"
disabled
>
Select
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
emT3Web/View.TimeEntries.pas
View file @
33f30507
...
@@ -55,6 +55,8 @@ type
...
@@ -55,6 +55,8 @@ type
FTaskPickerOffCanvas
:
TTaskPickerOffCanvas
;
FTaskPickerOffCanvas
:
TTaskPickerOffCanvas
;
FAddingNewEntry
:
Boolean
;
FAddingNewEntry
:
Boolean
;
FNewEntryRowIndex
:
Integer
;
FNewEntryRowIndex
:
Integer
;
FEditingEntryId
:
Integer
;
FOriginalTaskDate
:
string
;
[
async
]
procedure
LoadTimeEntries
;
[
async
]
procedure
LoadTimeEntries
;
function
BeginAddEntry
:
Boolean
;
function
BeginAddEntry
:
Boolean
;
...
@@ -63,6 +65,8 @@ type
...
@@ -63,6 +65,8 @@ type
procedure
BindNewEntryButtons
;
procedure
BindNewEntryButtons
;
procedure
NewEntrySaveClick
(
Event
:
TJSEvent
);
procedure
NewEntrySaveClick
(
Event
:
TJSEvent
);
procedure
NewEntryCancelClick
(
Event
:
TJSEvent
);
procedure
NewEntryCancelClick
(
Event
:
TJSEvent
);
[
async
]
procedure
EditedDateSaveClick
(
Event
:
TJSEvent
);
procedure
EditedDateCancelClick
(
Event
:
TJSEvent
);
[
async
]
procedure
SaveNewEntry
;
[
async
]
procedure
SaveNewEntry
;
procedure
CancelNewEntry
;
procedure
CancelNewEntry
;
procedure
RenderTable
;
procedure
RenderTable
;
...
@@ -94,10 +98,11 @@ type
...
@@ -94,10 +98,11 @@ type
function
GetTargetRowIndex
(
ATarget
:
TJSHTMLElement
):
Integer
;
function
GetTargetRowIndex
(
ATarget
:
TJSHTMLElement
):
Integer
;
procedure
DocumentMouseDown
(
Event
:
TJSEvent
);
procedure
DocumentMouseDown
(
Event
:
TJSEvent
);
[
async
]
procedure
TaskPickerButtonClick
(
Event
:
TJSEvent
);
[
async
]
procedure
TaskPickerButtonClick
(
Event
:
TJSEvent
);
procedure
TaskPickerTaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
;
AAddedToFocus
:
Boolean
);
procedure
TaskPickerTaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
);
procedure
TaskPickerFocusChanged
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
procedure
ApplyActiveRowState
;
procedure
ApplyActiveRowState
;
procedure
EditorBlur
(
Event
:
TJSEvent
);
procedure
EditorBlur
(
Event
:
TJSEvent
);
[
async
]
procedure
SaveField
(
AIndex
:
Integer
;
const
AFieldName
:
string
)
;
[
async
]
function
SaveField
(
AIndex
:
Integer
;
const
AFieldName
:
string
):
Boolean
;
[
async
]
procedure
DeleteSelectedEntry
;
[
async
]
procedure
DeleteSelectedEntry
;
function
CopySelectedEntry
:
Boolean
;
function
CopySelectedEntry
:
Boolean
;
public
public
...
@@ -135,7 +140,7 @@ begin
...
@@ -135,7 +140,7 @@ begin
FAddingNewEntry
:=
False
;
FAddingNewEntry
:=
False
;
FNewEntryRowIndex
:=
-
1
;
FNewEntryRowIndex
:=
-
1
;
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
);
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
,
@
TaskPickerFocusChanged
);
document
.
addEventListener
(
'mousedown'
,
TJSEventHandler
(@
DocumentMouseDown
));
document
.
addEventListener
(
'mousedown'
,
TJSEventHandler
(@
DocumentMouseDown
));
...
@@ -316,6 +321,7 @@ begin
...
@@ -316,6 +321,7 @@ begin
el
.
innerText
:=
displayName
+
'''s Time Entries'
;
el
.
innerText
:=
displayName
+
'''s Time Entries'
;
end
;
end
;
[
async
]
procedure
TFTimeEntries
.
LoadTimeEntries
;
[
async
]
procedure
TFTimeEntries
.
LoadTimeEntries
;
var
var
response
:
TXDataClientResponse
;
response
:
TXDataClientResponse
;
...
@@ -380,8 +386,6 @@ begin
...
@@ -380,8 +386,6 @@ begin
end
;
end
;
procedure
TFTimeEntries
.
RenderTable
;
procedure
TFTimeEntries
.
RenderTable
;
var
var
host
:
TJSHTMLElement
;
host
:
TJSHTMLElement
;
...
@@ -565,7 +569,15 @@ begin
...
@@ -565,7 +569,15 @@ begin
'</div>'
+
'</div>'
+
'</td>'
+
'</td>'
+
'</tr>'
;
'</tr>'
;
end
;
end
else
html
:=
html
+
'<tr id="time-edit-actions-'
+
IntToStr
(
rowIdx
)
+
'" hidden>'
+
'<td colspan="7">'
+
'<button type="button" class="btn btn-sm btn-success time-edit-save" data-idx="'
+
IntToStr
(
rowIdx
)
+
'">Save</button> '
+
'<button type="button" class="btn btn-sm btn-outline-secondary time-edit-cancel" data-idx="'
+
IntToStr
(
rowIdx
)
+
'">Cancel</button>'
+
'</td>'
+
'</tr>'
;
xdwdsTimeEntries
.
Next
;
xdwdsTimeEntries
.
Next
;
Inc
(
rowIdx
);
Inc
(
rowIdx
);
...
@@ -716,6 +728,98 @@ begin
...
@@ -716,6 +728,98 @@ begin
RenderTable
;
RenderTable
;
end
;
end
;
[
async
]
procedure
TFTimeEntries
.
EditedDateSaveClick
(
Event
:
TJSEvent
);
var
saveButton
,
cancelButton
:
TJSHTMLButtonElement
;
dateInput
:
TJSHTMLInputElement
;
rowEl
:
TJSHTMLElement
;
idx
,
savedEntryId
:
Integer
;
rowSelector
:
string
;
begin
saveButton
:=
TJSHTMLButtonElement
(
Event
.
target
);
idx
:=
StrToIntDef
(
string
(
saveButton
.
getAttribute
(
'data-idx'
)),
-
1
);
if
(
idx
<
0
)
or
(
FEditingEntryId
=
0
)
or
(
not
xdwdsTimeEntries
.
Active
)
then
Exit
;
GotoRowIndex
(
idx
);
if
xdwdsTimeEntries
.
Eof
then
Exit
;
savedEntryId
:=
xdwdsTimeEntriesentryId
.
AsInteger
;
if
savedEntryId
<>
FEditingEntryId
then
Exit
;
if
Trim
(
xdwdsTimeEntriestaskDate
.
AsString
)
=
''
then
begin
Utils
.
ShowErrorModal
(
'Enter a date before saving.'
);
Exit
;
end
;
rowSelector
:=
'.time-row-selectable[data-entry-id="'
+
IntToStr
(
savedEntryId
)
+
'"]'
;
rowEl
:=
TJSHTMLElement
(
document
.
querySelector
(
rowSelector
));
dateInput
:=
TJSHTMLInputElement
(
rowEl
.
querySelector
(
'[data-field="taskDate"]'
));
cancelButton
:=
TJSHTMLButtonElement
(
document
.
querySelector
(
'.time-edit-cancel[data-idx="'
+
IntToStr
(
idx
)
+
'"]'
));
saveButton
.
disabled
:=
True
;
cancelButton
.
disabled
:=
True
;
dateInput
.
disabled
:=
True
;
try
if
not
await
(
SaveField
(
idx
,
'taskDate'
))
then
Exit
;
finally
saveButton
.
disabled
:=
False
;
cancelButton
.
disabled
:=
False
;
dateInput
.
disabled
:=
False
;
end
;
FEditingEntryId
:=
0
;
FOriginalTaskDate
:=
''
;
CaptureTableScroll
;
RenderTable
;
rowEl
:=
TJSHTMLElement
(
document
.
querySelector
(
rowSelector
));
if
Assigned
(
rowEl
)
then
rowEl
.
classList
.
add
(
'time-row-saved'
);
end
;
procedure
TFTimeEntries
.
EditedDateCancelClick
(
Event
:
TJSEvent
);
var
el
:
TJSHTMLElement
;
idx
:
Integer
;
begin
Event
.
preventDefault
;
Event
.
stopPropagation
;
el
:=
TJSHTMLElement
(
Event
.
target
);
idx
:=
StrToIntDef
(
string
(
el
.
getAttribute
(
'data-idx'
)),
-
1
);
if
(
idx
<
0
)
or
(
FEditingEntryId
=
0
)
or
(
not
xdwdsTimeEntries
.
Active
)
then
Exit
;
GotoRowIndex
(
idx
);
if
xdwdsTimeEntries
.
Eof
then
Exit
;
if
xdwdsTimeEntriesentryId
.
AsInteger
<>
FEditingEntryId
then
Exit
;
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntriestaskDate
.
AsString
:=
FOriginalTaskDate
;
xdwdsTimeEntries
.
Post
;
FEditingEntryId
:=
0
;
FOriginalTaskDate
:=
''
;
CaptureTableScroll
;
RenderTable
;
if
ValidateRow
(
idx
)
then
ClearRowValidation
(
idx
);
end
;
procedure
TFTimeEntries
.
BindTableEditors
;
procedure
TFTimeEntries
.
BindTableEditors
;
var
var
nodes
:
TJSNodeList
;
nodes
:
TJSNodeList
;
...
@@ -733,6 +837,22 @@ begin
...
@@ -733,6 +837,22 @@ begin
el
.
addEventListener
(
'blur'
,
TJSEventHandler
(@
EditorBlur
));
el
.
addEventListener
(
'blur'
,
TJSEventHandler
(@
EditorBlur
));
end
;
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-edit-cancel'
);
console
.
log
(
'BindTableEditors: edit row cancel button clicked'
);
for
i
:=
0
to
nodes
.
length
-
1
do
begin
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
EditedDateCancelClick
));
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-edit-save'
);
console
.
log
(
'BindTableEditors: edit row save button click'
);
for
i
:=
0
to
nodes
.
length
-
1
do
begin
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
EditedDateSaveClick
));
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-dd-item'
);
nodes
:=
document
.
querySelectorAll
(
'.time-dd-item'
);
console
.
log
(
'BindTableEditors: time-dd-item count='
+
IntToStr
(
nodes
.
length
));
console
.
log
(
'BindTableEditors: time-dd-item count='
+
IntToStr
(
nodes
.
length
));
for
i
:=
0
to
nodes
.
length
-
1
do
for
i
:=
0
to
nodes
.
length
-
1
do
...
@@ -767,6 +887,7 @@ var
...
@@ -767,6 +887,7 @@ var
idxStr
:
string
;
idxStr
:
string
;
fieldName
:
string
;
fieldName
:
string
;
newVal
:
string
;
newVal
:
string
;
actionsRow
:
TJSHTMLElement
;
begin
begin
if
not
xdwdsTimeEntries
.
Active
then
if
not
xdwdsTimeEntries
.
Active
then
Exit
;
Exit
;
...
@@ -788,6 +909,14 @@ begin
...
@@ -788,6 +909,14 @@ begin
if
xdwdsTimeEntries
.
Eof
then
if
xdwdsTimeEntries
.
Eof
then
Exit
;
Exit
;
if
SameText
(
fieldName
,
'taskDate'
)
and
(
xdwdsTimeEntriesentryId
.
AsInteger
>
0
)
and
(
FEditingEntryId
=
0
)
then
begin
FEditingEntryId
:=
xdwdsTimeEntriesentryId
.
AsInteger
;
FOriginalTaskDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
end
;
newVal
:=
string
(
TJSObject
(
el
)[
'value'
]);
newVal
:=
string
(
TJSObject
(
el
)[
'value'
]);
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntries
.
Edit
;
...
@@ -810,6 +939,15 @@ begin
...
@@ -810,6 +939,15 @@ begin
xdwdsTimeEntries
.
Post
;
xdwdsTimeEntries
.
Post
;
if
SameText
(
fieldName
,
'taskDate'
)
and
(
FEditingEntryId
>
0
)
and
(
xdwdsTimeEntriesentryId
.
AsInteger
=
FEditingEntryId
)
then
begin
actionsRow
:=
TJSHTMLElement
(
document
.
getElementById
(
'time-edit-actions-'
+
IntToStr
(
idx
)));
if
Assigned
(
actionsRow
)
then
actionsRow
.
removeAttribute
(
'hidden'
);
end
;
el
.
setAttribute
(
'data-unsaved-data'
,
'1'
);
el
.
setAttribute
(
'data-unsaved-data'
,
'1'
);
if
IsNewEntryRow
(
idx
)
then
if
IsNewEntryRow
(
idx
)
then
...
@@ -1649,6 +1787,7 @@ end;
...
@@ -1649,6 +1787,7 @@ end;
var
var
el
:
TJSHTMLElement
;
el
:
TJSHTMLElement
;
idx
:
Integer
;
idx
:
Integer
;
taskId
:
string
;
begin
begin
Event
.
preventDefault
;
Event
.
preventDefault
;
Event
.
stopPropagation
;
Event
.
stopPropagation
;
...
@@ -1698,60 +1837,87 @@ begin
...
@@ -1698,60 +1837,87 @@ begin
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
idx
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
idx
);
if
not
Assigned
(
FTaskPickerOffCanvas
)
then
if
not
Assigned
(
FTaskPickerOffCanvas
)
then
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
);
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
,
@
TaskPickerFocusChanged
);
// Pass the row's current task so the picker opens on it (blank for rows without one)
taskId
:=
''
;
GotoRowIndex
(
idx
);
if
not
xdwdsTimeEntries
.
Eof
then
taskId
:=
xdwdsTimeEntriestaskId
.
AsString
;
await
(
FTaskPickerOffCanvas
.
Open
(
FUserId
,
idx
,
FTaskOptions
));
await
(
FTaskPickerOffCanvas
.
Open
(
FUserId
,
idx
,
FTaskOptions
,
taskId
));
end
;
end
;
procedure
TFTimeEntries
.
TaskPicker
TaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
;
AAddedToFocus
:
Boolean
);
procedure
TFTimeEntries
.
TaskPicker
FocusChanged
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
var
var
btn
:
TJSHTMLElement
;
triggerId
:
string
;
i
:
Integer
;
i
:
Integer
;
taskIndex
:
Integer
;
taskOption
:
TJSObject
;
taskOption
:
TJSObject
;
taskFound
:
Boolean
;
begin
begin
if
not
xdwdsTimeEntries
.
Active
then
if
not
Assigned
(
FTaskOptions
)
then
Exit
;
FTaskOptions
:=
TJSArray
.
new
;
GotoRowIndex
(
ARowIndex
);
if
xdwdsTimeEntries
.
Eof
then
Exit
;
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntriestaskId
.
AsString
:=
ATaskId
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
ATaskDisplay
;
xdwdsTimeEntries
.
Post
;
FActiveRowIndex
:=
ARowIndex
;
btnDeleteEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
if
AAddedToFocus
then
begin
taskFound
:=
False
;
taskIndex
:=
-
1
;
for
i
:=
0
to
FTaskOptions
.
length
-
1
do
for
i
:=
0
to
FTaskOptions
.
length
-
1
do
begin
begin
taskOption
:=
TJSObject
(
FTaskOptions
[
i
]);
taskOption
:=
TJSObject
(
FTaskOptions
[
i
]);
if
string
(
taskOption
[
'taskId'
])
=
ATaskId
then
if
string
(
taskOption
[
'taskId'
])
=
ATaskId
then
begin
begin
task
Found
:=
True
;
task
Index
:=
i
;
Break
;
Break
;
end
;
end
;
end
;
end
;
if
not
taskFoun
d
then
if
AFocuse
d
then
begin
begin
if
taskIndex
>=
0
then
Exit
;
taskOption
:=
TJSObject
.
new
;
taskOption
:=
TJSObject
.
new
;
taskOption
[
'taskId'
]
:=
ATaskId
;
taskOption
[
'taskId'
]
:=
ATaskId
;
taskOption
[
'taskDisplay'
]
:=
ATaskDisplay
;
taskOption
[
'taskDisplay'
]
:=
ATaskDisplay
;
FTaskOptions
.
push
(
taskOption
);
FTaskOptions
.
push
(
taskOption
);
end
else
begin
if
taskIndex
<
0
then
Exit
;
// Rows already using this task keep it; it is only removed from the dropdown options
FTaskOptions
.
splice
(
taskIndex
,
1
);
end
;
if
xdwdsTimeEntries
.
Active
then
begin
CaptureTableScroll
;
RenderTable
;
end
;
end
;
end
;
end
;
procedure
TFTimeEntries
.
TaskPickerTaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
);
var
btn
:
TJSHTMLElement
;
triggerId
:
string
;
begin
if
not
xdwdsTimeEntries
.
Active
then
Exit
;
GotoRowIndex
(
ARowIndex
);
if
xdwdsTimeEntries
.
Eof
then
Exit
;
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntriestaskId
.
AsString
:=
ATaskId
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
ATaskDisplay
;
xdwdsTimeEntries
.
Post
;
FActiveRowIndex
:=
ARowIndex
;
btnDeleteEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
CaptureTableScroll
;
CaptureTableScroll
;
RenderTable
;
RenderTable
;
...
@@ -1833,17 +1999,27 @@ begin
...
@@ -1833,17 +1999,27 @@ begin
Exit
;
Exit
;
end
;
end
;
if
SameText
(
fieldName
,
'taskDate'
)
and
(
FEditingEntryId
>
0
)
then
begin
GotoRowIndex
(
idx
);
if
not
xdwdsTimeEntries
.
Eof
then
if
xdwdsTimeEntriesentryId
.
AsInteger
=
FEditingEntryId
then
Exit
;
end
;
console
.
log
(
'EditorBlur: SAVE idx='
+
IntToStr
(
idx
)
+
' field='
+
fieldName
);
console
.
log
(
'EditorBlur: SAVE idx='
+
IntToStr
(
idx
)
+
' field='
+
fieldName
);
SaveField
(
idx
,
fieldName
);
SaveField
(
idx
,
fieldName
);
end
;
end
;
[
async
]
procedure
TFTimeEntries
.
SaveField
(
AIndex
:
Integer
;
const
AFieldName
:
string
)
;
[
async
]
function
TFTimeEntries
.
SaveField
(
AIndex
:
Integer
;
const
AFieldName
:
string
):
Boolean
;
var
var
response
:
TXDataClientResponse
;
response
:
TXDataClientResponse
;
payload
:
TJSObject
;
payload
:
TJSObject
;
fieldValue
:
string
;
fieldValue
:
string
;
begin
begin
Result
:=
False
;
if
not
xdwdsTimeEntries
.
Active
then
if
not
xdwdsTimeEntries
.
Active
then
Exit
;
Exit
;
...
@@ -1891,7 +2067,7 @@ begin
...
@@ -1891,7 +2067,7 @@ begin
'ITimeEntryService.SaveTimeEntryField'
,
'ITimeEntryService.SaveTimeEntryField'
,
[
payload
]
[
payload
]
));
));
Result
:=
True
;
console
.
log
(
'SaveField: response='
+
string
(
TJSJSON
.
stringify
(
response
.
Result
)));
console
.
log
(
'SaveField: response='
+
string
(
TJSJSON
.
stringify
(
response
.
Result
)));
if
SameText
(
AFieldName
,
'hours'
)
or
SameText
(
AFieldName
,
'taskDate'
)
then
if
SameText
(
AFieldName
,
'hours'
)
or
SameText
(
AFieldName
,
'taskDate'
)
then
...
...
emT3Web/css/time-entries.css
View file @
33f30507
...
@@ -50,3 +50,17 @@
...
@@ -50,3 +50,17 @@
border-color
:
var
(
--bs-danger
)
!important
;
border-color
:
var
(
--bs-danger
)
!important
;
padding-right
:
calc
(
1.5em
+
.75rem
);
padding-right
:
calc
(
1.5em
+
.75rem
);
}
}
.time-row-saved
>
td
{
animation
:
time-row-saved-flash
900ms
ease-out
;
}
@keyframes
time-row-saved-flash
{
from
{
box-shadow
:
inset
0
0
0
999px
rgba
(
25
,
135
,
84
,
0.25
);
}
to
{
box-shadow
:
inset
0
0
0
999px
rgba
(
25
,
135
,
84
,
0
);
}
}
\ No newline at end of file
emT3Web/uTaskPickerOffCanvas.pas
View file @
33f30507
...
@@ -8,9 +8,13 @@ uses
...
@@ -8,9 +8,13 @@ uses
type
type
TTaskPickedProc
=
reference
to
procedure
(
TTaskPickedProc
=
reference
to
procedure
(
ARowIndex
:
Integer
;
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
);
TTaskFocusChangedProc
=
reference
to
procedure
(
const
ATaskId
,
ATaskDisplay
:
string
;
const
ATaskId
,
ATaskDisplay
:
string
;
AAddedToFocus
:
Boolean
AFocused
:
Boolean
);
);
TTaskPickerOffCanvas
=
class
TTaskPickerOffCanvas
=
class
private
private
...
@@ -18,10 +22,14 @@ type
...
@@ -18,10 +22,14 @@ type
FUserId
:
string
;
FUserId
:
string
;
FRowIndex
:
Integer
;
FRowIndex
:
Integer
;
FOnTaskPicked
:
TTaskPickedProc
;
FOnTaskPicked
:
TTaskPickedProc
;
FOnFocusChanged
:
TTaskFocusChangedProc
;
FCustomers
:
TJSArray
;
FCustomers
:
TJSArray
;
FProjects
:
TJSArray
;
FProjects
:
TJSArray
;
FTasks
:
TJSArray
;
FTasks
:
TJSArray
;
FFocusedTasks
:
TJSArray
;
FFocusedTasks
:
TJSArray
;
FSavedFocus
:
Boolean
;
FSaving
:
Boolean
;
FPrefillToken
:
Integer
;
procedure
BindEvents
;
procedure
BindEvents
;
procedure
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
procedure
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
...
@@ -29,37 +37,53 @@ type
...
@@ -29,37 +37,53 @@ type
procedure
FilterProjects
(
const
ACustomerId
:
string
);
procedure
FilterProjects
(
const
ACustomerId
:
string
);
function
SelectedValue
(
const
AElementId
:
string
):
string
;
function
SelectedValue
(
const
AElementId
:
string
):
string
;
function
FindDisplay
(
AItems
:
TJSArray
;
const
AValue
:
string
):
string
;
function
FindDisplay
(
AItems
:
TJSArray
;
const
AValue
:
string
):
string
;
function
FocusCheckbox
:
TJSHTMLInputElement
;
function
IsTaskFocused
(
const
ATaskId
:
string
):
Boolean
;
procedure
SetTaskFocused
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
procedure
SetStatus
(
const
AMessage
:
string
);
procedure
SetStatus
(
const
AMessage
:
string
);
procedure
ClearStatus
;
procedure
ClearStatus
;
procedure
SetSaveEnabled
(
AEnabled
:
Boolean
);
procedure
SetButtonEnabled
(
const
AElementId
:
string
;
AEnabled
:
Boolean
);
procedure
UpdateButtons
;
procedure
Show
;
procedure
Show
;
procedure
Hide
;
procedure
Hide
;
[
async
]
procedure
LoadCustomers
;
[
async
]
procedure
LoadCustomers
;
[
async
]
procedure
LoadProjects
(
const
ACustomerId
:
string
);
[
async
]
procedure
LoadProjects
(
const
ACustomerId
:
string
);
[
async
]
procedure
LoadTasks
(
const
AProjectId
:
string
);
[
async
]
procedure
LoadTasks
(
const
AProjectId
:
string
);
[
async
]
procedure
PreselectTask
(
const
ATaskId
:
string
;
AToken
:
Integer
);
procedure
SetSelectValue
(
const
AElementId
,
AValue
:
string
);
procedure
CustomerChanged
(
Event
:
TJSEvent
);
procedure
CustomerChanged
(
Event
:
TJSEvent
);
[
async
]
procedure
ProjectChanged
(
Event
:
TJSEvent
);
[
async
]
procedure
ProjectChanged
(
Event
:
TJSEvent
);
procedure
TaskChanged
(
Event
:
TJSEvent
);
procedure
TaskChanged
(
Event
:
TJSEvent
);
procedure
FocusCheckboxChanged
(
Event
:
TJSEvent
);
procedure
UpdateFocusCheckbox
;
procedure
UpdateFocusCheckbox
;
procedure
SelectClicked
(
Event
:
TJSEvent
);
[
async
]
procedure
SaveClicked
(
Event
:
TJSEvent
);
[
async
]
procedure
SaveClicked
(
Event
:
TJSEvent
);
public
public
constructor
Create
(
AClient
:
TXDataWebClient
;
AOnTaskPicked
:
TTaskPickedProc
);
constructor
Create
(
AClient
:
TXDataWebClient
;
AOnTaskPicked
:
TTaskPickedProc
;
[
async
]
procedure
Open
(
const
AUserId
:
string
;
ARowIndex
:
Integer
;
AFocusedTasks
:
TJSArray
);
AOnFocusChanged
:
TTaskFocusChangedProc
);
[
async
]
procedure
Open
(
const
AUserId
:
string
;
ARowIndex
:
Integer
;
AFocusedTasks
:
TJSArray
;
const
ATaskId
:
string
);
end
;
end
;
implementation
implementation
constructor
TTaskPickerOffCanvas
.
Create
(
AClient
:
TXDataWebClient
;
AOnTaskPicked
:
TTaskPickedProc
);
constructor
TTaskPickerOffCanvas
.
Create
(
AClient
:
TXDataWebClient
;
AOnTaskPicked
:
TTaskPickedProc
;
AOnFocusChanged
:
TTaskFocusChangedProc
);
begin
begin
inherited
Create
;
inherited
Create
;
FClient
:=
AClient
;
FClient
:=
AClient
;
FOnTaskPicked
:=
AOnTaskPicked
;
FOnTaskPicked
:=
AOnTaskPicked
;
FOnFocusChanged
:=
AOnFocusChanged
;
FCustomers
:=
TJSArray
.
new
;
FCustomers
:=
TJSArray
.
new
;
FProjects
:=
TJSArray
.
new
;
FProjects
:=
TJSArray
.
new
;
FTasks
:=
TJSArray
.
new
;
FTasks
:=
TJSArray
.
new
;
FFocusedTasks
:=
TJSArray
.
new
;
FRowIndex
:=
-
1
;
FRowIndex
:=
-
1
;
FSavedFocus
:=
False
;
FSaving
:=
False
;
FPrefillToken
:=
0
;
BindEvents
;
BindEvents
;
end
;
end
;
...
@@ -80,9 +104,17 @@ begin
...
@@ -80,9 +104,17 @@ begin
if
Assigned
(
el
)
then
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
TaskChanged
));
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
TaskChanged
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_add_focus'
));
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
FocusCheckboxChanged
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'btn_task_picker_save'
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'btn_task_picker_save'
));
if
Assigned
(
el
)
then
if
Assigned
(
el
)
then
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
SaveClicked
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
SaveClicked
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'btn_task_picker_select'
));
if
Assigned
(
el
)
then
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
SelectClicked
));
end
;
end
;
procedure
TTaskPickerOffCanvas
.
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
procedure
TTaskPickerOffCanvas
.
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
...
@@ -170,6 +202,58 @@ begin
...
@@ -170,6 +202,58 @@ begin
end
;
end
;
end
;
end
;
function
TTaskPickerOffCanvas
.
FocusCheckbox
:
TJSHTMLInputElement
;
begin
Result
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'task_picker_add_focus'
));
end
;
function
TTaskPickerOffCanvas
.
IsTaskFocused
(
const
ATaskId
:
string
):
Boolean
;
var
taskOption
:
TJSObject
;
i
:
Integer
;
begin
Result
:=
False
;
if
ATaskId
=
''
then
Exit
;
for
i
:=
0
to
FFocusedTasks
.
length
-
1
do
begin
taskOption
:=
TJSObject
(
FFocusedTasks
[
i
]);
if
string
(
taskOption
[
'taskId'
])
=
ATaskId
then
Exit
(
True
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
SetTaskFocused
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
var
taskOption
:
TJSObject
;
i
:
Integer
;
begin
// Keep the picker's own copy of the focused list in sync with the server
for
i
:=
FFocusedTasks
.
length
-
1
downto
0
do
begin
taskOption
:=
TJSObject
(
FFocusedTasks
[
i
]);
if
string
(
taskOption
[
'taskId'
])
=
ATaskId
then
begin
if
AFocused
then
Exit
;
FFocusedTasks
.
splice
(
i
,
1
);
end
;
end
;
if
AFocused
then
begin
taskOption
:=
TJSObject
.
new
;
taskOption
[
'taskId'
]
:=
ATaskId
;
taskOption
[
'taskDisplay'
]
:=
ATaskDisplay
;
FFocusedTasks
.
push
(
taskOption
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
SetStatus
(
const
AMessage
:
string
);
procedure
TTaskPickerOffCanvas
.
SetStatus
(
const
AMessage
:
string
);
var
var
el
:
TJSHTMLElement
;
el
:
TJSHTMLElement
;
...
@@ -194,15 +278,38 @@ begin
...
@@ -194,15 +278,38 @@ begin
el
.
classList
.
add
(
'd-none'
);
el
.
classList
.
add
(
'd-none'
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
Set
SaveEnabled
(
AEnabled
:
Boolean
);
procedure
TTaskPickerOffCanvas
.
Set
ButtonEnabled
(
const
AElementId
:
string
;
AEnabled
:
Boolean
);
var
var
btn
:
TJSHTMLButtonElement
;
btn
:
TJSHTMLButtonElement
;
begin
begin
btn
:=
TJSHTMLButtonElement
(
document
.
getElementById
(
'btn_task_picker_save'
));
btn
:=
TJSHTMLButtonElement
(
document
.
getElementById
(
AElementId
));
if
Assigned
(
btn
)
then
if
Assigned
(
btn
)
then
btn
.
disabled
:=
not
AEnabled
;
btn
.
disabled
:=
not
AEnabled
;
end
;
end
;
procedure
TTaskPickerOffCanvas
.
UpdateButtons
;
var
hasTask
:
Boolean
;
focusChanged
:
Boolean
;
addFocus
:
TJSHTMLInputElement
;
begin
// Select: any picked task can be sent to the grid.
// Save: only when the Focused Task checkbox differs from what is saved on the server.
hasTask
:=
SelectedValue
(
'task_picker_task'
)
<>
''
;
addFocus
:=
FocusCheckbox
;
focusChanged
:=
False
;
if
Assigned
(
addFocus
)
then
begin
addFocus
.
disabled
:=
(
not
hasTask
)
or
FSaving
;
focusChanged
:=
addFocus
.
checked
<>
FSavedFocus
;
end
;
SetButtonEnabled
(
'btn_task_picker_select'
,
hasTask
and
not
FSaving
);
SetButtonEnabled
(
'btn_task_picker_save'
,
hasTask
and
focusChanged
and
not
FSaving
);
end
;
procedure
TTaskPickerOffCanvas
.
Show
;
procedure
TTaskPickerOffCanvas
.
Show
;
begin
begin
asm
asm
...
@@ -268,12 +375,77 @@ begin
...
@@ -268,12 +375,77 @@ begin
FillSelect
(
'task_picker_task'
,
FTasks
);
FillSelect
(
'task_picker_task'
,
FTasks
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
SetSelectValue
(
const
AElementId
,
AValue
:
string
);
var
selectEl
:
TJSHTMLSelectElement
;
begin
// Setting .value in code does not fire 'change', so the cascade handlers do not run
selectEl
:=
TJSHTMLSelectElement
(
document
.
getElementById
(
AElementId
));
if
Assigned
(
selectEl
)
then
selectEl
.
value
:=
AValue
;
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
PreselectTask
(
const
ATaskId
:
string
;
AToken
:
Integer
);
var
response
:
TXDataClientResponse
;
context
:
TJSObject
;
project
:
TJSObject
;
projectId
:
string
;
customerId
:
string
;
projectFound
:
Boolean
;
i
:
Integer
;
begin
response
:=
await
(
FClient
.
RawInvokeAsync
(
'ITimeEntryService.GetTaskPickerTaskContext'
,
[
ATaskId
]
));
// Picker was reopened or the user changed a dropdown while this was loading
if
AToken
<>
FPrefillToken
then
Exit
;
context
:=
TJSObject
(
response
.
Result
);
projectId
:=
string
(
context
[
'projectId'
]);
if
projectId
=
''
then
Exit
;
// FProjects only holds ACTIVE projects; a task under any other project opens blank
projectFound
:=
False
;
customerId
:=
''
;
for
i
:=
0
to
FProjects
.
length
-
1
do
begin
project
:=
TJSObject
(
FProjects
[
i
]);
if
string
(
project
[
'value'
])
=
projectId
then
begin
customerId
:=
string
(
project
[
'customerId'
]);
projectFound
:=
True
;
Break
;
end
;
end
;
if
not
projectFound
then
Exit
;
SetSelectValue
(
'task_picker_customer'
,
customerId
);
FilterProjects
(
customerId
);
SetSelectValue
(
'task_picker_project'
,
projectId
);
await
(
LoadTasks
(
projectId
));
if
AToken
<>
FPrefillToken
then
Exit
;
// If the task is not in the list (e.g. moved project) the task select just stays blank
SetSelectValue
(
'task_picker_task'
,
ATaskId
);
UpdateFocusCheckbox
;
end
;
procedure
TTaskPickerOffCanvas
.
CustomerChanged
(
Event
:
TJSEvent
);
procedure
TTaskPickerOffCanvas
.
CustomerChanged
(
Event
:
TJSEvent
);
var
var
customerId
:
string
;
customerId
:
string
;
begin
begin
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
ClearStatus
;
ClearStatus
;
SetSaveEnabled
(
False
);
ClearSelect
(
'task_picker_project'
,
True
);
ClearSelect
(
'task_picker_project'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
UpdateFocusCheckbox
;
UpdateFocusCheckbox
;
...
@@ -289,8 +461,8 @@ var
...
@@ -289,8 +461,8 @@ var
project
:
TJSObject
;
project
:
TJSObject
;
i
:
Integer
;
i
:
Integer
;
begin
begin
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
ClearStatus
;
ClearStatus
;
SetSaveEnabled
(
False
);
ClearSelect
(
'task_picker_task'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
UpdateFocusCheckbox
;
UpdateFocusCheckbox
;
...
@@ -328,53 +500,66 @@ end;
...
@@ -328,53 +500,66 @@ end;
procedure
TTaskPickerOffCanvas
.
UpdateFocusCheckbox
;
procedure
TTaskPickerOffCanvas
.
UpdateFocusCheckbox
;
var
var
taskId
:
string
;
taskOption
:
TJSObject
;
alreadyFocused
:
Boolean
;
addFocus
:
TJSHTMLInputElement
;
addFocus
:
TJSHTMLInputElement
;
i
:
Integer
;
begin
begin
taskId
:=
SelectedValue
(
'task_picker_task'
);
// Reset the checkbox to the task's saved focus state (discards any unsaved toggle)
alreadyFocused
:=
False
;
FSavedFocus
:=
IsTaskFocused
(
SelectedValue
(
'task_picker_task'
));
if
taskId
<>
''
then
begin
for
i
:=
0
to
FFocusedTasks
.
length
-
1
do
begin
taskOption
:=
TJSObject
(
FFocusedTasks
[
i
]);
if
string
(
taskOption
[
'taskId'
])
=
taskId
then
begin
alreadyFocused
:=
True
;
Break
;
end
;
end
;
end
;
addFocus
:=
TJSHTMLInputElement
(
addFocus
:=
FocusCheckbox
;
document
.
getElementById
(
'task_picker_add_focus'
)
if
Assigned
(
addFocus
)
then
)
;
addFocus
.
checked
:=
FSavedFocus
;
addFocus
.
checked
:=
alreadyFocused
;
UpdateButtons
;
addFocus
.
disabled
:=
alreadyFocused
or
(
taskId
=
''
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
TaskChanged
(
Event
:
TJSEvent
);
procedure
TTaskPickerOffCanvas
.
TaskChanged
(
Event
:
TJSEvent
);
begin
begin
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
ClearStatus
;
ClearStatus
;
UpdateFocusCheckbox
;
UpdateFocusCheckbox
;
SetSaveEnabled
(
SelectedValue
(
'task_picker_task'
)
<>
''
);
end
;
procedure
TTaskPickerOffCanvas
.
FocusCheckboxChanged
(
Event
:
TJSEvent
);
begin
ClearStatus
;
UpdateButtons
;
end
;
procedure
TTaskPickerOffCanvas
.
SelectClicked
(
Event
:
TJSEvent
);
var
taskId
:
string
;
begin
Event
.
preventDefault
;
taskId
:=
SelectedValue
(
'task_picker_task'
);
if
taskId
=
''
then
begin
SetStatus
(
'Select a task.'
);
Exit
;
end
;
ClearStatus
;
// Sends the task to the grid only; focus changes happen through Save
if
Assigned
(
FOnTaskPicked
)
then
FOnTaskPicked
(
FRowIndex
,
taskId
,
FindDisplay
(
FTasks
,
taskId
));
Hide
;
end
;
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
SaveClicked
(
Event
:
TJSEvent
);
[
async
]
procedure
TTaskPickerOffCanvas
.
SaveClicked
(
Event
:
TJSEvent
);
var
var
taskId
:
string
;
taskId
:
string
;
taskDisplay
:
string
;
taskDisplay
:
string
;
methodName
:
string
;
addFocus
:
TJSHTMLInputElement
;
addFocus
:
TJSHTMLInputElement
;
addedToFocus
:
Boolean
;
focused
:
Boolean
;
begin
begin
Event
.
preventDefault
;
Event
.
preventDefault
;
if
FSaving
then
Exit
;
taskId
:=
SelectedValue
(
'task_picker_task'
);
taskId
:=
SelectedValue
(
'task_picker_task'
);
if
taskId
=
''
then
if
taskId
=
''
then
begin
begin
...
@@ -382,53 +567,79 @@ begin
...
@@ -382,53 +567,79 @@ begin
Exit
;
Exit
;
end
;
end
;
addFocus
:=
FocusCheckbox
;
if
not
Assigned
(
addFocus
)
then
Exit
;
focused
:=
addFocus
.
checked
;
if
focused
=
FSavedFocus
then
begin
UpdateButtons
;
Exit
;
end
;
taskDisplay
:=
FindDisplay
(
FTasks
,
taskId
);
taskDisplay
:=
FindDisplay
(
FTasks
,
taskId
);
addFocus
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'task_picker_add_focus'
)
);
ClearStatus
;
if
focused
then
addedToFocus
:=
False
;
methodName
:=
'ITimeEntryService.AddTaskToFocus'
else
methodName
:=
'ITimeEntryService.RemoveTaskFromFocus'
;
if
addFocus
.
checked
and
not
addFocus
.
disabled
then
ClearStatus
;
begin
FSaving
:=
True
;
SetSaveEnabled
(
False
)
;
UpdateButtons
;
try
try
await
(
FClient
.
RawInvokeAsync
(
try
'ITimeEntryService.AddTaskToFocus'
,
await
(
FClient
.
RawInvokeAsync
(
methodName
,
[
FUserId
,
taskId
]));
[
FUserId
,
taskId
]
));
addedToFocus
:=
True
;
except
except
on
E
:
EXDataClientRequestException
do
on
E
:
EXDataClientRequestException
do
begin
begin
SetStatus
(
E
.
ErrorResult
.
ErrorMessage
);
SetStatus
(
E
.
ErrorResult
.
ErrorMessage
);
SetSaveEnabled
(
True
);
Exit
;
Exit
;
end
;
end
;
on
E
:
Exception
do
begin
SetStatus
(
'Unable to save focused task.'
);
Exit
;
end
;
end
;
SetSaveEnabled
(
True
);
end
;
end
;
if
Assigned
(
FOnTaskPicked
)
then
SetTaskFocused
(
taskId
,
taskDisplay
,
focused
);
FOnTaskPicked
(
FRowIndex
,
taskId
,
taskDisplay
,
addedToFocus
);
Hide
;
// The user may have picked a different task while the request was running
if
SelectedValue
(
'task_picker_task'
)
=
taskId
then
FSavedFocus
:=
focused
;
if
Assigned
(
FOnFocusChanged
)
then
FOnFocusChanged
(
taskId
,
taskDisplay
,
focused
);
finally
FSaving
:=
False
;
UpdateButtons
;
end
;
end
;
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
Open
(
[
async
]
procedure
TTaskPickerOffCanvas
.
Open
(
const
AUserId
:
string
;
const
AUserId
:
string
;
ARowIndex
:
Integer
;
ARowIndex
:
Integer
;
AFocusedTasks
:
TJSArray
AFocusedTasks
:
TJSArray
;
const
ATaskId
:
string
);
);
var
token
:
Integer
;
begin
begin
FUserId
:=
AUserId
;
FUserId
:=
AUserId
;
FRowIndex
:=
ARowIndex
;
FRowIndex
:=
ARowIndex
;
FFocusedTasks
:=
AFocusedTasks
;
Inc
(
FPrefillToken
);
token
:=
FPrefillToken
;
// Work on a copy so the grid's task options are only changed through FOnFocusChanged
if
Assigned
(
AFocusedTasks
)
then
FFocusedTasks
:=
AFocusedTasks
.
slice
(
0
)
else
FFocusedTasks
:=
TJSArray
.
new
;
ClearStatus
;
ClearStatus
;
SetSaveEnabled
(
False
);
ClearSelect
(
'task_picker_customer'
,
True
);
ClearSelect
(
'task_picker_customer'
,
True
);
ClearSelect
(
'task_picker_project'
,
True
);
ClearSelect
(
'task_picker_project'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
...
@@ -442,7 +653,21 @@ begin
...
@@ -442,7 +653,21 @@ begin
FilterProjects
(
''
);
FilterProjects
(
''
);
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
SetStatus
(
'Unable to load customers or projects.'
);
SetStatus
(
'Unable to load customers or projects.'
);
Exit
;
end
;
end
;
// Row already has a task: open on its customer, project and task
if
(
ATaskId
=
''
)
or
(
token
<>
FPrefillToken
)
then
Exit
;
try
await
(
PreselectTask
(
ATaskId
,
token
));
except
on
E
:
Exception
do
SetStatus
(
'Unable to load this row''s task.'
);
end
;
end
;
end
;
end
;
...
...
emT3XDataServer/Source/Api.Database.dfm
View file @
33f30507
...
@@ -1342,7 +1342,7 @@ object ApiDatabase: TApiDatabase
...
@@ -1342,7 +1342,7 @@ object ApiDatabase: TApiDatabase
SQL.Strings = (
SQL.Strings = (
'select distinct'
'select distinct'
' t.TASK_ID,'
' t.TASK_ID,'
' c.NAME as CUSTOMER_NAME,'
' c.
SHORT_
NAME as CUSTOMER_NAME,'
' p.NAME as PROJECT_NAME,'
' p.NAME as PROJECT_NAME,'
' t.TASK_NUM_1,'
' t.TASK_NUM_1,'
' t.TASK_NUM_2,'
' t.TASK_NUM_2,'
...
...
emT3XDataServer/Source/TimeEntry.Service.pas
View file @
33f30507
...
@@ -73,7 +73,6 @@ type
...
@@ -73,7 +73,6 @@ type
value
:
string
;
value
:
string
;
end
;
end
;
type
TTaskPickerOption
=
class
TTaskPickerOption
=
class
public
public
value
:
string
;
value
:
string
;
...
@@ -88,6 +87,13 @@ type
...
@@ -88,6 +87,13 @@ type
destructor
Destroy
;
override
;
destructor
Destroy
;
override
;
end
;
end
;
TTaskPickerTaskContext
=
class
public
taskId
:
string
;
projectId
:
string
;
customerId
:
string
;
end
;
[
ServiceContract
,
Model
(
API_MODEL
)]
[
ServiceContract
,
Model
(
API_MODEL
)]
ITimeEntryService
=
interface
(
IInvokable
)
ITimeEntryService
=
interface
(
IInvokable
)
[
'{B18BCD1E-B19A-4D25-BBA9-50A24FC4C690}'
]
[
'{B18BCD1E-B19A-4D25-BBA9-50A24FC4C690}'
]
...
@@ -97,9 +103,11 @@ type
...
@@ -97,9 +103,11 @@ type
[
HttpPost
]
function
SaveTimeEntryField
(
Item
:
TTimeEntryFieldSave
):
Boolean
;
[
HttpPost
]
function
SaveTimeEntryField
(
Item
:
TTimeEntryFieldSave
):
Boolean
;
[
HttpPost
]
function
DeleteTimeEntry
(
userId
:
string
;
entryId
:
Integer
):
Boolean
;
[
HttpPost
]
function
DeleteTimeEntry
(
userId
:
string
;
entryId
:
Integer
):
Boolean
;
[
HttpPost
]
function
AddTaskToFocus
(
userId
,
taskId
:
string
):
Boolean
;
[
HttpPost
]
function
AddTaskToFocus
(
userId
,
taskId
:
string
):
Boolean
;
[
HttpPost
]
function
RemoveTaskFromFocus
(
userId
,
taskId
:
string
):
Boolean
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTaskContext
(
taskId
:
string
):
TTaskPickerTaskContext
;
end
;
end
;
implementation
implementation
...
...
emT3XDataServer/Source/TimeEntry.ServiceImpl.pas
View file @
33f30507
...
@@ -37,8 +37,10 @@ type
...
@@ -37,8 +37,10 @@ type
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTaskContext
(
taskId
:
string
):
TTaskPickerTaskContext
;
function
DeleteTimeEntry
(
userId
:
string
;
entryId
:
Integer
):
Boolean
;
function
DeleteTimeEntry
(
userId
:
string
;
entryId
:
Integer
):
Boolean
;
function
AddTaskToFocus
(
userId
,
taskId
:
string
):
Boolean
;
function
AddTaskToFocus
(
userId
,
taskId
:
string
):
Boolean
;
function
RemoveTaskFromFocus
(
userId
,
taskId
:
string
):
Boolean
;
end
;
end
;
implementation
implementation
...
@@ -213,7 +215,7 @@ begin
...
@@ -213,7 +215,7 @@ begin
' ti.CATEGORY, '
+
' ti.CATEGORY, '
+
' cat.CODE_DESC as CATEGORY_DESC, '
+
' cat.CODE_DESC as CATEGORY_DESC, '
+
' ti.SUMMARY, '
+
' ti.SUMMARY, '
+
' c.NAME as CUSTOMER_NAME, '
+
' c.
SHORT_
NAME as CUSTOMER_NAME, '
+
' p.NAME as PROJECT_NAME, '
+
' p.NAME as PROJECT_NAME, '
+
' t.TASK_NUM_1, '
+
' t.TASK_NUM_1, '
+
' t.TASK_NUM_2, '
+
' t.TASK_NUM_2, '
+
...
@@ -293,7 +295,7 @@ begin
...
@@ -293,7 +295,7 @@ begin
tasksQuery
.
SQL
.
Text
:=
tasksQuery
.
SQL
.
Text
:=
'select distinct '
+
'select distinct '
+
' t.TASK_ID, '
+
' t.TASK_ID, '
+
' c.NAME as CUSTOMER_NAME, '
+
' c.
SHORT_
NAME as CUSTOMER_NAME, '
+
' p.NAME as PROJECT_NAME, '
+
' p.NAME as PROJECT_NAME, '
+
' t.TASK_NUM_1, '
+
' t.TASK_NUM_1, '
+
' t.TASK_NUM_2, '
+
' t.TASK_NUM_2, '
+
...
@@ -308,7 +310,7 @@ begin
...
@@ -308,7 +310,7 @@ begin
'join customers c on c.CUSTOMER_ID = p.CUSTOMER_ID '
+
'join customers c on c.CUSTOMER_ID = p.CUSTOMER_ID '
+
'where tau.USER_ID = :USER_ID '
+
'where tau.USER_ID = :USER_ID '
+
' and upper(trim(coalesce(tau.FOCUSED_TASK, ''''))) = ''T'' '
+
' and upper(trim(coalesce(tau.FOCUSED_TASK, ''''))) = ''T'' '
+
'order by c.NAME, p.NAME, t.TASK_NUM_1, t.TASK_NUM_2, t.TASK_NUM_3, t.TASK_NUM_4, t.TASK_NUM_5, t.TASK_NUM_6'
;
'order by c.
SHORT_
NAME, p.NAME, t.TASK_NUM_1, t.TASK_NUM_2, t.TASK_NUM_3, t.TASK_NUM_4, t.TASK_NUM_5, t.TASK_NUM_6'
;
tasksQuery
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
tasksQuery
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
tasksQuery
.
Open
;
tasksQuery
.
Open
;
...
@@ -850,6 +852,39 @@ begin
...
@@ -850,6 +852,39 @@ begin
end
;
end
;
function
TTimeEntryService
.
GetTaskPickerTaskContext
(
taskId
:
string
):
TTaskPickerTaskContext
;
var
q
:
TUniQuery
;
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTaskPickerTaskContext - TASK_ID="%s"'
,
[
taskId
]));
Result
:=
TTaskPickerTaskContext
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
Result
.
taskId
:=
taskId
;
// Read-only lookup; an unknown task returns blank ids so the picker opens empty
q
:=
TUniQuery
.
Create
(
nil
);
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
SQL
.
Text
:=
'select t.PROJECT_ID, p.CUSTOMER_ID '
+
'from tasks t '
+
'join project p on p.PROJECT_ID = t.PROJECT_ID '
+
'where t.TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
q
.
Open
;
if
not
q
.
Eof
then
begin
Result
.
projectId
:=
FieldText
(
q
,
'PROJECT_ID'
);
Result
.
customerId
:=
FieldText
(
q
,
'CUSTOMER_ID'
);
end
;
finally
q
.
Free
;
end
;
end
;
function
TTimeEntryService
.
DeleteTimeEntry
(
userId
:
string
;
entryId
:
Integer
):
Boolean
;
function
TTimeEntryService
.
DeleteTimeEntry
(
userId
:
string
;
entryId
:
Integer
):
Boolean
;
var
var
q
:
TUniQuery
;
q
:
TUniQuery
;
...
@@ -952,6 +987,47 @@ begin
...
@@ -952,6 +987,47 @@ begin
end
;
end
;
end
;
end
;
function
TTimeEntryService
.
RemoveTaskFromFocus
(
userId
,
taskId
:
string
):
Boolean
;
var
q
:
TUniQuery
;
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.RemoveTaskFromFocus - USER_ID="%s" TASK_ID="%s"'
,
[
userId
,
taskId
]
));
// Only clears the flag; the task_assigned_user row is kept and never inserted here
q
:=
TUniQuery
.
Create
(
nil
);
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
.
StartTransaction
;
try
q
.
SQL
.
Text
:=
'update task_assigned_user '
+
'set FOCUSED_TASK = ''F'' '
+
'where USER_ID = :USER_ID and TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
q
.
ExecSQL
;
q
.
Connection
.
Commit
;
Result
:=
True
;
except
on
E
:
Exception
do
begin
if
q
.
Connection
.
InTransaction
then
q
.
Connection
.
Rollback
;
Logger
.
Log
(
2
,
'TimeEntryService.RemoveTaskFromFocus - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
finally
q
.
Free
;
end
;
end
;
initialization
initialization
RegisterServiceType
(
TTimeEntryService
);
RegisterServiceType
(
TTimeEntryService
);
...
...
emT3XDataServer/bin/emT3XDataServer.ini
View file @
33f30507
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
MemoLogLevel
=
5
MemoLogLevel
=
5
FileLogLevel
=
5
FileLogLevel
=
5
webClientVersion
=
0.9.3
webClientVersion
=
0.9.3
LogFileNum
=
2
0
8
LogFileNum
=
2
1
8
[Database]
[Database]
--Server
=
192.168.102.131
--Server
=
192.168.102.131
...
...
emT3XDataServer/emT3XDataServer.dproj
View file @
33f30507
...
@@ -114,11 +114,11 @@
...
@@ -114,11 +114,11 @@
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_ExeOutput>.\bin</DCC_ExeOutput>
<DCC_ExeOutput>.\bin</DCC_ExeOutput>
<DCC_UnitSearchPath>C:\RADTOOLS\FastMM4;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<DCC_UnitSearchPath>C:\RADTOOLS\FastMM4;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.9.3.
18
;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.9.3.
25
;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
<VerInfo_AutoIncVersion>true</VerInfo_AutoIncVersion>
<VerInfo_Build>
18
</VerInfo_Build>
<VerInfo_Build>
25
</VerInfo_Build>
<VerInfo_Release>3</VerInfo_Release>
<VerInfo_Release>3</VerInfo_Release>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment