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
dd94c9fb
Commit
dd94c9fb
authored
Nov 12, 2026
by
Daniel Barker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deal with copy directory
parent
236fcdca
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
3245 additions
and
1072 deletions
+3245
-1072
Auth.Service.pas
emT3Web/Auth.Service.pas
+4
-1
ConnectionModule.pas
emT3Web/ConnectionModule.pas
+6
-2
Utils.pas
emT3Web/Utils.pas
+12
-9
View.Login.dfm
emT3Web/View.Login.dfm
+0
-12
View.Login.html
emT3Web/View.Login.html
+0
-3
View.Login.pas
emT3Web/View.Login.pas
+3
-11
View.Main.html
emT3Web/View.Main.html
+2
-2
View.Main.pas
emT3Web/View.Main.pas
+17
-0
View.TaskItems.dfm
emT3Web/View.TaskItems.dfm
+12
-0
View.TaskItems.html
emT3Web/View.TaskItems.html
+1
-0
View.TaskItems.pas
emT3Web/View.TaskItems.pas
+18
-1
View.TimeEntries.dfm
emT3Web/View.TimeEntries.dfm
+1
-1
View.TimeEntries.html
emT3Web/View.TimeEntries.html
+77
-46
View.TimeEntries.pas
emT3Web/View.TimeEntries.pas
+558
-191
app.css
emT3Web/css/app.css
+5
-0
emT3web.dproj
emT3Web/emT3web.dproj
+4
-3
uTaskPickerOffCanvas.pas
emT3Web/uTaskPickerOffCanvas.pas
+588
-57
Api.Database.dfm
emT3XDataServer/Source/Api.Database.dfm
+31
-10
Api.Database.pas
emT3XDataServer/Source/Api.Database.pas
+1
-0
TaskItem.ServiceImpl.pas
emT3XDataServer/Source/TaskItem.ServiceImpl.pas
+417
-343
TimeEntry.Service.pas
emT3XDataServer/Source/TimeEntry.Service.pas
+12
-13
TimeEntry.ServiceImpl.pas
emT3XDataServer/Source/TimeEntry.ServiceImpl.pas
+686
-364
emT3XDataServer.ini
emT3XDataServer/bin/emT3XDataServer.ini
+2
-2
View.ErrorPage.html
...ataServer/bin/static-View.TimeEntries/View.ErrorPage.html
+17
-0
View.Login.html
emT3XDataServer/bin/static-View.TimeEntries/View.Login.html
+42
-0
View.Main.html
emT3XDataServer/bin/static-View.TimeEntries/View.Main.html
+131
-0
View.TaskItems.html
...ataServer/bin/static-View.TimeEntries/View.TaskItems.html
+61
-0
View.TimeEntries.html
...aServer/bin/static-View.TimeEntries/View.TimeEntries.html
+108
-0
index.html
emT3XDataServer/bin/static-View.TimeEntries/index.html
+427
-0
emT3XDataServer.dproj
emT3XDataServer/emT3XDataServer.dproj
+2
-1
No files found.
emT3Web/Auth.Service.pas
View file @
dd94c9fb
...
@@ -172,7 +172,10 @@ procedure TAuthService.Logout;
...
@@ -172,7 +172,10 @@ procedure TAuthService.Logout;
begin
begin
DeleteToken
;
DeleteToken
;
DMConnection
.
currentTaskId
:=
''
;
DMConnection
.
currentTaskId
:=
''
;
DMConnection
.
currentTimeEntryDate
:=
''
;
DMConnection
.
timeEntriesWeekOf
:=
''
;
DMConnection
.
timeEntriesStartDate
:=
''
;
DMConnection
.
timeEntriesEndDate
:=
''
;
DMConnection
.
timeEntriesKeptIds
:=
''
;
end
;
end
;
procedure
TAuthService
.
SetToken
(
AToken
:
string
);
procedure
TAuthService
.
SetToken
(
AToken
:
string
);
...
...
emT3Web/ConnectionModule.pas
View file @
dd94c9fb
...
@@ -21,8 +21,12 @@ type
...
@@ -21,8 +21,12 @@ type
public
public
currentTaskId
:
string
;
currentTaskId
:
string
;
currentTimeEntryDate
:
string
;
// Time Entries range saved when a row opens Task Items, restored by Back ('' = none)
const
clientVersion
=
'0.9.4.0'
;
timeEntriesWeekOf
:
string
;
timeEntriesStartDate
:
string
;
timeEntriesEndDate
:
string
;
timeEntriesKeptIds
:
string
;
const
clientVersion
=
'0.9.4.1'
;
procedure
InitApp
(
SuccessProc
:
TSuccessProc
;
procedure
InitApp
(
SuccessProc
:
TSuccessProc
;
UnauthorizedAccessProc
:
TUnauthorizedAccessProc
);
UnauthorizedAccessProc
:
TUnauthorizedAccessProc
);
procedure
SetClientConfig
(
Callback
:
TVersionCheckCallback
);
procedure
SetClientConfig
(
Callback
:
TVersionCheckCallback
);
...
...
emT3Web/Utils.pas
View file @
dd94c9fb
...
@@ -95,9 +95,9 @@ end;
...
@@ -95,9 +95,9 @@ end;
procedure
ShowErrorModal
(
msg
:
string
);
procedure
ShowErrorModal
(
msg
:
string
);
begin
begin
asm
asm
var
modal
=
document
.
getElementById
(
'm
ain_errormodal
'
);
var
modal
=
document
.
getElementById
(
'm
dl_error
'
);
var
label
=
document
.
getElementById
(
'
main_lbl
modal_body'
);
var
label
=
document
.
getElementById
(
'
lbl_
modal_body'
);
var
reloadBtn
=
document
.
getElementById
(
'btn_modal_restart
'
);
var
closeBtn
=
document
.
getElementById
(
'btn_modal_error_close
'
);
if
(
label
)
label
.
innerText
=
msg
;
if
(
label
)
label
.
innerText
=
msg
;
...
@@ -106,10 +106,13 @@ begin
...
@@ -106,10 +106,13 @@ begin
document.body.appendChild(modal);
document.body.appendChild(modal);
}
}
// Bind hard reload to button
// Button simply closes the modal
if
(
reloadBtn
)
{
if
(
closeBtn
)
{
reloadBtn.onclick = function () {
closeBtn.onclick = function () {
window.location.reload(true); // hard reload, bypass cache
var existing = bootstrap.Modal.getInstance(modal);
if (existing) {
existing.hide();
}
};
};
}
}
...
@@ -123,8 +126,8 @@ end;
...
@@ -123,8 +126,8 @@ end;
procedure
ShowNotificationModal
(
msg
:
string
);
procedure
ShowNotificationModal
(
msg
:
string
);
begin
begin
asm
asm
var
modal
=
document
.
getElementById
(
'm
ain_notification_modal
'
);
var
modal
=
document
.
getElementById
(
'm
dl_notification
'
);
var
label
=
document
.
getElementById
(
'
main_notification_modal
_body'
);
var
label
=
document
.
getElementById
(
'
lbl_notification
_body'
);
var
closeBtn
=
document
.
getElementById
(
'btn_modal_close'
);
var
closeBtn
=
document
.
getElementById
(
'btn_modal_close'
);
if
(
label
)
label
.
innerText
=
msg
;
if
(
label
)
label
.
innerText
=
msg
;
...
...
emT3Web/View.Login.dfm
View file @
dd94c9fb
...
@@ -92,18 +92,6 @@ object FViewLogin: TFViewLogin
...
@@ -92,18 +92,6 @@ object FViewLogin: TFViewLogin
TextHint = 'TaskId'
TextHint = 'TaskId'
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object edtDate: TWebEdit
Left = 240
Top = 156
Width = 121
Height = 22
ChildOrder = 6
ElementID = 'view.login.edtdate'
ElementFont = efCSS
HeightPercent = 100.000000000000000000
TextHint = 'Date'
WidthPercent = 100.000000000000000000
end
object XDataWebClient: TXDataWebClient
object XDataWebClient: TXDataWebClient
Connection = DMConnection.AuthConnection
Connection = DMConnection.AuthConnection
Left = 492
Left = 492
...
...
emT3Web/View.Login.html
View file @
dd94c9fb
...
@@ -20,9 +20,6 @@
...
@@ -20,9 +20,6 @@
<div
id=
"view.login.taskid.group"
class=
"mb-3"
>
<div
id=
"view.login.taskid.group"
class=
"mb-3"
>
<input
id=
"view.login.edttaskid"
class=
"form-control"
type=
"text"
placeholder=
"Task Id"
>
<input
id=
"view.login.edttaskid"
class=
"form-control"
type=
"text"
placeholder=
"Task Id"
>
</div>
</div>
<div
id=
"view.login.date.group"
class=
"mb-3"
>
<input
id=
"view.login.edtdate"
class=
"form-control"
type=
"date"
placeholder=
"Date"
>
</div>
<div
class=
"mb-3"
>
<div
class=
"mb-3"
>
<input
id=
"view.login.edtusername"
class=
"form-control"
type=
"text"
autofocus
placeholder=
"Username"
>
<input
id=
"view.login.edtusername"
class=
"form-control"
type=
"text"
autofocus
placeholder=
"Username"
>
</div>
</div>
...
...
emT3Web/View.Login.pas
View file @
dd94c9fb
...
@@ -19,7 +19,6 @@ type
...
@@ -19,7 +19,6 @@ type
btnCloseNotification
:
TWebButton
;
btnCloseNotification
:
TWebButton
;
XDataWebClient
:
TXDataWebClient
;
XDataWebClient
:
TXDataWebClient
;
edtTaskId
:
TWebEdit
;
edtTaskId
:
TWebEdit
;
edtDate
:
TWebEdit
;
procedure
btnLoginClick
(
Sender
:
TObject
);
procedure
btnLoginClick
(
Sender
:
TObject
);
procedure
btnCloseNotificationClick
(
Sender
:
TObject
);
procedure
btnCloseNotificationClick
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
...
@@ -58,13 +57,9 @@ var
...
@@ -58,13 +57,9 @@ var
if
isTimeEntriesMode
then
if
isTimeEntriesMode
then
begin
begin
DMConnection
.
currentTaskId
:=
''
;
DMConnection
.
currentTaskId
:=
''
;
DMConnection
.
currentTimeEntryDate
:=
edtDate
.
Text
;
if
edtDate
.
Text
<>
''
then
newUrl
:=
window
.
location
.
pathname
+
'?time_entries=true&date='
+
edtDate
.
Text
else
newUrl
:=
window
.
location
.
pathname
+
'?time_entries=true'
;
// Time Entries always opens on the current week, so no date goes in the URL
newUrl
:=
window
.
location
.
pathname
+
'?time_entries=true'
;
window
.
history
.
replaceState
(
TJSObject
.
new
,
''
,
newUrl
);
window
.
history
.
replaceState
(
TJSObject
.
new
,
''
,
newUrl
);
end
end
else
else
...
@@ -89,7 +84,7 @@ begin
...
@@ -89,7 +84,7 @@ begin
AuthService
.
WebLogin
(
AuthService
.
WebLogin
(
edtUsername
.
Text
,
edtUsername
.
Text
,
'time_entries'
,
'time_entries'
,
edtDate
.
Text
,
''
,
// the server ignores the login value for time entries
edtPassword
.
Text
,
edtPassword
.
Text
,
@
LoginSuccess
,
@
LoginSuccess
,
@
LoginError
@
LoginError
...
@@ -164,19 +159,16 @@ begin
...
@@ -164,19 +159,16 @@ begin
edtUsername
.
Text
:=
FUserId
;
edtUsername
.
Text
:=
FUserId
;
edtTaskId
.
Text
:=
FTaskId
;
edtTaskId
.
Text
:=
FTaskId
;
edtDate
.
Text
:=
Application
.
Parameters
.
Values
[
'date'
];
if
isTimeEntriesMode
then
if
isTimeEntriesMode
then
begin
begin
WebLabel1
.
Caption
:=
'Time Entries Sign In'
;
WebLabel1
.
Caption
:=
'Time Entries Sign In'
;
TJSHTMLElement
(
document
.
getElementById
(
'view.login.taskid.group'
)).
classList
.
add
(
'd-none'
);
TJSHTMLElement
(
document
.
getElementById
(
'view.login.taskid.group'
)).
classList
.
add
(
'd-none'
);
TJSHTMLElement
(
document
.
getElementById
(
'view.login.date.group'
)).
classList
.
remove
(
'd-none'
);
end
end
else
else
begin
begin
WebLabel1
.
Caption
:=
'Task Items Sign In'
;
WebLabel1
.
Caption
:=
'Task Items Sign In'
;
TJSHTMLElement
(
document
.
getElementById
(
'view.login.taskid.group'
)).
classList
.
remove
(
'd-none'
);
TJSHTMLElement
(
document
.
getElementById
(
'view.login.taskid.group'
)).
classList
.
remove
(
'd-none'
);
TJSHTMLElement
(
document
.
getElementById
(
'view.login.date.group'
)).
classList
.
add
(
'd-none'
);
end
;
end
;
if
FMessage
<>
''
then
if
FMessage
<>
''
then
...
...
emT3Web/View.Main.html
View file @
dd94c9fb
...
@@ -76,11 +76,11 @@
...
@@ -76,11 +76,11 @@
<h5
class=
"modal-title"
id=
"lbl_modal_title"
>
Error
</h5>
<h5
class=
"modal-title"
id=
"lbl_modal_title"
>
Error
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
</div>
<div
class=
"modal-body fs-6
fw-bold
"
id=
"lbl_modal_body"
>
<div
class=
"modal-body fs-6"
id=
"lbl_modal_body"
>
Please contact EMSystems to solve the issue.
Please contact EMSystems to solve the issue.
</div>
</div>
<div
class=
"modal-footer justify-content-center"
>
<div
class=
"modal-footer justify-content-center"
>
<button
type=
"button"
id=
"btn_modal_
restart"
class=
"btn btn-primary"
>
Back to Orders
</button>
<button
type=
"button"
id=
"btn_modal_
error_close"
class=
"btn btn-primary"
>
Close
</button>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
emT3Web/View.Main.pas
View file @
dd94c9fb
...
@@ -26,6 +26,8 @@ type
...
@@ -26,6 +26,8 @@ type
procedure
ShowForm
(
aFormClass
:
TWebFormClass
);
procedure
ShowForm
(
aFormClass
:
TWebFormClass
);
public
public
class
procedure
Display
(
logoutProc
:
TLogoutProc
);
class
procedure
Display
(
logoutProc
:
TLogoutProc
);
procedure
ShowTaskItems
(
const
ATaskId
:
string
);
procedure
ShowTimeEntries
;
end
;
end
;
var
var
...
@@ -78,6 +80,21 @@ begin
...
@@ -78,6 +80,21 @@ begin
Application
.
CreateForm
(
aFormClass
,
pnlMain
.
ElementID
,
FChildForm
);
Application
.
CreateForm
(
aFormClass
,
pnlMain
.
ElementID
,
FChildForm
);
end
;
end
;
// Opened from a Time Entries row; the URL is left as-is, so a refresh lands back on Time Entries
procedure
TFViewMain
.
ShowTaskItems
(
const
ATaskId
:
string
);
begin
DMConnection
.
currentTaskId
:=
ATaskId
;
lblAppTitle
.
Caption
:=
'Task Items'
;
ShowForm
(
TFTaskItems
);
end
;
procedure
TFViewMain
.
ShowTimeEntries
;
begin
DMConnection
.
currentTaskId
:=
''
;
lblAppTitle
.
Caption
:=
'Time Entries'
;
ShowForm
(
TFTimeEntries
);
end
;
class
procedure
TFViewMain
.
Display
(
logoutProc
:
TLogoutProc
);
class
procedure
TFViewMain
.
Display
(
logoutProc
:
TLogoutProc
);
begin
begin
if
Assigned
(
FViewMain
)
then
if
Assigned
(
FViewMain
)
then
...
...
emT3Web/View.TaskItems.dfm
View file @
dd94c9fb
...
@@ -16,6 +16,18 @@ object FTaskItems: TFTaskItems
...
@@ -16,6 +16,18 @@ object FTaskItems: TFTaskItems
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnReloadClick
OnClick = btnReloadClick
end
end
object btnBack: TWebButton
Left = 78
Top = 57
Width = 96
Height = 25
Caption = 'Back'
ElementID = 'btn_back'
HeightPercent = 100.000000000000000000
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnBackClick
end
object btnAddRow: TWebButton
object btnAddRow: TWebButton
Left = 78
Left = 78
Top = 119
Top = 119
...
...
emT3Web/View.TaskItems.html
View file @
dd94c9fb
<div
class=
"container-fluid p-2 d-flex flex-column h-100 overflow-hidden"
>
<div
class=
"container-fluid p-2 d-flex flex-column h-100 overflow-hidden"
>
<div
class=
"d-flex align-items-center justify-content-between mb-2 flex-shrink-0 gap-3"
>
<div
class=
"d-flex align-items-center justify-content-between mb-2 flex-shrink-0 gap-3"
>
<button
id=
"btn_back"
type=
"button"
class=
"btn btn-sm btn-secondary text-nowrap d-none"
>
Back
</button>
<h5
class=
"mb-0"
id=
"lbl_project_name"
></h5>
<h5
class=
"mb-0"
id=
"lbl_project_name"
></h5>
<div
class=
"d-flex align-items-center gap-2 ms-auto flex-nowrap"
>
<div
class=
"d-flex align-items-center gap-2 ms-auto flex-nowrap"
>
...
...
emT3Web/View.TaskItems.pas
View file @
dd94c9fb
...
@@ -36,6 +36,7 @@ type
...
@@ -36,6 +36,7 @@ type
btnFmtBold
:
TWebButton
;
btnFmtBold
:
TWebButton
;
btnFmtItalic
:
TWebButton
;
btnFmtItalic
:
TWebButton
;
btnFmtUnderline
:
TWebButton
;
btnFmtUnderline
:
TWebButton
;
btnBack
:
TWebButton
;
[
async
]
procedure
btnAddRowClick
(
Sender
:
TObject
);
[
async
]
procedure
btnAddRowClick
(
Sender
:
TObject
);
procedure
btnReloadClick
(
Sender
:
TObject
);
procedure
btnReloadClick
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
...
@@ -46,6 +47,7 @@ type
...
@@ -46,6 +47,7 @@ type
procedure
btnFmtBoldClick
(
Sender
:
TObject
);
procedure
btnFmtBoldClick
(
Sender
:
TObject
);
procedure
btnFmtItalicClick
(
Sender
:
TObject
);
procedure
btnFmtItalicClick
(
Sender
:
TObject
);
procedure
btnFmtUnderlineClick
(
Sender
:
TObject
);
procedure
btnFmtUnderlineClick
(
Sender
:
TObject
);
procedure
btnBackClick
(
Sender
:
TObject
);
private
private
FTaskId
:
string
;
FTaskId
:
string
;
FApplicationOptions
:
TJSArray
;
FApplicationOptions
:
TJSArray
;
...
@@ -120,7 +122,8 @@ var
...
@@ -120,7 +122,8 @@ var
implementation
implementation
uses
uses
ConnectionModule
;
ConnectionModule
,
View
.
Main
;
{$R *.dfm}
{$R *.dfm}
...
@@ -166,6 +169,10 @@ begin
...
@@ -166,6 +169,10 @@ begin
FNameManager
.
BindControls
;
FNameManager
.
BindControls
;
// Back only applies when opened from a Time Entries row (no task_id in the URL)
if
Application
.
Parameters
.
Values
[
'task_id'
]
=
''
then
btnBack
.
ElementHandle
.
classList
.
remove
(
'd-none'
);
if
FTaskId
=
''
then
if
FTaskId
=
''
then
begin
begin
Utils
.
ShowErrorModal
(
'Missing task_id. Please reopen from emt3.'
);
Utils
.
ShowErrorModal
(
'Missing task_id. Please reopen from emt3.'
);
...
@@ -658,6 +665,16 @@ begin
...
@@ -658,6 +665,16 @@ begin
end
;
end
;
procedure
TFTaskItems
.
btnBackClick
(
Sender
:
TObject
);
begin
// Deferred so this form isn't freed while its own click is still running
window
.
setTimeout
(
procedure
begin
FViewMain
.
ShowTimeEntries
;
end
,
0
);
end
;
procedure
TFTaskItems
.
btnTextColorClick
(
Sender
:
TObject
);
procedure
TFTaskItems
.
btnTextColorClick
(
Sender
:
TObject
);
var
var
colorEl
:
TJSHTMLElement
;
colorEl
:
TJSHTMLElement
;
...
...
emT3Web/View.TimeEntries.dfm
View file @
dd94c9fb
...
@@ -27,7 +27,7 @@ object FTimeEntries: TFTimeEntries
...
@@ -27,7 +27,7 @@ object FTimeEntries: TFTimeEntries
ShowFocus = False
ShowFocus = False
Text = 'edtWeekOf'
Text = 'edtWeekOf'
WidthPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
On
Exit = edtWeekOfExit
On
Change = edtWeekOfChange
end
end
object edtStartDate: TWebEdit
object edtStartDate: TWebEdit
Left = 245
Left = 245
...
...
emT3Web/View.TimeEntries.html
View file @
dd94c9fb
...
@@ -43,55 +43,86 @@
...
@@ -43,55 +43,86 @@
<div
id=
"time_entries_table_host"
class=
"flex-grow-1 min-h-0 overflow-auto"
></div>
<div
id=
"time_entries_table_host"
class=
"flex-grow-1 min-h-0 overflow-auto"
></div>
<div
class=
"offcanvas offcanvas-end"
tabindex=
"-1"
id=
"task_picker_offcanvas"
aria-labelledby=
"task_picker_title"
>
<div
class=
"modal fade"
tabindex=
"-1"
id=
"task_picker_modal"
aria-labelledby=
"task_picker_title"
aria-hidden=
"true"
data-bs-backdrop=
"static"
>
<div
class=
"offcanvas-header"
>
<div
class=
"modal-dialog modal-lg"
>
<h5
class=
"offcanvas-title"
id=
"task_picker_title"
>
Find Task
</h5>
<div
class=
"modal-content"
>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"offcanvas"
aria-label=
"Close"
></button>
<div
class=
"modal-header"
>
</div>
<h5
class=
"modal-title"
id=
"task_picker_title"
>
Find Task
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
<div
class=
"offcanvas-body"
>
<div
class=
"mb-3"
>
<label
for=
"task_picker_customer"
class=
"form-label"
>
Customer
</label>
<select
id=
"task_picker_customer"
class=
"form-select form-select-sm"
>
<option
value=
""
></option>
</select>
</div>
<div
class=
"mb-3"
>
<label
for=
"task_picker_project"
class=
"form-label"
>
Project
</label>
<select
id=
"task_picker_project"
class=
"form-select form-select-sm"
disabled
>
<option
value=
""
></option>
</select>
</div>
<div
class=
"mb-3"
>
<label
for=
"task_picker_task"
class=
"form-label"
>
Task
</label>
<select
id=
"task_picker_task"
class=
"form-select form-select-sm"
disabled
>
<option
value=
""
></option>
</select>
</div>
<div
id=
"task_picker_status"
class=
"alert alert-danger py-1 px-2 mb-3 d-none small"
></div>
<div
class=
"d-flex align-items-center gap-2"
>
<div
class=
"d-flex align-items-center gap-2 me-auto"
>
<input
class=
"form-check-input m-0"
type=
"checkbox"
id=
"task_picker_add_focus"
/>
<label
class=
"form-check-label mb-0"
for=
"task_picker_add_focus"
>
Focused Task
</label>
</div>
</div>
<button
type=
"button"
class=
"btn btn-outline-secondary btn-sm"
data-bs-dismiss=
"offcanvas"
>
<div
class=
"modal-body"
>
Cancel
<div
class=
"row g-2 mb-3"
>
</button>
<div
class=
"col-md-4"
>
<label
for=
"task_picker_date"
class=
"form-label"
>
Work Date
</label>
<button
type=
"button"
class=
"btn btn-outline-success btn-sm"
id=
"btn_task_picker_save"
disabled
>
<input
type=
"date"
id=
"task_picker_date"
class=
"form-control form-control-sm"
Save
title=
"Select also sets the row's date. Only projects and tasks open on this date are listed."
/>
</button>
</div>
</div>
<div
class=
"row g-2 align-items-end mb-3"
>
<div
class=
"col-md"
>
<label
for=
"task_picker_scope"
class=
"form-label"
>
Show
</label>
<select
id=
"task_picker_scope"
class=
"form-select form-select-sm"
>
<option
value=
"MY"
selected
>
My Projects
</option>
<option
value=
"ACTIVE"
>
Active Projects
</option>
<option
value=
"ALL"
>
All Projects
</option>
</select>
</div>
<div
class=
"col-md"
id=
"task_picker_customer_group"
>
<label
for=
"task_picker_customer"
class=
"form-label"
>
Customer
</label>
<select
id=
"task_picker_customer"
class=
"form-select form-select-sm"
>
<option
value=
""
></option>
</select>
</div>
<div
class=
"col-md"
>
<label
for=
"task_picker_project"
class=
"form-label"
>
Project
</label>
<select
id=
"task_picker_project"
class=
"form-select form-select-sm"
disabled
>
<option
value=
""
></option>
</select>
</div>
</div>
<div
class=
"row g-2 align-items-end mb-3"
>
<div
class=
"col-md"
>
<label
for=
"task_picker_task"
class=
"form-label"
>
Task
</label>
<select
id=
"task_picker_task"
class=
"form-select form-select-sm"
disabled
>
<option
value=
""
></option>
</select>
</div>
</div>
<div
id=
"task_picker_status"
class=
"alert alert-danger py-1 px-2 mb-0 d-none small"
></div>
</div>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
id=
"btn_task_picker_select"
disabled
>
<div
class=
"modal-footer"
>
Select
<div
class=
"d-flex align-items-center gap-2"
>
</button>
<input
class=
"form-check-input m-0"
type=
"checkbox"
id=
"task_picker_add_focus"
/>
<label
class=
"form-check-label mb-0"
for=
"task_picker_add_focus"
>
Focused Task
</label>
</div>
<!-- The selected task's own status; Save applies it with Focused Task -->
<div
class=
"d-flex align-items-center gap-2 ms-3 me-auto"
>
<label
for=
"task_picker_task_status"
class=
"form-label mb-0"
>
Status
</label>
<select
id=
"task_picker_task_status"
class=
"form-select form-select-sm"
style=
"width: 9rem;"
disabled
></select>
</div>
<button
type=
"button"
class=
"btn btn-outline-secondary btn-sm"
data-bs-dismiss=
"modal"
>
Cancel
</button>
<button
type=
"button"
class=
"btn btn-outline-success btn-sm"
id=
"btn_task_picker_save"
disabled
>
Save
</button>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
id=
"btn_task_picker_select"
disabled
>
Select
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
emT3Web/View.TimeEntries.pas
View file @
dd94c9fb
...
@@ -33,7 +33,7 @@ type
...
@@ -33,7 +33,7 @@ type
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
WebFormCreate
(
Sender
:
TObject
);
procedure
btnAddEntryClick
(
Sender
:
TObject
);
procedure
btnAddEntryClick
(
Sender
:
TObject
);
procedure
btnDeleteEntryClick
(
Sender
:
TObject
);
procedure
btnDeleteEntryClick
(
Sender
:
TObject
);
procedure
edtWeekOf
Exit
(
Sender
:
TObject
);
procedure
edtWeekOf
Change
(
Sender
:
TObject
);
[
async
]
procedure
btnSearchRangeClick
(
Sender
:
TObject
);
[
async
]
procedure
btnSearchRangeClick
(
Sender
:
TObject
);
procedure
btnCopyEntryClick
(
Sender
:
TObject
);
procedure
btnCopyEntryClick
(
Sender
:
TObject
);
private
private
...
@@ -56,17 +56,41 @@ type
...
@@ -56,17 +56,41 @@ type
FAddingNewEntry
:
Boolean
;
FAddingNewEntry
:
Boolean
;
FNewEntryRowIndex
:
Integer
;
FNewEntryRowIndex
:
Integer
;
FEditingEntryId
:
Integer
;
FEditingEntryId
:
Integer
;
FEditingRowIndex
:
Integer
;
FOriginalTaskDate
:
string
;
FOriginalTaskDate
:
string
;
FOriginalHours
:
Double
;
FOriginalTaskId
:
string
;
FOriginalTaskDisplay
:
string
;
FOriginalTaskTime
:
string
;
FOriginalPlace
:
string
;
FOriginalPlaceDesc
:
string
;
FOriginalCategory
:
string
;
FOriginalCategoryDesc
:
string
;
FOriginalSummary
:
string
;
FUserStartDate
:
string
;
FUserEndDate
:
string
;
FKeptEntryIds
:
string
;
// comma list of entries saved outside the range, shown until the range changes
[
async
]
procedure
LoadTimeEntries
;
[
async
]
procedure
LoadTimeEntries
;
procedure
KeepEntryIfOutsideRange
(
const
AEntryId
,
ATaskDate
:
string
);
function
BeginAddEntry
:
Boolean
;
function
BeginAddEntry
:
Boolean
;
function
IsNewEntryRow
(
AIndex
:
Integer
):
Boolean
;
function
IsNewEntryRow
(
AIndex
:
Integer
):
Boolean
;
procedure
ResetNewEntryState
;
procedure
ResetNewEntryState
;
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
);
[
async
]
procedure
EntryDraftSaveClick
(
Event
:
TJSEvent
);
procedure
EditedDateCancelClick
(
Event
:
TJSEvent
);
procedure
EntryDraftCancelClick
(
Event
:
TJSEvent
);
function
BuildTimeEntryPayload
(
const
AEntryId
:
string
):
TJSObject
;
procedure
BeginEntryDraft
(
AIndex
:
Integer
);
procedure
ClearEntryDraft
;
function
IsDraftEntryRow
:
Boolean
;
procedure
ShowEntryDraftActions
(
AIndex
:
Integer
);
function
BlockForDraftRow
(
AIndex
:
Integer
;
const
AAction
:
string
):
Boolean
;
procedure
DocumentFocusIn
(
Event
:
TJSEvent
);
function
JsText
(
const
AValue
:
JSValue
):
string
;
function
IsTaskOpenOn
(
const
ATaskStart
,
ATaskEnd
,
ADate
:
string
):
Boolean
;
procedure
RefreshTaskOptionStates
(
AIndex
:
Integer
;
const
ADate
:
string
);
[
async
]
procedure
SaveNewEntry
;
[
async
]
procedure
SaveNewEntry
;
procedure
CancelNewEntry
;
procedure
CancelNewEntry
;
procedure
RenderTable
;
procedure
RenderTable
;
...
@@ -98,11 +122,11 @@ type
...
@@ -98,11 +122,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
);
procedure
TaskItemsButtonClick
(
Event
:
TJSEvent
);
procedure
CloseTaskMenu
(
AEl
:
TJSHTMLElement
);
procedure
TaskPickerTaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
,
ATaskDate
:
string
);
procedure
TaskPickerFocusChanged
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
procedure
TaskPickerFocusChanged
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
procedure
ApplyActiveRowState
;
procedure
ApplyActiveRowState
;
procedure
EditorBlur
(
Event
:
TJSEvent
);
[
async
]
function
SaveField
(
AIndex
:
Integer
;
const
AFieldName
:
string
):
Boolean
;
[
async
]
procedure
DeleteSelectedEntry
;
[
async
]
procedure
DeleteSelectedEntry
;
function
CopySelectedEntry
:
Boolean
;
function
CopySelectedEntry
:
Boolean
;
public
public
...
@@ -115,7 +139,8 @@ implementation
...
@@ -115,7 +139,8 @@ implementation
uses
uses
Auth
.
Service
,
Auth
.
Service
,
Utils
;
Utils
,
View
.
Main
;
{$R *.dfm}
{$R *.dfm}
...
@@ -135,14 +160,18 @@ begin
...
@@ -135,14 +160,18 @@ begin
FActiveRowIndex
:=
-
1
;
FActiveRowIndex
:=
-
1
;
FBlockedRowIndex
:=
-
1
;
FBlockedRowIndex
:=
-
1
;
FPendingEntryId
:=
''
;
FPendingEntryId
:=
''
;
FKeptEntryIds
:=
''
;
FLastMouseDownRowIndex
:=
-
1
;
FLastMouseDownRowIndex
:=
-
1
;
FLastMouseDownTime
:=
0
;
FLastMouseDownTime
:=
0
;
FAddingNewEntry
:=
False
;
FAddingNewEntry
:=
False
;
FNewEntryRowIndex
:=
-
1
;
FNewEntryRowIndex
:=
-
1
;
FEditingEntryId
:=
0
;
FEditingRowIndex
:=
-
1
;
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
,
@
TaskPickerFocusChanged
);
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
,
@
TaskPickerFocusChanged
);
document
.
addEventListener
(
'mousedown'
,
TJSEventHandler
(@
DocumentMouseDown
));
document
.
addEventListener
(
'mousedown'
,
TJSEventHandler
(@
DocumentMouseDown
));
document
.
addEventListener
(
'focusin'
,
TJSEventHandler
(@
DocumentFocusIn
));
payload
:=
AuthService
.
TokenPayload
;
payload
:=
AuthService
.
TokenPayload
;
if
Assigned
(
payload
)
then
if
Assigned
(
payload
)
then
...
@@ -158,15 +187,35 @@ begin
...
@@ -158,15 +187,35 @@ begin
btnDeleteEntry
.
Enabled
:=
False
;
btnDeleteEntry
.
Enabled
:=
False
;
btnCopyEntry
.
Enabled
:=
False
;
btnCopyEntry
.
Enabled
:=
False
;
anchorDate
:=
DMConnection
.
currentTimeEntryDate
;
if
DMConnection
.
timeEntriesStartDate
<>
''
then
begin
if
anchorDate
=
''
then
// Back from Task Items: reopen on the range (and kept entries) that was showing
anchorDate
:=
Application
.
Parameters
.
Values
[
'date'
];
FUpdatingDates
:=
True
;
try
edtWeekOf
.
Text
:=
DMConnection
.
timeEntriesWeekOf
;
edtStartDate
.
Text
:=
DMConnection
.
timeEntriesStartDate
;
edtEndDate
.
Text
:=
DMConnection
.
timeEntriesEndDate
;
FStartDate
:=
edtStartDate
.
Text
;
FEndDate
:=
edtEndDate
.
Text
;
FKeptEntryIds
:=
DMConnection
.
timeEntriesKeptIds
;
finally
FUpdatingDates
:=
False
;
end
;
if
anchorDate
=
''
then
DMConnection
.
timeEntriesWeekOf
:=
''
;
anchorDate
:=
DateToIso
(
Date
);
DMConnection
.
timeEntriesStartDate
:=
''
;
DMConnection
.
timeEntriesEndDate
:=
''
;
DMConnection
.
timeEntriesKeptIds
:=
''
;
end
else
begin
// Otherwise open on the current Monday-Sunday week of the user's computer date.
// DayOfWeek: 1 = Sunday .. 7 = Saturday, so this steps back 0-6 days to Monday.
anchorDate
:=
DateToIso
(
Date
-
((
DayOfWeek
(
Date
)
+
5
)
mod
7
));
SetWeekRangeFromAnchor
(
anchorDate
,
False
);
SetWeekRangeFromAnchor
(
anchorDate
,
False
);
end
;
if
not
DMConnection
.
ApiConnection
.
Connected
then
if
not
DMConnection
.
ApiConnection
.
Connected
then
begin
begin
...
@@ -232,6 +281,7 @@ begin
...
@@ -232,6 +281,7 @@ begin
FStartDate
:=
edtStartDate
.
Text
;
FStartDate
:=
edtStartDate
.
Text
;
FEndDate
:=
edtEndDate
.
Text
;
FEndDate
:=
edtEndDate
.
Text
;
FKeptEntryIds
:=
''
;
finally
finally
FUpdatingDates
:=
False
;
FUpdatingDates
:=
False
;
end
;
end
;
...
@@ -241,7 +291,8 @@ begin
...
@@ -241,7 +291,8 @@ begin
end
;
end
;
procedure
TFTimeEntries
.
edtWeekOfExit
(
Sender
:
TObject
);
// Only fills Start/End from Week Of; Search Range applies the range and reloads
procedure
TFTimeEntries
.
edtWeekOfChange
(
Sender
:
TObject
);
begin
begin
if
FUpdatingDates
then
if
FUpdatingDates
then
Exit
;
Exit
;
...
@@ -249,7 +300,8 @@ begin
...
@@ -249,7 +300,8 @@ begin
if
edtWeekOf
.
Text
=
''
then
if
edtWeekOf
.
Text
=
''
then
Exit
;
Exit
;
SetWeekRangeFromAnchor
(
edtWeekOf
.
Text
,
True
);
edtStartDate
.
Text
:=
edtWeekOf
.
Text
;
edtEndDate
.
Text
:=
DateToIso
(
IsoToDate
(
edtWeekOf
.
Text
)
+
6
);
end
;
end
;
...
@@ -291,9 +343,8 @@ begin
...
@@ -291,9 +343,8 @@ begin
xdwdsTimeEntries
.
First
;
xdwdsTimeEntries
.
First
;
while
not
xdwdsTimeEntries
.
Eof
do
while
not
xdwdsTimeEntries
.
Eof
do
begin
begin
// Every saved row in the grid counts, including ones kept from outside the range
if
(
xdwdsTimeEntriesentryId
.
AsInteger
>
0
)
and
if
(
xdwdsTimeEntriesentryId
.
AsInteger
>
0
)
and
(
xdwdsTimeEntriestaskDate
.
AsString
>=
FStartDate
)
and
(
xdwdsTimeEntriestaskDate
.
AsString
<=
FEndDate
)
and
(
not
xdwdsTimeEntrieshours
.
IsNull
)
then
(
not
xdwdsTimeEntrieshours
.
IsNull
)
then
totalHours
:=
totalHours
+
xdwdsTimeEntrieshours
.
AsFloat
;
totalHours
:=
totalHours
+
xdwdsTimeEntrieshours
.
AsFloat
;
...
@@ -330,7 +381,7 @@ var
...
@@ -330,7 +381,7 @@ var
userNameValue
:
string
;
userNameValue
:
string
;
rowCount
:
Integer
;
rowCount
:
Integer
;
begin
begin
console
.
log
(
'ITimeEntryService.GetTimeEntries called with user_id='
+
FUserId
+
' start='
+
FStartDate
+
' end='
+
FEndDate
);
console
.
log
(
'ITimeEntryService.GetTimeEntries called with user_id='
+
FUserId
+
' start='
+
FStartDate
+
' end='
+
FEndDate
+
' kept='
+
FKeptEntryIds
);
if
FUserId
=
''
then
if
FUserId
=
''
then
begin
begin
...
@@ -342,7 +393,7 @@ begin
...
@@ -342,7 +393,7 @@ begin
try
try
try
try
response
:=
await
(
xdwcTimeEntries
.
RawInvokeAsync
(
response
:=
await
(
xdwcTimeEntries
.
RawInvokeAsync
(
'ITimeEntryService.GetTimeEntries'
,
[
FUserId
,
FStartDate
,
FEndDate
]
'ITimeEntryService.GetTimeEntries'
,
[
FUserId
,
FStartDate
,
FEndDate
,
FKeptEntryIds
]
));
));
except
except
on
E
:
EXDataClientRequestException
do
on
E
:
EXDataClientRequestException
do
...
@@ -360,6 +411,9 @@ begin
...
@@ -360,6 +411,9 @@ begin
else
else
SetTimeEntriesLabel
(
FUserName
);
SetTimeEntriesLabel
(
FUserName
);
FUserStartDate
:=
JsText
(
resultObj
[
'userStartDate'
]);
FUserEndDate
:=
JsText
(
resultObj
[
'userEndDate'
]);
rowCount
:=
StrToIntDef
(
string
(
resultObj
[
'count'
]),
0
);
rowCount
:=
StrToIntDef
(
string
(
resultObj
[
'count'
]),
0
);
SetTotalRowsLabel
(
rowCount
);
SetTotalRowsLabel
(
rowCount
);
...
@@ -371,6 +425,7 @@ begin
...
@@ -371,6 +425,7 @@ begin
xdwdsTimeEntries
.
Close
;
xdwdsTimeEntries
.
Close
;
xdwdsTimeEntries
.
SetJsonData
(
itemsArray
);
xdwdsTimeEntries
.
SetJsonData
(
itemsArray
);
xdwdsTimeEntries
.
Open
;
xdwdsTimeEntries
.
Open
;
ClearEntryDraft
;
UpdateTotalHours
;
UpdateTotalHours
;
FActiveRowIndex
:=
-
1
;
FActiveRowIndex
:=
-
1
;
...
@@ -386,12 +441,31 @@ begin
...
@@ -386,12 +441,31 @@ begin
end
;
end
;
// A saved entry dated outside Start-End stays in the grid until the range changes
procedure
TFTimeEntries
.
KeepEntryIfOutsideRange
(
const
AEntryId
,
ATaskDate
:
string
);
begin
if
(
AEntryId
=
''
)
or
(
AEntryId
=
'0'
)
then
Exit
;
if
(
ATaskDate
>=
FStartDate
)
and
(
ATaskDate
<=
FEndDate
)
then
Exit
;
if
Pos
(
','
+
AEntryId
+
','
,
','
+
FKeptEntryIds
+
','
)
>
0
then
Exit
;
if
FKeptEntryIds
<>
''
then
FKeptEntryIds
:=
FKeptEntryIds
+
','
;
FKeptEntryIds
:=
FKeptEntryIds
+
AEntryId
;
end
;
procedure
TFTimeEntries
.
RenderTable
;
procedure
TFTimeEntries
.
RenderTable
;
var
var
host
:
TJSHTMLElement
;
host
:
TJSHTMLElement
;
html
:
string
;
html
:
string
;
rowIdx
:
Integer
;
rowIdx
:
Integer
;
hoursText
:
string
;
hoursText
:
string
;
rowDate
:
string
;
function
Th
(
const
s
:
string
):
string
;
function
Th
(
const
s
:
string
):
string
;
begin
begin
...
@@ -443,8 +517,13 @@ var
...
@@ -443,8 +517,13 @@ var
optionValue
:
string
;
optionValue
:
string
;
optionDisplay
:
string
;
optionDisplay
:
string
;
triggerId
:
string
;
triggerId
:
string
;
taskAttrs
:
string
;
taskStart
:
string
;
taskEnd
:
string
;
openTaskCount
:
Integer
;
begin
begin
triggerId
:=
'time_dd_'
+
FieldName
+
'_'
+
IntToStr
(
AIdx
);
triggerId
:=
'time_dd_'
+
FieldName
+
'_'
+
IntToStr
(
AIdx
);
openTaskCount
:=
0
;
Result
:=
''
;
Result
:=
''
;
...
@@ -457,6 +536,7 @@ var
...
@@ -457,6 +536,7 @@ var
'<button id="'
+
triggerId
+
'" class="btn btn-sm border w-100 d-flex justify-content-between align-items-center text-start time-dd-toggle btn-light'
+
'<button id="'
+
triggerId
+
'" class="btn btn-sm border w-100 d-flex justify-content-between align-items-center text-start time-dd-toggle btn-light'
+
IfThen
(
AShowTaskPicker
,
' rounded-end-0'
,
''
)
+
'" '
+
IfThen
(
AShowTaskPicker
,
' rounded-end-0'
,
''
)
+
'" '
+
'type="button" data-bs-toggle="dropdown" aria-expanded="false" '
+
'type="button" data-bs-toggle="dropdown" aria-expanded="false" '
+
IfThen
(
FieldName
=
'taskId'
,
'title="'
+
HtmlEncode
(
CurrentDisplay
)
+
'" '
,
''
)
+
// full name when truncated
'data-idx="'
+
IntToStr
(
AIdx
)
+
'" data-field="'
+
FieldName
+
'">'
+
'data-idx="'
+
IntToStr
(
AIdx
)
+
'" data-field="'
+
FieldName
+
'">'
+
'<span class="time-dd-label text-truncate">'
+
HtmlEncode
(
CurrentDisplay
)
+
'</span>'
+
'<span class="time-dd-label text-truncate">'
+
HtmlEncode
(
CurrentDisplay
)
+
'</span>'
+
'<span class="dropdown-toggle dropdown-toggle-split border-0 ms-2"></span>'
+
'<span class="dropdown-toggle dropdown-toggle-split border-0 ms-2"></span>'
+
...
@@ -480,24 +560,56 @@ var
...
@@ -480,24 +560,56 @@ var
optionValue
:=
string
(
optionObj
[
ValueProp
]);
optionValue
:=
string
(
optionObj
[
ValueProp
]);
optionDisplay
:=
string
(
optionObj
[
DisplayProp
]);
optionDisplay
:=
string
(
optionObj
[
DisplayProp
]);
// Tasks carry their date window; ones not open on the row's date are
// hidden (and disabled), like emT3's Time Entry screen
taskAttrs
:=
''
;
if
FieldName
=
'taskId'
then
begin
taskStart
:=
JsText
(
optionObj
[
'startDate'
]);
taskEnd
:=
JsText
(
optionObj
[
'completionDate'
]);
taskAttrs
:=
'data-start="'
+
taskStart
+
'" data-end="'
+
taskEnd
+
'" '
;
if
IsTaskOpenOn
(
taskStart
,
taskEnd
,
rowDate
)
then
Inc
(
openTaskCount
)
else
taskAttrs
:=
taskAttrs
+
'disabled hidden '
;
end
;
Result
:=
Result
+
Result
:=
Result
+
'<button type="button" class="dropdown-item time-dd-item" '
+
'<button type="button" class="dropdown-item time-dd-item" '
+
'data-idx="'
+
IntToStr
(
AIdx
)
+
'" '
+
'data-idx="'
+
IntToStr
(
AIdx
)
+
'" '
+
'data-field="'
+
FieldName
+
'" '
+
'data-field="'
+
FieldName
+
'" '
+
'data-value="'
+
HtmlEncode
(
optionValue
)
+
'" '
+
'data-value="'
+
HtmlEncode
(
optionValue
)
+
'" '
+
'data-display="'
+
HtmlEncode
(
optionDisplay
)
+
'" '
+
'data-display="'
+
HtmlEncode
(
optionDisplay
)
+
'" '
+
taskAttrs
+
'data-trigger-id="'
+
triggerId
+
'">'
+
HtmlEncode
(
optionDisplay
)
+
'</button>'
;
'data-trigger-id="'
+
triggerId
+
'">'
+
HtmlEncode
(
optionDisplay
)
+
'</button>'
;
end
;
end
;
// Shown instead of an empty menu when no focused task is open on the row's date
if
FieldName
=
'taskId'
then
Result
:=
Result
+
'<span class="dropdown-item-text small text-body-secondary time-dd-empty" '
+
'data-idx="'
+
IntToStr
(
AIdx
)
+
'"'
+
IfThen
(
openTaskCount
>
0
,
' hidden'
,
''
)
+
'>'
+
'No focused tasks are open on this date.</span>'
;
Result
:=
Result
+
Result
:=
Result
+
'</div>'
+
'</div>'
+
'</div>'
;
'</div>'
;
if
AShowTaskPicker
then
if
AShowTaskPicker
then
begin
begin
// Split button: Task opens the picker; the caret's menu also has Task Items
Result
:=
Result
+
Result
:=
Result
+
'<button type="button" class="btn btn-outline-secondary time-task-picker-btn flex-shrink-0 text-nowrap ms-0" '
+
'<button type="button" class="btn btn-outline-secondary time-task-picker-btn flex-shrink-0 text-nowrap ms-0" '
+
'data-idx="'
+
IntToStr
(
AIdx
)
+
'" title="Select a task">Task</button>'
+
'data-idx="'
+
IntToStr
(
AIdx
)
+
'" title="Select a task">Task</button>'
+
'<button type="button" class="btn btn-outline-secondary dropdown-toggle dropdown-toggle-split flex-shrink-0" '
+
'data-bs-toggle="dropdown" aria-expanded="false" title="More task options">'
+
'<span class="visually-hidden">More task options</span></button>'
+
'<ul class="dropdown-menu dropdown-menu-end">'
+
'<li><button type="button" class="dropdown-item time-task-picker-btn" data-idx="'
+
IntToStr
(
AIdx
)
+
'">Find Task</button></li>'
+
'<li><button type="button" class="dropdown-item time-task-items-btn" data-idx="'
+
IntToStr
(
AIdx
)
+
'"'
+
IfThen
(
CurrentValue
=
''
,
' disabled'
,
''
)
+
'>Task Items</button></li>'
+
'</ul>'
+
'</div>'
;
'</div>'
;
end
;
end
;
end
;
end
;
...
@@ -519,12 +631,12 @@ begin
...
@@ -519,12 +631,12 @@ begin
'<table class="table table-sm table-bordered align-middle mb-0 time-table" style="min-width: 1710px; table-layout: fixed;">'
+
'<table class="table table-sm table-bordered align-middle mb-0 time-table" style="min-width: 1710px; table-layout: fixed;">'
+
'<colgroup>'
+
'<colgroup>'
+
'<col style="width:140px">'
+
// Date
'<col style="width:140px">'
+
// Date
'<col style="width:5
0
0px">'
+
// Task
'<col style="width:5
4
0px">'
+
// Task
'<col style="width:90px">'
+
// Hours
'<col style="width:90px">'
+
// Hours
'<col style="width:1
5
0px">'
+
// Time
'<col style="width:1
4
0px">'
+
// Time
'<col style="width:160px">'
+
// Place
'<col style="width:160px">'
+
// Place
'<col style="width:190px">'
+
// Category
'<col style="width:190px">'
+
// Category
'<col style="width:4
8
0px">'
+
// Summary
'<col style="width:4
5
0px">'
+
// Summary
'</colgroup>'
+
'</colgroup>'
+
'<thead><tr>'
+
'<thead><tr>'
+
Th
(
'Date'
)
+
Th
(
'Date'
)
+
...
@@ -545,6 +657,8 @@ begin
...
@@ -545,6 +657,8 @@ begin
else
else
hoursText
:=
FormatFloat
(
'0.##'
,
xdwdsTimeEntrieshours
.
AsFloat
);
hoursText
:=
FormatFloat
(
'0.##'
,
xdwdsTimeEntrieshours
.
AsFloat
);
rowDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
html
:=
html
+
html
:=
html
+
'<tr class="time-row-selectable" data-idx="'
+
IntToStr
(
rowIdx
)
+
'" data-entry-id="'
+
IntToStr
(
xdwdsTimeEntriesentryId
.
AsInteger
)
+
'" data-task-id="'
+
xdwdsTimeEntriestaskId
.
AsString
+
'">'
+
'<tr class="time-row-selectable" data-idx="'
+
IntToStr
(
rowIdx
)
+
'" data-entry-id="'
+
IntToStr
(
xdwdsTimeEntriesentryId
.
AsInteger
)
+
'" data-task-id="'
+
xdwdsTimeEntriestaskId
.
AsString
+
'">'
+
TdNowrap
(
DateInput
(
'taskDate'
,
xdwdsTimeEntriestaskDate
.
AsString
,
rowIdx
))
+
TdNowrap
(
DateInput
(
'taskDate'
,
xdwdsTimeEntriestaskDate
.
AsString
,
rowIdx
))
+
...
@@ -572,7 +686,8 @@ begin
...
@@ -572,7 +686,8 @@ begin
end
end
else
else
html
:=
html
+
html
:=
html
+
'<tr id="time-edit-actions-'
+
IntToStr
(
rowIdx
)
+
'" hidden>'
+
'<tr id="time-edit-actions-'
+
IntToStr
(
rowIdx
)
+
'"'
+
IfThen
(
IsDraftEntryRow
,
''
,
' hidden'
)
+
'>'
+
'<td colspan="7">'
+
'<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-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>'
+
'<button type="button" class="btn btn-sm btn-outline-secondary time-edit-cancel" data-idx="'
+
IntToStr
(
rowIdx
)
+
'">Cancel</button>'
+
...
@@ -640,11 +755,203 @@ begin
...
@@ -640,11 +755,203 @@ begin
end
;
end
;
function
TFTimeEntries
.
BuildTimeEntryPayload
(
const
AEntryId
:
string
):
TJSObject
;
begin
Result
:=
TJSObject
.
new
;
Result
[
'entryId'
]
:=
AEntryId
;
Result
[
'userId'
]
:=
FUserId
;
Result
[
'taskDate'
]
:=
xdwdsTimeEntriestaskDate
.
AsString
;
Result
[
'taskId'
]
:=
xdwdsTimeEntriestaskId
.
AsString
;
Result
[
'hours'
]
:=
xdwdsTimeEntrieshours
.
AsFloat
;
Result
[
'taskTime'
]
:=
xdwdsTimeEntriestaskTime
.
AsString
;
Result
[
'place'
]
:=
xdwdsTimeEntriesplace
.
AsString
;
Result
[
'category'
]
:=
xdwdsTimeEntriescategory
.
AsString
;
Result
[
'summary'
]
:=
xdwdsTimeEntriessummary
.
AsString
;
end
;
// Call with the dataset positioned on the row, before changing it.
// Snapshots the saved values once, on the first drafted edit of the row.
procedure
TFTimeEntries
.
BeginEntryDraft
(
AIndex
:
Integer
);
begin
if
(
FEditingEntryId
<>
0
)
or
(
xdwdsTimeEntriesentryId
.
AsInteger
<=
0
)
then
Exit
;
FEditingEntryId
:=
xdwdsTimeEntriesentryId
.
AsInteger
;
FEditingRowIndex
:=
AIndex
;
FOriginalTaskDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
FOriginalHours
:=
xdwdsTimeEntrieshours
.
AsFloat
;
FOriginalTaskId
:=
xdwdsTimeEntriestaskId
.
AsString
;
FOriginalTaskDisplay
:=
xdwdsTimeEntriestaskDisplay
.
AsString
;
FOriginalTaskTime
:=
xdwdsTimeEntriestaskTime
.
AsString
;
FOriginalPlace
:=
xdwdsTimeEntriesplace
.
AsString
;
FOriginalPlaceDesc
:=
xdwdsTimeEntriesplaceDesc
.
AsString
;
FOriginalCategory
:=
xdwdsTimeEntriescategory
.
AsString
;
FOriginalCategoryDesc
:=
xdwdsTimeEntriescategoryDesc
.
AsString
;
FOriginalSummary
:=
xdwdsTimeEntriessummary
.
AsString
;
end
;
procedure
TFTimeEntries
.
ClearEntryDraft
;
begin
FEditingEntryId
:=
0
;
FEditingRowIndex
:=
-
1
;
FOriginalTaskDate
:=
''
;
FOriginalTaskId
:=
''
;
FOriginalTaskDisplay
:=
''
;
FOriginalTaskTime
:=
''
;
FOriginalPlace
:=
''
;
FOriginalPlaceDesc
:=
''
;
FOriginalCategory
:=
''
;
FOriginalCategoryDesc
:=
''
;
FOriginalSummary
:=
''
;
end
;
// True when the dataset's current row is the one being drafted.
function
TFTimeEntries
.
IsDraftEntryRow
:
Boolean
;
begin
Result
:=
(
FEditingEntryId
>
0
)
and
(
xdwdsTimeEntriesentryId
.
AsInteger
=
FEditingEntryId
);
end
;
procedure
TFTimeEntries
.
ShowEntryDraftActions
(
AIndex
:
Integer
);
var
actionsRow
:
TJSHTMLElement
;
begin
actionsRow
:=
TJSHTMLElement
(
document
.
getElementById
(
'time-edit-actions-'
+
IntToStr
(
AIndex
)));
if
Assigned
(
actionsRow
)
then
actionsRow
.
removeAttribute
(
'hidden'
);
end
;
// While a saved row has unsaved draft changes, no other row may be used.
// Returns True (and shows the message) when AIndex is a different row.
function
TFTimeEntries
.
BlockForDraftRow
(
AIndex
:
Integer
;
const
AAction
:
string
):
Boolean
;
begin
Result
:=
(
FEditingEntryId
>
0
)
and
(
FEditingRowIndex
>=
0
)
and
(
AIndex
>=
0
)
and
(
AIndex
<>
FEditingRowIndex
);
if
not
Result
then
Exit
;
FActiveRowIndex
:=
FEditingRowIndex
;
FBlockedRowIndex
:=
FEditingRowIndex
;
SetTopControlsEnabled
(
False
);
lblValidationMessage
.
Caption
:=
'Save or cancel the changes to this entry before '
+
AAction
+
'.'
;
lblValidationMessage
.
ElementHandle
.
classList
.
remove
(
'd-none'
);
lblValidationMessage
.
ElementHandle
.
classList
.
remove
(
'invisible'
);
ApplyActiveRowState
;
end
;
// Keyboard guard: Tab into another row's editor sends focus back to the draft row.
procedure
TFTimeEntries
.
DocumentFocusIn
(
Event
:
TJSEvent
);
var
draftRowEl
:
TJSHTMLElement
;
firstEditor
:
TJSHTMLElement
;
begin
if
not
BlockForDraftRow
(
GetTargetRowIndex
(
TJSHTMLElement
(
Event
.
target
)),
'editing another row'
)
then
Exit
;
draftRowEl
:=
TJSHTMLElement
(
document
.
querySelector
(
'tr[data-idx="'
+
IntToStr
(
FEditingRowIndex
)
+
'"]'
));
if
not
Assigned
(
draftRowEl
)
then
Exit
;
firstEditor
:=
TJSHTMLElement
(
draftRowEl
.
querySelector
(
'.time-editor'
));
if
Assigned
(
firstEditor
)
then
firstEditor
.
focus
;
end
;
// A JSON property as a string; '' when missing (e.g. options added from the picker)
function
TFTimeEntries
.
JsText
(
const
AValue
:
JSValue
):
string
;
begin
if
JS
.
isString
(
AValue
)
then
Result
:=
string
(
AValue
)
else
Result
:=
''
;
end
;
// Same rule the server enforces on Save: ADate must be inside the user's
// employment window and the task's window. Inclusive; '' = open-ended.
// All values are 'yyyy-mm-dd', so plain string comparison is date order.
function
TFTimeEntries
.
IsTaskOpenOn
(
const
ATaskStart
,
ATaskEnd
,
ADate
:
string
):
Boolean
;
begin
Result
:=
True
;
if
ADate
=
''
then
Exit
;
// no date yet; required-field validation handles it
if
(
FUserStartDate
<>
''
)
and
(
ADate
<
FUserStartDate
)
then
Exit
(
False
);
if
(
FUserEndDate
<>
''
)
and
(
ADate
>
FUserEndDate
)
then
Exit
(
False
);
if
(
ATaskStart
<>
''
)
and
(
ADate
<
ATaskStart
)
then
Exit
(
False
);
if
(
ATaskEnd
<>
''
)
and
(
ADate
>
ATaskEnd
)
then
Exit
(
False
);
end
;
// Re-check one row's task dropdown items after its date changes, without a re-render:
// tasks not open on the new date are hidden, and the empty-menu note shows if none are left
procedure
TFTimeEntries
.
RefreshTaskOptionStates
(
AIndex
:
Integer
;
const
ADate
:
string
);
var
nodes
:
TJSNodeList
;
item
:
TJSHTMLElement
;
emptyEl
:
TJSHTMLElement
;
openTaskCount
:
Integer
;
i
:
Integer
;
begin
nodes
:=
document
.
querySelectorAll
(
'.time-dd-item[data-field="taskId"][data-idx="'
+
IntToStr
(
AIndex
)
+
'"]'
);
openTaskCount
:=
0
;
for
i
:=
0
to
nodes
.
length
-
1
do
begin
item
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
if
IsTaskOpenOn
(
string
(
item
.
getAttribute
(
'data-start'
)),
string
(
item
.
getAttribute
(
'data-end'
)),
ADate
)
then
begin
item
.
removeAttribute
(
'disabled'
);
item
.
removeAttribute
(
'hidden'
);
Inc
(
openTaskCount
);
end
else
begin
item
.
setAttribute
(
'disabled'
,
''
);
item
.
setAttribute
(
'hidden'
,
''
);
end
;
end
;
emptyEl
:=
TJSHTMLElement
(
document
.
querySelector
(
'.time-dd-empty[data-idx="'
+
IntToStr
(
AIndex
)
+
'"]'
));
if
Assigned
(
emptyEl
)
then
begin
if
openTaskCount
>
0
then
emptyEl
.
setAttribute
(
'hidden'
,
''
)
else
emptyEl
.
removeAttribute
(
'hidden'
);
end
;
end
;
[
async
]
procedure
TFTimeEntries
.
SaveNewEntry
;
[
async
]
procedure
TFTimeEntries
.
SaveNewEntry
;
var
var
response
:
TXDataClientResponse
;
response
:
TXDataClientResponse
;
resultObj
:
TJSObject
;
resultObj
:
TJSObject
;
payload
:
TJSObject
;
payload
:
TJSObject
;
newTaskDate
:
string
;
begin
begin
if
not
FAddingNewEntry
then
if
not
FAddingNewEntry
then
Exit
;
Exit
;
...
@@ -653,6 +960,8 @@ begin
...
@@ -653,6 +960,8 @@ begin
if
xdwdsTimeEntries
.
Eof
then
if
xdwdsTimeEntries
.
Eof
then
Exit
;
Exit
;
newTaskDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
if
not
ValidateRow
(
FNewEntryRowIndex
)
then
if
not
ValidateRow
(
FNewEntryRowIndex
)
then
begin
begin
ApplyRowValidation
(
FNewEntryRowIndex
);
ApplyRowValidation
(
FNewEntryRowIndex
);
...
@@ -661,16 +970,7 @@ begin
...
@@ -661,16 +970,7 @@ begin
Exit
;
Exit
;
end
;
end
;
payload
:=
TJSObject
.
new
;
payload
:=
BuildTimeEntryPayload
(
'0'
);
payload
[
'entryId'
]
:=
'0'
;
payload
[
'userId'
]
:=
FUserId
;
payload
[
'taskDate'
]
:=
xdwdsTimeEntriestaskDate
.
AsString
;
payload
[
'taskId'
]
:=
xdwdsTimeEntriestaskId
.
AsString
;
payload
[
'hours'
]
:=
xdwdsTimeEntrieshours
.
AsFloat
;
payload
[
'taskTime'
]
:=
xdwdsTimeEntriestaskTime
.
AsString
;
payload
[
'place'
]
:=
xdwdsTimeEntriesplace
.
AsString
;
payload
[
'category'
]
:=
xdwdsTimeEntriescategory
.
AsString
;
payload
[
'summary'
]
:=
xdwdsTimeEntriessummary
.
AsString
;
Utils
.
ShowSpinner
(
'spinner'
);
Utils
.
ShowSpinner
(
'spinner'
);
try
try
...
@@ -682,11 +982,15 @@ begin
...
@@ -682,11 +982,15 @@ begin
resultObj
:=
TJSObject
(
response
.
Result
);
resultObj
:=
TJSObject
(
response
.
Result
);
FPendingEntryId
:=
string
(
resultObj
[
'value'
]);
FPendingEntryId
:=
string
(
resultObj
[
'value'
]);
KeepEntryIfOutsideRange
(
FPendingEntryId
,
newTaskDate
);
except
except
on
E
:
EXDataClientRequestException
do
on
E
:
EXDataClientRequestException
do
begin
begin
console
.
log
(
'SaveNewEntry ERROR: '
+
E
.
ErrorResult
.
ErrorMessage
);
console
.
log
(
'SaveNewEntry ERROR: '
+
E
.
ErrorResult
.
ErrorMessage
);
Utils
.
ShowErrorModal
(
E
.
ErrorResult
.
ErrorMessage
);
TJSHTMLElement
(
document
.
querySelector
(
'tr[data-idx="'
+
IntToStr
(
FNewEntryRowIndex
)
+
'"] [data-field="taskDate"]'
)).
classList
.
add
(
'is-invalid'
);
ShowRowValidationMessage
(
FNewEntryRowIndex
,
E
.
ErrorResult
.
ErrorMessage
);
SetTopControlsEnabled
(
False
);
Exit
;
Exit
;
end
;
end
;
end
;
end
;
...
@@ -728,13 +1032,15 @@ begin
...
@@ -728,13 +1032,15 @@ begin
RenderTable
;
RenderTable
;
end
;
end
;
[
async
]
procedure
TFTimeEntries
.
E
ditedDate
SaveClick
(
Event
:
TJSEvent
);
[
async
]
procedure
TFTimeEntries
.
E
ntryDraft
SaveClick
(
Event
:
TJSEvent
);
var
var
saveButton
,
cancelButton
:
TJSHTMLButtonElement
;
saveButton
,
cancelButton
:
TJSHTMLButtonElement
;
dateInput
:
TJSHTMLInputElement
;
rowEl
:
TJSHTMLElement
;
rowEl
:
TJSHTMLElement
;
payload
:
TJSObject
;
idx
,
savedEntryId
:
Integer
;
idx
,
savedEntryId
:
Integer
;
rowSelector
:
string
;
rowSelector
:
string
;
saveError
:
string
;
savedTaskDate
:
string
;
begin
begin
saveButton
:=
TJSHTMLButtonElement
(
Event
.
target
);
saveButton
:=
TJSHTMLButtonElement
(
Event
.
target
);
idx
:=
StrToIntDef
(
string
(
saveButton
.
getAttribute
(
'data-idx'
)),
-
1
);
idx
:=
StrToIntDef
(
string
(
saveButton
.
getAttribute
(
'data-idx'
)),
-
1
);
...
@@ -750,34 +1056,61 @@ begin
...
@@ -750,34 +1056,61 @@ begin
if
savedEntryId
<>
FEditingEntryId
then
if
savedEntryId
<>
FEditingEntryId
then
Exit
;
Exit
;
if
Trim
(
xdwdsTimeEntriestaskDate
.
AsString
)
=
''
then
if
not
ValidateRow
(
idx
)
then
begin
begin
Utils
.
ShowErrorModal
(
'Enter a date before saving.'
);
ApplyRowValidation
(
idx
);
ShowRowValidationMessage
(
idx
,
'Complete required fields before saving this entry.'
);
Exit
;
Exit
;
end
;
end
;
payload
:=
BuildTimeEntryPayload
(
IntToStr
(
savedEntryId
));
savedTaskDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
rowSelector
:=
'.time-row-selectable[data-entry-id="'
+
rowSelector
:=
'.time-row-selectable[data-entry-id="'
+
IntToStr
(
savedEntryId
)
+
'"]'
;
IntToStr
(
savedEntryId
)
+
'"]'
;
rowEl
:=
TJSHTMLElement
(
document
.
querySelector
(
rowSelector
));
rowEl
:=
TJSHTMLElement
(
document
.
querySelector
(
rowSelector
));
dateInput
:=
TJSHTMLInputElement
(
rowEl
.
querySelector
(
'[data-field="taskDate"]'
));
cancelButton
:=
TJSHTMLButtonElement
(
document
.
querySelector
(
cancelButton
:=
TJSHTMLButtonElement
(
document
.
querySelector
(
'.time-edit-cancel[data-idx="'
+
IntToStr
(
idx
)
+
'"]'
));
'.time-edit-cancel[data-idx="'
+
IntToStr
(
idx
)
+
'"]'
));
saveError
:=
''
;
saveButton
.
disabled
:=
True
;
saveButton
.
disabled
:=
True
;
cancelButton
.
disabled
:=
True
;
cancelButton
.
disabled
:=
True
;
dateInput
.
disabled
:=
True
;
rowEl
.
setAttribute
(
'inert'
,
''
)
;
try
try
if
not
await
(
SaveField
(
idx
,
'taskDate'
))
then
try
Exit
;
await
(
xdwcTimeEntries
.
RawInvokeAsync
(
'ITimeEntryService.SaveTimeEntry'
,
[
payload
]));
except
on
E
:
EXDataClientRequestException
do
begin
console
.
log
(
'EntryDraftSaveClick ERROR: '
+
E
.
ErrorResult
.
ErrorMessage
);
saveError
:=
E
.
ErrorResult
.
ErrorMessage
;
end
;
end
;
finally
finally
saveButton
.
disabled
:=
False
;
saveButton
.
disabled
:=
False
;
cancelButton
.
disabled
:=
False
;
cancelButton
.
disabled
:=
False
;
dateInput
.
disabled
:=
False
;
rowEl
.
removeAttribute
(
'inert'
)
;
end
;
end
;
FEditingEntryId
:=
0
;
// Shown after the row is no longer inert so the date field can take focus
FOriginalTaskDate
:=
''
;
if
saveError
<>
''
then
begin
TJSHTMLElement
(
rowEl
.
querySelector
(
'[data-field="taskDate"]'
)).
classList
.
add
(
'is-invalid'
);
ShowRowValidationMessage
(
idx
,
saveError
);
Exit
;
end
;
KeepEntryIfOutsideRange
(
IntToStr
(
savedEntryId
),
savedTaskDate
);
if
FEditingEntryId
<>
savedEntryId
then
Exit
;
ClearEntryDraft
;
HideRowValidationMessage
;
SetTopControlsEnabled
(
True
);
UpdateTotalHours
;
CaptureTableScroll
;
CaptureTableScroll
;
RenderTable
;
RenderTable
;
...
@@ -786,7 +1119,7 @@ begin
...
@@ -786,7 +1119,7 @@ begin
rowEl
.
classList
.
add
(
'time-row-saved'
);
rowEl
.
classList
.
add
(
'time-row-saved'
);
end
;
end
;
procedure
TFTimeEntries
.
E
ditedDate
CancelClick
(
Event
:
TJSEvent
);
procedure
TFTimeEntries
.
E
ntryDraft
CancelClick
(
Event
:
TJSEvent
);
var
var
el
:
TJSHTMLElement
;
el
:
TJSHTMLElement
;
idx
:
Integer
;
idx
:
Integer
;
...
@@ -809,10 +1142,18 @@ begin
...
@@ -809,10 +1142,18 @@ begin
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntriestaskDate
.
AsString
:=
FOriginalTaskDate
;
xdwdsTimeEntriestaskDate
.
AsString
:=
FOriginalTaskDate
;
xdwdsTimeEntrieshours
.
AsFloat
:=
FOriginalHours
;
xdwdsTimeEntriestaskId
.
AsString
:=
FOriginalTaskId
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
FOriginalTaskDisplay
;
xdwdsTimeEntriestaskTime
.
AsString
:=
FOriginalTaskTime
;
xdwdsTimeEntriesplace
.
AsString
:=
FOriginalPlace
;
xdwdsTimeEntriesplaceDesc
.
AsString
:=
FOriginalPlaceDesc
;
xdwdsTimeEntriescategory
.
AsString
:=
FOriginalCategory
;
xdwdsTimeEntriescategoryDesc
.
AsString
:=
FOriginalCategoryDesc
;
xdwdsTimeEntriessummary
.
AsString
:=
FOriginalSummary
;
xdwdsTimeEntries
.
Post
;
xdwdsTimeEntries
.
Post
;
FEditingEntryId
:=
0
;
ClearEntryDraft
;
FOriginalTaskDate
:=
''
;
CaptureTableScroll
;
CaptureTableScroll
;
RenderTable
;
RenderTable
;
...
@@ -834,7 +1175,6 @@ begin
...
@@ -834,7 +1175,6 @@ begin
begin
begin
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
.
addEventListener
(
'input'
,
TJSEventHandler
(@
EditorInput
));
el
.
addEventListener
(
'input'
,
TJSEventHandler
(@
EditorInput
));
el
.
addEventListener
(
'blur'
,
TJSEventHandler
(@
EditorBlur
));
end
;
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-edit-cancel'
);
nodes
:=
document
.
querySelectorAll
(
'.time-edit-cancel'
);
...
@@ -842,7 +1182,7 @@ begin
...
@@ -842,7 +1182,7 @@ begin
for
i
:=
0
to
nodes
.
length
-
1
do
for
i
:=
0
to
nodes
.
length
-
1
do
begin
begin
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
E
ditedDate
CancelClick
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
E
ntryDraft
CancelClick
));
end
;
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-edit-save'
);
nodes
:=
document
.
querySelectorAll
(
'.time-edit-save'
);
...
@@ -850,7 +1190,7 @@ begin
...
@@ -850,7 +1190,7 @@ begin
for
i
:=
0
to
nodes
.
length
-
1
do
for
i
:=
0
to
nodes
.
length
-
1
do
begin
begin
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
E
ditedDate
SaveClick
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
E
ntryDraft
SaveClick
));
end
;
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-dd-item'
);
nodes
:=
document
.
querySelectorAll
(
'.time-dd-item'
);
...
@@ -869,6 +1209,13 @@ begin
...
@@ -869,6 +1209,13 @@ begin
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
TaskPickerButtonClick
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
TaskPickerButtonClick
));
end
;
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-task-items-btn'
);
for
i
:=
0
to
nodes
.
length
-
1
do
begin
el
:=
TJSHTMLElement
(
nodes
.
item
(
i
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
TaskItemsButtonClick
));
end
;
nodes
:=
document
.
querySelectorAll
(
'.time-row-selectable'
);
nodes
:=
document
.
querySelectorAll
(
'.time-row-selectable'
);
console
.
log
(
'BindTableEditors: time-row-selectable count='
+
IntToStr
(
nodes
.
length
));
console
.
log
(
'BindTableEditors: time-row-selectable count='
+
IntToStr
(
nodes
.
length
));
for
i
:=
0
to
nodes
.
length
-
1
do
for
i
:=
0
to
nodes
.
length
-
1
do
...
@@ -887,7 +1234,6 @@ var
...
@@ -887,7 +1234,6 @@ 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
;
...
@@ -909,13 +1255,8 @@ begin
...
@@ -909,13 +1255,8 @@ begin
if
xdwdsTimeEntries
.
Eof
then
if
xdwdsTimeEntries
.
Eof
then
Exit
;
Exit
;
if
SameText
(
fieldName
,
'taskDate'
)
and
// Every edit on a saved row joins that row's draft (Save/Cancel)
(
xdwdsTimeEntriesentryId
.
AsInteger
>
0
)
and
BeginEntryDraft
(
idx
);
(
FEditingEntryId
=
0
)
then
begin
FEditingEntryId
:=
xdwdsTimeEntriesentryId
.
AsInteger
;
FOriginalTaskDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
end
;
newVal
:=
string
(
TJSObject
(
el
)[
'value'
]);
newVal
:=
string
(
TJSObject
(
el
)[
'value'
]);
...
@@ -939,16 +1280,11 @@ begin
...
@@ -939,16 +1280,11 @@ begin
xdwdsTimeEntries
.
Post
;
xdwdsTimeEntries
.
Post
;
if
SameText
(
fieldName
,
'taskDate'
)
and
(
FEditingEntryId
>
0
)
and
if
SameText
(
fieldName
,
'taskDate'
)
then
(
xdwdsTimeEntriesentryId
.
AsInteger
=
FEditingEntryId
)
then
RefreshTaskOptionStates
(
idx
,
newVal
);
begin
actionsRow
:=
TJSHTMLElement
(
document
.
getElementById
(
'time-edit-actions-'
+
IntToStr
(
idx
)));
if
Assigned
(
actionsRow
)
then
actionsRow
.
removeAttribute
(
'hidden'
);
end
;
el
.
setAttribute
(
'data-unsaved-data'
,
'1'
);
if
IsDraftEntryRow
then
ShowEntryDraftActions
(
idx
);
if
IsNewEntryRow
(
idx
)
then
if
IsNewEntryRow
(
idx
)
then
begin
begin
...
@@ -1000,6 +1336,13 @@ begin
...
@@ -1000,6 +1336,13 @@ begin
Exit
;
Exit
;
end
;
end
;
if
BlockForDraftRow
(
idx
,
'selecting another row'
)
then
begin
Event
.
preventDefault
;
Event
.
stopPropagation
;
Exit
;
end
;
if
(
FActiveRowIndex
>=
0
)
and
if
(
FActiveRowIndex
>=
0
)
and
(
idx
<>
FActiveRowIndex
)
and
(
idx
<>
FActiveRowIndex
)
and
(
not
ValidateRow
(
FActiveRowIndex
))
then
(
not
ValidateRow
(
FActiveRowIndex
))
then
...
@@ -1073,6 +1416,7 @@ var
...
@@ -1073,6 +1416,7 @@ var
triggerId
:
string
;
triggerId
:
string
;
btn
:
TJSHTMLElement
;
btn
:
TJSHTMLElement
;
labelEl
:
TJSHTMLElement
;
labelEl
:
TJSHTMLElement
;
isDraftRow
:
Boolean
;
begin
begin
if
not
xdwdsTimeEntries
.
Active
then
if
not
xdwdsTimeEntries
.
Active
then
Exit
;
Exit
;
...
@@ -1111,6 +1455,13 @@ begin
...
@@ -1111,6 +1455,13 @@ begin
Exit
;
Exit
;
end
;
end
;
if
BlockForDraftRow
(
idx
,
'changing another row'
)
then
begin
Event
.
preventDefault
;
Event
.
stopPropagation
;
Exit
;
end
;
if
(
FActiveRowIndex
>=
0
)
and
if
(
FActiveRowIndex
>=
0
)
and
(
idx
<>
FActiveRowIndex
)
and
(
idx
<>
FActiveRowIndex
)
and
(
not
ValidateRow
(
FActiveRowIndex
))
then
(
not
ValidateRow
(
FActiveRowIndex
))
then
...
@@ -1129,6 +1480,8 @@ begin
...
@@ -1129,6 +1480,8 @@ begin
if
xdwdsTimeEntries
.
Eof
then
if
xdwdsTimeEntries
.
Eof
then
Exit
;
Exit
;
BeginEntryDraft
(
idx
);
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntries
.
Edit
;
if
SameText
(
fieldName
,
'taskId'
)
then
if
SameText
(
fieldName
,
'taskId'
)
then
...
@@ -1151,6 +1504,8 @@ begin
...
@@ -1151,6 +1504,8 @@ begin
xdwdsTimeEntries
.
Post
;
xdwdsTimeEntries
.
Post
;
isDraftRow
:=
IsDraftEntryRow
;
FActiveRowIndex
:=
idx
;
FActiveRowIndex
:=
idx
;
btnDeleteEntry
.
Enabled
:=
not
IsNewEntryRow
(
idx
);
btnDeleteEntry
.
Enabled
:=
not
IsNewEntryRow
(
idx
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
idx
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
idx
);
...
@@ -1162,11 +1517,15 @@ begin
...
@@ -1162,11 +1517,15 @@ begin
if
Assigned
(
labelEl
)
then
if
Assigned
(
labelEl
)
then
labelEl
.
textContent
:=
newDisplay
;
labelEl
.
textContent
:=
newDisplay
;
// Keep the task's full-name tooltip in step with the new choice
if
SameText
(
fieldName
,
'taskId'
)
then
btn
.
setAttribute
(
'title'
,
newDisplay
);
btn
.
focus
;
btn
.
focus
;
end
;
end
;
if
not
IsNewEntryRow
(
idx
)
then
if
isDraftRow
then
S
aveField
(
idx
,
fieldName
);
S
howEntryDraftActions
(
idx
);
if
IsNewEntryRow
(
idx
)
then
if
IsNewEntryRow
(
idx
)
then
begin
begin
...
@@ -1429,6 +1788,16 @@ begin
...
@@ -1429,6 +1788,16 @@ begin
Exit
;
Exit
;
end
;
end
;
if
BlockForDraftRow
(
targetRowIndex
,
'selecting another row'
)
then
begin
Event
.
preventDefault
;
Event
.
stopPropagation
;
FLastMouseDownRowIndex
:=
FEditingRowIndex
;
FLastMouseDownTime
:=
TJSDate
.
now
;
Exit
;
end
;
if
(
FActiveRowIndex
>=
0
)
and
if
(
FActiveRowIndex
>=
0
)
and
(
targetRowIndex
>=
0
)
and
(
targetRowIndex
>=
0
)
and
(
targetRowIndex
<>
FActiveRowIndex
)
and
(
targetRowIndex
<>
FActiveRowIndex
)
and
...
@@ -1549,7 +1918,7 @@ begin
...
@@ -1549,7 +1918,7 @@ begin
xdwdsTimeEntries
.
Append
;
xdwdsTimeEntries
.
Append
;
xdwdsTimeEntriesentryId
.
AsInteger
:=
0
;
xdwdsTimeEntriesentryId
.
AsInteger
:=
0
;
xdwdsTimeEntriestaskDate
.
AsString
:=
edtWeekOf
.
Text
;
xdwdsTimeEntriestaskDate
.
AsString
:=
DateToIso
(
Date
)
;
xdwdsTimeEntriestaskId
.
AsString
:=
''
;
xdwdsTimeEntriestaskId
.
AsString
:=
''
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
''
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
''
;
xdwdsTimeEntrieshours
.
Clear
;
xdwdsTimeEntrieshours
.
Clear
;
...
@@ -1599,6 +1968,12 @@ begin
...
@@ -1599,6 +1968,12 @@ begin
Exit
;
Exit
;
end
;
end
;
if
FEditingEntryId
>
0
then
begin
Utils
.
ShowErrorModal
(
'Save or cancel the changes to this entry before copying.'
);
Exit
;
end
;
if
FActiveRowIndex
<
0
then
if
FActiveRowIndex
<
0
then
begin
begin
Utils
.
ShowErrorModal
(
'Select a time entry to copy.'
);
Utils
.
ShowErrorModal
(
'Select a time entry to copy.'
);
...
@@ -1683,6 +2058,12 @@ end;
...
@@ -1683,6 +2058,12 @@ end;
procedure
TFTimeEntries
.
btnDeleteEntryClick
(
Sender
:
TObject
);
procedure
TFTimeEntries
.
btnDeleteEntryClick
(
Sender
:
TObject
);
begin
begin
if
FEditingEntryId
>
0
then
begin
Utils
.
ShowErrorModal
(
'Save or cancel the changes to this entry before deleting.'
);
Exit
;
end
;
if
FActiveRowIndex
<
0
then
if
FActiveRowIndex
<
0
then
begin
begin
Utils
.
ShowErrorModal
(
'Select a time entry to delete.'
);
Utils
.
ShowErrorModal
(
'Select a time entry to delete.'
);
...
@@ -1723,6 +2104,7 @@ begin
...
@@ -1723,6 +2104,7 @@ begin
FStartDate
:=
edtStartDate
.
Text
;
FStartDate
:=
edtStartDate
.
Text
;
FEndDate
:=
edtEndDate
.
Text
;
FEndDate
:=
edtEndDate
.
Text
;
FKeptEntryIds
:=
''
;
await
(
LoadTimeEntries
);
await
(
LoadTimeEntries
);
end
;
end
;
...
@@ -1775,6 +2157,10 @@ end;
...
@@ -1775,6 +2157,10 @@ end;
procedure
TFTimeEntries
.
SetTopControlsEnabled
(
AEnabled
:
Boolean
);
procedure
TFTimeEntries
.
SetTopControlsEnabled
(
AEnabled
:
Boolean
);
begin
begin
// An open row draft must be saved or cancelled first
if
FEditingEntryId
>
0
then
AEnabled
:=
False
;
edtWeekOf
.
Enabled
:=
AEnabled
;
edtWeekOf
.
Enabled
:=
AEnabled
;
edtStartDate
.
Enabled
:=
AEnabled
;
edtStartDate
.
Enabled
:=
AEnabled
;
edtEndDate
.
Enabled
:=
AEnabled
;
edtEndDate
.
Enabled
:=
AEnabled
;
...
@@ -1788,11 +2174,13 @@ var
...
@@ -1788,11 +2174,13 @@ var
el
:
TJSHTMLElement
;
el
:
TJSHTMLElement
;
idx
:
Integer
;
idx
:
Integer
;
taskId
:
string
;
taskId
:
string
;
taskDate
:
string
;
begin
begin
Event
.
preventDefault
;
Event
.
preventDefault
;
Event
.
stopPropagation
;
Event
.
stopPropagation
;
el
:=
TJSHTMLElement
(
Event
.
currentTarget
);
el
:=
TJSHTMLElement
(
Event
.
currentTarget
);
CloseTaskMenu
(
el
);
idx
:=
StrToIntDef
(
string
(
el
.
getAttribute
(
'data-idx'
)),
-
1
);
idx
:=
StrToIntDef
(
string
(
el
.
getAttribute
(
'data-idx'
)),
-
1
);
if
idx
<
0
then
if
idx
<
0
then
...
@@ -1818,6 +2206,13 @@ begin
...
@@ -1818,6 +2206,13 @@ begin
Exit
;
Exit
;
end
;
end
;
if
BlockForDraftRow
(
idx
,
'changing another row'
)
then
begin
Event
.
preventDefault
;
Event
.
stopPropagation
;
Exit
;
end
;
if
(
FActiveRowIndex
>=
0
)
and
if
(
FActiveRowIndex
>=
0
)
and
(
idx
<>
FActiveRowIndex
)
and
(
idx
<>
FActiveRowIndex
)
and
(
not
ValidateRow
(
FActiveRowIndex
))
then
(
not
ValidateRow
(
FActiveRowIndex
))
then
...
@@ -1839,13 +2234,94 @@ begin
...
@@ -1839,13 +2234,94 @@ begin
if
not
Assigned
(
FTaskPickerOffCanvas
)
then
if
not
Assigned
(
FTaskPickerOffCanvas
)
then
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
,
@
TaskPickerFocusChanged
);
FTaskPickerOffCanvas
:=
TTaskPickerOffCanvas
.
Create
(
xdwcTimeEntries
,
@
TaskPickerTaskSelected
,
@
TaskPickerFocusChanged
);
// Pass the row's current task
so the picker opens on it (blank for rows without one)
// Pass the row's current task
and (draft) date so the picker opens on them
taskId
:=
''
;
taskId
:=
''
;
taskDate
:=
''
;
GotoRowIndex
(
idx
);
GotoRowIndex
(
idx
);
if
not
xdwdsTimeEntries
.
Eof
then
if
not
xdwdsTimeEntries
.
Eof
then
begin
taskId
:=
xdwdsTimeEntriestaskId
.
AsString
;
taskId
:=
xdwdsTimeEntriestaskId
.
AsString
;
taskDate
:=
xdwdsTimeEntriestaskDate
.
AsString
;
end
;
await
(
FTaskPickerOffCanvas
.
Open
(
FUserId
,
idx
,
FTaskOptions
,
taskId
));
await
(
FTaskPickerOffCanvas
.
Open
(
FUserId
,
idx
,
FTaskOptions
,
taskId
,
taskDate
));
end
;
// The task menu's items stop propagation (so the row click doesn't run), which
// also stops Bootstrap closing the menu; close it here. No-op when it isn't open.
procedure
TFTimeEntries
.
CloseTaskMenu
(
AEl
:
TJSHTMLElement
);
begin
asm
var
group
=
AEl
?
AEl
.
closest
(
'.input-group'
)
:
null
;
var
toggle
=
group
?
group
.
querySelector
(
'.dropdown-toggle-split[data-bs-toggle="dropdown"]'
)
:
null
;
var
dd
=
(
toggle
&&
window
.
bootstrap
)
?
bootstrap
.
Dropdown
.
getInstance
(
toggle
)
:
null
;
if
(
dd
)
dd
.
hide
();
end
;
end
;
// Swaps this screen for the row's Task Items; blocked while a new entry or an
// edit is unsaved, since leaving the screen would lose it
procedure
TFTimeEntries
.
TaskItemsButtonClick
(
Event
:
TJSEvent
);
var
el
:
TJSHTMLElement
;
idx
:
Integer
;
taskId
:
string
;
begin
Event
.
preventDefault
;
Event
.
stopPropagation
;
el
:=
TJSHTMLElement
(
Event
.
currentTarget
);
CloseTaskMenu
(
el
);
idx
:=
StrToIntDef
(
string
(
el
.
getAttribute
(
'data-idx'
)),
-
1
);
if
idx
<
0
then
Exit
;
if
FAddingNewEntry
or
((
FEditingEntryId
>
0
)
and
(
FEditingRowIndex
>=
0
))
then
begin
if
FAddingNewEntry
then
FBlockedRowIndex
:=
FNewEntryRowIndex
else
FBlockedRowIndex
:=
FEditingRowIndex
;
FActiveRowIndex
:=
FBlockedRowIndex
;
SetTopControlsEnabled
(
False
);
lblValidationMessage
.
Caption
:=
'Save or cancel your changes before opening Task Items.'
;
lblValidationMessage
.
ElementHandle
.
classList
.
remove
(
'd-none'
);
lblValidationMessage
.
ElementHandle
.
classList
.
remove
(
'invisible'
);
ApplyActiveRowState
;
Exit
;
end
;
taskId
:=
''
;
GotoRowIndex
(
idx
);
if
not
xdwdsTimeEntries
.
Eof
then
taskId
:=
xdwdsTimeEntriestaskId
.
AsString
;
if
taskId
=
''
then
Exit
;
// This form is freed by the switch; its document-wide guards would otherwise keep
// firing on the Task Items screen (and pile up each time Time Entries is reopened)
document
.
removeEventListener
(
'mousedown'
,
TJSEventHandler
(@
DocumentMouseDown
));
document
.
removeEventListener
(
'focusin'
,
TJSEventHandler
(@
DocumentFocusIn
));
// Back from Task Items reopens on this range
DMConnection
.
timeEntriesWeekOf
:=
edtWeekOf
.
Text
;
DMConnection
.
timeEntriesStartDate
:=
FStartDate
;
DMConnection
.
timeEntriesEndDate
:=
FEndDate
;
DMConnection
.
timeEntriesKeptIds
:=
FKeptEntryIds
;
// Deferred so this form isn't freed while its own click is still running
window
.
setTimeout
(
procedure
begin
FViewMain
.
ShowTaskItems
(
taskId
);
end
,
0
);
end
;
end
;
...
@@ -1897,7 +2373,7 @@ begin
...
@@ -1897,7 +2373,7 @@ begin
end
;
end
;
procedure
TFTimeEntries
.
TaskPickerTaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
);
procedure
TFTimeEntries
.
TaskPickerTaskSelected
(
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
,
ATaskDate
:
string
);
var
var
btn
:
TJSHTMLElement
;
btn
:
TJSHTMLElement
;
triggerId
:
string
;
triggerId
:
string
;
...
@@ -1909,11 +2385,17 @@ begin
...
@@ -1909,11 +2385,17 @@ begin
if
xdwdsTimeEntries
.
Eof
then
if
xdwdsTimeEntries
.
Eof
then
Exit
;
Exit
;
BeginEntryDraft
(
ARowIndex
);
// The picker's work date also becomes the row's date (part of the same draft)
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntries
.
Edit
;
xdwdsTimeEntriestaskId
.
AsString
:=
ATaskId
;
xdwdsTimeEntriestaskId
.
AsString
:=
ATaskId
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
ATaskDisplay
;
xdwdsTimeEntriestaskDisplay
.
AsString
:=
ATaskDisplay
;
if
ATaskDate
<>
''
then
xdwdsTimeEntriestaskDate
.
AsString
:=
ATaskDate
;
xdwdsTimeEntries
.
Post
;
xdwdsTimeEntries
.
Post
;
// RenderTable shows this row's Save/Cancel when it is the draft row
FActiveRowIndex
:=
ARowIndex
;
FActiveRowIndex
:=
ARowIndex
;
btnDeleteEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
btnDeleteEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
btnCopyEntry
.
Enabled
:=
not
IsNewEntryRow
(
ARowIndex
);
...
@@ -1927,9 +2409,6 @@ begin
...
@@ -1927,9 +2409,6 @@ begin
if
Assigned
(
btn
)
then
if
Assigned
(
btn
)
then
btn
.
focus
;
btn
.
focus
;
if
not
IsNewEntryRow
(
ARowIndex
)
then
SaveField
(
ARowIndex
,
'taskId'
);
if
IsNewEntryRow
(
ARowIndex
)
then
if
IsNewEntryRow
(
ARowIndex
)
then
begin
begin
if
ValidateRow
(
ARowIndex
)
then
if
ValidateRow
(
ARowIndex
)
then
...
@@ -1969,118 +2448,6 @@ begin
...
@@ -1969,118 +2448,6 @@ begin
end
;
end
;
procedure
TFTimeEntries
.
EditorBlur
(
Event
:
TJSEvent
);
var
el
:
TJSHTMLElement
;
idx
:
Integer
;
idxStr
:
string
;
fieldName
:
string
;
begin
el
:=
TJSHTMLElement
(
Event
.
target
);
idxStr
:=
string
(
el
.
getAttribute
(
'data-idx'
));
fieldName
:=
string
(
el
.
getAttribute
(
'data-field'
));
if
string
(
el
.
getAttribute
(
'data-unsaved-data'
))
<>
'1'
then
begin
console
.
log
(
'EditorBlur: skip (not unsaved) idx='
+
idxStr
+
' field='
+
fieldName
);
Exit
;
end
;
el
.
removeAttribute
(
'data-unsaved-data'
);
idx
:=
StrToIntDef
(
idxStr
,
-
1
);
if
idx
<
0
then
Exit
;
if
IsNewEntryRow
(
idx
)
then
begin
console
.
log
(
'EditorBlur: skip local new row idx='
+
IntToStr
(
idx
)
+
' field='
+
fieldName
);
Exit
;
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
);
SaveField
(
idx
,
fieldName
);
end
;
[
async
]
function
TFTimeEntries
.
SaveField
(
AIndex
:
Integer
;
const
AFieldName
:
string
):
Boolean
;
var
response
:
TXDataClientResponse
;
payload
:
TJSObject
;
fieldValue
:
string
;
begin
Result
:=
False
;
if
not
xdwdsTimeEntries
.
Active
then
Exit
;
GotoRowIndex
(
AIndex
);
if
xdwdsTimeEntries
.
Eof
then
Exit
;
if
xdwdsTimeEntriesentryId
.
AsInteger
<=
0
then
Exit
;
fieldValue
:=
''
;
if
SameText
(
AFieldName
,
'taskDate'
)
then
fieldValue
:=
xdwdsTimeEntriestaskDate
.
AsString
else
if
SameText
(
AFieldName
,
'taskId'
)
then
fieldValue
:=
xdwdsTimeEntriestaskId
.
AsString
else
if
SameText
(
AFieldName
,
'hours'
)
then
begin
if
xdwdsTimeEntrieshours
.
IsNull
then
fieldValue
:=
''
else
fieldValue
:=
xdwdsTimeEntrieshours
.
AsString
;
end
else
if
SameText
(
AFieldName
,
'taskTime'
)
then
fieldValue
:=
xdwdsTimeEntriestaskTime
.
AsString
else
if
SameText
(
AFieldName
,
'place'
)
then
fieldValue
:=
xdwdsTimeEntriesplace
.
AsString
else
if
SameText
(
AFieldName
,
'category'
)
then
fieldValue
:=
xdwdsTimeEntriescategory
.
AsString
else
if
SameText
(
AFieldName
,
'summary'
)
then
fieldValue
:=
xdwdsTimeEntriessummary
.
AsString
else
Exit
;
payload
:=
TJSObject
.
new
;
payload
[
'entryId'
]
:=
xdwdsTimeEntriesentryId
.
AsInteger
;
payload
[
'userId'
]
:=
FUserId
;
payload
[
'fieldName'
]
:=
AFieldName
;
payload
[
'value'
]
:=
fieldValue
;
console
.
log
(
'SaveField: idx='
+
IntToStr
(
AIndex
)
+
' field='
+
AFieldName
+
' value='
+
fieldValue
);
try
response
:=
await
(
xdwcTimeEntries
.
RawInvokeAsync
(
'ITimeEntryService.SaveTimeEntryField'
,
[
payload
]
));
Result
:=
True
;
console
.
log
(
'SaveField: response='
+
string
(
TJSJSON
.
stringify
(
response
.
Result
)));
if
SameText
(
AFieldName
,
'hours'
)
or
SameText
(
AFieldName
,
'taskDate'
)
then
UpdateTotalHours
;
except
on
E
:
EXDataClientRequestException
do
begin
console
.
log
(
'SaveField ERROR: '
+
E
.
ErrorResult
.
ErrorMessage
);
Utils
.
ShowErrorModal
(
E
.
ErrorResult
.
ErrorMessage
);
end
;
end
;
end
;
[
async
]
procedure
TFTimeEntries
.
DeleteSelectedEntry
;
[
async
]
procedure
TFTimeEntries
.
DeleteSelectedEntry
;
var
var
entryId
:
Integer
;
entryId
:
Integer
;
...
...
emT3Web/css/app.css
View file @
dd94c9fb
...
@@ -62,3 +62,8 @@ span.card {
...
@@ -62,3 +62,8 @@ span.card {
.dropdown-menu
{
.dropdown-menu
{
z-index
:
1055
;
z-index
:
1055
;
}
}
/* Even out the error modal's lines so one word isn't left alone on the last line */
#lbl_modal_body
{
text-wrap
:
balance
;
}
emT3Web/emT3web.dproj
View file @
dd94c9fb
...
@@ -94,15 +94,16 @@
...
@@ -94,15 +94,16 @@
<DCC_RemoteDebug>false</DCC_RemoteDebug>
<DCC_RemoteDebug>false</DCC_RemoteDebug>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Locale>1033</VerInfo_Locale>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=0.9.4.
0
;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.8.0;Comments=;LastCompiledTime=2018/08/27 15:18:29</VerInfo_Keys>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=0.9.4.
1
;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.8.0;Comments=;LastCompiledTime=2018/08/27 15:18:29</VerInfo_Keys>
<AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode>
<AppDPIAwarenessMode>PerMonitor</AppDPIAwarenessMode>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_Release>4</VerInfo_Release>
<VerInfo_Release>4</VerInfo_Release>
<TMSWebBrowser>1</TMSWebBrowser>
<TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebSingleInstance>1</TMSWebSingleInstance>
<TMSWebSingleInstance>1</TMSWebSingleInstance>
<VerInfo_Build>1</VerInfo_Build>
<TMSWebOutputPath>..\emT3XDataServer\bin\static</TMSWebOutputPath>
<TMSWebOutputPath>..\emT3XDataServer\bin\static</TMSWebOutputPath>
<TMSUseJSDebugger>2</TMSUseJSDebugger>
<TMSWebBrowser>1</TMSWebBrowser>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
...
...
emT3Web/uTaskPickerOffCanvas.pas
View file @
dd94c9fb
...
@@ -8,7 +8,7 @@ uses
...
@@ -8,7 +8,7 @@ uses
type
type
TTaskPickedProc
=
reference
to
procedure
(
TTaskPickedProc
=
reference
to
procedure
(
ARowIndex
:
Integer
;
ARowIndex
:
Integer
;
const
ATaskId
,
ATaskDisplay
:
string
const
ATaskId
,
ATaskDisplay
,
ATaskDate
:
string
);
);
TTaskFocusChangedProc
=
reference
to
procedure
(
TTaskFocusChangedProc
=
reference
to
procedure
(
...
@@ -28,16 +28,27 @@ type
...
@@ -28,16 +28,27 @@ type
FTasks
:
TJSArray
;
FTasks
:
TJSArray
;
FFocusedTasks
:
TJSArray
;
FFocusedTasks
:
TJSArray
;
FSavedFocus
:
Boolean
;
FSavedFocus
:
Boolean
;
FSavedTaskStatus
:
string
;
// selected task's status on the server, '' = no task
FSaving
:
Boolean
;
FSaving
:
Boolean
;
FPrefillToken
:
Integer
;
FPrefillToken
:
Integer
;
FScope
:
string
;
// MY, ACTIVE or ALL; kept between opens until the page reloads
FStatusesLoaded
:
Boolean
;
// footer Status dropdown is filled on the first open
procedure
BindEvents
;
procedure
BindEvents
;
procedure
ApplyScope
(
const
AScope
:
string
);
function
FindProjectCustomer
(
const
AProjectId
:
string
;
out
ACustomerId
:
string
):
Boolean
;
procedure
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
procedure
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
procedure
FillSelect
(
const
AElementId
:
string
;
AItems
:
TJSArray
);
procedure
FillSelect
(
const
AElementId
:
string
;
AItems
:
TJSArray
);
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
FocusCheckbox
:
TJSHTMLInputElement
;
function
TaskStatusSelect
:
TJSHTMLSelectElement
;
function
PickerDate
:
string
;
function
IsTaskCompleted
(
const
ATaskId
:
string
):
Boolean
;
function
TaskStatus
(
const
ATaskId
:
string
):
string
;
function
TaskUnavailableReason
(
const
ATaskId
:
string
):
string
;
procedure
ShowTaskAvailability
;
function
IsTaskFocused
(
const
ATaskId
:
string
):
Boolean
;
function
IsTaskFocused
(
const
ATaskId
:
string
):
Boolean
;
procedure
SetTaskFocused
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
procedure
SetTaskFocused
(
const
ATaskId
,
ATaskDisplay
:
string
;
AFocused
:
Boolean
);
procedure
SetStatus
(
const
AMessage
:
string
);
procedure
SetStatus
(
const
AMessage
:
string
);
...
@@ -48,15 +59,21 @@ type
...
@@ -48,15 +59,21 @@ type
procedure
Hide
;
procedure
Hide
;
[
async
]
procedure
LoadCustomers
;
[
async
]
procedure
LoadCustomers
;
[
async
]
procedure
LoadStatuses
;
procedure
FillCustomers
;
[
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
);
[
async
]
procedure
PreselectTask
(
const
ATaskId
:
string
;
AToken
:
Integer
);
[
async
]
procedure
ReloadForDate
;
procedure
SetSelectValue
(
const
AElementId
,
AValue
:
string
);
procedure
SetSelectValue
(
const
AElementId
,
AValue
:
string
);
[
async
]
procedure
DateChanged
(
Event
:
TJSEvent
);
[
async
]
procedure
ScopeChanged
(
Event
:
TJSEvent
);
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
FocusCheckboxChanged
(
Event
:
TJSEvent
);
procedure
TaskStatusChanged
(
Event
:
TJSEvent
);
procedure
UpdateFocusCheckbox
;
procedure
UpdateFocusCheckbox
;
procedure
SelectClicked
(
Event
:
TJSEvent
);
procedure
SelectClicked
(
Event
:
TJSEvent
);
[
async
]
procedure
SaveClicked
(
Event
:
TJSEvent
);
[
async
]
procedure
SaveClicked
(
Event
:
TJSEvent
);
...
@@ -64,7 +81,7 @@ type
...
@@ -64,7 +81,7 @@ type
constructor
Create
(
AClient
:
TXDataWebClient
;
AOnTaskPicked
:
TTaskPickedProc
;
constructor
Create
(
AClient
:
TXDataWebClient
;
AOnTaskPicked
:
TTaskPickedProc
;
AOnFocusChanged
:
TTaskFocusChangedProc
);
AOnFocusChanged
:
TTaskFocusChangedProc
);
[
async
]
procedure
Open
(
const
AUserId
:
string
;
ARowIndex
:
Integer
;
AFocusedTasks
:
TJSArray
;
[
async
]
procedure
Open
(
const
AUserId
:
string
;
ARowIndex
:
Integer
;
AFocusedTasks
:
TJSArray
;
const
ATaskId
:
string
);
const
ATaskId
,
ATaskDate
:
string
);
end
;
end
;
implementation
implementation
...
@@ -82,8 +99,11 @@ begin
...
@@ -82,8 +99,11 @@ begin
FFocusedTasks
:=
TJSArray
.
new
;
FFocusedTasks
:=
TJSArray
.
new
;
FRowIndex
:=
-
1
;
FRowIndex
:=
-
1
;
FSavedFocus
:=
False
;
FSavedFocus
:=
False
;
FSavedTaskStatus
:=
''
;
FSaving
:=
False
;
FSaving
:=
False
;
FPrefillToken
:=
0
;
FPrefillToken
:=
0
;
FScope
:=
'MY'
;
FStatusesLoaded
:=
False
;
BindEvents
;
BindEvents
;
end
;
end
;
...
@@ -92,6 +112,14 @@ procedure TTaskPickerOffCanvas.BindEvents;
...
@@ -92,6 +112,14 @@ procedure TTaskPickerOffCanvas.BindEvents;
var
var
el
:
TJSHTMLElement
;
el
:
TJSHTMLElement
;
begin
begin
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_date'
));
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
DateChanged
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_scope'
));
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
ScopeChanged
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_customer'
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_customer'
));
if
Assigned
(
el
)
then
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
CustomerChanged
));
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
CustomerChanged
));
...
@@ -104,10 +132,15 @@ begin
...
@@ -104,10 +132,15 @@ 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'
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_add_focus'
));
if
Assigned
(
el
)
then
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
FocusCheckboxChanged
));
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
FocusCheckboxChanged
));
el
:=
TJSHTMLElement
(
document
.
getElementById
(
'task_picker_task_status'
));
if
Assigned
(
el
)
then
el
.
addEventListener
(
'change'
,
TJSEventHandler
(@
TaskStatusChanged
));
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
));
...
@@ -117,6 +150,34 @@ begin
...
@@ -117,6 +150,34 @@ begin
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
SelectClicked
));
el
.
addEventListener
(
'click'
,
TJSEventHandler
(@
SelectClicked
));
end
;
end
;
// Sets the scope dropdown. The customer field shows in every scope; projects
// are listed as "SHORT_NAME - project"
procedure
TTaskPickerOffCanvas
.
ApplyScope
(
const
AScope
:
string
);
begin
FScope
:=
AScope
;
SetSelectValue
(
'task_picker_scope'
,
AScope
);
end
;
function
TTaskPickerOffCanvas
.
FindProjectCustomer
(
const
AProjectId
:
string
;
out
ACustomerId
:
string
):
Boolean
;
var
project
:
TJSObject
;
i
:
Integer
;
begin
Result
:=
False
;
ACustomerId
:=
''
;
for
i
:=
0
to
FProjects
.
length
-
1
do
begin
project
:=
TJSObject
(
FProjects
[
i
]);
if
string
(
project
[
'value'
])
=
AProjectId
then
begin
ACustomerId
:=
string
(
project
[
'customerId'
]);
Exit
(
True
);
end
;
end
;
end
;
procedure
TTaskPickerOffCanvas
.
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
procedure
TTaskPickerOffCanvas
.
ClearSelect
(
const
AElementId
:
string
;
ADisabled
:
Boolean
);
var
var
selectEl
:
TJSHTMLSelectElement
;
selectEl
:
TJSHTMLSelectElement
;
...
@@ -207,6 +268,89 @@ begin
...
@@ -207,6 +268,89 @@ begin
Result
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'task_picker_add_focus'
));
Result
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'task_picker_add_focus'
));
end
;
end
;
function
TTaskPickerOffCanvas
.
TaskStatusSelect
:
TJSHTMLSelectElement
;
begin
Result
:=
TJSHTMLSelectElement
(
document
.
getElementById
(
'task_picker_task_status'
));
end
;
function
TTaskPickerOffCanvas
.
PickerDate
:
string
;
var
dateEl
:
TJSHTMLInputElement
;
begin
Result
:=
''
;
dateEl
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'task_picker_date'
));
if
Assigned
(
dateEl
)
then
Result
:=
dateEl
.
value
;
end
;
// The server marks a task completed when its COMPLETION_DATE is set
function
TTaskPickerOffCanvas
.
IsTaskCompleted
(
const
ATaskId
:
string
):
Boolean
;
var
itemObj
:
TJSObject
;
i
:
Integer
;
begin
Result
:=
False
;
for
i
:=
0
to
FTasks
.
length
-
1
do
begin
itemObj
:=
TJSObject
(
FTasks
[
i
]);
if
string
(
itemObj
[
'value'
])
=
ATaskId
then
Exit
(
JS
.
isBoolean
(
itemObj
[
'completed'
])
and
Boolean
(
itemObj
[
'completed'
]));
end
;
end
;
// The task's status code as loaded with the task list; '' = unknown
function
TTaskPickerOffCanvas
.
TaskStatus
(
const
ATaskId
:
string
):
string
;
var
itemObj
:
TJSObject
;
i
:
Integer
;
begin
Result
:=
''
;
for
i
:=
0
to
FTasks
.
length
-
1
do
begin
itemObj
:=
TJSObject
(
FTasks
[
i
]);
if
string
(
itemObj
[
'value'
])
=
ATaskId
then
begin
if
JS
.
isString
(
itemObj
[
'status'
])
then
Exit
(
string
(
itemObj
[
'status'
]));
Exit
;
end
;
end
;
end
;
// Why hours can't go on the picker date for this task; '' = allowed (or unknown)
function
TTaskPickerOffCanvas
.
TaskUnavailableReason
(
const
ATaskId
:
string
):
string
;
var
itemObj
:
TJSObject
;
i
:
Integer
;
begin
Result
:=
''
;
for
i
:=
0
to
FTasks
.
length
-
1
do
begin
itemObj
:=
TJSObject
(
FTasks
[
i
]);
if
string
(
itemObj
[
'value'
])
=
ATaskId
then
begin
if
JS
.
isString
(
itemObj
[
'unavailableReason'
])
then
Exit
(
string
(
itemObj
[
'unavailableReason'
]));
Exit
;
end
;
end
;
end
;
procedure
TTaskPickerOffCanvas
.
ShowTaskAvailability
;
var
reason
:
string
;
begin
reason
:=
TaskUnavailableReason
(
SelectedValue
(
'task_picker_task'
));
if
reason
<>
''
then
SetStatus
(
reason
)
else
ClearStatus
;
end
;
function
TTaskPickerOffCanvas
.
IsTaskFocused
(
const
ATaskId
:
string
):
Boolean
;
function
TTaskPickerOffCanvas
.
IsTaskFocused
(
const
ATaskId
:
string
):
Boolean
;
var
var
taskOption
:
TJSObject
;
taskOption
:
TJSObject
;
...
@@ -291,44 +435,95 @@ procedure TTaskPickerOffCanvas.UpdateButtons;
...
@@ -291,44 +435,95 @@ procedure TTaskPickerOffCanvas.UpdateButtons;
var
var
hasTask
:
Boolean
;
hasTask
:
Boolean
;
focusChanged
:
Boolean
;
focusChanged
:
Boolean
;
focusBlocked
:
Boolean
;
statusChanged
:
Boolean
;
pendingStatus
:
string
;
addFocus
:
TJSHTMLInputElement
;
addFocus
:
TJSHTMLInputElement
;
statusSelect
:
TJSHTMLSelectElement
;
begin
begin
// Select: any picked task can be sent to the grid.
// 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.
// Save: only when the Focused Task checkbox or the Status differs from what
// is saved on the server.
hasTask
:=
SelectedValue
(
'task_picker_task'
)
<>
''
;
hasTask
:=
SelectedValue
(
'task_picker_task'
)
<>
''
;
statusSelect
:=
TaskStatusSelect
;
pendingStatus
:=
''
;
statusChanged
:=
False
;
if
Assigned
(
statusSelect
)
then
begin
statusSelect
.
disabled
:=
(
not
hasTask
)
or
FSaving
or
(
not
FStatusesLoaded
);
pendingStatus
:=
statusSelect
.
value
;
statusChanged
:=
hasTask
and
(
pendingStatus
<>
''
)
and
(
pendingStatus
<>
FSavedTaskStatus
);
end
;
// A completed task can be selected for historical hours but not newly focused
// (it can still be unfocused if it already is). With a status change pending,
// the new status decides: Save sends it first, and the server sets the
// completion date for CLOSED/COMP and clears it for any other status.
if
statusChanged
then
focusBlocked
:=
(
pendingStatus
=
'CLOSED'
)
or
(
pendingStatus
=
'COMP'
)
else
focusBlocked
:=
IsTaskCompleted
(
SelectedValue
(
'task_picker_task'
));
focusBlocked
:=
focusBlocked
and
hasTask
and
(
not
FSavedFocus
);
addFocus
:=
FocusCheckbox
;
addFocus
:=
FocusCheckbox
;
focusChanged
:=
False
;
focusChanged
:=
False
;
if
Assigned
(
addFocus
)
then
if
Assigned
(
addFocus
)
then
begin
begin
addFocus
.
disabled
:=
(
not
hasTask
)
or
FSaving
;
// Closing the task drops a focus tick that hasn't been saved yet
if
focusBlocked
then
addFocus
.
checked
:=
False
;
addFocus
.
disabled
:=
(
not
hasTask
)
or
FSaving
or
focusBlocked
;
focusChanged
:=
addFocus
.
checked
<>
FSavedFocus
;
focusChanged
:=
addFocus
.
checked
<>
FSavedFocus
;
end
;
end
;
SetButtonEnabled
(
'btn_task_picker_select'
,
hasTask
and
not
FSaving
);
SetButtonEnabled
(
'btn_task_picker_select'
,
hasTask
and
not
FSaving
);
SetButtonEnabled
(
'btn_task_picker_save'
,
hasTask
and
focusChanged
and
not
FSaving
);
SetButtonEnabled
(
'btn_task_picker_save'
,
hasTask
and
(
focusChanged
or
statusChanged
)
and
not
FSaving
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
Show
;
procedure
TTaskPickerOffCanvas
.
Show
;
begin
begin
asm
asm
const
el
=
document
.
getElementById
(
'task_picker_
offcanvas
'
);
const
el
=
document
.
getElementById
(
'task_picker_
modal
'
);
if
(!
el
||
!
window
.
bootstrap
)
return
;
if
(!
el
||
!
window
.
bootstrap
)
return
;
const
oc
=
bootstrap
.
Offcanvas
.
getOrCreateInstance
(
el
);
// The modal's backdrop is added to <body>; left inside the form's TMS
oc
.
show
();
// containers (which carry their own z-index) the modal sits under it.
// So it moves to <body> while open and goes back into the form when hidden,
// so the form still frees it and no second copy of its IDs is left behind.
if
(
el
.
parentNode
!==
document
.
body
)
{
const home = el.parentNode;
const homeNext = el.nextSibling;
el.addEventListener('hidden.bs.modal', function () {
if (home.isConnected)
home.insertBefore(el, (homeNext && homeNext.parentNode === home) ? homeNext : null);
else {
bootstrap.Modal.getOrCreateInstance(el).dispose();
el.remove();
}
},
{ once: true }
);
document
.
body
.
appendChild
(
el
);
}
const
modal
=
bootstrap
.
Modal
.
getOrCreateInstance
(
el
);
modal
.
show
();
end
;
end
;
end
;
end
;
procedure
TTaskPickerOffCanvas
.
Hide
;
procedure
TTaskPickerOffCanvas
.
Hide
;
begin
begin
asm
asm
const
el
=
document
.
getElementById
(
'task_picker_
offcanvas
'
);
const
el
=
document
.
getElementById
(
'task_picker_
modal
'
);
if
(!
el
||
!
window
.
bootstrap
)
return
;
if
(!
el
||
!
window
.
bootstrap
)
return
;
const
oc
=
bootstrap
.
Offcanvas
.
getOrCreateInstance
(
el
);
const
modal
=
bootstrap
.
Modal
.
getOrCreateInstance
(
el
);
oc
.
hide
();
modal
.
hide
();
end
;
end
;
end
;
end
;
...
@@ -346,33 +541,123 @@ begin
...
@@ -346,33 +541,123 @@ begin
FillSelect
(
'task_picker_customer'
,
FCustomers
);
FillSelect
(
'task_picker_customer'
,
FCustomers
);
end
;
end
;
// Fills the footer's Status dropdown with the task status codes
[
async
]
procedure
TTaskPickerOffCanvas
.
LoadStatuses
;
var
response
:
TXDataClientResponse
;
resultObj
:
TJSObject
;
statuses
:
TJSArray
;
statusObj
:
TJSObject
;
statusSelect
:
TJSHTMLSelectElement
;
optionEl
:
TJSHTMLOptionElement
;
i
:
Integer
;
begin
response
:=
await
(
FClient
.
RawInvokeAsync
(
'ITimeEntryService.GetTaskPickerStatuses'
,
[]
));
resultObj
:=
TJSObject
(
response
.
Result
);
statuses
:=
TJSArray
(
resultObj
[
'options'
]);
statusSelect
:=
TaskStatusSelect
;
if
not
Assigned
(
statusSelect
)
then
Exit
;
statusSelect
.
innerHTML
:=
''
;
for
i
:=
0
to
statuses
.
length
-
1
do
begin
statusObj
:=
TJSObject
(
statuses
[
i
]);
optionEl
:=
TJSHTMLOptionElement
(
document
.
createElement
(
'option'
));
optionEl
.
value
:=
string
(
statusObj
[
'value'
]);
optionEl
.
text
:=
string
(
statusObj
[
'display'
]);
statusSelect
.
appendChild
(
optionEl
);
end
;
// Blank until a task is picked (UpdateFocusCheckbox sets the task's status)
statusSelect
.
value
:=
FSavedTaskStatus
;
FStatusesLoaded
:=
True
;
end
;
// Only customers with a listed project (so the scope and Work Date apply to
// them too, like emT3's Time Entry screen); keeps the chosen customer if still listed
procedure
TTaskPickerOffCanvas
.
FillCustomers
;
var
filteredCustomers
:
TJSArray
;
customer
:
TJSObject
;
selectedCustomer
:
string
;
customerId
:
string
;
i
:
Integer
;
j
:
Integer
;
begin
selectedCustomer
:=
SelectedValue
(
'task_picker_customer'
);
filteredCustomers
:=
TJSArray
.
new
;
for
i
:=
0
to
FCustomers
.
length
-
1
do
begin
customer
:=
TJSObject
(
FCustomers
[
i
]);
customerId
:=
string
(
customer
[
'value'
]);
for
j
:=
0
to
FProjects
.
length
-
1
do
if
string
(
TJSObject
(
FProjects
[
j
])[
'customerId'
])
=
customerId
then
begin
filteredCustomers
.
push
(
customer
);
Break
;
end
;
end
;
FillSelect
(
'task_picker_customer'
,
filteredCustomers
);
if
(
selectedCustomer
<>
''
)
and
(
FindDisplay
(
filteredCustomers
,
selectedCustomer
)
<>
''
)
then
SetSelectValue
(
'task_picker_customer'
,
selectedCustomer
);
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
LoadProjects
(
const
ACustomerId
:
string
);
[
async
]
procedure
TTaskPickerOffCanvas
.
LoadProjects
(
const
ACustomerId
:
string
);
var
var
response
:
TXDataClientResponse
;
response
:
TXDataClientResponse
;
resultObj
:
TJSObject
;
resultObj
:
TJSObject
;
begin
begin
// Projects in the scope that are open on the Work Date (any date when it's
// blank); the customer list then follows the projects
response
:=
await
(
FClient
.
RawInvokeAsync
(
response
:=
await
(
FClient
.
RawInvokeAsync
(
'ITimeEntryService.GetTaskPickerProjects'
,
'ITimeEntryService.GetTaskPickerProjects'
,
[
ACustomerId
]
[
ACustomerId
,
FScope
,
FUserId
,
PickerDate
]
));
));
resultObj
:=
TJSObject
(
response
.
Result
);
resultObj
:=
TJSObject
(
response
.
Result
);
FProjects
:=
TJSArray
(
resultObj
[
'options'
]);
FProjects
:=
TJSArray
(
resultObj
[
'options'
]);
FillCustomers
;
end
;
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
LoadTasks
(
const
AProjectId
:
string
);
[
async
]
procedure
TTaskPickerOffCanvas
.
LoadTasks
(
const
AProjectId
:
string
);
var
var
response
:
TXDataClientResponse
;
response
:
TXDataClientResponse
;
resultObj
:
TJSObject
;
resultObj
:
TJSObject
;
taskDate
:
string
;
begin
begin
// The server returns the project's tasks open on the Work Date (every task
// when it's blank); each one carries unavailableReason for this date and
// user ('' when allowed or no date)
taskDate
:=
PickerDate
;
response
:=
await
(
FClient
.
RawInvokeAsync
(
response
:=
await
(
FClient
.
RawInvokeAsync
(
'ITimeEntryService.GetTaskPickerTasks'
,
'ITimeEntryService.GetTaskPickerTasks'
,
[
AProjectId
]
[
AProjectId
,
FUserId
,
taskDate
]
));
));
resultObj
:=
TJSObject
(
response
.
Result
);
resultObj
:=
TJSObject
(
response
.
Result
);
FTasks
:=
TJSArray
(
resultObj
[
'options'
]);
FTasks
:=
TJSArray
(
resultObj
[
'options'
]);
FillSelect
(
'task_picker_task'
,
FTasks
);
FillSelect
(
'task_picker_task'
,
FTasks
);
if
FTasks
.
length
=
0
then
begin
if
taskDate
<>
''
then
SetStatus
(
'No tasks in this project are open on this date.'
)
else
SetStatus
(
'No tasks in this project.'
);
end
;
end
;
end
;
procedure
TTaskPickerOffCanvas
.
SetSelectValue
(
const
AElementId
,
AValue
:
string
);
procedure
TTaskPickerOffCanvas
.
SetSelectValue
(
const
AElementId
,
AValue
:
string
);
...
@@ -389,11 +674,8 @@ end;
...
@@ -389,11 +674,8 @@ end;
var
var
response
:
TXDataClientResponse
;
response
:
TXDataClientResponse
;
context
:
TJSObject
;
context
:
TJSObject
;
project
:
TJSObject
;
projectId
:
string
;
projectId
:
string
;
customerId
:
string
;
customerId
:
string
;
projectFound
:
Boolean
;
i
:
Integer
;
begin
begin
response
:=
await
(
FClient
.
RawInvokeAsync
(
response
:=
await
(
FClient
.
RawInvokeAsync
(
'ITimeEntryService.GetTaskPickerTaskContext'
,
'ITimeEntryService.GetTaskPickerTaskContext'
,
...
@@ -409,22 +691,37 @@ begin
...
@@ -409,22 +691,37 @@ begin
if
projectId
=
''
then
if
projectId
=
''
then
Exit
;
Exit
;
// FProjects only holds ACTIVE projects; a task under any other project opens blank
// Not one of My Projects: switch to Active, which lists every active project
projectFound
:=
False
;
if
(
not
FindProjectCustomer
(
projectId
,
customerId
))
and
(
FScope
=
'MY'
)
then
customerId
:=
''
;
for
i
:=
0
to
FProjects
.
length
-
1
do
begin
begin
project
:=
TJSObject
(
FProjects
[
i
]);
ApplyScope
(
'ACTIVE'
);
if
string
(
project
[
'value'
])
=
projectId
then
await
(
LoadProjects
(
''
));
begin
FilterProjects
(
''
);
customerId
:=
string
(
project
[
'customerId'
]);
projectFound
:=
True
;
if
AToken
<>
FPrefillToken
then
Break
;
Exit
;
end
;
end
;
end
;
if
not
projectFound
then
// Not active (closed, complete or pending): switch to All, which lists every project
if
(
not
FindProjectCustomer
(
projectId
,
customerId
))
and
(
FScope
=
'ACTIVE'
)
then
begin
ApplyScope
(
'ALL'
);
await
(
LoadProjects
(
''
));
FilterProjects
(
''
);
if
AToken
<>
FPrefillToken
then
Exit
;
end
;
// Still not listed under All: its project isn't open on the Work Date
if
not
FindProjectCustomer
(
projectId
,
customerId
)
then
begin
if
PickerDate
<>
''
then
SetStatus
(
'This row''s project isn''t open on this date.'
)
else
SetStatus
(
'This row''s task couldn''t be found in its project.'
);
Exit
;
Exit
;
end
;
SetSelectValue
(
'task_picker_customer'
,
customerId
);
SetSelectValue
(
'task_picker_customer'
,
customerId
);
FilterProjects
(
customerId
);
FilterProjects
(
customerId
);
...
@@ -435,9 +732,129 @@ begin
...
@@ -435,9 +732,129 @@ begin
if
AToken
<>
FPrefillToken
then
if
AToken
<>
FPrefillToken
then
Exit
;
Exit
;
// If the task is not in the list (e.g. moved project) the task select just stays blank
// Not open on the Work Date (e.g. the row's date was just changed), or moved
if
FindDisplay
(
FTasks
,
ATaskId
)
=
''
then
begin
if
PickerDate
<>
''
then
SetStatus
(
'This row''s task isn''t open on this date.'
)
else
SetStatus
(
'This row''s task couldn''t be found in its project.'
);
UpdateFocusCheckbox
;
Exit
;
end
;
SetSelectValue
(
'task_picker_task'
,
ATaskId
);
SetSelectValue
(
'task_picker_task'
,
ATaskId
);
UpdateFocusCheckbox
;
UpdateFocusCheckbox
;
ShowTaskAvailability
;
end
;
// The Work Date changed: reload the projects (and so the
// customers) and the selected project's tasks for the new date, keeping the
// customer, project and task when they're still listed
[
async
]
procedure
TTaskPickerOffCanvas
.
ReloadForDate
;
var
projectId
:
string
;
taskId
:
string
;
token
:
Integer
;
begin
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
token
:=
FPrefillToken
;
ClearStatus
;
projectId
:=
SelectedValue
(
'task_picker_project'
);
taskId
:=
SelectedValue
(
'task_picker_task'
);
ClearSelect
(
'task_picker_project'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
UpdateFocusCheckbox
;
try
await
(
LoadProjects
(
''
));
except
on
E
:
Exception
do
begin
SetStatus
(
'Unable to load projects.'
);
Exit
;
end
;
end
;
if
token
<>
FPrefillToken
then
Exit
;
// FillCustomers kept the customer if it still has a project on this date
FilterProjects
(
SelectedValue
(
'task_picker_customer'
));
if
projectId
=
''
then
Exit
;
if
FindDisplay
(
FProjects
,
projectId
)
=
''
then
begin
SetStatus
(
'The selected project isn''t open on this date.'
);
Exit
;
end
;
SetSelectValue
(
'task_picker_project'
,
projectId
);
try
await
(
LoadTasks
(
projectId
));
except
on
E
:
Exception
do
begin
SetStatus
(
'Unable to load tasks.'
);
Exit
;
end
;
end
;
if
token
<>
FPrefillToken
then
Exit
;
// Keep the chosen task and say whether it can take hours on the new date
if
(
taskId
<>
''
)
and
(
FindDisplay
(
FTasks
,
taskId
)
<>
''
)
then
SetSelectValue
(
'task_picker_task'
,
taskId
)
else
if
(
taskId
<>
''
)
and
(
FTasks
.
length
>
0
)
then
SetStatus
(
'The selected task isn''t open on this date.'
);
UpdateFocusCheckbox
;
// Only when a task is selected, so an empty-project status isn't cleared
if
SelectedValue
(
'task_picker_task'
)
<>
''
then
ShowTaskAvailability
;
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
DateChanged
(
Event
:
TJSEvent
);
begin
await
(
ReloadForDate
);
end
;
[
async
]
procedure
TTaskPickerOffCanvas
.
ScopeChanged
(
Event
:
TJSEvent
);
var
token
:
Integer
;
begin
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
token
:=
FPrefillToken
;
ClearStatus
;
ApplyScope
(
SelectedValue
(
'task_picker_scope'
));
SetSelectValue
(
'task_picker_customer'
,
''
);
ClearSelect
(
'task_picker_project'
,
True
);
ClearSelect
(
'task_picker_task'
,
True
);
UpdateFocusCheckbox
;
try
await
(
LoadProjects
(
''
));
except
on
E
:
Exception
do
begin
SetStatus
(
'Unable to load projects.'
);
Exit
;
end
;
end
;
// Another scope was picked while this list was loading
if
token
<>
FPrefillToken
then
Exit
;
FilterProjects
(
''
);
end
;
end
;
procedure
TTaskPickerOffCanvas
.
CustomerChanged
(
Event
:
TJSEvent
);
procedure
TTaskPickerOffCanvas
.
CustomerChanged
(
Event
:
TJSEvent
);
...
@@ -472,6 +889,7 @@ begin
...
@@ -472,6 +889,7 @@ begin
customerId
:=
SelectedValue
(
'task_picker_customer'
);
customerId
:=
SelectedValue
(
'task_picker_customer'
);
// No customer chosen: fill it in from the project
if
customerId
=
''
then
if
customerId
=
''
then
begin
begin
for
i
:=
0
to
FProjects
.
length
-
1
do
for
i
:=
0
to
FProjects
.
length
-
1
do
...
@@ -501,6 +919,7 @@ end;
...
@@ -501,6 +919,7 @@ end;
procedure
TTaskPickerOffCanvas
.
UpdateFocusCheckbox
;
procedure
TTaskPickerOffCanvas
.
UpdateFocusCheckbox
;
var
var
addFocus
:
TJSHTMLInputElement
;
addFocus
:
TJSHTMLInputElement
;
statusSelect
:
TJSHTMLSelectElement
;
begin
begin
// Reset the checkbox to the task's saved focus state (discards any unsaved toggle)
// Reset the checkbox to the task's saved focus state (discards any unsaved toggle)
FSavedFocus
:=
IsTaskFocused
(
SelectedValue
(
'task_picker_task'
));
FSavedFocus
:=
IsTaskFocused
(
SelectedValue
(
'task_picker_task'
));
...
@@ -509,6 +928,13 @@ begin
...
@@ -509,6 +928,13 @@ begin
if
Assigned
(
addFocus
)
then
if
Assigned
(
addFocus
)
then
addFocus
.
checked
:=
FSavedFocus
;
addFocus
.
checked
:=
FSavedFocus
;
// Same for the Status dropdown: back to the task's saved status (blank with no task)
FSavedTaskStatus
:=
TaskStatus
(
SelectedValue
(
'task_picker_task'
));
statusSelect
:=
TaskStatusSelect
;
if
Assigned
(
statusSelect
)
then
statusSelect
.
value
:=
FSavedTaskStatus
;
UpdateButtons
;
UpdateButtons
;
end
;
end
;
...
@@ -517,6 +943,7 @@ begin
...
@@ -517,6 +943,7 @@ begin
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
Inc
(
FPrefillToken
);
// user took over; abandon any prefill still loading
ClearStatus
;
ClearStatus
;
UpdateFocusCheckbox
;
UpdateFocusCheckbox
;
ShowTaskAvailability
;
end
;
end
;
procedure
TTaskPickerOffCanvas
.
FocusCheckboxChanged
(
Event
:
TJSEvent
);
procedure
TTaskPickerOffCanvas
.
FocusCheckboxChanged
(
Event
:
TJSEvent
);
...
@@ -525,9 +952,17 @@ begin
...
@@ -525,9 +952,17 @@ begin
UpdateButtons
;
UpdateButtons
;
end
;
end
;
// Only marks the change; Save sends it, like the Focused Task checkbox
procedure
TTaskPickerOffCanvas
.
TaskStatusChanged
(
Event
:
TJSEvent
);
begin
ClearStatus
;
UpdateButtons
;
end
;
procedure
TTaskPickerOffCanvas
.
SelectClicked
(
Event
:
TJSEvent
);
procedure
TTaskPickerOffCanvas
.
SelectClicked
(
Event
:
TJSEvent
);
var
var
taskId
:
string
;
taskId
:
string
;
reason
:
string
;
begin
begin
Event
.
preventDefault
;
Event
.
preventDefault
;
...
@@ -538,11 +973,20 @@ begin
...
@@ -538,11 +973,20 @@ begin
Exit
;
Exit
;
end
;
end
;
// Listed but can't take hours on this date (completed, not started, or
// outside employment); the picker stays open so the date or task can change
reason
:=
TaskUnavailableReason
(
taskId
);
if
reason
<>
''
then
begin
SetStatus
(
reason
);
Exit
;
end
;
ClearStatus
;
ClearStatus
;
// Sends the task
to the grid only; foc
us changes happen through Save
// Sends the task
and work date to the grid only; focus and stat
us changes happen through Save
if
Assigned
(
FOnTaskPicked
)
then
if
Assigned
(
FOnTaskPicked
)
then
FOnTaskPicked
(
FRowIndex
,
taskId
,
FindDisplay
(
FTasks
,
taskId
));
FOnTaskPicked
(
FRowIndex
,
taskId
,
FindDisplay
(
FTasks
,
taskId
)
,
PickerDate
);
Hide
;
Hide
;
end
;
end
;
...
@@ -551,9 +995,17 @@ end;
...
@@ -551,9 +995,17 @@ end;
var
var
taskId
:
string
;
taskId
:
string
;
taskDisplay
:
string
;
taskDisplay
:
string
;
projectId
:
string
;
methodName
:
string
;
methodName
:
string
;
newStatus
:
string
;
addFocus
:
TJSHTMLInputElement
;
addFocus
:
TJSHTMLInputElement
;
statusSelect
:
TJSHTMLSelectElement
;
focused
:
Boolean
;
focused
:
Boolean
;
focusChanged
:
Boolean
;
statusChanged
:
Boolean
;
statusSaved
:
Boolean
;
focusFailed
:
Boolean
;
token
:
Integer
;
begin
begin
Event
.
preventDefault
;
Event
.
preventDefault
;
...
@@ -568,68 +1020,144 @@ begin
...
@@ -568,68 +1020,144 @@ begin
end
;
end
;
addFocus
:=
FocusCheckbox
;
addFocus
:=
FocusCheckbox
;
if
not
Assigned
(
addFocus
)
then
statusSelect
:=
TaskStatusSelect
;
if
(
not
Assigned
(
addFocus
))
or
(
not
Assigned
(
statusSelect
))
then
Exit
;
Exit
;
focused
:=
addFocus
.
checked
;
focused
:=
addFocus
.
checked
;
if
focused
=
FSavedFocus
then
focusChanged
:=
focused
<>
FSavedFocus
;
newStatus
:=
statusSelect
.
value
;
statusChanged
:=
(
newStatus
<>
''
)
and
(
newStatus
<>
FSavedTaskStatus
);
if
(
not
focusChanged
)
and
(
not
statusChanged
)
then
begin
begin
UpdateButtons
;
UpdateButtons
;
Exit
;
Exit
;
end
;
end
;
taskDisplay
:=
FindDisplay
(
FTasks
,
taskId
);
taskDisplay
:=
FindDisplay
(
FTasks
,
taskId
);
projectId
:=
SelectedValue
(
'task_picker_project'
);
if
focused
then
statusSaved
:=
False
;
methodName
:=
'ITimeEntryService.AddTaskToFocus'
focusFailed
:=
False
;
else
methodName
:=
'ITimeEntryService.RemoveTaskFromFocus'
;
ClearStatus
;
ClearStatus
;
FSaving
:=
True
;
FSaving
:=
True
;
UpdateButtons
;
UpdateButtons
;
try
try
try
// Status first: closing the task decides whether it can still be focused
await
(
FClient
.
RawInvokeAsync
(
methodName
,
[
FUserId
,
taskId
]));
if
statusChanged
then
except
begin
on
E
:
EXDataClientRequestException
do
try
begin
await
(
FClient
.
RawInvokeAsync
(
'ITimeEntryService.SetTaskStatus'
,
SetStatus
(
E
.
ErrorResult
.
ErrorMessage
);
[
taskId
,
newStatus
,
PickerDate
]));
Exit
;
statusSaved
:=
True
;
except
on
E
:
EXDataClientRequestException
do
SetStatus
(
E
.
ErrorResult
.
ErrorMessage
);
on
E
:
Exception
do
SetStatus
(
'Unable to save task status.'
);
end
;
end
;
on
E
:
Exception
do
begin
if
not
statusSaved
then
SetStatus
(
'Unable to save focused task.'
);
Exit
;
Exit
;
end
;
if
SelectedValue
(
'task_picker_task'
)
=
taskId
then
FSavedTaskStatus
:=
newStatus
;
end
;
end
;
SetTaskFocused
(
taskId
,
taskDisplay
,
focused
);
if
focusChanged
then
begin
if
focused
then
methodName
:=
'ITimeEntryService.AddTaskToFocus'
else
methodName
:=
'ITimeEntryService.RemoveTaskFromFocus'
;
try
await
(
FClient
.
RawInvokeAsync
(
methodName
,
[
FUserId
,
taskId
]));
except
on
E
:
EXDataClientRequestException
do
begin
SetStatus
(
E
.
ErrorResult
.
ErrorMessage
);
focusFailed
:=
True
;
end
;
on
E
:
Exception
do
begin
SetStatus
(
'Unable to save focused task.'
);
focusFailed
:=
True
;
end
;
end
;
if
not
focusFailed
then
begin
SetTaskFocused
(
taskId
,
taskDisplay
,
focused
);
// The user may have picked a different task while the request was running
// The user may have picked a different task while the request was running
if
SelectedValue
(
'task_picker_task'
)
=
taskId
then
if
SelectedValue
(
'task_picker_task'
)
=
taskId
then
FSavedFocus
:=
focused
;
FSavedFocus
:=
focused
;
if
Assigned
(
FOnFocusChanged
)
then
if
Assigned
(
FOnFocusChanged
)
then
FOnFocusChanged
(
taskId
,
taskDisplay
,
focused
);
FOnFocusChanged
(
taskId
,
taskDisplay
,
focused
);
end
;
end
;
finally
finally
FSaving
:=
False
;
FSaving
:=
False
;
UpdateButtons
;
UpdateButtons
;
end
;
end
;
// Reload the task list so its completed flag and availability follow the new
// status. A task closed here gets the Work Date as its completion date, so it
// stays listed for this date. Skipped when the user has moved to another task
// or project meanwhile.
if
(
not
statusSaved
)
or
(
SelectedValue
(
'task_picker_task'
)
<>
taskId
)
or
(
SelectedValue
(
'task_picker_project'
)
<>
projectId
)
then
Exit
;
Inc
(
FPrefillToken
);
token
:=
FPrefillToken
;
try
await
(
LoadTasks
(
projectId
));
except
on
E
:
Exception
do
begin
SetStatus
(
'Unable to load tasks.'
);
Exit
;
end
;
end
;
if
token
<>
FPrefillToken
then
Exit
;
if
FindDisplay
(
FTasks
,
taskId
)
<>
''
then
SetSelectValue
(
'task_picker_task'
,
taskId
);
UpdateFocusCheckbox
;
// Keep a focus error on screen rather than replacing it
if
not
focusFailed
then
ShowTaskAvailability
;
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
const
ATaskId
,
ATaskDate
:
string
);
);
var
var
token
:
Integer
;
token
:
Integer
;
dateEl
:
TJSHTMLInputElement
;
begin
begin
FUserId
:=
AUserId
;
FUserId
:=
AUserId
;
FRowIndex
:=
ARowIndex
;
FRowIndex
:=
ARowIndex
;
// Start from the row's (draft) work date; it is only used to validate the chosen task
FTasks
:=
TJSArray
.
new
;
dateEl
:=
TJSHTMLInputElement
(
document
.
getElementById
(
'task_picker_date'
));
if
Assigned
(
dateEl
)
then
dateEl
.
value
:=
ATaskDate
;
Inc
(
FPrefillToken
);
Inc
(
FPrefillToken
);
token
:=
FPrefillToken
;
token
:=
FPrefillToken
;
...
@@ -640,6 +1168,7 @@ begin
...
@@ -640,6 +1168,7 @@ begin
FFocusedTasks
:=
TJSArray
.
new
;
FFocusedTasks
:=
TJSArray
.
new
;
ClearStatus
;
ClearStatus
;
ApplyScope
(
FScope
);
// reopen on the last scope picked
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
);
...
@@ -649,12 +1178,14 @@ begin
...
@@ -649,12 +1178,14 @@ begin
try
try
await
(
LoadCustomers
);
await
(
LoadCustomers
);
if
not
FStatusesLoaded
then
await
(
LoadStatuses
);
await
(
LoadProjects
(
''
));
await
(
LoadProjects
(
''
));
FilterProjects
(
''
);
FilterProjects
(
''
);
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
SetStatus
(
'Unable to load customers or projects.'
);
SetStatus
(
'Unable to load customers
, statuses
or projects.'
);
Exit
;
Exit
;
end
;
end
;
end
;
end
;
...
...
emT3XDataServer/Source/Api.Database.dfm
View file @
dd94c9fb
...
@@ -1282,7 +1282,6 @@ object ApiDatabase: TApiDatabase
...
@@ -1282,7 +1282,6 @@ object ApiDatabase: TApiDatabase
' c.NAME as CUSTOMER_NAME'
' c.NAME as CUSTOMER_NAME'
'from customers c '
'from customers c '
'join project p on p.CUSTOMER_ID = c.CUSTOMER_ID'
'join project p on p.CUSTOMER_ID = c.CUSTOMER_ID'
'where p.STATUS = '#39'ACTIVE'#39
'order by c.NAME'
'order by c.NAME'
'')
'')
Left = 404
Left = 404
...
@@ -1302,18 +1301,20 @@ object ApiDatabase: TApiDatabase
...
@@ -1302,18 +1301,20 @@ object ApiDatabase: TApiDatabase
'select'
'select'
' p.PROJECT_ID,'
' p.PROJECT_ID,'
' p.NAME as PROJECT_NAME,'
' p.NAME as PROJECT_NAME,'
' p.CUSTOMER_ID'
' p.CUSTOMER_ID,'
' c.SHORT_NAME as CUSTOMER_SHORT_NAME'
'from project p '
'from project p '
'join customers c on c.CUSTOMER_ID = p.CUSTOMER_ID'
'join customers c on c.CUSTOMER_ID = p.CUSTOMER_ID'
'where
p.STATUS = '#39'ACTIVE'#39
'where
(:SCOPE = '#39'ALL'#39' or p.STATUS = '#39'ACTIVE'#39')'
'and (:CUSTOMER_ID = '#39#39' or p.CUSTOMER_ID = :CUSTOMER_ID)'
'and (:CUSTOMER_ID = '#39#39' or p.CUSTOMER_ID = :CUSTOMER_ID)'
'order by p.NAME'
'and (:SCOPE <> '#39'MY'#39' or p.PROJECT_ID in ('
''
' select up.PROJECT_ID from user_project up where up.USER_ID = :USER_ID))'
''
'and (:PROJECT_DATE = '#39#39' or ('
''
' (p.START_DATE is null or date(p.START_DATE) <= :PROJECT_DATE)'
''
' and (p.END_DATE is null or date(p.END_DATE) >= :PROJECT_DATE)))'
''
'order by'
''
' c.SHORT_NAME,'
' p.NAME'
'')
'')
Left = 544
Left = 544
Top = 494
Top = 494
...
@@ -1322,6 +1323,21 @@ object ApiDatabase: TApiDatabase
...
@@ -1322,6 +1323,21 @@ object ApiDatabase: TApiDatabase
DataType = ftUnknown
DataType = ftUnknown
Name = 'CUSTOMER_ID'
Name = 'CUSTOMER_ID'
Value = nil
Value = nil
end
item
DataType = ftUnknown
Name = 'SCOPE'
Value = nil
end
item
DataType = ftUnknown
Name = 'USER_ID'
Value = nil
end
item
DataType = ftUnknown
Name = 'PROJECT_DATE'
Value = nil
end>
end>
object uqTaskPickerProjectsPROJECT_ID: TStringField
object uqTaskPickerProjectsPROJECT_ID: TStringField
FieldName = 'PROJECT_ID'
FieldName = 'PROJECT_ID'
...
@@ -1336,6 +1352,11 @@ object ApiDatabase: TApiDatabase
...
@@ -1336,6 +1352,11 @@ object ApiDatabase: TApiDatabase
FieldName = 'CUSTOMER_ID'
FieldName = 'CUSTOMER_ID'
Size = 7
Size = 7
end
end
object uqTaskPickerProjectsCUSTOMER_SHORT_NAME: TStringField
FieldName = 'CUSTOMER_SHORT_NAME'
ReadOnly = True
Size = 30
end
end
end
object uqTaskPickerTasks: TUniQuery
object uqTaskPickerTasks: TUniQuery
Connection = ucETaskApi
Connection = ucETaskApi
...
...
emT3XDataServer/Source/Api.Database.pas
View file @
dd94c9fb
...
@@ -97,6 +97,7 @@ type
...
@@ -97,6 +97,7 @@ type
uqTaskPickerProjectsPROJECT_ID
:
TStringField
;
uqTaskPickerProjectsPROJECT_ID
:
TStringField
;
uqTaskPickerProjectsPROJECT_NAME
:
TStringField
;
uqTaskPickerProjectsPROJECT_NAME
:
TStringField
;
uqTaskPickerProjectsCUSTOMER_ID
:
TStringField
;
uqTaskPickerProjectsCUSTOMER_ID
:
TStringField
;
uqTaskPickerProjectsCUSTOMER_SHORT_NAME
:
TStringField
;
uqTaskPickerTasksTASK_ID
:
TStringField
;
uqTaskPickerTasksTASK_ID
:
TStringField
;
uqTaskPickerTasksCUSTOMER_NAME
:
TStringField
;
uqTaskPickerTasksCUSTOMER_NAME
:
TStringField
;
uqTaskPickerTasksPROJECT_NAME
:
TStringField
;
uqTaskPickerTasksPROJECT_NAME
:
TStringField
;
...
...
emT3XDataServer/Source/TaskItem.ServiceImpl.pas
View file @
dd94c9fb
...
@@ -226,24 +226,25 @@ var
...
@@ -226,24 +226,25 @@ var
begin
begin
Logger
.
Log
(
4
,
Format
(
'TaskItemService.AddTaskRow - TASK_ID="%s" INSERT_AFTER_ITEM_NUM="%d"'
,
[
taskId
,
insertAfterItemNum
]));
Logger
.
Log
(
4
,
Format
(
'TaskItemService.AddTaskRow - TASK_ID="%s" INSERT_AFTER_ITEM_NUM="%d"'
,
[
taskId
,
insertAfterItemNum
]));
apiDB
.
uqGetTaskMaxItemNum
.
Close
;
try
apiDB
.
uqGetTaskMaxItemNum
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqGetTaskMaxItemNum
.
Close
;
apiDB
.
uqGetTaskMaxItemNum
.
Open
;
apiDB
.
uqGetTaskMaxItemNum
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
maxItemNum
:=
apiDB
.
uqGetTaskMaxItemNum
.
FieldByName
(
'MAX_ITEM_NUM'
).
AsInteger
;
apiDB
.
uqGetTaskMaxItemNum
.
Open
;
maxItemNum
:=
apiDB
.
uqGetTaskMaxItemNum
.
FieldByName
(
'MAX_ITEM_NUM'
).
AsInteger
;
if
insertAfterItemNum
<
0
then
insertAfterItemNum
:=
0
;
if
insertAfterItemNum
<
0
then
if
insertAfterItemNum
>
maxItemNum
then
insertAfterItemNum
:=
0
;
insertAfterItemNum
:=
maxItemNum
;
if
insertAfterItemNum
>
maxItemNum
then
if
insertAfterItemNum
=
0
then
insertAfterItemNum
:=
maxItemNum
;
newItemNum
:=
maxItemNum
+
1
else
newItemNum
:=
insertAfterItemNum
+
1
;
if
insertAfterItemNum
=
0
then
apiDB
.
uqAddTaskRow
.
Connection
.
StartTransaction
;
newItemNum
:=
maxItemNum
+
1
else
newItemNum
:=
insertAfterItemNum
+
1
;
apiDB
.
uqAddTaskRow
.
Connection
.
StartTransaction
;
try
if
insertAfterItemNum
>
0
then
if
insertAfterItemNum
>
0
then
begin
begin
apiDB
.
uqShiftTaskRowsForInsert
.
Close
;
apiDB
.
uqShiftTaskRowsForInsert
.
Close
;
...
@@ -281,24 +282,22 @@ var
...
@@ -281,24 +282,22 @@ var
begin
begin
Logger
.
Log
(
4
,
Format
(
'TaskItemService.CopyTaskRow - TASK_ID="%s" SOURCE_TASK_ITEM_ID="%d"'
,
[
taskId
,
sourceTaskItemId
]));
Logger
.
Log
(
4
,
Format
(
'TaskItemService.CopyTaskRow - TASK_ID="%s" SOURCE_TASK_ITEM_ID="%d"'
,
[
taskId
,
sourceTaskItemId
]));
apiDB
.
uqGetTaskRowPosition
.
Close
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
sourceTaskItemId
;
apiDB
.
uqGetTaskRowPosition
.
Open
;
if
apiDB
.
uqGetTaskRowPosition
.
IsEmpty
then
begin
Logger
.
Log
(
2
,
Format
(
'TaskItemService.CopyTaskRow - row not found TASK_ID="%s" TASK_ITEM_ID="%d"'
,
[
taskId
,
sourceTaskItemId
]));
raise
Exception
.
Create
(
'Task row not found.'
);
end
;
sourceItemNum
:=
apiDB
.
uqGetTaskRowPositionITEM_NUM
.
AsInteger
;
q
:=
TUniQuery
.
Create
(
nil
);
q
:=
TUniQuery
.
Create
(
nil
);
try
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
:=
apiDB
.
ucETaskApi
;
apiDB
.
ucETaskApi
.
StartTransaction
;
try
try
apiDB
.
uqGetTaskRowPosition
.
Close
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
sourceTaskItemId
;
apiDB
.
uqGetTaskRowPosition
.
Open
;
if
apiDB
.
uqGetTaskRowPosition
.
IsEmpty
then
raise
Exception
.
Create
(
'Task row not found.'
);
sourceItemNum
:=
apiDB
.
uqGetTaskRowPositionITEM_NUM
.
AsInteger
;
apiDB
.
ucETaskApi
.
StartTransaction
;
apiDB
.
uqShiftTaskRowsForInsert
.
Close
;
apiDB
.
uqShiftTaskRowsForInsert
.
Close
;
apiDB
.
uqShiftTaskRowsForInsert
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqShiftTaskRowsForInsert
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqShiftTaskRowsForInsert
.
ParamByName
(
'INSERT_AFTER_ITEM_NUM'
).
AsInteger
:=
sourceItemNum
;
apiDB
.
uqShiftTaskRowsForInsert
.
ParamByName
(
'INSERT_AFTER_ITEM_NUM'
).
AsInteger
:=
sourceItemNum
;
...
@@ -345,46 +344,43 @@ begin
...
@@ -345,46 +344,43 @@ begin
' TASK_ITEM_ID='
+
IntToStr
(
taskItemId
)
+
' TASK_ITEM_ID='
+
IntToStr
(
taskItemId
)
+
' NEW_ITEM_NUM='
+
IntToStr
(
newItemNum
));
' NEW_ITEM_NUM='
+
IntToStr
(
newItemNum
));
apiDB
.
uqGetTaskRowPosition
.
Close
;
try
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqGetTaskRowPosition
.
Close
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqGetTaskRowPosition
.
Open
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqGetTaskRowPosition
.
Open
;
if
apiDB
.
uqGetTaskRowPosition
.
IsEmpty
then
if
apiDB
.
uqGetTaskRowPosition
.
IsEmpty
then
begin
raise
Exception
.
Create
(
'Task row not found.'
);
logger
.
log
(
2
,
'MoveTaskRow row not found TASK_ID='
+
IntToStr
(
taskId
)
+
' TASK_ITEM_ID='
+
IntToStr
(
taskItemId
));
raise
Exception
.
Create
(
'Task row not found.'
);
end
;
oldItemNum
:=
apiDB
.
uqGetTaskRowPositionITEM_NUM
.
AsInteger
;
oldItemNum
:=
apiDB
.
uqGetTaskRowPositionITEM_NUM
.
AsInteger
;
apiDB
.
uqGetTaskMaxItemNum
.
Close
;
apiDB
.
uqGetTaskMaxItemNum
.
Close
;
apiDB
.
uqGetTaskMaxItemNum
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqGetTaskMaxItemNum
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqGetTaskMaxItemNum
.
Open
;
apiDB
.
uqGetTaskMaxItemNum
.
Open
;
maxItemNum
:=
apiDB
.
uqGetTaskMaxItemNum
.
FieldByName
(
'MAX_ITEM_NUM'
).
AsInteger
;
maxItemNum
:=
apiDB
.
uqGetTaskMaxItemNum
.
FieldByName
(
'MAX_ITEM_NUM'
).
AsInteger
;
finalItemNum
:=
newItemNum
;
finalItemNum
:=
newItemNum
;
if
finalItemNum
<
1
then
if
finalItemNum
<
1
then
finalItemNum
:=
1
;
finalItemNum
:=
1
;
if
finalItemNum
>
maxItemNum
then
if
finalItemNum
>
maxItemNum
then
finalItemNum
:=
maxItemNum
;
finalItemNum
:=
maxItemNum
;
if
finalItemNum
=
oldItemNum
then
if
finalItemNum
=
oldItemNum
then
begin
begin
logger
.
log
(
4
,
'MoveTaskRow no move needed TASK_ID='
+
IntToStr
(
taskId
)
+
logger
.
log
(
4
,
'MoveTaskRow no move needed TASK_ID='
+
IntToStr
(
taskId
)
+
' TASK_ITEM_ID='
+
IntToStr
(
taskItemId
)
+
' TASK_ITEM_ID='
+
IntToStr
(
taskItemId
)
+
' ITEM_NUM='
+
IntToStr
(
oldItemNum
));
' ITEM_NUM='
+
IntToStr
(
oldItemNum
));
Exit
;
Exit
;
end
;
end
;
tempItemNum
:=
-
1
;
tempItemNum
:=
-
1
;
apiDB
.
uqGetTaskRowPosition
.
Connection
.
StartTransaction
;
apiDB
.
uqGetTaskRowPosition
.
Connection
.
StartTransaction
;
try
apiDB
.
uqMoveTaskRowTemp
.
ParamByName
(
'TEMP_ITEM_NUM'
).
AsInteger
:=
tempItemNum
;
apiDB
.
uqMoveTaskRowTemp
.
ParamByName
(
'TEMP_ITEM_NUM'
).
AsInteger
:=
tempItemNum
;
apiDB
.
uqMoveTaskRowTemp
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqMoveTaskRowTemp
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqMoveTaskRowTemp
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqMoveTaskRowTemp
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
...
@@ -496,47 +492,55 @@ var
...
@@ -496,47 +492,55 @@ var
end
;
end
;
begin
begin
Result
:=
False
;
try
Result
:=
False
;
if
not
Assigned
(
Item
)
then
if
not
Assigned
(
Item
)
then
raise
Exception
.
Create
(
'SaveTaskItemField: Item is nil.'
);
raise
Exception
.
Create
(
'SaveTaskItemField: Item is nil.'
);
if
Item
.
taskItemId
<=
0
then
if
Item
.
taskItemId
<=
0
then
raise
Exception
.
Create
(
'SaveTaskItemField: Invalid taskItemId.'
);
raise
Exception
.
Create
(
'SaveTaskItemField: Invalid taskItemId.'
);
columnName
:=
MapFieldNameToColumn
(
Item
.
fieldName
);
columnName
:=
MapFieldNameToColumn
(
Item
.
fieldName
);
if
columnName
=
''
then
if
columnName
=
''
then
raise
Exception
.
Create
(
'SaveTaskItemField: Invalid field name: '
+
Item
.
fieldName
);
raise
Exception
.
Create
(
'SaveTaskItemField: Invalid field name: '
+
Item
.
fieldName
);
uqSaveField
:=
TUniQuery
.
Create
(
nil
);
uqSaveField
:=
TUniQuery
.
Create
(
nil
);
try
try
uqSaveField
.
Connection
:=
apiDB
.
ucETaskApi
;
uqSaveField
.
Connection
:=
apiDB
.
ucETaskApi
;
uqSaveField
.
SQL
.
Text
:=
uqSaveField
.
SQL
.
Text
:=
'update task_items '
+
'update task_items '
+
'set '
+
columnName
+
' = :'
+
columnName
+
' '
+
'set '
+
columnName
+
' = :'
+
columnName
+
' '
+
'where TASK_ITEM_ID = :TASK_ITEM_ID'
;
'where TASK_ITEM_ID = :TASK_ITEM_ID'
;
uqSaveField
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
Item
.
taskItemId
;
uqSaveField
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
Item
.
taskItemId
;
if
IsDateField
(
Item
.
fieldName
)
then
if
IsDateField
(
Item
.
fieldName
)
then
begin
begin
if
ParseDateOrZero
(
Item
.
value
,
d
)
then
if
ParseDateOrZero
(
Item
.
value
,
d
)
then
uqSaveField
.
ParamByName
(
columnName
).
AsDateTime
:=
d
uqSaveField
.
ParamByName
(
columnName
).
AsDateTime
:=
d
else
uqSaveField
.
ParamByName
(
columnName
).
Clear
;
end
else
else
uqSaveField
.
ParamByName
(
columnName
).
Clear
;
begin
end
if
Trim
(
Item
.
value
)
=
''
then
else
uqSaveField
.
ParamByName
(
columnName
).
Clear
else
uqSaveField
.
ParamByName
(
columnName
).
AsString
:=
Item
.
value
;
end
;
uqSaveField
.
ExecSQL
;
Result
:=
True
;
finally
uqSaveField
.
Free
;
end
;
except
on
E
:
Exception
do
begin
begin
if
Trim
(
Item
.
value
)
=
''
then
Logger
.
Log
(
2
,
'TaskItemService.SaveTaskItemField - ERROR: '
+
E
.
Message
);
uqSaveField
.
ParamByName
(
columnName
).
Clear
raise
;
else
uqSaveField
.
ParamByName
(
columnName
).
AsString
:=
Item
.
value
;
end
;
end
;
uqSaveField
.
ExecSQL
;
Result
:=
True
;
finally
uqSaveField
.
Free
;
end
;
end
;
end
;
end
;
...
@@ -590,21 +594,19 @@ var
...
@@ -590,21 +594,19 @@ var
begin
begin
Logger
.
Log
(
4
,
Format
(
'TaskItemService.DeleteTaskRow - TASK_ID="%d" TASK_ITEM_ID="%d"'
,
[
taskId
,
taskItemId
]));
Logger
.
Log
(
4
,
Format
(
'TaskItemService.DeleteTaskRow - TASK_ID="%d" TASK_ITEM_ID="%d"'
,
[
taskId
,
taskItemId
]));
apiDB
.
uqGetTaskRowPosition
.
Close
;
try
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqGetTaskRowPosition
.
Close
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqGetTaskRowPosition
.
Open
;
apiDB
.
uqGetTaskRowPosition
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqGetTaskRowPosition
.
Open
;
if
apiDB
.
uqGetTaskRowPosition
.
IsEmpty
then
if
apiDB
.
uqGetTaskRowPosition
.
IsEmpty
then
begin
raise
Exception
.
Create
(
'Task row not found.'
);
Logger
.
Log
(
2
,
Format
(
'TaskItemService.DeleteTaskRow - row not found TASK_ID="%d" TASK_ITEM_ID="%d"'
,
[
taskId
,
taskItemId
]));
raise
Exception
.
Create
(
'Task row not found.'
);
end
;
oldItemNum
:=
apiDB
.
uqGetTaskRowPositionITEM_NUM
.
AsInteger
;
oldItemNum
:=
apiDB
.
uqGetTaskRowPositionITEM_NUM
.
AsInteger
;
apiDB
.
uqGetTaskRowPosition
.
Connection
.
StartTransaction
;
apiDB
.
uqGetTaskRowPosition
.
Connection
.
StartTransaction
;
try
apiDB
.
uqDeleteTaskRow
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqDeleteTaskRow
.
ParamByName
(
'TASK_ID'
).
AsInteger
:=
taskId
;
apiDB
.
uqDeleteTaskRow
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqDeleteTaskRow
.
ParamByName
(
'TASK_ITEM_ID'
).
AsInteger
:=
taskItemId
;
apiDB
.
uqDeleteTaskRow
.
ExecSQL
;
apiDB
.
uqDeleteTaskRow
.
ExecSQL
;
...
@@ -678,35 +680,43 @@ var
...
@@ -678,35 +680,43 @@ var
existingName
:
string
;
existingName
:
string
;
newGuid
:
TGuid
;
newGuid
:
TGuid
;
begin
begin
newName
:=
Trim
(
name
);
try
if
newName
=
''
then
newName
:=
Trim
(
name
);
raise
Exception
.
Create
(
'Assigned name cannot be blank.'
);
if
newName
=
''
then
raise
Exception
.
Create
(
'Assigned name cannot be blank.'
);
existingName
:=
FindAssignedOptionName
(
taskId
,
newName
);
existingName
:=
FindAssignedOptionName
(
taskId
,
newName
);
if
existingName
=
''
then
if
existingName
=
''
then
begin
begin
CreateGUID
(
newGuid
);
CreateGUID
(
newGuid
);
apiDB
.
uqAssignedInsert
.
Connection
.
StartTransaction
;
apiDB
.
uqAssignedInsert
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqAssignedInsert
.
Close
;
apiDB
.
uqAssignedInsert
.
Close
;
apiDB
.
uqAssignedInsert
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
GuidToString
(
newGuid
);
apiDB
.
uqAssignedInsert
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
GuidToString
(
newGuid
);
apiDB
.
uqAssignedInsert
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedInsert
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedInsert
.
ParamByName
(
'NAME'
).
AsString
:=
newName
;
apiDB
.
uqAssignedInsert
.
ParamByName
(
'NAME'
).
AsString
:=
newName
;
apiDB
.
uqAssignedInsert
.
ExecSQL
;
apiDB
.
uqAssignedInsert
.
ExecSQL
;
apiDB
.
uqAssignedInsert
.
Connection
.
Commit
;
apiDB
.
uqAssignedInsert
.
Connection
.
Commit
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqAssignedInsert
.
Connection
.
InTransaction
then
if
apiDB
.
uqAssignedInsert
.
Connection
.
InTransaction
then
apiDB
.
uqAssignedInsert
.
Connection
.
Rollback
;
apiDB
.
uqAssignedInsert
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
end
;
end
;
Result
:=
BuildAssignedOptionsResponse
(
taskId
);
Result
:=
BuildAssignedOptionsResponse
(
taskId
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TaskItemService.AddAssignedName - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
end
;
end
;
...
@@ -717,56 +727,64 @@ var
...
@@ -717,56 +727,64 @@ var
trimmedOldName
:
string
;
trimmedOldName
:
string
;
trimmedNewName
:
string
;
trimmedNewName
:
string
;
begin
begin
trimmedOldName
:=
Trim
(
oldName
);
try
trimmedNewName
:=
Trim
(
newName
);
trimmedOldName
:=
Trim
(
oldName
);
trimmedNewName
:=
Trim
(
newName
);
if
trimmedOldName
=
''
then
if
trimmedOldName
=
''
then
raise
Exception
.
Create
(
'Old assigned name cannot be blank.'
);
raise
Exception
.
Create
(
'Old assigned name cannot be blank.'
);
if
trimmedNewName
=
''
then
if
trimmedNewName
=
''
then
raise
Exception
.
Create
(
'New assigned name cannot be blank.'
);
raise
Exception
.
Create
(
'New assigned name cannot be blank.'
);
oldAssignedId
:=
FindAssignedOptionId
(
taskId
,
trimmedOldName
);
oldAssignedId
:=
FindAssignedOptionId
(
taskId
,
trimmedOldName
);
if
oldAssignedId
=
''
then
if
oldAssignedId
=
''
then
raise
Exception
.
Create
(
'Assigned name not found.'
);
raise
Exception
.
Create
(
'Assigned name not found.'
);
existingAssignedId
:=
FindAssignedOptionId
(
taskId
,
trimmedNewName
);
existingAssignedId
:=
FindAssignedOptionId
(
taskId
,
trimmedNewName
);
apiDB
.
uqAssignedRename
.
Connection
.
StartTransaction
;
apiDB
.
uqAssignedRename
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqRenameAssignedTo
.
Close
;
apiDB
.
uqRenameAssignedTo
.
Close
;
apiDB
.
uqRenameAssignedTo
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqRenameAssignedTo
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqRenameAssignedTo
.
ParamByName
(
'OLD_NAME'
).
AsString
:=
trimmedOldName
;
apiDB
.
uqRenameAssignedTo
.
ParamByName
(
'OLD_NAME'
).
AsString
:=
trimmedOldName
;
apiDB
.
uqRenameAssignedTo
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqRenameAssignedTo
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqRenameAssignedTo
.
ExecSQL
;
apiDB
.
uqRenameAssignedTo
.
ExecSQL
;
if
(
existingAssignedId
<>
''
)
and
(
not
SameText
(
existingAssignedId
,
oldAssignedId
))
then
if
(
existingAssignedId
<>
''
)
and
(
not
SameText
(
existingAssignedId
,
oldAssignedId
))
then
begin
begin
apiDB
.
uqAssignedDelete
.
Close
;
apiDB
.
uqAssignedDelete
.
Close
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldAssignedId
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldAssignedId
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedDelete
.
ExecSQL
;
apiDB
.
uqAssignedDelete
.
ExecSQL
;
end
end
else
else
begin
begin
apiDB
.
uqAssignedRename
.
Close
;
apiDB
.
uqAssignedRename
.
Close
;
apiDB
.
uqAssignedRename
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldAssignedId
;
apiDB
.
uqAssignedRename
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldAssignedId
;
apiDB
.
uqAssignedRename
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedRename
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedRename
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqAssignedRename
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqAssignedRename
.
ExecSQL
;
apiDB
.
uqAssignedRename
.
ExecSQL
;
end
;
apiDB
.
uqAssignedRename
.
Connection
.
Commit
;
except
on
E
:
Exception
do
begin
if
apiDB
.
uqAssignedRename
.
Connection
.
InTransaction
then
apiDB
.
uqAssignedRename
.
Connection
.
Rollback
;
raise
;
end
;
end
;
end
;
apiDB
.
uqAssignedRename
.
Connection
.
Commit
;
Result
:=
BuildAssignedOptionsResponse
(
taskId
)
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqAssignedRename
.
Connection
.
InTransaction
then
Logger
.
Log
(
2
,
'TaskItemService.RenameAssignedName - ERROR: '
+
E
.
Message
);
apiDB
.
uqAssignedRename
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
Result
:=
BuildAssignedOptionsResponse
(
taskId
);
end
;
end
;
...
@@ -775,35 +793,43 @@ var
...
@@ -775,35 +793,43 @@ var
assignedId
:
string
;
assignedId
:
string
;
assignedName
:
string
;
assignedName
:
string
;
begin
begin
assignedId
:=
FindAssignedOptionId
(
taskId
,
name
);
try
assignedName
:=
FindAssignedOptionName
(
taskId
,
name
);
assignedId
:=
FindAssignedOptionId
(
taskId
,
name
);
assignedName
:=
FindAssignedOptionName
(
taskId
,
name
);
if
assignedId
=
''
then
if
assignedId
=
''
then
raise
Exception
.
Create
(
'Assigned name not found.'
);
raise
Exception
.
Create
(
'Assigned name not found.'
);
apiDB
.
uqAssignedDelete
.
Connection
.
StartTransaction
;
apiDB
.
uqAssignedDelete
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqBlankAssignedTo
.
Close
;
apiDB
.
uqBlankAssignedTo
.
Close
;
apiDB
.
uqBlankAssignedTo
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqBlankAssignedTo
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqBlankAssignedTo
.
ParamByName
(
'NAME'
).
AsString
:=
assignedName
;
apiDB
.
uqBlankAssignedTo
.
ParamByName
(
'NAME'
).
AsString
:=
assignedName
;
apiDB
.
uqBlankAssignedTo
.
ExecSQL
;
apiDB
.
uqBlankAssignedTo
.
ExecSQL
;
apiDB
.
uqAssignedDelete
.
Close
;
apiDB
.
uqAssignedDelete
.
Close
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
assignedId
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
assignedId
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqAssignedDelete
.
ExecSQL
;
apiDB
.
uqAssignedDelete
.
ExecSQL
;
apiDB
.
uqAssignedDelete
.
Connection
.
Commit
;
except
on
E
:
Exception
do
begin
if
apiDB
.
uqAssignedDelete
.
Connection
.
InTransaction
then
apiDB
.
uqAssignedDelete
.
Connection
.
Rollback
;
raise
;
end
;
end
;
apiDB
.
uqAssignedDelete
.
Connection
.
Commit
;
Result
:=
BuildAssignedOptionsResponse
(
taskId
)
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqAssignedDelete
.
Connection
.
InTransaction
then
Logger
.
Log
(
2
,
'TaskItemService.DeleteAssignedName - ERROR: '
+
E
.
Message
);
apiDB
.
uqAssignedDelete
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
Result
:=
BuildAssignedOptionsResponse
(
taskId
);
end
;
end
;
...
@@ -916,36 +942,44 @@ var
...
@@ -916,36 +942,44 @@ var
newName
:
string
;
newName
:
string
;
existingName
:
string
;
existingName
:
string
;
begin
begin
newName
:=
Trim
(
name
);
try
if
newName
=
''
then
newName
:=
Trim
(
name
);
raise
Exception
.
Create
(
'Application name cannot be blank.'
);
if
newName
=
''
then
raise
Exception
.
Create
(
'Application name cannot be blank.'
);
projectId
:=
FindProjectId
(
taskId
);
projectId
:=
FindProjectId
(
taskId
);
if
projectId
=
''
then
if
projectId
=
''
then
raise
Exception
.
Create
(
'Project not found for task.'
);
raise
Exception
.
Create
(
'Project not found for task.'
);
existingName
:=
FindApplicationName
(
taskId
,
newName
);
existingName
:=
FindApplicationName
(
taskId
,
newName
);
if
existingName
=
''
then
if
existingName
=
''
then
begin
begin
apiDB
.
uqApplicationInsert
.
Connection
.
StartTransaction
;
apiDB
.
uqApplicationInsert
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqApplicationInsert
.
Close
;
apiDB
.
uqApplicationInsert
.
Close
;
apiDB
.
uqApplicationInsert
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationInsert
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationInsert
.
ParamByName
(
'NAME'
).
AsString
:=
newName
;
apiDB
.
uqApplicationInsert
.
ParamByName
(
'NAME'
).
AsString
:=
newName
;
apiDB
.
uqApplicationInsert
.
ExecSQL
;
apiDB
.
uqApplicationInsert
.
ExecSQL
;
apiDB
.
uqApplicationInsert
.
Connection
.
Commit
;
apiDB
.
uqApplicationInsert
.
Connection
.
Commit
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqApplicationInsert
.
Connection
.
InTransaction
then
if
apiDB
.
uqApplicationInsert
.
Connection
.
InTransaction
then
apiDB
.
uqApplicationInsert
.
Connection
.
Rollback
;
apiDB
.
uqApplicationInsert
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
end
;
end
;
Result
:=
BuildApplicationOptionsResponse
(
taskId
);
Result
:=
BuildApplicationOptionsResponse
(
taskId
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TaskItemService.AddApplicationName - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
end
;
end
;
...
@@ -957,60 +991,68 @@ var
...
@@ -957,60 +991,68 @@ var
trimmedOldName
:
string
;
trimmedOldName
:
string
;
trimmedNewName
:
string
;
trimmedNewName
:
string
;
begin
begin
trimmedOldName
:=
Trim
(
oldName
);
try
trimmedNewName
:=
Trim
(
newName
);
trimmedOldName
:=
Trim
(
oldName
);
trimmedNewName
:=
Trim
(
newName
);
if
trimmedOldName
=
''
then
if
trimmedOldName
=
''
then
raise
Exception
.
Create
(
'Old application name cannot be blank.'
);
raise
Exception
.
Create
(
'Old application name cannot be blank.'
);
if
trimmedNewName
=
''
then
if
trimmedNewName
=
''
then
raise
Exception
.
Create
(
'New application name cannot be blank.'
);
raise
Exception
.
Create
(
'New application name cannot be blank.'
);
projectId
:=
FindProjectId
(
taskId
);
projectId
:=
FindProjectId
(
taskId
);
if
projectId
=
''
then
if
projectId
=
''
then
raise
Exception
.
Create
(
'Project not found for task.'
);
raise
Exception
.
Create
(
'Project not found for task.'
);
oldApplicationId
:=
FindApplicationId
(
taskId
,
trimmedOldName
);
oldApplicationId
:=
FindApplicationId
(
taskId
,
trimmedOldName
);
if
oldApplicationId
=
0
then
if
oldApplicationId
=
0
then
raise
Exception
.
Create
(
'Application name not found.'
);
raise
Exception
.
Create
(
'Application name not found.'
);
existingApplicationId
:=
FindApplicationId
(
taskId
,
trimmedNewName
);
existingApplicationId
:=
FindApplicationId
(
taskId
,
trimmedNewName
);
apiDB
.
uqApplicationRename
.
Connection
.
StartTransaction
;
apiDB
.
uqApplicationRename
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqRenameTaskItemApplication
.
Close
;
apiDB
.
uqRenameTaskItemApplication
.
Close
;
apiDB
.
uqRenameTaskItemApplication
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqRenameTaskItemApplication
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqRenameTaskItemApplication
.
ParamByName
(
'OLD_NAME'
).
AsString
:=
trimmedOldName
;
apiDB
.
uqRenameTaskItemApplication
.
ParamByName
(
'OLD_NAME'
).
AsString
:=
trimmedOldName
;
apiDB
.
uqRenameTaskItemApplication
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqRenameTaskItemApplication
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqRenameTaskItemApplication
.
ExecSQL
;
apiDB
.
uqRenameTaskItemApplication
.
ExecSQL
;
if
(
existingApplicationId
<>
0
)
and
(
existingApplicationId
<>
oldApplicationId
)
then
if
(
existingApplicationId
<>
0
)
and
(
existingApplicationId
<>
oldApplicationId
)
then
begin
begin
apiDB
.
uqApplicationDelete
.
Close
;
apiDB
.
uqApplicationDelete
.
Close
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'TASK_ITEM_APPLICATION_ID'
).
AsInteger
:=
oldApplicationId
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'TASK_ITEM_APPLICATION_ID'
).
AsInteger
:=
oldApplicationId
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationDelete
.
ExecSQL
;
apiDB
.
uqApplicationDelete
.
ExecSQL
;
end
end
else
else
begin
begin
apiDB
.
uqApplicationRename
.
Close
;
apiDB
.
uqApplicationRename
.
Close
;
apiDB
.
uqApplicationRename
.
ParamByName
(
'TASK_ITEM_APPLICATION_ID'
).
AsInteger
:=
oldApplicationId
;
apiDB
.
uqApplicationRename
.
ParamByName
(
'TASK_ITEM_APPLICATION_ID'
).
AsInteger
:=
oldApplicationId
;
apiDB
.
uqApplicationRename
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationRename
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationRename
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqApplicationRename
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqApplicationRename
.
ExecSQL
;
apiDB
.
uqApplicationRename
.
ExecSQL
;
end
;
apiDB
.
uqApplicationRename
.
Connection
.
Commit
;
except
on
E
:
Exception
do
begin
if
apiDB
.
uqApplicationRename
.
Connection
.
InTransaction
then
apiDB
.
uqApplicationRename
.
Connection
.
Rollback
;
raise
;
end
;
end
;
end
;
apiDB
.
uqApplicationRename
.
Connection
.
Commit
;
Result
:=
BuildApplicationOptionsResponse
(
taskId
)
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqApplicationRename
.
Connection
.
InTransaction
then
Logger
.
Log
(
2
,
'TaskItemService.RenameApplicationName - ERROR: '
+
E
.
Message
);
apiDB
.
uqApplicationRename
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
Result
:=
BuildApplicationOptionsResponse
(
taskId
);
end
;
end
;
...
@@ -1020,39 +1062,47 @@ var
...
@@ -1020,39 +1062,47 @@ var
applicationId
:
Integer
;
applicationId
:
Integer
;
applicationName
:
string
;
applicationName
:
string
;
begin
begin
projectId
:=
FindProjectId
(
taskId
);
try
if
projectId
=
''
then
projectId
:=
FindProjectId
(
taskId
);
raise
Exception
.
Create
(
'Project not found for task.'
);
if
projectId
=
''
then
raise
Exception
.
Create
(
'Project not found for task.'
);
applicationId
:=
FindApplicationId
(
taskId
,
name
);
applicationId
:=
FindApplicationId
(
taskId
,
name
);
applicationName
:=
FindApplicationName
(
taskId
,
name
);
applicationName
:=
FindApplicationName
(
taskId
,
name
);
if
applicationId
=
0
then
if
applicationId
=
0
then
raise
Exception
.
Create
(
'Application name not found.'
);
raise
Exception
.
Create
(
'Application name not found.'
);
apiDB
.
uqApplicationDelete
.
Connection
.
StartTransaction
;
apiDB
.
uqApplicationDelete
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqBlankTaskItemApplication
.
Close
;
apiDB
.
uqBlankTaskItemApplication
.
Close
;
apiDB
.
uqBlankTaskItemApplication
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqBlankTaskItemApplication
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqBlankTaskItemApplication
.
ParamByName
(
'NAME'
).
AsString
:=
applicationName
;
apiDB
.
uqBlankTaskItemApplication
.
ParamByName
(
'NAME'
).
AsString
:=
applicationName
;
apiDB
.
uqBlankTaskItemApplication
.
ExecSQL
;
apiDB
.
uqBlankTaskItemApplication
.
ExecSQL
;
apiDB
.
uqApplicationDelete
.
Close
;
apiDB
.
uqApplicationDelete
.
Close
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'TASK_ITEM_APPLICATION_ID'
).
AsInteger
:=
applicationId
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'TASK_ITEM_APPLICATION_ID'
).
AsInteger
:=
applicationId
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationDelete
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqApplicationDelete
.
ExecSQL
;
apiDB
.
uqApplicationDelete
.
ExecSQL
;
apiDB
.
uqApplicationDelete
.
Connection
.
Commit
;
except
on
E
:
Exception
do
begin
if
apiDB
.
uqApplicationDelete
.
Connection
.
InTransaction
then
apiDB
.
uqApplicationDelete
.
Connection
.
Rollback
;
raise
;
end
;
end
;
apiDB
.
uqApplicationDelete
.
Connection
.
Commit
;
Result
:=
BuildApplicationOptionsResponse
(
taskId
)
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqApplicationDelete
.
Connection
.
InTransaction
then
Logger
.
Log
(
2
,
'TaskItemService.DeleteApplicationName - ERROR: '
+
E
.
Message
);
apiDB
.
uqApplicationDelete
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
Result
:=
BuildApplicationOptionsResponse
(
taskId
);
end
;
end
;
...
@@ -1128,35 +1178,43 @@ var
...
@@ -1128,35 +1178,43 @@ var
existingName
:
string
;
existingName
:
string
;
newGuid
:
TGuid
;
newGuid
:
TGuid
;
begin
begin
newName
:=
Trim
(
name
);
try
if
newName
=
''
then
newName
:=
Trim
(
name
);
raise
Exception
.
Create
(
'Reported name cannot be blank.'
);
if
newName
=
''
then
raise
Exception
.
Create
(
'Reported name cannot be blank.'
);
existingName
:=
FindReportedOptionName
(
taskId
,
newName
);
existingName
:=
FindReportedOptionName
(
taskId
,
newName
);
if
existingName
=
''
then
if
existingName
=
''
then
begin
begin
CreateGUID
(
newGuid
);
CreateGUID
(
newGuid
);
apiDB
.
uqReportedInsert
.
Connection
.
StartTransaction
;
apiDB
.
uqReportedInsert
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqReportedInsert
.
Close
;
apiDB
.
uqReportedInsert
.
Close
;
apiDB
.
uqReportedInsert
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
GuidToString
(
newGuid
);
apiDB
.
uqReportedInsert
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
GuidToString
(
newGuid
);
apiDB
.
uqReportedInsert
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedInsert
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedInsert
.
ParamByName
(
'NAME'
).
AsString
:=
newName
;
apiDB
.
uqReportedInsert
.
ParamByName
(
'NAME'
).
AsString
:=
newName
;
apiDB
.
uqReportedInsert
.
ExecSQL
;
apiDB
.
uqReportedInsert
.
ExecSQL
;
apiDB
.
uqReportedInsert
.
Connection
.
Commit
;
apiDB
.
uqReportedInsert
.
Connection
.
Commit
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqReportedInsert
.
Connection
.
InTransaction
then
if
apiDB
.
uqReportedInsert
.
Connection
.
InTransaction
then
apiDB
.
uqReportedInsert
.
Connection
.
Rollback
;
apiDB
.
uqReportedInsert
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
end
;
end
;
Result
:=
BuildReportedOptionsResponse
(
taskId
);
Result
:=
BuildReportedOptionsResponse
(
taskId
);
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TaskItemService.AddReportedName - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
end
;
end
;
...
@@ -1167,56 +1225,64 @@ var
...
@@ -1167,56 +1225,64 @@ var
trimmedOldName
:
string
;
trimmedOldName
:
string
;
trimmedNewName
:
string
;
trimmedNewName
:
string
;
begin
begin
trimmedOldName
:=
Trim
(
oldName
);
try
trimmedNewName
:=
Trim
(
newName
);
trimmedOldName
:=
Trim
(
oldName
);
trimmedNewName
:=
Trim
(
newName
);
if
trimmedOldName
=
''
then
if
trimmedOldName
=
''
then
raise
Exception
.
Create
(
'Old reported name cannot be blank.'
);
raise
Exception
.
Create
(
'Old reported name cannot be blank.'
);
if
trimmedNewName
=
''
then
if
trimmedNewName
=
''
then
raise
Exception
.
Create
(
'New reported name cannot be blank.'
);
raise
Exception
.
Create
(
'New reported name cannot be blank.'
);
oldReportedId
:=
FindReportedOptionId
(
taskId
,
trimmedOldName
);
oldReportedId
:=
FindReportedOptionId
(
taskId
,
trimmedOldName
);
if
oldReportedId
=
''
then
if
oldReportedId
=
''
then
raise
Exception
.
Create
(
'Reported name not found.'
);
raise
Exception
.
Create
(
'Reported name not found.'
);
existingReportedId
:=
FindReportedOptionId
(
taskId
,
trimmedNewName
);
existingReportedId
:=
FindReportedOptionId
(
taskId
,
trimmedNewName
);
apiDB
.
uqReportedRename
.
Connection
.
StartTransaction
;
apiDB
.
uqReportedRename
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqRenameTaskItemReportedBy
.
Close
;
apiDB
.
uqRenameTaskItemReportedBy
.
Close
;
apiDB
.
uqRenameTaskItemReportedBy
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqRenameTaskItemReportedBy
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqRenameTaskItemReportedBy
.
ParamByName
(
'OLD_NAME'
).
AsString
:=
trimmedOldName
;
apiDB
.
uqRenameTaskItemReportedBy
.
ParamByName
(
'OLD_NAME'
).
AsString
:=
trimmedOldName
;
apiDB
.
uqRenameTaskItemReportedBy
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqRenameTaskItemReportedBy
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqRenameTaskItemReportedBy
.
ExecSQL
;
apiDB
.
uqRenameTaskItemReportedBy
.
ExecSQL
;
if
(
existingReportedId
<>
''
)
and
(
not
SameText
(
existingReportedId
,
oldReportedId
))
then
if
(
existingReportedId
<>
''
)
and
(
not
SameText
(
existingReportedId
,
oldReportedId
))
then
begin
begin
apiDB
.
uqReportedDelete
.
Close
;
apiDB
.
uqReportedDelete
.
Close
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldReportedId
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldReportedId
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedDelete
.
ExecSQL
;
apiDB
.
uqReportedDelete
.
ExecSQL
;
end
end
else
else
begin
begin
apiDB
.
uqReportedRename
.
Close
;
apiDB
.
uqReportedRename
.
Close
;
apiDB
.
uqReportedRename
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldReportedId
;
apiDB
.
uqReportedRename
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
oldReportedId
;
apiDB
.
uqReportedRename
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedRename
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedRename
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqReportedRename
.
ParamByName
(
'NEW_NAME'
).
AsString
:=
trimmedNewName
;
apiDB
.
uqReportedRename
.
ExecSQL
;
apiDB
.
uqReportedRename
.
ExecSQL
;
end
;
apiDB
.
uqReportedRename
.
Connection
.
Commit
;
except
on
E
:
Exception
do
begin
if
apiDB
.
uqReportedRename
.
Connection
.
InTransaction
then
apiDB
.
uqReportedRename
.
Connection
.
Rollback
;
raise
;
end
;
end
;
end
;
apiDB
.
uqReportedRename
.
Connection
.
Commit
;
Result
:=
BuildReportedOptionsResponse
(
taskId
)
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqReportedRename
.
Connection
.
InTransaction
then
Logger
.
Log
(
2
,
'TaskItemService.RenameReportedName - ERROR: '
+
E
.
Message
);
apiDB
.
uqReportedRename
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
Result
:=
BuildReportedOptionsResponse
(
taskId
);
end
;
end
;
...
@@ -1225,35 +1291,43 @@ var
...
@@ -1225,35 +1291,43 @@ var
reportedId
:
string
;
reportedId
:
string
;
reportedName
:
string
;
reportedName
:
string
;
begin
begin
reportedId
:=
FindReportedOptionId
(
taskId
,
name
);
try
reportedName
:=
FindReportedOptionName
(
taskId
,
name
);
reportedId
:=
FindReportedOptionId
(
taskId
,
name
);
reportedName
:=
FindReportedOptionName
(
taskId
,
name
);
if
reportedId
=
''
then
if
reportedId
=
''
then
raise
Exception
.
Create
(
'Reported name not found.'
);
raise
Exception
.
Create
(
'Reported name not found.'
);
apiDB
.
uqReportedDelete
.
Connection
.
StartTransaction
;
apiDB
.
uqReportedDelete
.
Connection
.
StartTransaction
;
try
try
apiDB
.
uqBlankTaskItemReportedBy
.
Close
;
apiDB
.
uqBlankTaskItemReportedBy
.
Close
;
apiDB
.
uqBlankTaskItemReportedBy
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqBlankTaskItemReportedBy
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqBlankTaskItemReportedBy
.
ParamByName
(
'NAME'
).
AsString
:=
reportedName
;
apiDB
.
uqBlankTaskItemReportedBy
.
ParamByName
(
'NAME'
).
AsString
:=
reportedName
;
apiDB
.
uqBlankTaskItemReportedBy
.
ExecSQL
;
apiDB
.
uqBlankTaskItemReportedBy
.
ExecSQL
;
apiDB
.
uqReportedDelete
.
Close
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
reportedId
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
apiDB
.
uqReportedDelete
.
ExecSQL
;
apiDB
.
uqReportedDelete
.
Close
;
apiDB
.
uqReportedDelete
.
Connection
.
Commit
;
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ITEM_USER_ID'
).
AsString
:=
reportedId
;
except
apiDB
.
uqReportedDelete
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
on
E
:
Exception
do
apiDB
.
uqReportedDelete
.
ExecSQL
;
begin
if
apiDB
.
uqReportedDelete
.
Connection
.
InTransaction
then
apiDB
.
uqReportedDelete
.
Connection
.
Rollback
;
raise
;
end
;
end
;
apiDB
.
uqReportedDelete
.
Connection
.
Commit
;
Result
:=
BuildReportedOptionsResponse
(
taskId
)
;
except
except
on
E
:
Exception
do
on
E
:
Exception
do
begin
begin
if
apiDB
.
uqReportedDelete
.
Connection
.
InTransaction
then
Logger
.
Log
(
2
,
'TaskItemService.DeleteReportedName - ERROR: '
+
E
.
Message
);
apiDB
.
uqReportedDelete
.
Connection
.
Rollback
;
raise
;
raise
;
end
;
end
;
end
;
end
;
Result
:=
BuildReportedOptionsResponse
(
taskId
);
end
;
end
;
initialization
initialization
...
...
emT3XDataServer/Source/TimeEntry.Service.pas
View file @
dd94c9fb
...
@@ -31,6 +31,8 @@ type
...
@@ -31,6 +31,8 @@ type
public
public
taskId
:
string
;
taskId
:
string
;
taskDisplay
:
string
;
taskDisplay
:
string
;
startDate
:
string
;
// yyyy-mm-dd, '' = no lower limit
completionDate
:
string
;
// yyyy-mm-dd, '' = still open
end
;
end
;
TTimeEntryCategoryOption
=
class
TTimeEntryCategoryOption
=
class
...
@@ -42,6 +44,8 @@ type
...
@@ -42,6 +44,8 @@ type
TTimeEntriesResponse
=
class
TTimeEntriesResponse
=
class
public
public
userName
:
string
;
userName
:
string
;
userStartDate
:
string
;
// yyyy-mm-dd employment window, '' = open-ended
userEndDate
:
string
;
count
:
Integer
;
count
:
Integer
;
items
:
TList
<
TTimeEntry
>;
items
:
TList
<
TTimeEntry
>;
taskOptions
:
TList
<
TTimeEntryTaskOption
>;
taskOptions
:
TList
<
TTimeEntryTaskOption
>;
...
@@ -64,20 +68,14 @@ type
...
@@ -64,20 +68,14 @@ type
summary
:
string
;
summary
:
string
;
end
;
end
;
TTimeEntryFieldSave
=
class
public
entryId
:
Integer
;
userId
:
string
;
fieldName
:
string
;
value
:
string
;
end
;
TTaskPickerOption
=
class
TTaskPickerOption
=
class
public
public
value
:
string
;
value
:
string
;
display
:
string
;
display
:
string
;
customerId
:
string
;
customerId
:
string
;
completed
:
Boolean
;
// tasks only: COMPLETION_DATE is set
unavailableReason
:
string
;
// tasks only: why hours can't go on the picker date, '' = allowed
status
:
string
;
// tasks only: task status code
end
;
end
;
TTaskPickerOptionsResponse
=
class
TTaskPickerOptionsResponse
=
class
...
@@ -97,16 +95,17 @@ type
...
@@ -97,16 +95,17 @@ type
[
ServiceContract
,
Model
(
API_MODEL
)]
[
ServiceContract
,
Model
(
API_MODEL
)]
ITimeEntryService
=
interface
(
IInvokable
)
ITimeEntryService
=
interface
(
IInvokable
)
[
'{B18BCD1E-B19A-4D25-BBA9-50A24FC4C690}'
]
[
'{B18BCD1E-B19A-4D25-BBA9-50A24FC4C690}'
]
[
HttpGet
]
function
GetTimeEntries
(
userId
,
startDate
,
endDate
:
string
):
TTimeEntriesResponse
;
[
HttpGet
]
function
GetTimeEntries
(
userId
,
startDate
,
endDate
,
keptEntryIds
:
string
):
TTimeEntriesResponse
;
[
HttpPost
]
function
AddTimeEntry
(
userId
,
taskDate
:
string
):
string
;
[
HttpPost
]
function
AddTimeEntry
(
userId
,
taskDate
:
string
):
string
;
[
HttpPost
]
function
SaveTimeEntry
(
Item
:
TTimeEntrySave
):
string
;
[
HttpPost
]
function
SaveTimeEntry
(
Item
:
TTimeEntrySave
):
string
;
[
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
;
[
HttpPost
]
function
RemoveTaskFromFocus
(
userId
,
taskId
:
string
):
Boolean
;
[
HttpPost
]
function
SetTaskStatus
(
taskId
,
status
,
taskDate
:
string
):
Boolean
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerStatuses
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
,
scope
,
userId
,
taskDate
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
,
userId
,
taskDate
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTaskContext
(
taskId
:
string
):
TTaskPickerTaskContext
;
function
GetTaskPickerTaskContext
(
taskId
:
string
):
TTaskPickerTaskContext
;
end
;
end
;
...
...
emT3XDataServer/Source/TimeEntry.ServiceImpl.pas
View file @
dd94c9fb
...
@@ -20,27 +20,30 @@ type
...
@@ -20,27 +20,30 @@ type
function
ParseIsoDate
(
value
:
string
):
TDateTime
;
function
ParseIsoDate
(
value
:
string
):
TDateTime
;
function
FieldText
(
AQuery
:
TUniQuery
;
AFieldName
:
string
):
string
;
function
FieldText
(
AQuery
:
TUniQuery
;
AFieldName
:
string
):
string
;
function
DateText
(
AQuery
:
TUniQuery
;
AFieldName
:
string
):
string
;
procedure
CheckTimeEntryDate
(
userId
,
taskId
:
string
;
taskDate
:
TDateTime
);
function
BuildTaskNumber
(
AQuery
:
TUniQuery
):
string
;
function
BuildTaskNumber
(
AQuery
:
TUniQuery
):
string
;
function
BuildTaskDisplay
(
AQuery
:
TUniQuery
):
string
;
function
BuildTaskDisplay
(
AQuery
:
TUniQuery
):
string
;
procedure
LoadUserName
(
AResponse
:
TTimeEntriesResponse
;
userId
:
string
);
procedure
LoadUserName
(
AResponse
:
TTimeEntriesResponse
;
userId
:
string
);
procedure
LoadTimeEntryItems
(
AResponse
:
TTimeEntriesResponse
;
userId
:
string
;
startDateValue
,
exclusiveEndDateValue
:
TDateTime
);
procedure
LoadTimeEntryItems
(
AResponse
:
TTimeEntriesResponse
;
userId
,
keptEntryIds
:
string
;
startDateValue
,
exclusiveEndDateValue
:
TDateTime
);
procedure
LoadTaskOptions
(
AResponse
:
TTimeEntriesResponse
;
userId
:
string
;
startDateValue
,
exclusiveEndDateValue
:
TDateTime
);
procedure
LoadTaskOptions
(
AResponse
:
TTimeEntriesResponse
;
userId
:
string
;
startDateValue
,
exclusiveEndDateValue
:
TDateTime
);
procedure
LoadPlaceOptions
(
AResponse
:
TTimeEntriesResponse
);
procedure
LoadPlaceOptions
(
AResponse
:
TTimeEntriesResponse
);
procedure
LoadCategoryOptions
(
AResponse
:
TTimeEntriesResponse
);
procedure
LoadCategoryOptions
(
AResponse
:
TTimeEntriesResponse
);
function
GetNextIdValue
(
const
AKeyName
:
string
):
string
;
function
GetNextIdValue
(
const
AKeyName
:
string
):
string
;
public
public
function
GetTimeEntries
(
userId
,
startDate
,
endDate
:
string
):
TTimeEntriesResponse
;
function
GetTimeEntries
(
userId
,
startDate
,
endDate
,
keptEntryIds
:
string
):
TTimeEntriesResponse
;
function
AddTimeEntry
(
userId
,
taskDate
:
string
):
string
;
function
AddTimeEntry
(
userId
,
taskDate
:
string
):
string
;
function
SaveTimeEntry
(
Item
:
TTimeEntrySave
):
string
;
function
SaveTimeEntry
(
Item
:
TTimeEntrySave
):
string
;
function
SaveTimeEntryField
(
Item
:
TTimeEntryFieldSave
):
Boolean
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerStatuses
:
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerProjects
(
customerId
,
scope
,
userId
,
taskDate
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTasks
(
projectId
,
userId
,
taskDate
:
string
):
TTaskPickerOptionsResponse
;
function
GetTaskPickerTaskContext
(
taskId
:
string
):
TTaskPickerTaskContext
;
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
;
function
RemoveTaskFromFocus
(
userId
,
taskId
:
string
):
Boolean
;
function
SetTaskStatus
(
taskId
,
status
,
taskDate
:
string
):
Boolean
;
end
;
end
;
implementation
implementation
...
@@ -88,6 +91,101 @@ begin
...
@@ -88,6 +91,101 @@ begin
end
;
end
;
// Date (or datetime) column as 'yyyy-mm-dd'; '' when null
function
TTimeEntryService
.
DateText
(
AQuery
:
TUniQuery
;
AFieldName
:
string
):
string
;
begin
if
AQuery
.
FieldByName
(
AFieldName
).
IsNull
then
Result
:=
''
else
Result
:=
FormatDateTime
(
'yyyy-mm-dd'
,
AQuery
.
FieldByName
(
AFieldName
).
AsDateTime
);
end
;
// Hours may only be entered on a date that is not in the future (server's
// today) and is inside both the user's employment window and the task's
// window. All values are 'yyyy-mm-dd'; '' is open-ended and all ends are
// inclusive. The task's upper bound is its actual COMPLETION_DATE (DUE_DATE is
// ignored). Returns '' when ADate is '' or allowed, otherwise the message to
// show. Shared by SaveTimeEntry, AddTimeEntry and the task picker.
function
TimeEntryDateProblem
(
const
ADate
,
AUserStart
,
AUserEnd
,
ATaskStart
,
ATaskEnd
:
string
):
string
;
begin
Result
:=
''
;
if
ADate
=
''
then
Exit
;
// ISO date strings compare in date order
if
ADate
>
FormatDateTime
(
'yyyy-mm-dd'
,
Date
)
then
Exit
(
Format
(
'Hours can''t be entered on %s because it is a future date.'
,
[
ADate
]));
if
((
AUserStart
<>
''
)
and
(
ADate
<
AUserStart
))
or
((
AUserEnd
<>
''
)
and
(
ADate
>
AUserEnd
))
then
Exit
(
Format
(
'Hours can''t be entered on %s because it is outside your employment dates.'
,
[
ADate
]));
if
(
ATaskStart
<>
''
)
and
(
ADate
<
ATaskStart
)
then
Exit
(
Format
(
'This task starts on %s, so hours can''t be entered on %s.'
,
[
ATaskStart
,
ADate
]));
if
(
ATaskEnd
<>
''
)
and
(
ADate
>
ATaskEnd
)
then
Exit
(
Format
(
'This task was completed on %s, so hours can''t be entered on %s.'
,
[
ATaskEnd
,
ADate
]));
end
;
procedure
TTimeEntryService
.
CheckTimeEntryDate
(
userId
,
taskId
:
string
;
taskDate
:
TDateTime
);
var
q
:
TUniQuery
;
dateValue
:
string
;
userStart
:
string
;
userEnd
:
string
;
problem
:
string
;
begin
dateValue
:=
FormatDateTime
(
'yyyy-mm-dd'
,
taskDate
);
q
:=
TUniQuery
.
Create
(
nil
);
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
SQL
.
Text
:=
'select START_DATE, END_DATE from users where USER_ID = :USER_ID'
;
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
q
.
Open
;
if
q
.
IsEmpty
then
raise
Exception
.
Create
(
'User not found.'
);
userStart
:=
DateText
(
q
,
'START_DATE'
);
userEnd
:=
DateText
(
q
,
'END_DATE'
);
// Future and employment dates are checked before the task lookup
problem
:=
TimeEntryDateProblem
(
dateValue
,
userStart
,
userEnd
,
''
,
''
);
if
problem
<>
''
then
raise
Exception
.
Create
(
problem
);
q
.
Close
;
q
.
SQL
.
Text
:=
'select START_DATE, COMPLETION_DATE from tasks where TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
q
.
Open
;
if
q
.
IsEmpty
then
raise
Exception
.
Create
(
'Task not found.'
);
problem
:=
TimeEntryDateProblem
(
dateValue
,
userStart
,
userEnd
,
DateText
(
q
,
'START_DATE'
),
DateText
(
q
,
'COMPLETION_DATE'
));
if
problem
<>
''
then
raise
Exception
.
Create
(
problem
);
finally
q
.
Free
;
end
;
end
;
function
TTimeEntryService
.
BuildTaskNumber
(
AQuery
:
TUniQuery
):
string
;
function
TTimeEntryService
.
BuildTaskNumber
(
AQuery
:
TUniQuery
):
string
;
procedure
AddPart
(
AValue
:
string
);
procedure
AddPart
(
AValue
:
string
);
...
@@ -180,7 +278,7 @@ begin
...
@@ -180,7 +278,7 @@ begin
try
try
userQuery
.
Connection
:=
apiDB
.
ucETaskApi
;
userQuery
.
Connection
:=
apiDB
.
ucETaskApi
;
userQuery
.
SQL
.
Text
:=
userQuery
.
SQL
.
Text
:=
'select USER_ID, NAME, USER_NAME '
+
'select USER_ID, NAME, USER_NAME
, START_DATE, END_DATE
'
+
'from users '
+
'from users '
+
'where USER_ID = :USER_ID'
;
'where USER_ID = :USER_ID'
;
...
@@ -190,17 +288,40 @@ begin
...
@@ -190,17 +288,40 @@ begin
AResponse
.
userName
:=
FieldText
(
userQuery
,
'NAME'
);
AResponse
.
userName
:=
FieldText
(
userQuery
,
'NAME'
);
if
AResponse
.
userName
=
''
then
if
AResponse
.
userName
=
''
then
AResponse
.
userName
:=
FieldText
(
userQuery
,
'USER_NAME'
);
AResponse
.
userName
:=
FieldText
(
userQuery
,
'USER_NAME'
);
AResponse
.
userStartDate
:=
DateText
(
userQuery
,
'START_DATE'
);
AResponse
.
userEndDate
:=
DateText
(
userQuery
,
'END_DATE'
);
finally
finally
userQuery
.
Free
;
userQuery
.
Free
;
end
;
end
;
end
;
end
;
procedure
TTimeEntryService
.
LoadTimeEntryItems
(
AResponse
:
TTimeEntriesResponse
;
userId
:
string
;
startDateValue
,
exclusiveEndDateValue
:
TDateTime
);
procedure
TTimeEntryService
.
LoadTimeEntryItems
(
AResponse
:
TTimeEntriesResponse
;
userId
,
keptEntryIds
:
string
;
startDateValue
,
exclusiveEndDateValue
:
TDateTime
);
var
var
itemsQuery
:
TUniQuery
;
itemsQuery
:
TUniQuery
;
item
:
TTimeEntry
;
item
:
TTimeEntry
;
keptFilter
:
string
;
idText
:
string
;
idValue
:
Integer
;
begin
begin
// Entries the client saved outside the range stay in the grid until the range changes.
// Only whole numbers go into the IN list.
keptFilter
:=
''
;
for
idText
in
keptEntryIds
.
Split
([
','
])
do
begin
idValue
:=
StrToIntDef
(
Trim
(
idText
),
0
);
if
idValue
>
0
then
begin
if
keptFilter
<>
''
then
keptFilter
:=
keptFilter
+
','
;
keptFilter
:=
keptFilter
+
IntToStr
(
idValue
);
end
;
end
;
if
keptFilter
<>
''
then
keptFilter
:=
' or ti.ENTRY_ID in ('
+
keptFilter
+
')'
;
itemsQuery
:=
TUniQuery
.
Create
(
nil
);
itemsQuery
:=
TUniQuery
.
Create
(
nil
);
try
try
itemsQuery
.
Connection
:=
apiDB
.
ucETaskApi
;
itemsQuery
.
Connection
:=
apiDB
.
ucETaskApi
;
...
@@ -232,8 +353,8 @@ begin
...
@@ -232,8 +353,8 @@ begin
'left join codes cat on cat.CATEGORY = ''TASK'' and cat.CODE_TYPE = ''CATGRY'' and cat.CODE = ti.CATEGORY '
+
'left join codes cat on cat.CATEGORY = ''TASK'' and cat.CODE_TYPE = ''CATGRY'' and cat.CODE = ti.CATEGORY '
+
'left join codes plc on plc.CATEGORY = ''GENERAL'' and plc.CODE_TYPE = ''PLACE'' and plc.CODE = ti.PLACE '
+
'left join codes plc on plc.CATEGORY = ''GENERAL'' and plc.CODE_TYPE = ''PLACE'' and plc.CODE = ti.PLACE '
+
'where ti.USER_ID = :USER_ID '
+
'where ti.USER_ID = :USER_ID '
+
' and ti.TASK_DATE >= :START_DATE '
+
' and
((
ti.TASK_DATE >= :START_DATE '
+
' and ti.TASK_DATE < :END_DATE '
+
' and ti.TASK_DATE < :END_DATE
)'
+
keptFilter
+
')
'
+
'order by ti.TASK_DATE, ti.ENTRY_ID'
;
'order by ti.TASK_DATE, ti.ENTRY_ID'
;
itemsQuery
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
itemsQuery
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
...
@@ -303,7 +424,9 @@ begin
...
@@ -303,7 +424,9 @@ begin
' t.TASK_NUM_4, '
+
' t.TASK_NUM_4, '
+
' t.TASK_NUM_5, '
+
' t.TASK_NUM_5, '
+
' t.TASK_NUM_6, '
+
' t.TASK_NUM_6, '
+
' t.SUBJECT as TASK_SUBJECT '
+
' t.SUBJECT as TASK_SUBJECT, '
+
' t.START_DATE, '
+
' t.COMPLETION_DATE '
+
'from task_assigned_user tau '
+
'from task_assigned_user tau '
+
'join tasks t on t.TASK_ID = tau.TASK_ID '
+
'join tasks t on t.TASK_ID = tau.TASK_ID '
+
'join project p on p.PROJECT_ID = t.PROJECT_ID '
+
'join project p on p.PROJECT_ID = t.PROJECT_ID '
+
...
@@ -322,6 +445,8 @@ begin
...
@@ -322,6 +445,8 @@ begin
taskOption
.
taskId
:=
FieldText
(
tasksQuery
,
'TASK_ID'
);
taskOption
.
taskId
:=
FieldText
(
tasksQuery
,
'TASK_ID'
);
taskOption
.
taskDisplay
:=
BuildTaskDisplay
(
tasksQuery
);
taskOption
.
taskDisplay
:=
BuildTaskDisplay
(
tasksQuery
);
taskOption
.
startDate
:=
DateText
(
tasksQuery
,
'START_DATE'
);
taskOption
.
completionDate
:=
DateText
(
tasksQuery
,
'COMPLETION_DATE'
);
AResponse
.
taskOptions
.
Add
(
taskOption
);
AResponse
.
taskOptions
.
Add
(
taskOption
);
tasksQuery
.
Next
;
tasksQuery
.
Next
;
...
@@ -400,30 +525,38 @@ begin
...
@@ -400,30 +525,38 @@ begin
end
;
end
;
function
TTimeEntryService
.
GetTimeEntries
(
userId
,
startDate
,
endDate
:
string
):
TTimeEntriesResponse
;
function
TTimeEntryService
.
GetTimeEntries
(
userId
,
startDate
,
endDate
,
keptEntryIds
:
string
):
TTimeEntriesResponse
;
var
var
startDateValue
:
TDateTime
;
startDateValue
:
TDateTime
;
endDateValue
:
TDateTime
;
endDateValue
:
TDateTime
;
exclusiveEndDateValue
:
TDateTime
;
exclusiveEndDateValue
:
TDateTime
;
begin
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTimeEntries - USER_ID="%s" START="%s" END="%s"
'
,
[
userId
,
startDate
,
endDate
]));
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTimeEntries - USER_ID="%s" START="%s" END="%s"
KEPT="%s"'
,
[
userId
,
startDate
,
endDate
,
keptEntryIds
]));
Result
:=
TTimeEntriesResponse
.
Create
;
Result
:=
TTimeEntriesResponse
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
startDateValue
:=
ParseIsoDate
(
startDate
);
try
endDateValue
:=
ParseIsoDate
(
endDate
);
startDateValue
:=
ParseIsoDate
(
startDate
);
exclusiveEndDateValue
:=
IncDay
(
endDateValue
,
1
);
endDateValue
:=
ParseIsoDate
(
endDate
);
exclusiveEndDateValue
:=
IncDay
(
endDateValue
,
1
);
LoadUserName
(
Result
,
userId
);
LoadUserName
(
Result
,
userId
);
LoadTimeEntryItems
(
Result
,
userId
,
startDateValue
,
exclusiveEndDateValue
);
LoadTimeEntryItems
(
Result
,
userId
,
keptEntryIds
,
startDateValue
,
exclusiveEndDateValue
);
LoadTaskOptions
(
Result
,
userId
,
startDateValue
,
exclusiveEndDateValue
);
LoadTaskOptions
(
Result
,
userId
,
startDateValue
,
exclusiveEndDateValue
);
LoadPlaceOptions
(
Result
);
LoadPlaceOptions
(
Result
);
LoadCategoryOptions
(
Result
);
LoadCategoryOptions
(
Result
);
Result
.
count
:=
Result
.
items
.
Count
;
Result
.
count
:=
Result
.
items
.
Count
;
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTimeEntries - returned %d item(s)'
,
[
Result
.
count
]));
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTimeEntries - returned %d item(s)'
,
[
Result
.
count
]));
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TimeEntryService.GetTimeEntries - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
end
;
end
;
...
@@ -461,23 +594,44 @@ function TTimeEntryService.AddTimeEntry(userId, taskDate: string): string;
...
@@ -461,23 +594,44 @@ function TTimeEntryService.AddTimeEntry(userId, taskDate: string): string;
var
var
taskDateValue
:
TDateTime
;
taskDateValue
:
TDateTime
;
entryId
:
string
;
entryId
:
string
;
problem
:
string
;
begin
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.AddTimeEntry - USER_ID="%s" TASK_DATE="%s"'
,
[
userId
,
taskDate
]));
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.AddTimeEntry - USER_ID="%s" TASK_DATE="%s"'
,
[
userId
,
taskDate
]));
t
askDateValue
:=
ParseIsoDate
(
taskDate
);
t
ry
entryId
:=
GetNextIdValue
(
'TimeEntryId'
);
taskDateValue
:=
ParseIsoDate
(
taskDate
);
apiDB
.
uqAddTimeEntry
.
Close
;
problem
:=
TimeEntryDateProblem
(
FormatDateTime
(
'yyyy-mm-dd'
,
taskDateValue
),
''
,
''
,
''
,
''
);
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'ENTRY_ID'
).
AsString
:=
entryId
;
if
problem
<>
''
then
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
raise
Exception
.
Create
(
problem
);
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'TASK_DATE'
).
AsDateTime
:=
taskDateValue
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'CREATED_BY'
).
AsString
:=
userId
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
userId
;
apiDB
.
uqAddTimeEntry
.
ExecSQL
;
Result
:=
entryId
;
apiDB
.
ucETaskApi
.
StartTransaction
;
Logger
.
Log
(
4
,
'TimeEntryService.AddTimeEntry - new ENTRY_ID='
+
Result
);
entryId
:=
GetNextIdValue
(
'TimeEntryId'
);
apiDB
.
uqAddTimeEntry
.
Close
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'ENTRY_ID'
).
AsString
:=
entryId
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'TASK_DATE'
).
AsDateTime
:=
taskDateValue
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'CREATED_BY'
).
AsString
:=
userId
;
apiDB
.
uqAddTimeEntry
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
userId
;
apiDB
.
uqAddTimeEntry
.
ExecSQL
;
apiDB
.
ucETaskApi
.
Commit
;
Result
:=
entryId
;
Logger
.
Log
(
4
,
'TimeEntryService.AddTimeEntry - new ENTRY_ID='
+
Result
);
except
on
E
:
Exception
do
begin
if
apiDB
.
ucETaskApi
.
InTransaction
then
apiDB
.
ucETaskApi
.
Rollback
;
Logger
.
Log
(
2
,
'TimeEntryService.AddTimeEntry - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
end
;
end
;
...
@@ -488,366 +642,401 @@ var
...
@@ -488,366 +642,401 @@ var
isNewEntry
:
Boolean
;
isNewEntry
:
Boolean
;
q
:
TUniQuery
;
q
:
TUniQuery
;
begin
begin
if
not
Assigned
(
Item
)
then
try
raise
Exception
.
Create
(
'SaveTimeEntry: Item is nil.'
);
if
not
Assigned
(
Item
)
then
raise
Exception
.
Create
(
'SaveTimeEntry: Item is nil.'
);
if
Trim
(
Item
.
userId
)
=
''
then
raise
Exception
.
Create
(
'SaveTimeEntry: Invalid userId.'
);
if
Trim
(
Item
.
taskDate
)
=
''
then
if
Trim
(
Item
.
userId
)
=
''
then
raise
Exception
.
Create
(
'SaveTimeEntry: Task date is require
d.'
);
raise
Exception
.
Create
(
'SaveTimeEntry: Invalid userI
d.'
);
if
Trim
(
Item
.
taskId
)
=
''
then
if
Trim
(
Item
.
taskDate
)
=
''
then
raise
Exception
.
Create
(
'SaveTimeEntry: Task
is required.'
);
raise
Exception
.
Create
(
'SaveTimeEntry: Task date
is required.'
);
if
Item
.
hours
<=
0
then
if
Trim
(
Item
.
taskId
)
=
''
then
raise
Exception
.
Create
(
'SaveTimeEntry: Hours must be greater than zero
.'
);
raise
Exception
.
Create
(
'SaveTimeEntry: Task is required
.'
);
if
Trim
(
Item
.
category
)
=
''
then
if
Item
.
hours
<=
0
then
raise
Exception
.
Create
(
'SaveTimeEntry: Category is required
.'
);
raise
Exception
.
Create
(
'SaveTimeEntry: Hours must be greater than zero
.'
);
if
Trim
(
Item
.
summa
ry
)
=
''
then
if
Trim
(
Item
.
catego
ry
)
=
''
then
raise
Exception
.
Create
(
'SaveTimeEntry: Summa
ry is required.'
);
raise
Exception
.
Create
(
'SaveTimeEntry: Catego
ry is required.'
);
Logger
.
Log
(
4
,
Format
(
if
Trim
(
Item
.
summary
)
=
''
then
'TimeEntryService.SaveTimeEntry - ENTRY_ID="%s" USER_ID="%s"'
,
raise
Exception
.
Create
(
'SaveTimeEntry: Summary is required.'
);
[
Item
.
entryId
,
Item
.
userId
]
));
taskDateValue
:=
ParseIsoDate
(
Item
.
taskDate
);
Logger
.
Log
(
4
,
Format
(
isNewEntry
:=
StrToIntDef
(
Item
.
entryId
,
0
)
<=
0
;
'TimeEntryService.SaveTimeEntry - ENTRY_ID="%s" USER_ID="%s"'
,
[
Item
.
entryId
,
Item
.
userId
]
if
isNewEntry
then
));
begin
entryId
:=
GetNextIdValue
(
'TimeEntryId'
);
q
:=
TUniQuery
.
Create
(
nil
);
taskDateValue
:=
ParseIsoDate
(
Item
.
taskDate
);
try
CheckTimeEntryDate
(
Item
.
userId
,
Item
.
taskId
,
taskDateValue
);
q
.
Connection
:=
apiDB
.
ucETaskApi
;
isNewEntry
:=
StrToIntDef
(
Item
.
entryId
,
0
)
<=
0
;
q
.
SQL
.
Text
:=
'insert into time_items ( '
+
' ENTRY_ID, '
+
' USER_ID, '
+
' TASK_DATE, '
+
' TASK_ID, '
+
' PROJECT_ID, '
+
' HOURS, '
+
' TASK_TIME, '
+
' PLACE, '
+
' CATEGORY, '
+
' SUMMARY, '
+
' CREATE_DATE, '
+
' CREATED_BY, '
+
' MODIFY_DATE, '
+
' MODIFIED_BY '
+
') values ( '
+
' :ENTRY_ID, '
+
' :USER_ID, '
+
' :TASK_DATE, '
+
' :TASK_ID, '
+
' (select t.PROJECT_ID from tasks t where t.TASK_ID = :TASK_ID), '
+
' :HOURS, '
+
' :TASK_TIME, '
+
' :PLACE, '
+
' :CATEGORY, '
+
' :SUMMARY, '
+
' now(), '
+
' :CREATED_BY, '
+
' now(), '
+
' :MODIFIED_BY '
+
')'
;
q
.
ParamByName
(
'ENTRY_ID'
).
AsString
:=
entryId
;
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
Item
.
userId
;
q
.
ParamByName
(
'TASK_DATE'
).
AsDateTime
:=
taskDateValue
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
Item
.
taskId
;
q
.
ParamByName
(
'HOURS'
).
AsFloat
:=
Item
.
hours
;
if
Trim
(
Item
.
taskTime
)
=
''
then
apiDB
.
ucETaskApi
.
StartTransaction
;
q
.
ParamByName
(
'TASK_TIME'
).
Clear
else
q
.
ParamByName
(
'TASK_TIME'
).
AsString
:=
Item
.
taskTime
;
if
Trim
(
Item
.
place
)
=
''
then
if
isNewEntry
then
q
.
ParamByName
(
'PLACE'
).
Clear
begin
else
entryId
:=
GetNextIdValue
(
'TimeEntryId'
);
q
.
ParamByName
(
'PLACE'
).
AsString
:=
Item
.
place
;
q
.
ParamByName
(
'CATEGORY'
).
AsString
:=
Item
.
category
;
q
:=
TUniQuery
.
Create
(
nil
);
q
.
ParamByName
(
'SUMMARY'
).
AsString
:=
Item
.
summary
;
try
q
.
ParamByName
(
'CREATED_BY'
).
AsString
:=
Item
.
userId
;
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
Item
.
userId
;
q
.
SQL
.
Text
:=
'insert into time_items ( '
+
' ENTRY_ID, '
+
' USER_ID, '
+
' TASK_DATE, '
+
' TASK_ID, '
+
' PROJECT_ID, '
+
' HOURS, '
+
' TASK_TIME, '
+
' PLACE, '
+
' CATEGORY, '
+
' SUMMARY, '
+
' CREATE_DATE, '
+
' CREATED_BY, '
+
' MODIFY_DATE, '
+
' MODIFIED_BY '
+
') values ( '
+
' :ENTRY_ID, '
+
' :USER_ID, '
+
' :TASK_DATE, '
+
' :TASK_ID, '
+
' (select t.PROJECT_ID from tasks t where t.TASK_ID = :TASK_ID), '
+
' :HOURS, '
+
' :TASK_TIME, '
+
' :PLACE, '
+
' :CATEGORY, '
+
' :SUMMARY, '
+
' now(), '
+
' :CREATED_BY, '
+
' now(), '
+
' :MODIFIED_BY '
+
')'
;
q
.
ParamByName
(
'ENTRY_ID'
).
AsString
:=
entryId
;
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
Item
.
userId
;
q
.
ParamByName
(
'TASK_DATE'
).
AsDateTime
:=
taskDateValue
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
Item
.
taskId
;
q
.
ParamByName
(
'HOURS'
).
AsFloat
:=
Item
.
hours
;
if
Trim
(
Item
.
taskTime
)
=
''
then
q
.
ParamByName
(
'TASK_TIME'
).
Clear
else
q
.
ParamByName
(
'TASK_TIME'
).
AsString
:=
Item
.
taskTime
;
q
.
ExecSQL
;
if
Trim
(
Item
.
place
)
=
''
then
finally
q
.
ParamByName
(
'PLACE'
).
Clear
q
.
Free
;
else
end
;
q
.
ParamByName
(
'PLACE'
).
AsString
:=
Item
.
place
;
end
else
begin
entryId
:=
Item
.
entryId
;
apiDB
.
uqSaveTimeEntry
.
Close
;
q
.
ParamByName
(
'CATEGORY'
).
AsString
:=
Item
.
category
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'ENTRY_ID'
).
AsString
:=
entryId
;
q
.
ParamByName
(
'SUMMARY'
).
AsString
:=
Item
.
summary
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'USER_ID'
).
AsString
:=
Item
.
userId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_DATE'
).
AsDateTime
:=
taskDateValue
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_ID'
).
AsString
:=
Item
.
taskId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'HOURS'
).
AsFloat
:=
Item
.
hours
;
if
Trim
(
Item
.
taskTime
)
=
''
then
q
.
ParamByName
(
'CREATED_BY'
).
AsString
:=
Item
.
userId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_TIME'
).
Clear
q
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
Item
.
userId
;
else
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_TIME'
).
AsString
:=
Item
.
taskTime
;
if
Trim
(
Item
.
place
)
=
''
then
q
.
ExecSQL
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'PLACE'
).
Clear
finally
q
.
Free
;
end
;
end
else
else
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'PLACE'
).
AsString
:=
Item
.
place
;
begin
entryId
:=
Item
.
entryId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'CATEGORY'
).
AsString
:=
Item
.
category
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'SUMMARY'
).
AsString
:=
Item
.
summary
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
Item
.
userId
;
apiDB
.
uqSaveTimeEntry
.
ExecSQL
;
apiDB
.
uqSaveTimeEntry
.
Close
;
end
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'ENTRY_ID'
).
AsString
:=
entryId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'USER_ID'
).
AsString
:=
Item
.
userId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_DATE'
).
AsDateTime
:=
taskDateValue
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_ID'
).
AsString
:=
Item
.
taskId
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'HOURS'
).
AsFloat
:=
Item
.
hours
;
Result
:=
entryId
;
if
Trim
(
Item
.
taskTime
)
=
''
then
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_TIME'
).
Clear
else
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'TASK_TIME'
).
AsString
:=
Item
.
taskTime
;
Logger
.
Log
(
4
,
'TimeEntryService.SaveTimeEntry - saved ENTRY_ID='
+
Result
);
if
Trim
(
Item
.
place
)
=
''
then
end
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'PLACE'
).
Clear
else
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'PLACE'
).
AsString
:=
Item
.
place
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'CATEGORY'
).
AsString
:=
Item
.
category
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'SUMMARY'
).
AsString
:=
Item
.
summary
;
function
TTimeEntryService
.
SaveTimeEntryField
(
Item
:
TTimeEntryFieldSave
):
Boolean
;
apiDB
.
uqSaveTimeEntry
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
Item
.
userId
;
var
uqSaveField
:
TUniQuery
;
columnName
:
string
;
d
:
TDateTime
;
function
MapFieldNameToColumn
(
AFieldName
:
string
):
string
;
apiDB
.
uqSaveTimeEntry
.
ExecSQL
;
begin
end
;
Result
:=
''
;
if
SameText
(
AFieldName
,
'taskDate'
)
then
Result
:=
'TASK_DATE'
else
if
SameText
(
AFieldName
,
'hours'
)
then
Result
:=
'HOURS'
else
if
SameText
(
AFieldName
,
'taskTime'
)
then
Result
:=
'TASK_TIME'
else
if
SameText
(
AFieldName
,
'place'
)
then
Result
:=
'PLACE'
else
if
SameText
(
AFieldName
,
'category'
)
then
Result
:=
'CATEGORY'
else
if
SameText
(
AFieldName
,
'summary'
)
then
Result
:=
'SUMMARY'
;
end
;
function
ParseDateOrZero
(
const
S
:
string
;
out
ADate
:
TDateTime
):
Boolean
;
apiDB
.
ucETaskApi
.
Commit
;
var
y
:
Integer
;
m
:
Integer
;
dInt
:
Integer
;
begin
Result
:=
False
;
ADate
:=
0
;
if
Length
(
Trim
(
S
))
<>
10
then
Result
:=
entryId
;
Exit
;
y
:=
StrToIntDef
(
Copy
(
S
,
1
,
4
),
0
);
Logger
.
Log
(
4
,
'TimeEntryService.SaveTimeEntry - saved ENTRY_ID='
+
Result
);
m
:=
StrToIntDef
(
Copy
(
S
,
6
,
2
),
0
);
except
dInt
:=
StrToIntDef
(
Copy
(
S
,
9
,
2
),
0
);
on
E
:
Exception
do
if
(
y
>
0
)
and
(
m
>
0
)
and
(
dInt
>
0
)
then
begin
begin
try
if
apiDB
.
ucETaskApi
.
InTransaction
then
ADate
:=
EncodeDate
(
y
,
m
,
dInt
);
apiDB
.
ucETaskApi
.
Rollback
;
Result
:=
True
;
except
Logger
.
Log
(
2
,
'TimeEntryService.SaveTimeEntry - ERROR: '
+
E
.
Message
);
Result
:=
False
;
raise
;
end
;
end
;
end
;
end
;
end
;
end
;
begin
Result
:=
False
;
if
not
Assigned
(
Item
)
then
raise
Exception
.
Create
(
'SaveTimeEntryField: Item is nil.'
);
if
Item
.
entryId
<=
0
then
function
TTimeEntryService
.
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
raise
Exception
.
Create
(
'SaveTimeEntryField: Invalid entryId.'
);
begin
Logger
.
Log
(
4
,
'TimeEntryService.GetTaskPickerCustomers Start'
);
if
Trim
(
Item
.
userId
)
=
''
then
Result
:=
TTaskPickerOptionsResponse
.
Create
;
raise
Exception
.
Create
(
'SaveTimeEntryField: Invalid userId.'
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
uqSaveField
:=
TUniQuery
.
Create
(
nil
);
try
try
uqSaveField
.
Connection
:=
apiDB
.
ucETaskApi
;
apiDB
.
uqTaskPickerCustomers
.
Close
;
apiDB
.
uqTaskPickerCustomers
.
Open
;
if
SameText
(
Item
.
fieldName
,
'taskId'
)
then
try
begin
while
not
apiDB
.
uqTaskPickerCustomers
.
Eof
do
if
Trim
(
Item
.
value
)
=
''
then
begin
uqSaveField
.
SQL
.
Text
:=
'update time_items '
+
'set TASK_ID = null, '
+
' PROJECT_ID = null, '
+
' MODIFY_DATE = now(), '
+
' MODIFIED_BY = :MODIFIED_BY '
+
'where ENTRY_ID = :ENTRY_ID '
+
' and USER_ID = :USER_ID'
;
end
else
begin
begin
uqSaveField
.
SQL
.
Text
:=
AddTaskPickerOption
(
'update time_items '
+
Result
,
'set TASK_ID = :TASK_ID, '
+
FieldText
(
apiDB
.
uqTaskPickerCustomers
,
'CUSTOMER_ID'
),
' PROJECT_ID = ( '
+
FieldText
(
apiDB
.
uqTaskPickerCustomers
,
'CUSTOMER_NAME'
)
' select t.PROJECT_ID '
+
);
' from tasks t '
+
' where t.TASK_ID = :TASK_ID '
+
' ), '
+
' MODIFY_DATE = now(), '
+
' MODIFIED_BY = :MODIFIED_BY '
+
'where ENTRY_ID = :ENTRY_ID '
+
' and USER_ID = :USER_ID'
;
uqSaveField
.
ParamByName
(
'TASK_ID'
).
AsString
:=
Item
.
value
;
end
;
end
else
begin
columnName
:=
MapFieldNameToColumn
(
Item
.
fieldName
);
if
columnName
=
''
then
raise
Exception
.
Create
(
'SaveTimeEntryField: Invalid field name: '
+
Item
.
fieldName
);
uqSaveField
.
SQL
.
Text
:=
'update time_items '
+
'set '
+
columnName
+
' = :'
+
columnName
+
', '
+
' MODIFY_DATE = now(), '
+
' MODIFIED_BY = :MODIFIED_BY '
+
'where ENTRY_ID = :ENTRY_ID '
+
' and USER_ID = :USER_ID'
;
if
SameText
(
Item
.
fieldName
,
'taskDate'
)
then
apiDB
.
uqTaskPickerCustomers
.
Next
;
begin
if
ParseDateOrZero
(
Item
.
value
,
d
)
then
uqSaveField
.
ParamByName
(
columnName
).
AsDateTime
:=
d
else
uqSaveField
.
ParamByName
(
columnName
).
Clear
;
end
else
if
SameText
(
Item
.
fieldName
,
'hours'
)
then
begin
if
Trim
(
Item
.
value
)
=
''
then
uqSaveField
.
ParamByName
(
columnName
).
Clear
else
uqSaveField
.
ParamByName
(
columnName
).
AsFloat
:=
StrToFloatDef
(
Item
.
value
,
0
);
end
else
begin
if
Trim
(
Item
.
value
)
=
''
then
uqSaveField
.
ParamByName
(
columnName
).
Clear
else
uqSaveField
.
ParamByName
(
columnName
).
AsString
:=
Item
.
value
;
end
;
end
;
finally
apiDB
.
uqTaskPickerCustomers
.
Close
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TimeEntryService.GetTaskPickerCustomers - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
uqSaveField
.
ParamByName
(
'ENTRY_ID'
).
AsInteger
:=
Item
.
entryId
;
uqSaveField
.
ParamByName
(
'USER_ID'
).
AsString
:=
Item
.
userId
;
uqSaveField
.
ParamByName
(
'MODIFIED_BY'
).
AsString
:=
Item
.
userId
;
uqSaveField
.
ExecSQL
;
Result
:=
True
;
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.SaveTimeEntryField - ENTRY_ID="%d" FIELD="%s"'
,
[
Item
.
entryId
,
Item
.
fieldName
]
));
finally
uqSaveField
.
Free
;
end
;
end
;
end
;
end
;
function
TTimeEntryService
.
GetTaskPickerCustomers
:
TTaskPickerOptionsResponse
;
// Task status codes for the picker's Status dropdown, same list as emT3's Tasks screen
function
TTimeEntryService
.
GetTaskPickerStatuses
:
TTaskPickerOptionsResponse
;
var
q
:
TUniQuery
;
begin
begin
Logger
.
Log
(
4
,
'TimeEntryService.GetTaskPicker
Customer
s Start'
);
Logger
.
Log
(
4
,
'TimeEntryService.GetTaskPicker
Statuse
s Start'
);
Result
:=
TTaskPickerOptionsResponse
.
Create
;
Result
:=
TTaskPickerOptionsResponse
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
apiDB
.
uqTaskPickerCustomers
.
Close
;
apiDB
.
uqTaskPickerCustomers
.
Open
;
try
try
while
not
apiDB
.
uqTaskPickerCustomers
.
Eof
do
q
:=
TUniQuery
.
Create
(
nil
);
begin
try
AddTaskPickerOption
(
q
.
Connection
:=
apiDB
.
ucETaskApi
;
Result
,
q
.
SQL
.
Text
:=
FieldText
(
apiDB
.
uqTaskPickerCustomers
,
'CUSTOMER_ID'
),
'select CODE, CODE_DESC '
+
FieldText
(
apiDB
.
uqTaskPickerCustomers
,
'CUSTOMER_NAME'
)
'from codes '
+
);
'where CATEGORY = ''TASK'' '
+
' and CODE_TYPE = ''STATUS'' '
+
'order by CODE_DESC'
;
apiDB
.
uqTaskPickerCustomers
.
Next
;
q
.
Open
;
while
not
q
.
Eof
do
begin
AddTaskPickerOption
(
Result
,
FieldText
(
q
,
'CODE'
),
FieldText
(
q
,
'CODE_DESC'
)
);
q
.
Next
;
end
;
finally
q
.
Free
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TimeEntryService.GetTaskPickerStatuses - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
finally
apiDB
.
uqTaskPickerCustomers
.
Close
;
end
;
end
;
end
;
end
;
function
TTimeEntryService
.
GetTaskPickerProjects
(
customerId
:
string
):
TTaskPickerOptionsResponse
;
// scope: MY = the user's active projects (user_project), ACTIVE = all active
// projects (customer field hidden for both); ALL = every project whatever its
// status (customer field shown). Every scope lists "SHORT_NAME - project",
// ordered by short name then project, like emT3's Tasks screen.
// taskDate (yyyy-mm-dd) keeps only projects whose START_DATE-END_DATE includes
// it, like emT3's Time Entry screen; '' = any date
function
TTimeEntryService
.
GetTaskPickerProjects
(
customerId
,
scope
,
userId
,
taskDate
:
string
):
TTaskPickerOptionsResponse
;
var
projectDisplay
:
string
;
dateValue
:
string
;
begin
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTaskPickerProjects - CUSTOMER_ID="%s"'
,
[
customerId
]));
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTaskPickerProjects - CUSTOMER_ID="%s" SCOPE="%s" USER_ID="%s" TASK_DATE="%s"'
,
[
customerId
,
scope
,
userId
,
taskDate
]));
Result
:=
TTaskPickerOptionsResponse
.
Create
;
Result
:=
TTaskPickerOptionsResponse
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
apiDB
.
uqTaskPickerProjects
.
Close
;
scope
:=
UpperCase
(
Trim
(
scope
));
apiDB
.
uqTaskPickerProjects
.
ParamByName
(
'CUSTOMER_ID'
).
AsString
:=
customerId
;
if
(
scope
<>
'MY'
)
and
(
scope
<>
'ACTIVE'
)
then
apiDB
.
uqTaskPickerProjects
.
Open
;
scope
:=
'ALL'
;
try
try
while
not
apiDB
.
uqTaskPickerProjects
.
Eof
do
if
Trim
(
taskDate
)
=
''
then
begin
dateValue
:=
''
AddTaskPickerOption
(
else
Result
,
dateValue
:=
FormatDateTime
(
'yyyy-mm-dd'
,
ParseIsoDate
(
Trim
(
taskDate
)));
FieldText
(
apiDB
.
uqTaskPickerProjects
,
'PROJECT_ID'
),
FieldText
(
apiDB
.
uqTaskPickerProjects
,
'PROJECT_NAME'
)
);
Result
.
options
[
Result
.
options
.
Count
-
1
].
customerId
:=
apiDB
.
uqTaskPickerProjects
.
Close
;
apiDB
.
uqTaskPickerProjectsCUSTOMER_ID
.
AsString
;
apiDB
.
uqTaskPickerProjects
.
ParamByName
(
'CUSTOMER_ID'
).
AsString
:=
customerId
;
apiDB
.
uqTaskPickerProjects
.
ParamByName
(
'SCOPE'
).
AsString
:=
scope
;
apiDB
.
uqTaskPickerProjects
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
apiDB
.
uqTaskPickerProjects
.
ParamByName
(
'PROJECT_DATE'
).
AsString
:=
dateValue
;
apiDB
.
uqTaskPickerProjects
.
Open
;
try
while
not
apiDB
.
uqTaskPickerProjects
.
Eof
do
begin
projectDisplay
:=
FieldText
(
apiDB
.
uqTaskPickerProjects
,
'CUSTOMER_SHORT_NAME'
)
+
' - '
+
FieldText
(
apiDB
.
uqTaskPickerProjects
,
'PROJECT_NAME'
);
AddTaskPickerOption
(
Result
,
FieldText
(
apiDB
.
uqTaskPickerProjects
,
'PROJECT_ID'
),
projectDisplay
);
apiDB
.
uqTaskPickerProjects
.
Next
;
Result
.
options
[
Result
.
options
.
Count
-
1
].
customerId
:=
apiDB
.
uqTaskPickerProjectsCUSTOMER_ID
.
AsString
;
apiDB
.
uqTaskPickerProjects
.
Next
;
end
;
finally
apiDB
.
uqTaskPickerProjects
.
Close
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TimeEntryService.GetTaskPickerProjects - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
finally
apiDB
.
uqTaskPickerProjects
.
Close
;
end
;
end
;
end
;
end
;
function
TTimeEntryService
.
GetTaskPickerTasks
(
projectId
:
string
):
TTaskPickerOptionsResponse
;
// The project's tasks, whatever the task's status (the picker's scope decides
// which projects are offered). Like emT3's Time Entry screen, only tasks open
// on taskDate are listed: START_DATE on or before it and COMPLETION_DATE on or
// after it ('' = open-ended); a blank taskDate lists every task. Each task
// carries unavailableReason: why hours can't go on taskDate for this user (same
// rule as SaveTimeEntry via TimeEntryDateProblem), '' when allowed or taskDate is blank.
function
TTimeEntryService
.
GetTaskPickerTasks
(
projectId
,
userId
,
taskDate
:
string
):
TTaskPickerOptionsResponse
;
var
q
:
TUniQuery
;
option
:
TTaskPickerOption
;
dateValue
:
string
;
userStart
:
string
;
userEnd
:
string
;
dateFilter
:
string
;
begin
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTaskPickerTasks - PROJECT_ID="%s"'
,
[
projectId
]));
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.GetTaskPickerTasks - PROJECT_ID="%s" USER_ID="%s" TASK_DATE="%s"'
,
Result
:=
TTaskPickerOptionsResponse
.
Create
;
[
projectId
,
userId
,
taskDate
]));
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
apiDB
.
uqTaskPickerTasks
.
Close
;
apiDB
.
uqTaskPickerTasks
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
apiDB
.
uqTaskPickerTasks
.
Open
;
try
try
while
not
apiDB
.
uqTaskPickerTasks
.
Eof
do
if
Trim
(
taskDate
)
=
''
then
begin
dateValue
:=
''
AddTaskPickerOption
(
else
Result
,
dateValue
:=
FormatDateTime
(
'yyyy-mm-dd'
,
ParseIsoDate
(
Trim
(
taskDate
)));
FieldText
(
apiDB
.
uqTaskPickerTasks
,
'TASK_ID'
),
BuildTaskDisplay
(
apiDB
.
uqTaskPickerTasks
)
dateFilter
:=
''
;
);
if
dateValue
<>
''
then
dateFilter
:=
' and (t.START_DATE is null or date(t.START_DATE) <= :TASK_DATE) '
+
' and (t.COMPLETION_DATE is null or date(t.COMPLETION_DATE) >= :TASK_DATE) '
;
Result
:=
TTaskPickerOptionsResponse
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
q
:=
TUniQuery
.
Create
(
nil
);
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
// No user row: treat employment as open-ended
userStart
:=
''
;
userEnd
:=
''
;
q
.
SQL
.
Text
:=
'select START_DATE, END_DATE from users where USER_ID = :USER_ID'
;
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
q
.
Open
;
if
not
q
.
IsEmpty
then
begin
userStart
:=
DateText
(
q
,
'START_DATE'
);
userEnd
:=
DateText
(
q
,
'END_DATE'
);
end
;
q
.
Close
;
apiDB
.
uqTaskPickerTasks
.
Next
;
q
.
SQL
.
Text
:=
'select distinct '
+
' t.TASK_ID, '
+
' c.SHORT_NAME as CUSTOMER_NAME, '
+
' p.NAME as PROJECT_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, '
+
' t.SUBJECT as TASK_SUBJECT, '
+
' t.START_DATE, '
+
' t.COMPLETION_DATE, '
+
' t.STATUS '
+
'from tasks t '
+
'join project p on p.PROJECT_ID = t.PROJECT_ID '
+
'join customers c on c.CUSTOMER_ID = p.CUSTOMER_ID '
+
'where t.PROJECT_ID = :PROJECT_ID '
+
dateFilter
+
'order by '
+
' t.TASK_NUM_1, t.TASK_NUM_2, t.TASK_NUM_3, '
+
' t.TASK_NUM_4, t.TASK_NUM_5, t.TASK_NUM_6, t.SUBJECT'
;
q
.
ParamByName
(
'PROJECT_ID'
).
AsString
:=
projectId
;
if
dateFilter
<>
''
then
q
.
ParamByName
(
'TASK_DATE'
).
AsString
:=
dateValue
;
q
.
Open
;
while
not
q
.
Eof
do
begin
option
:=
TTaskPickerOption
.
Create
;
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
option
);
option
.
value
:=
FieldText
(
q
,
'TASK_ID'
);
option
.
display
:=
BuildTaskDisplay
(
q
);
option
.
completed
:=
not
q
.
FieldByName
(
'COMPLETION_DATE'
).
IsNull
;
option
.
unavailableReason
:=
TimeEntryDateProblem
(
dateValue
,
userStart
,
userEnd
,
DateText
(
q
,
'START_DATE'
),
DateText
(
q
,
'COMPLETION_DATE'
));
option
.
status
:=
FieldText
(
q
,
'STATUS'
);
Result
.
options
.
Add
(
option
);
q
.
Next
;
end
;
finally
q
.
Free
;
end
;
except
on
E
:
Exception
do
begin
Logger
.
Log
(
2
,
'TimeEntryService.GetTaskPickerTasks - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
finally
apiDB
.
uqTaskPickerTasks
.
Close
;
end
;
end
;
end
;
end
;
...
@@ -862,25 +1051,33 @@ begin
...
@@ -862,25 +1051,33 @@ begin
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
TXDataOperationContext
.
Current
.
Handler
.
ManagedObjects
.
Add
(
Result
);
Result
.
taskId
:=
taskId
;
Result
.
taskId
:=
taskId
;
// Read-only lookup; an unknown task returns blank ids so the picker opens empty
q
:=
TUniQuery
.
Create
(
nil
);
try
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
// Read-only lookup; an unknown task returns blank ids so the picker opens empty
q
.
SQL
.
Text
:=
q
:=
TUniQuery
.
Create
(
nil
);
'select t.PROJECT_ID, p.CUSTOMER_ID '
+
try
'from tasks t '
+
q
.
Connection
:=
apiDB
.
ucETaskApi
;
'join project p on p.PROJECT_ID = t.PROJECT_ID '
+
q
.
SQL
.
Text
:=
'where t.TASK_ID = :TASK_ID'
;
'select t.PROJECT_ID, p.CUSTOMER_ID '
+
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
'from tasks t '
+
q
.
Open
;
'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
if
not
q
.
Eof
then
begin
Result
.
projectId
:=
FieldText
(
q
,
'PROJECT_ID'
);
Result
.
customerId
:=
FieldText
(
q
,
'CUSTOMER_ID'
);
end
;
finally
q
.
Free
;
end
;
except
on
E
:
Exception
do
begin
begin
Result
.
projectId
:=
FieldText
(
q
,
'PROJECT_ID'
);
Logger
.
Log
(
2
,
'TimeEntryService.GetTaskPickerTaskContext - ERROR: '
+
E
.
Message
);
Result
.
customerId
:=
FieldText
(
q
,
'CUSTOMER_ID'
)
;
raise
;
end
;
end
;
finally
q
.
Free
;
end
;
end
;
end
;
end
;
...
@@ -891,38 +1088,53 @@ var
...
@@ -891,38 +1088,53 @@ var
begin
begin
Result
:=
False
;
Result
:=
False
;
if
Trim
(
userId
)
=
''
then
raise
Exception
.
Create
(
'DeleteTimeEntry: Invalid userId.'
);
if
entryId
<=
0
then
raise
Exception
.
Create
(
'DeleteTimeEntry: Invalid entryId.'
);
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.DeleteTimeEntry - USER_ID="%s" ENTRY_ID="%d"'
,
[
userId
,
entryId
]
));
q
:=
TUniQuery
.
Create
(
nil
);
q
:=
TUniQuery
.
Create
(
nil
);
try
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
SQL
.
Text
:=
try
'delete from time_items '
+
if
Trim
(
userId
)
=
''
then
'where ENTRY_ID = :ENTRY_ID '
+
raise
Exception
.
Create
(
'DeleteTimeEntry: Invalid userId.'
);
' and USER_ID = :USER_ID'
;
q
.
ParamByName
(
'ENTRY_ID'
).
AsInteger
:=
entryId
;
if
entryId
<=
0
then
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
raise
Exception
.
Create
(
'DeleteTimeEntry: Invalid entryId.'
);
q
.
ExecSQL
;
if
q
.
RowsAffected
<=
0
then
Logger
.
Log
(
4
,
Format
(
raise
Exception
.
Create
(
'Time entry was not found or does not belong to this user.'
);
'TimeEntryService.DeleteTimeEntry - USER_ID="%s" ENTRY_ID="%d"'
,
[
userId
,
entryId
]
));
Result
:=
True
;
q
.
Connection
.
StartTransaction
;
Logger
.
Log
(
4
,
Format
(
q
.
SQL
.
Text
:=
'TimeEntryService.DeleteTimeEntry - deleted ENTRY_ID="%d"'
,
'delete from time_items '
+
[
entryId
]
'where ENTRY_ID = :ENTRY_ID '
+
));
' and USER_ID = :USER_ID'
;
q
.
ParamByName
(
'ENTRY_ID'
).
AsInteger
:=
entryId
;
q
.
ParamByName
(
'USER_ID'
).
AsString
:=
userId
;
q
.
ExecSQL
;
if
q
.
RowsAffected
<=
0
then
raise
Exception
.
Create
(
'Time entry was not found or does not belong to this user.'
);
q
.
Connection
.
Commit
;
Result
:=
True
;
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.DeleteTimeEntry - deleted ENTRY_ID="%d"'
,
[
entryId
]
));
except
on
E
:
Exception
do
begin
if
q
.
Connection
.
InTransaction
then
q
.
Connection
.
Rollback
;
Logger
.
Log
(
2
,
'TimeEntryService.DeleteTimeEntry - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
finally
finally
q
.
Free
;
q
.
Free
;
end
;
end
;
...
@@ -940,8 +1152,22 @@ begin
...
@@ -940,8 +1152,22 @@ begin
q
:=
TUniQuery
.
Create
(
nil
);
q
:=
TUniQuery
.
Create
(
nil
);
try
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
.
StartTransaction
;
try
try
// A completed task can still get historical hours, but can't be newly focused
q
.
SQL
.
Text
:=
'select COMPLETION_DATE from tasks where TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
q
.
Open
;
if
q
.
IsEmpty
then
raise
Exception
.
Create
(
'Task not found.'
);
if
not
q
.
FieldByName
(
'COMPLETION_DATE'
).
IsNull
then
raise
Exception
.
Create
(
'Completed tasks can''t be added to Focused Tasks.'
);
q
.
Close
;
q
.
Connection
.
StartTransaction
;
q
.
SQL
.
Text
:=
q
.
SQL
.
Text
:=
'select TASK_ID from task_assigned_user '
+
'select TASK_ID from task_assigned_user '
+
'where USER_ID = :USER_ID and TASK_ID = :TASK_ID'
;
'where USER_ID = :USER_ID and TASK_ID = :TASK_ID'
;
...
@@ -1000,8 +1226,9 @@ begin
...
@@ -1000,8 +1226,9 @@ begin
q
:=
TUniQuery
.
Create
(
nil
);
q
:=
TUniQuery
.
Create
(
nil
);
try
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
:=
apiDB
.
ucETaskApi
;
q
.
Connection
.
StartTransaction
;
try
try
q
.
Connection
.
StartTransaction
;
q
.
SQL
.
Text
:=
q
.
SQL
.
Text
:=
'update task_assigned_user '
+
'update task_assigned_user '
+
'set FOCUSED_TASK = ''F'' '
+
'set FOCUSED_TASK = ''F'' '
+
...
@@ -1028,6 +1255,101 @@ begin
...
@@ -1028,6 +1255,101 @@ begin
end
;
end
;
end
;
end
;
// Changes a task's status from the task picker, like emT3's New Status on its
// Time Entry screen. CLOSED and COMP (the statuses emT3 requires a completion
// date for) set COMPLETION_DATE to the picker's work date (today when blank),
// but only when it is empty, as emT3's Task Entry screen does. Any other status
// reopens the task and clears COMPLETION_DATE (emT3 leaves it, which keeps a
// reopened task counted as completed). An unchanged status writes nothing.
function
TTimeEntryService
.
SetTaskStatus
(
taskId
,
status
,
taskDate
:
string
):
Boolean
;
var
q
:
TUniQuery
;
statusCode
:
string
;
completionDate
:
TDateTime
;
begin
Logger
.
Log
(
4
,
Format
(
'TimeEntryService.SetTaskStatus - TASK_ID="%s" STATUS="%s" TASK_DATE="%s"'
,
[
taskId
,
status
,
taskDate
]
));
q
:=
TUniQuery
.
Create
(
nil
);
try
q
.
Connection
:=
apiDB
.
ucETaskApi
;
try
statusCode
:=
Trim
(
status
);
if
Trim
(
taskId
)
=
''
then
raise
Exception
.
Create
(
'Select a task.'
);
if
Trim
(
taskDate
)
=
''
then
completionDate
:=
Date
else
completionDate
:=
ParseIsoDate
(
Trim
(
taskDate
));
// Only codes the picker offers (GetTaskPickerStatuses)
q
.
SQL
.
Text
:=
'select CODE from codes '
+
'where CATEGORY = ''TASK'' '
+
' and CODE_TYPE = ''STATUS'' '
+
' and CODE = :CODE'
;
q
.
ParamByName
(
'CODE'
).
AsString
:=
statusCode
;
q
.
Open
;
if
q
.
IsEmpty
then
raise
Exception
.
Create
(
'Unknown task status.'
);
q
.
Close
;
q
.
SQL
.
Text
:=
'select STATUS from tasks where TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'TASK_ID'
).
AsString
:=
taskId
;
q
.
Open
;
if
q
.
IsEmpty
then
raise
Exception
.
Create
(
'Task not found.'
);
if
FieldText
(
q
,
'STATUS'
)
=
statusCode
then
Exit
(
True
);
q
.
Close
;
q
.
Connection
.
StartTransaction
;
if
(
statusCode
=
'CLOSED'
)
or
(
statusCode
=
'COMP'
)
then
begin
q
.
SQL
.
Text
:=
'update tasks '
+
'set STATUS = :STATUS, '
+
' COMPLETION_DATE = coalesce(COMPLETION_DATE, :COMPLETION_DATE) '
+
'where TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'COMPLETION_DATE'
).
AsDate
:=
completionDate
;
end
else
q
.
SQL
.
Text
:=
'update tasks '
+
'set STATUS = :STATUS, '
+
' COMPLETION_DATE = null '
+
'where TASK_ID = :TASK_ID'
;
q
.
ParamByName
(
'STATUS'
).
AsString
:=
statusCode
;
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.SetTaskStatus - ERROR: '
+
E
.
Message
);
raise
;
end
;
end
;
finally
q
.
Free
;
end
;
end
;
initialization
initialization
RegisterServiceType
(
TTimeEntryService
);
RegisterServiceType
(
TTimeEntryService
);
...
...
emT3XDataServer/bin/emT3XDataServer.ini
View file @
dd94c9fb
[Settings]
[Settings]
MemoLogLevel
=
5
MemoLogLevel
=
5
FileLogLevel
=
5
FileLogLevel
=
5
webClientVersion
=
0.9.4.
0
webClientVersion
=
0.9.4.
1
LogFileNum
=
2
18
LogFileNum
=
2
43
[Database]
[Database]
--Server
=
192.168.102.131
--Server
=
192.168.102.131
...
...
emT3XDataServer/bin/static-View.TimeEntries/View.ErrorPage.html
0 → 100644
View file @
dd94c9fb
<div
class=
"container"
>
<br
/>
<div
class=
"panel panel-red"
>
<div
id=
"view.errorpage.title"
class=
"panel-heading"
>
Error Page
</div>
<div
id=
"view.errorpage.message"
class=
"panel-body"
>
Message
</div>
<div
class=
"panel-footer"
>
<a
href=
"."
>
Reload web application
</a>
</div>
</div>
</div>
emT3XDataServer/bin/static-View.TimeEntries/View.Login.html
0 → 100644
View file @
dd94c9fb
<nav
class=
"navbar navbar-light bg-light login-navbar"
>
<div
class=
"container-fluid"
>
<a
class=
"navbar-brand"
>
emT3web
</a>
</div>
</nav>
<div
class=
"container mt-5"
>
<div
class=
"row justify-content-center"
>
<div
class=
"col-md-6 col-lg-4"
>
<div
class=
"card login-card"
>
<div
class=
"card-header"
>
<h3
id=
"view.login.title"
class=
"fs-6 card-title"
>
Please Sign In
</h3>
</div>
<div
class=
"card-body"
>
<div
role=
"form"
>
<div
id=
"view.login.message"
class=
"alert alert-danger"
>
<button
id=
"view.login.message.button"
type=
"button"
class=
"btn-close"
aria-label=
"Close"
></button>
<span
id=
"view.login.message.label"
></span>
</div>
<fieldset>
<div
id=
"view.login.taskid.group"
class=
"mb-3"
>
<input
id=
"view.login.edttaskid"
class=
"form-control"
type=
"text"
placeholder=
"Task Id"
>
</div>
<div
id=
"view.login.date.group"
class=
"mb-3"
>
<input
id=
"view.login.edtdate"
class=
"form-control"
type=
"date"
placeholder=
"Date"
>
</div>
<div
class=
"mb-3"
>
<input
id=
"view.login.edtusername"
class=
"form-control"
type=
"text"
autofocus
placeholder=
"Username"
>
</div>
<div
class=
"mb-3"
>
<input
id=
"view.login.edtpassword"
class=
"form-control"
type=
"password"
placeholder=
"Password"
>
</div>
<div
class=
"mb-3"
>
<button
id=
"view.login.btnlogin"
class=
"btn btn-primary w-100"
>
Login
</button>
</div>
</fieldset>
</div>
</div>
</div>
</div>
</div>
</div>
emT3XDataServer/bin/static-View.TimeEntries/View.Main.html
0 → 100644
View file @
dd94c9fb
<div
id=
"div_wrapper"
>
<nav
class=
"navbar navbar-expand-lg bg-body-tertiary border-bottom shadow-sm"
>
<div
class=
"container-fluid"
>
<div
class=
"d-flex align-items-center gap-2"
>
<a
id=
"lbl_app_title"
class=
"navbar-brand fw-semibold"
href=
"index.html"
>
emT3Web
</a>
<span
id=
"lbl_version"
class=
"badge text-bg-light border text-muted fw-normal"
></span>
</div>
<div
class=
"collapse navbar-collapse show"
id=
"pnl_navbar_nav_dropdown"
>
<ul
class=
"navbar-nav ms-auto"
>
<li
class=
"nav-item dropdown"
>
<a
class=
"nav-link dropdown-toggle d-flex align-items-center gap-2"
id=
"lnk_navbar_dropdown_menu_link"
role=
"button"
data-bs-toggle=
"dropdown"
aria-expanded=
"false"
>
<i
class=
"fa fa-user fa-fw"
></i>
<span
id=
"lbl_username"
class=
"fw-semibold"
>
Username
</span>
</a>
<ul
class=
"dropdown-menu dropdown-menu-end shadow-sm"
aria-labelledby=
"lnk_navbar_dropdown_menu_link"
>
<li>
<a
class=
"dropdown-item d-flex align-items-center gap-2"
id=
"lbl_home"
>
<i
class=
"fa fa-home fa-fw"
></i><span>
Home
</span>
</a>
</li>
<li>
<a
class=
"dropdown-item d-flex align-items-center gap-2"
id=
"lbl_user_profile"
>
<i
class=
"fa fa-user fa-fw"
></i><span>
User Profile
</span>
</a>
</li>
<li><hr
class=
"dropdown-divider"
></li>
<li>
<a
class=
"dropdown-item d-flex align-items-center gap-2 text-danger"
id=
"lbl_logout"
>
<i
class=
"fa fa-sign-out fa-fw"
></i><span>
Logout
</span>
</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Toast -->
<div
id=
"pnl_toast_wrapper"
class=
"position-fixed top-0 start-0 mt-5 ms-4"
style=
"z-index: 1080; min-width: 300px; max-width: 500px;"
>
<div
id=
"toast_bootstrap"
class=
"toast align-items-center text-white bg-success border-0 shadow"
role=
"alert"
aria-live=
"assertive"
aria-atomic=
"true"
>
<div
class=
"d-flex"
>
<div
class=
"toast-body"
id=
"lbl_bootstrap_toast_body"
>
Success message
</div>
<button
type=
"button"
class=
"btn-close btn-close-white me-2 m-auto"
data-bs-dismiss=
"toast"
aria-label=
"Close"
></button>
</div>
</div>
</div>
<!-- Main Panel (where all forms display) -->
<div
class=
"container-fluid py-3 d-flex flex-column overflow-hidden"
style=
"height: calc(100vh - 57px);"
>
<div
id=
"pnl_main"
class=
"flex-grow-1 min-h-0 overflow-hidden"
></div>
</div>
<!-- Spinner Modal -->
<div
id=
"div_spinner"
class=
"position-absolute top-50 start-50 translate-middle d-none"
>
<div
class=
"lds-roller"
>
<div></div><div></div><div></div><div></div>
<div></div><div></div><div></div><div></div>
</div>
</div>
<!-- Error Modal -->
<div
class=
"modal fade"
id=
"mdl_error"
tabindex=
"-1"
aria-labelledby=
"lbl_modal_title"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content shadow-lg"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"lbl_modal_title"
>
Error
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
<div
class=
"modal-body fs-6 fw-bold"
id=
"lbl_modal_body"
>
Please contact EMSystems to solve the issue.
</div>
<div
class=
"modal-footer justify-content-center"
>
<button
type=
"button"
id=
"btn_modal_restart"
class=
"btn btn-primary"
>
Back to Orders
</button>
</div>
</div>
</div>
</div>
<!-- Confirmation Modal -->
<div
class=
"modal fade"
id=
"main_confirmation_modal"
tabindex=
"-1"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content shadow-lg"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
>
Confirm
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
<div
class=
"modal-body fw-bold"
id=
"main_modal_body"
>
Placeholder text
</div>
<div
class=
"modal-footer justify-content-center"
>
<button
type=
"button"
class=
"btn btn-danger me-3"
id=
"btn_confirm_left"
>
Delete
</button>
<button
type=
"button"
class=
"btn btn-secondary"
id=
"btn_confirm_right"
>
Cancel
</button>
</div>
</div>
</div>
</div>
<!-- Notification Modal -->
<div
class=
"modal fade"
id=
"mdl_notification"
tabindex=
"-1"
aria-labelledby=
"lbl_notification_title"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content shadow-lg"
>
<div
class=
"modal-header"
>
<h5
class=
"modal-title"
id=
"lbl_notification_title"
>
Info
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"modal"
aria-label=
"Close"
></button>
</div>
<div
class=
"modal-body fs-6 fw-bold"
id=
"lbl_notification_body"
>
Please contact EMSystems to solve the issue.
</div>
<div
class=
"modal-footer justify-content-center"
>
<button
type=
"button"
id=
"btn_modal_close"
class=
"btn btn-primary"
>
Close
</button>
</div>
</div>
</div>
</div>
</div>
emT3XDataServer/bin/static-View.TimeEntries/View.TaskItems.html
0 → 100644
View file @
dd94c9fb
<div
class=
"container-fluid p-2 d-flex flex-column h-100 overflow-hidden"
>
<div
class=
"d-flex align-items-center justify-content-between mb-2 flex-shrink-0 gap-3"
>
<h5
class=
"mb-0"
id=
"lbl_project_name"
></h5>
<div
class=
"d-flex align-items-center gap-2 ms-auto flex-nowrap"
>
<div
id=
"lbl_total_rows"
class=
"me-2 text-nowrap"
></div>
<div
class=
"task-toolbar d-flex align-items-center gap-1 px-2 py-1"
>
<button
id=
"btn_fmt_bold"
type=
"button"
class=
"btn btn-sm btn-light task-toolbar-btn"
title=
"Bold"
>
<i
class=
"fas fa-bold"
></i>
</button>
<button
id=
"btn_fmt_italic"
type=
"button"
class=
"btn btn-sm btn-light task-toolbar-btn"
title=
"Italic"
>
<i
class=
"fas fa-italic"
></i>
</button>
<button
id=
"btn_fmt_underline"
type=
"button"
class=
"btn btn-sm btn-light task-toolbar-btn"
title=
"Underline"
>
<i
class=
"fas fa-underline"
></i>
</button>
<div
class=
"vr mx-1"
></div>
<button
id=
"btn_text_color"
type=
"button"
class=
"btn btn-sm btn-light task-toolbar-btn task-color-btn"
title=
"Text color"
>
<span
class=
"task-color-glyph"
>
A
</span>
<span
id=
"text_color_swatch"
class=
"task-color-swatch"
></span>
<input
id=
"issue_notes_text_color"
type=
"color"
class=
"task-hidden-color-input"
value=
"#000000"
>
</button>
</div>
<button
id=
"btn_add_row"
class=
"btn btn-sm btn-success text-nowrap"
>
Add Row
</button>
<button
id=
"btn_insert_row"
class=
"btn btn-sm btn-success text-nowrap"
>
Insert Row
</button>
<button
id=
"btn_copy_row"
class=
"btn btn-sm btn-primary text-nowrap"
disabled
>
Copy Row
</button>
<button
id=
"btn_delete_row"
class=
"btn btn-sm btn-danger text-nowrap"
>
Delete Row
</button>
<button
id=
"btn_reload"
class=
"btn btn-sm btn-primary text-nowrap"
>
Reload
</button>
</div>
</div>
<div
id=
"tasks_table_host"
class=
"flex-grow-1 min-h-0 overflow-auto"
></div>
<div
class=
"offcanvas offcanvas-end"
tabindex=
"-1"
id=
"offcanvasNameManager"
aria-labelledby=
"nm_title"
>
<div
class=
"offcanvas-header"
>
<h5
class=
"offcanvas-title"
id=
"nm_title"
>
Add Item
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"offcanvas"
aria-label=
"Close"
></button>
</div>
<div
class=
"offcanvas-body"
>
<div
id=
"nm_existing_list"
class=
"list-group mb-3"
></div>
<div
id=
"nm_add_wrap"
class=
"d-none mb-3"
>
<input
id=
"nm_name_input"
type=
"text"
class=
"form-control"
maxlength=
"100"
>
<div
id=
"nm_name_invalid"
class=
"invalid-feedback d-none"
></div>
<div
class=
"d-flex justify-content-end mt-2"
>
<button
id=
"btn_nm_save"
type=
"button"
class=
"btn btn-success"
>
Save
</button>
</div>
</div>
<button
id=
"btn_nm_add_another"
type=
"button"
class=
"btn btn-secondary"
>
Add another item
</button>
</div>
</div>
</div>
emT3XDataServer/bin/static-View.TimeEntries/View.TimeEntries.html
0 → 100644
View file @
dd94c9fb
<div
class=
"container-fluid p-2 d-flex flex-column h-100 overflow-hidden"
>
<div
class=
"d-flex align-items-center justify-content-between mb-2 flex-shrink-0 gap-3"
>
<h5
class=
"mb-0 text-nowrap"
id=
"lbl_time_entries_title"
></h5>
<div
class=
"d-flex align-items-center gap-2 ms-auto flex-nowrap"
>
<div
id=
"lbl_time_total_hours"
class=
"me-2 text-nowrap fw-semibold"
>
Total Hours: 0
</div>
<div
id=
"lbl_time_total_rows"
class=
"me-2 text-nowrap"
></div>
<div
class=
"d-flex align-items-center gap-2 flex-nowrap"
>
<label
for=
"edt_week_of"
class=
"form-label mb-0 text-nowrap small"
>
Week of
</label>
<input
id=
"edt_week_of"
type=
"date"
class=
"form-control form-control-sm time-date-picker"
/>
</div>
<div
class=
"d-flex align-items-center gap-2 flex-nowrap"
>
<label
for=
"edt_start_date"
class=
"form-label mb-0 text-nowrap small"
>
Start
</label>
<input
id=
"edt_start_date"
type=
"date"
class=
"form-control form-control-sm time-date-picker"
/>
</div>
<div
class=
"d-flex align-items-center gap-2 flex-nowrap"
>
<label
for=
"edt_end_date"
class=
"form-label mb-0 text-nowrap small"
>
End
</label>
<input
id=
"edt_end_date"
type=
"date"
class=
"form-control form-control-sm time-date-picker"
/>
</div>
<button
id=
"btn_search_range"
class=
"btn btn-sm btn-primary text-nowrap"
>
Search Range
</button>
<button
id=
"btn_add_entry"
class=
"btn btn-sm btn-success text-nowrap"
>
Add Entry
</button>
<button
id=
"btn_copy_entry"
class=
"btn btn-sm btn-primary text-nowrap"
disabled
>
Copy Entry
</button>
<button
id=
"btn_delete_entry"
class=
"btn btn-sm btn-danger text-nowrap"
disabled
>
Delete Entry
</button>
</div>
</div>
<div
id=
"lbl_validation_message"
class=
"alert alert-danger py-1 px-2 mb-2 invisible small"
style=
"min-height: 31px;"
></div>
<div
id=
"time_entries_table_host"
class=
"flex-grow-1 min-h-0 overflow-auto"
></div>
<div
class=
"offcanvas offcanvas-end"
tabindex=
"-1"
id=
"task_picker_offcanvas"
aria-labelledby=
"task_picker_title"
>
<div
class=
"offcanvas-header"
>
<h5
class=
"offcanvas-title"
id=
"task_picker_title"
>
Find Task
</h5>
<button
type=
"button"
class=
"btn-close"
data-bs-dismiss=
"offcanvas"
aria-label=
"Close"
></button>
</div>
<div
class=
"offcanvas-body"
>
<div
class=
"mb-3"
>
<label
for=
"task_picker_date"
class=
"form-label"
>
Work Date
</label>
<input
type=
"date"
id=
"task_picker_date"
class=
"form-control form-control-sm"
/>
<div
class=
"form-text"
>
Only tasks open on this date are listed. Select also sets the row's date.
</div>
</div>
<div
class=
"mb-3"
>
<label
for=
"task_picker_customer"
class=
"form-label"
>
Customer
</label>
<select
id=
"task_picker_customer"
class=
"form-select form-select-sm"
>
<option
value=
""
></option>
</select>
</div>
<div
class=
"mb-3"
>
<label
for=
"task_picker_project"
class=
"form-label"
>
Project
</label>
<select
id=
"task_picker_project"
class=
"form-select form-select-sm"
disabled
>
<option
value=
""
></option>
</select>
</div>
<div
class=
"mb-3"
>
<label
for=
"task_picker_task"
class=
"form-label"
>
Task
</label>
<select
id=
"task_picker_task"
class=
"form-select form-select-sm"
disabled
>
<option
value=
""
></option>
</select>
</div>
<div
id=
"task_picker_status"
class=
"alert alert-danger py-1 px-2 mb-3 d-none small"
></div>
<div
class=
"d-flex align-items-center gap-2"
>
<div
class=
"d-flex align-items-center gap-2 me-auto"
>
<input
class=
"form-check-input m-0"
type=
"checkbox"
id=
"task_picker_add_focus"
/>
<label
class=
"form-check-label mb-0"
for=
"task_picker_add_focus"
>
Focused Task
</label>
</div>
<button
type=
"button"
class=
"btn btn-outline-secondary btn-sm"
data-bs-dismiss=
"offcanvas"
>
Cancel
</button>
<button
type=
"button"
class=
"btn btn-outline-success btn-sm"
id=
"btn_task_picker_save"
disabled
>
Save
</button>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
id=
"btn_task_picker_select"
disabled
>
Select
</button>
</div>
<div
id=
"task_picker_focus_hint"
class=
"form-text d-none"
>
Completed tasks can't be added to Focused Tasks.
</div>
</div>
</div>
</div>
emT3XDataServer/bin/static-View.TimeEntries/index.html
0 → 100644
View file @
dd94c9fb
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
An error has occured
</title>
</head>
<body>
<nav>
<svg
width=
"500px"
height=
"500px"
viewBox=
"0 0 500 500"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
>
<defs>
<polygon
id=
"path-1"
points=
"1.69775 1.8321055 31.83 1.8321055 31.83 32.0148853 1.69775 32.0148853"
/>
<polygon
id=
"path-3"
points=
"0 2.18650459 346.5945 2.18650459 346.5945 199.685474 0 199.685474"
/>
<polygon
id=
"path-5"
points=
"0 0.762897248 46.607 0.762897248 46.607 41.0241358 0 41.0241358"
/>
<polygon
id=
"path-7"
points=
"0 270.813495 354.33 270.813495 354.33 2.50458716 0 2.50458716"
/>
</defs>
<g
id=
"web"
stroke=
"none"
stroke-width=
"1"
fill=
"none"
fill-rule=
"evenodd"
>
<g
id=
"Group-49"
transform=
"translate(73.000000, 114.000000)"
>
<path
d=
"M75.528,85.1887734 L75.528,118.655067 C75.528,121.527828 76.2655,123.774443 77.7455,125.389902 C79.223,127.01037 80.978,127.821856 83.0105,127.821856 C86.893,127.821856 90.173,126.063636 92.8555,122.547195 L100.6155,137.126397 C94.1455,143.049746 87.3305,146.007663 80.1705,146.007663 C73.0105,146.007663 66.958,143.653351 62.0155,138.9297 C57.073,134.206049 54.6005,127.776773 54.6005,119.626847 L54.6005,85.1887734 L45.868,85.1887734 L45.868,70.1938101 L54.6005,70.1938101 L54.6005,47.8353606 L75.528,47.8353606 L75.528,70.1938101 L93.548,70.1938101 L93.548,85.1887734 L75.528,85.1887734 Z"
id=
"Fill-1"
fill=
"#171716"
/>
<path
d=
"M180.163,104.633637 L180.163,144.899884 L159.238,144.899884 L159.238,104.075114 C159.238,98.1517651 158.338,93.7987927 156.533,91.0212055 C154.733,88.2461229 151.823,86.8560771 147.8055,86.8560771 C143.783,86.8560771 140.223,88.3613339 137.133,91.3718477 C134.033,94.3823615 132.4905,98.8004532 132.4905,104.633637 L132.4905,144.899884 L111.698,144.899884 L111.698,70.1955633 L132.4905,70.1955633 L132.4905,78.6610679 C138.218,72.1867101 144.778,68.9432697 152.168,68.9432697 C156.8805,68.9432697 161.153,70.330811 164.988,73.1083982 C168.8205,75.8834807 171.7105,79.2646734 173.653,83.2494716 C176.5155,78.7136642 180.3755,75.1897101 185.223,72.6926367 C190.0755,70.1955633 194.948,68.9432697 199.848,68.9432697 C208.623,68.9432697 215.6905,71.5630679 221.0505,76.7926459 C226.408,82.0222239 229.088,89.5885817 229.088,99.4942239 L229.088,144.899884 L208.1605,144.899884 L208.1605,104.075114 C208.1605,92.5990954 203.958,86.8560771 195.5505,86.8560771 C191.3905,86.8560771 187.7905,88.3613339 184.738,91.3718477 C181.688,94.3823615 180.163,98.8004532 180.163,104.633637"
id=
"Fill-3"
fill=
"#171716"
/>
<path
d=
"M304.06925,121.638531 C304.06925,129.002017 301.36425,134.90032 295.96175,139.343458 C290.55425,143.7891 283.69675,146.00566 275.37675,146.00566 C269.83425,146.00566 264.05675,145.016348 258.05675,143.022696 C252.04675,141.039063 246.64175,138.098678 241.83925,134.20655 L250.98675,121.152641 C258.74675,127.173669 267.01425,130.184183 275.79425,130.184183 C278.47425,130.184183 280.59675,129.650706 282.16925,128.586256 C283.74175,127.524311 284.52675,126.109219 284.52675,124.350999 C284.52675,122.592779 283.43925,120.969806 281.26675,119.4921 C279.09925,118.011889 275.95425,116.624348 271.84425,115.324467 C267.73425,114.027091 264.58925,112.920063 262.41925,111.990861 C260.24675,111.069173 257.77425,109.726715 255.00425,107.963485 C249.36675,104.44454 246.54925,99.2425128 246.54925,92.3448798 C246.54925,85.4472468 249.32425,79.821944 254.86425,75.4689716 C260.40925,71.1235128 267.56925,68.9420174 276.34925,68.9420174 C285.12675,68.9420174 293.90175,71.9074486 302.68175,77.8307972 L294.92175,91.7162284 C288.45175,87.2705862 282.00925,85.0540266 275.58675,85.0540266 C269.16425,85.0540266 265.95675,86.8097422 265.95675,90.3286872 C265.95675,92.2722468 266.96925,93.7975404 269.00425,94.9145862 C271.03425,96.0241183 274.40925,97.3214945 279.12175,98.7992009 C283.83175,100.279412 287.17925,101.416494 289.16675,102.20043 C291.15675,102.99188 293.53675,104.211614 296.30925,105.879669 C301.48175,109.02543 304.06925,114.280054 304.06925,121.638531"
id=
"Fill-5"
fill=
"#171716"
/>
<path
d=
"M331.938,135.338122 L331.938,185.319663 L54.603,185.319663 L54.603,200.004058 L346.593,200.004058 L346.593,135.335617 C344.2505,135.931709 341.8055,136.264819 339.2655,136.264819 C336.7255,136.264819 334.2805,135.931709 331.938,135.338122"
id=
"Fill-7"
fill=
"#000000"
/>
<g
id=
"Group-11"
transform=
"translate(322.500000, 90.483220)"
>
<mask
id=
"mask-2"
fill=
"white"
>
<polygon
points=
"1.69775 1.8321055 31.83 1.8321055 31.83 32.0148853 1.69775 32.0148853"
transform=
"matrix(1, 0, 0, 1, 0, 0)"
/>
</mask>
<g
id=
"Clip-10"
/>
<path
d=
"M27.46275,27.6468853 C30.37525,24.7290413 31.83025,21.1549954 31.83025,16.9247477 C31.83025,12.6919954 30.37525,9.11794954 27.46275,6.2001055 C24.55275,3.29227982 20.98275,1.8321055 16.76525,1.8321055 C12.54025,1.8321055 8.97275,3.29227982 6.06525,6.2001055 C3.15275,9.11794954 1.69775,12.6919954 1.69775,16.9247477 C1.69775,21.1549954 3.15275,24.7290413 6.06525,27.6468853 C8.97275,30.5647294 12.54025,32.0148853 16.76525,32.0148853 C20.98275,32.0148853 24.55275,30.5647294 27.46275,27.6468853"
id=
"Fill-9"
fill=
"#009BDE"
mask=
"url(#mask-2)"
/>
</g>
<g
id=
"Group-14"
transform=
"translate(0.000000, 0.318083)"
>
<g
id=
"Clip-13"
/>
</g>
<g
id=
"Group-17"
transform=
"translate(0.000000, 215.712578)"
>
<g
id=
"Clip-16"
/>
</g>
<mask
id=
"mask-8"
fill=
"white"
>
<polygon
points=
"0 270.813495 354.33 270.813495 354.33 2.50458716 0 2.50458716"
transform=
"matrix(1, 0, 0, 1, 0, 0)"
/>
</mask>
<g
id=
"Clip-19"
/>
<path
d=
"M80.594,228.646266 L80.619,228.721404 C80.464,230.489642 79.834,231.887202 78.729,232.90156 C77.6215,233.915917 76.139,234.426853 74.2815,234.426853 C72.319,234.426853 70.7365,233.713046 69.5315,232.29545 C68.329,230.875349 67.7265,229.034477 67.7265,226.780349 L67.7265,223.900073 C67.7265,221.650954 68.329,219.815092 69.5315,218.382468 C70.7365,216.954853 72.319,216.241046 74.2815,216.241046 C76.154,216.241046 77.6415,216.739459 78.739,217.736284 C79.839,218.730606 80.464,220.133174 80.619,221.933972 L80.594,222.006606 L79.2365,222.006606 C79.044,220.543927 78.5415,219.419367 77.729,218.64545 C76.9165,217.869028 75.7665,217.478312 74.2815,217.478312 C72.7365,217.478312 71.5015,218.076908 70.5665,219.274101 C69.6365,220.471294 69.169,222.004101 69.169,223.872523 L69.169,226.77033 C69.169,228.663798 69.6365,230.204119 70.5665,231.398807 C71.5015,232.588486 72.7365,233.187083 74.2815,233.187083 C75.7665,233.187083 76.919,232.806385 77.734,232.05 C78.5515,231.29111 79.049,230.159037 79.2365,228.646266 L80.594,228.646266 Z"
id=
"Fill-20"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<polygon
id=
"Fill-21"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"94.28525 225.613211 85.79025 225.613211 85.79025 232.931615 95.52025 232.931615 95.52025 234.171385 84.34775 234.171385 84.34775 216.496514 95.46025 216.496514 95.46025 217.73378 85.79025 217.73378 85.79025 224.375945 94.28525 224.375945"
/>
<path
d=
"M100.052,224.945488 L104.402,224.945488 C105.992,224.945488 107.1545,224.622396 107.892,223.978717 C108.627,223.335039 108.9945,222.468451 108.9945,221.376451 C108.9945,220.211818 108.627,219.315176 107.897,218.686525 C107.1645,218.060378 106.062,217.7448 104.582,217.7448 L100.052,217.7448 L100.052,224.945488 Z M100.052,226.182754 L100.052,234.172387 L98.6095,234.172387 L98.6095,216.507534 L104.582,216.507534 C106.4745,216.507534 107.9245,216.923295 108.9345,217.754818 C109.9445,218.583837 110.447,219.793552 110.447,221.388974 C110.447,222.32569 110.177,223.167231 109.6345,223.908589 C109.0945,224.647442 108.332,225.188433 107.3445,225.526552 C108.437,225.802057 109.222,226.295461 109.702,227.001754 C110.1845,227.710552 110.4245,228.599681 110.4245,229.669139 L110.4245,231.329681 C110.4245,231.88069 110.487,232.374094 110.617,232.809892 C110.747,233.24569 110.9595,233.603846 111.2595,233.876846 L111.2595,234.172387 L109.782,234.172387 C109.482,233.876846 109.272,233.471103 109.152,232.942635 C109.0295,232.416672 108.9695,231.873176 108.9695,231.307139 L108.9695,229.691681 C108.9695,228.607194 108.6195,227.750626 107.9195,227.124479 C107.222,226.498332 106.247,226.182754 104.997,226.182754 L100.052,226.182754 Z"
id=
"Fill-22"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<polygon
id=
"Fill-23"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"125.8355 217.735032 119.7655 217.735032 119.7655 234.170133 118.3105 234.170133 118.3105 217.735032 112.243 217.735032 112.243 216.497766 125.8355 216.497766"
/>
<polygon
id=
"Fill-24"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"129.0225 234.171385 130.4775 234.171385 130.4775 216.496514 129.0225 216.496514"
/>
<polygon
id=
"Fill-25"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"145.44 225.87995 136.86 225.87995 136.86 234.172638 135.42 234.172638 135.42 216.497766 146.6775 216.497766 146.6775 217.735032 136.86 217.735032 136.86 224.642683 145.44 224.642683"
/>
<polygon
id=
"Fill-26"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"150.0425 234.171385 151.4975 234.171385 151.4975 216.496514 150.0425 216.496514"
/>
<polygon
id=
"Fill-27"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"166.37775 225.613211 157.88275 225.613211 157.88275 232.931615 167.61525 232.931615 167.61525 234.171385 156.44025 234.171385 156.44025 216.496514 167.55275 216.496514 167.55275 217.73378 157.88275 217.73378 157.88275 224.375945 166.37775 224.375945"
/>
<path
d=
"M172.18075,217.735032 L172.18075,232.930362 L175.86325,232.930362 C177.60825,232.930362 179.04575,232.321748 180.17325,231.102014 C181.30075,229.879775 181.86325,228.334445 181.86325,226.466023 L181.86325,224.161803 C181.86325,222.318427 181.29575,220.788124 180.16825,219.565885 C179.03575,218.343647 177.60075,217.735032 175.86325,217.735032 L172.18075,217.735032 Z M170.73825,234.170133 L170.73825,216.497766 L175.86325,216.497766 C178.01825,216.497766 179.80075,217.216583 181.20575,218.65672 C182.61075,220.096858 183.31825,221.950252 183.31825,224.204381 L183.31825,226.476041 C183.31825,228.742693 182.61075,230.588573 181.20575,232.021197 C179.80075,233.453821 178.01825,234.170133 175.86325,234.170133 L170.73825,234.170133 Z"
id=
"Fill-28"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<path
d=
"M194.499,225.588917 L199.1265,225.588917 C200.5815,225.588917 201.674,225.218238 202.404,224.479384 C203.134,223.738027 203.5015,222.80632 203.5015,221.679256 C203.5015,220.547183 203.1365,219.605458 202.4115,218.856586 C201.684,218.112724 200.5915,217.734531 199.1265,217.734531 L194.499,217.734531 L194.499,225.588917 Z M194.499,226.826183 L194.499,234.172137 L193.0565,234.172137 L193.0565,216.497265 L199.1265,216.497265 C200.9765,216.497265 202.409,216.970632 203.4215,217.912357 C204.439,218.854082 204.944,220.103871 204.944,221.656715 C204.944,223.227091 204.439,224.481889 203.4215,225.418605 C202.409,226.357825 200.9765,226.826183 199.1265,226.826183 L194.499,226.826183 Z"
id=
"Fill-29"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<path
d=
"M208.61525,227.941726 L215.74025,227.941726 L212.22525,218.379212 L212.15275,218.379212 L208.61525,227.941726 Z M216.21275,229.244111 L208.13275,229.244111 L206.31275,234.170634 L204.81275,234.170634 L211.51275,216.498267 L212.88275,216.498267 L219.53025,234.170634 L218.03025,234.170634 L216.21275,229.244111 Z"
id=
"Fill-30"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<path
d=
"M223.6395,224.945488 L227.9895,224.945488 C229.582,224.945488 230.747,224.622396 231.4795,223.978717 C232.2145,223.335039 232.582,222.468451 232.582,221.376451 C232.582,220.211818 232.2195,219.315176 231.4845,218.686525 C230.7545,218.060378 229.6495,217.7448 228.1695,217.7448 L223.6395,217.7448 L223.6395,224.945488 Z M223.6395,226.182754 L223.6395,234.172387 L222.1995,234.172387 L222.1995,216.507534 L228.1695,216.507534 C230.062,216.507534 231.512,216.923295 232.522,217.754818 C233.532,218.583837 234.037,219.793552 234.037,221.388974 C234.037,222.32569 233.7645,223.167231 233.222,223.908589 C232.6845,224.647442 231.922,225.188433 230.9345,225.526552 C232.0245,225.802057 232.8095,226.295461 233.2895,227.001754 C233.772,227.710552 234.012,228.599681 234.012,229.669139 L234.012,231.329681 C234.012,231.88069 234.077,232.374094 234.207,232.809892 C234.3345,233.24569 234.547,233.603846 234.847,233.876846 L234.847,234.172387 L233.372,234.172387 C233.0695,233.876846 232.862,233.471103 232.7395,232.942635 C232.617,232.416672 232.5545,231.873176 232.5545,231.307139 L232.5545,229.691681 C232.5545,228.607194 232.2095,227.750626 231.507,227.124479 C230.812,226.498332 229.8345,226.182754 228.5845,226.182754 L223.6395,226.182754 Z"
id=
"Fill-31"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<polygon
id=
"Fill-32"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"249.42325 217.735032 243.35325 217.735032 243.35325 234.170133 241.90075 234.170133 241.90075 217.735032 235.83075 217.735032 235.83075 216.497766 249.42325 216.497766"
/>
<polygon
id=
"Fill-33"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"265.285 234.171385 263.8425 234.171385 253.8225 218.97355 253.7525 218.986073 253.7525 234.171385 252.295 234.171385 252.295 216.496514 253.7525 216.496514 263.77 231.669303 263.8425 231.65678 263.8425 216.496514 265.285 216.496514"
/>
<polygon
id=
"Fill-34"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"279.848 225.613211 271.3555 225.613211 271.3555 232.931615 281.083 232.931615 281.083 234.171385 269.9105 234.171385 269.9105 216.496514 281.023 216.496514 281.023 217.73378 271.3555 217.73378 271.3555 224.375945 279.848 224.375945"
/>
<path
d=
"M285.61475,224.945488 L289.96475,224.945488 C291.55725,224.945488 292.71975,224.622396 293.45475,223.978717 C294.18975,223.335039 294.55475,222.468451 294.55475,221.376451 C294.55475,220.211818 294.19225,219.315176 293.45975,218.686525 C292.72975,218.060378 291.62475,217.7448 290.14475,217.7448 L285.61475,217.7448 L285.61475,224.945488 Z M285.61475,226.182754 L285.61475,234.172387 L284.17225,234.172387 L284.17225,216.507534 L290.14475,216.507534 C292.03475,216.507534 293.48475,216.923295 294.49475,217.754818 C295.50725,218.583837 296.01225,219.793552 296.01225,221.388974 C296.01225,222.32569 295.73975,223.167231 295.19725,223.908589 C294.65975,224.647442 293.89725,225.188433 292.90975,225.526552 C293.99975,225.802057 294.78475,226.295461 295.26475,227.001754 C295.74475,227.710552 295.98475,228.599681 295.98475,229.669139 L295.98475,231.329681 C295.98475,231.88069 296.05225,232.374094 296.18225,232.809892 C296.30725,233.24569 296.52225,233.603846 296.82225,233.876846 L296.82225,234.172387 L295.34725,234.172387 C295.04475,233.876846 294.83475,233.471103 294.71475,232.942635 C294.59225,232.416672 294.52975,231.873176 294.52975,231.307139 L294.52975,229.691681 C294.52975,228.607194 294.18475,227.750626 293.48225,227.124479 C292.78725,226.498332 291.80975,226.182754 290.55975,226.182754 L285.61475,226.182754 Z"
id=
"Fill-35"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<polygon
id=
"Fill-36"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"72.331 251.312279 72.331 251.33482 72.341 251.272206 75.8685 238.346031 78.2185 238.346031 81.781 251.312279 81.7935 251.39493 81.806 251.272206 84.591 238.346031 87.486 238.346031 83.296 256.020903 80.6185 256.020903 77.091 243.335169 77.0185 243.335169 73.481 256.020903 70.791 256.020903 66.611 238.346031 69.5085 238.346031"
/>
<polygon
id=
"Fill-37"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"100.67075 248.071343 92.95325 248.071343 92.95325 253.654068 101.90825 253.654068 101.90825 256.020903 90.00825 256.020903 90.00825 238.346031 101.82075 238.346031 101.82075 240.715371 92.95325 240.715371 92.95325 245.704508 100.67075 245.704508"
/>
<path
d=
"M107.33475,247.985686 L107.33475,253.653567 L111.04225,253.653567 C112.05975,253.653567 112.84475,253.423145 113.39225,252.957292 C113.94225,252.493943 114.21725,251.820209 114.21725,250.941099 C114.21725,250.006888 113.98725,249.280558 113.52725,248.762108 C113.06475,248.243659 112.34725,247.985686 111.36975,247.985686 L107.33475,247.985686 Z M107.33475,245.789163 L110.58225,245.789163 C111.49475,245.789163 112.21475,245.571264 112.74475,245.140475 C113.27225,244.704677 113.53975,244.093558 113.53975,243.302108 C113.53975,242.425503 113.25975,241.776815 112.70225,241.353539 C112.14475,240.92776 111.32975,240.717374 110.25475,240.717374 L107.33475,240.717374 L107.33475,245.789163 Z M104.38975,256.020402 L104.38975,238.34553 L110.25475,238.34553 C112.20975,238.34553 113.73725,238.748769 114.83475,239.555246 C115.93225,240.359218 116.48225,241.566429 116.48225,243.166861 C116.48225,243.968328 116.25225,244.68464 115.79225,245.315796 C115.33225,245.949457 114.69225,246.41531 113.87725,246.723374 C114.92725,246.958806 115.73475,247.464732 116.30225,248.241154 C116.86725,249.017576 117.14975,249.916723 117.14975,250.948613 C117.14975,252.60665 116.60725,253.868961 115.52475,254.72553 C114.44225,255.589613 112.94975,256.020402 111.04225,256.020402 L104.38975,256.020402 Z"
id=
"Fill-38"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<path
d=
"M139.33425,250.157664 L139.35925,250.230297 C139.38925,252.018572 138.81175,253.473738 137.61925,254.593288 C136.42675,255.715343 134.81425,256.276371 132.77925,256.276371 C130.71925,256.276371 129.04675,255.5826 127.75675,254.195059 C126.46925,252.807517 125.82425,251.031765 125.82425,248.870306 L125.82425,245.511655 C125.82425,243.355206 126.46175,241.584462 127.73425,240.186903 C129.00675,238.789343 130.65925,238.093068 132.69425,238.093068 C134.77925,238.093068 136.41925,238.641572 137.61925,239.738582 C138.81925,240.835591 139.40175,242.310793 139.37175,244.159178 L139.34675,244.23682 L136.49925,244.23682 C136.49925,243.044637 136.17675,242.117939 135.53675,241.454224 C134.89425,240.790508 133.94675,240.459903 132.69425,240.459903 C131.48925,240.459903 130.53675,240.935774 129.82925,241.890022 C129.12175,242.84427 128.76925,244.041462 128.76925,245.4816 L128.76925,248.862793 C128.76925,250.317958 129.12925,251.525169 129.85425,252.479417 C130.57675,253.433664 131.55175,253.909536 132.77925,253.909536 C133.99925,253.909536 134.92425,253.583939 135.55425,252.927738 C136.18425,252.276545 136.49925,251.352352 136.49925,250.157664 L139.33425,250.157664 Z"
id=
"Fill-39"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<path
d=
"M153.061,245.569261 C153.061,244.096563 152.6685,242.886848 151.881,241.940114 C151.0935,240.99338 150.0285,240.520013 148.686,240.520013 C147.396,240.520013 146.3735,240.99338 145.621,241.940114 C144.871,242.886848 144.496,244.096563 144.496,245.569261 L144.496,248.775132 C144.496,250.262857 144.871,251.482591 145.621,252.434334 C146.3735,253.386077 147.3985,253.861949 148.6985,253.861949 C150.0485,253.861949 151.1135,253.386077 151.8935,252.439343 C152.671,251.492609 153.061,250.272875 153.061,248.775132 L153.061,245.569261 Z M155.9935,248.775132 C155.9935,250.936591 155.316,252.724866 153.9635,254.147472 C152.611,255.565068 150.856,256.276371 148.6985,256.276371 C146.5835,256.276371 144.866,255.565068 143.5435,254.147472 C142.2235,252.724866 141.5635,250.936591 141.5635,248.775132 L141.5635,245.594306 C141.5635,243.442866 142.2235,241.654591 143.5435,240.229481 C144.866,238.804371 146.5785,238.093068 148.686,238.093068 C150.8435,238.093068 152.601,238.804371 153.9585,240.229481 C155.316,241.654591 155.9935,243.442866 155.9935,245.594306 L155.9935,248.775132 Z"
id=
"Fill-40"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<polygon
id=
"Fill-41"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"162.9975 238.346532 168.0725 251.941431 168.1475 251.941431 173.235 238.346532 177.0525 238.346532 177.0525 256.021404 174.1075 256.021404 174.1075 249.997872 174.4 242.341349 174.325 242.33133 169.0925 256.021404 167.115 256.021404 161.9075 242.36389 161.835 242.376413 162.125 249.997872 162.125 256.021404 159.18 256.021404 159.18 238.346532"
/>
<path
d=
"M183.85925,246.95605 L187.80925,246.95605 C188.90175,246.95605 189.72175,246.663014 190.26925,246.079445 C190.81925,245.495876 191.09675,244.757023 191.09675,243.857876 C191.09675,242.961234 190.81925,242.212362 190.26925,241.611261 C189.72175,241.012665 188.90175,240.717124 187.80925,240.717124 L183.85925,240.717124 L183.85925,246.95605 Z M183.85925,249.320381 L183.85925,256.020151 L180.91675,256.020151 L180.91675,238.34528 L187.80925,238.34528 C189.75675,238.34528 191.28175,238.851206 192.38425,239.85805 C193.48925,240.864894 194.03675,242.192326 194.03675,243.835335 C194.03675,245.493372 193.48925,246.820803 192.38425,247.825142 C191.28175,248.821968 189.75675,249.320381 187.80925,249.320381 L183.85925,249.320381 Z"
id=
"Fill-42"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<path
d=
"M207.768,245.569261 C207.768,244.096563 207.373,242.886848 206.583,241.940114 C205.798,240.99338 204.733,240.520013 203.393,240.520013 C202.1005,240.520013 201.078,240.99338 200.328,241.940114 C199.578,242.886848 199.2005,244.096563 199.2005,245.569261 L199.2005,248.775132 C199.2005,250.262857 199.578,251.482591 200.328,252.434334 C201.078,253.386077 202.103,253.861949 203.403,253.861949 C204.753,253.861949 205.818,253.386077 206.598,252.439343 C207.3755,251.492609 207.768,250.272875 207.768,248.775132 L207.768,245.569261 Z M210.698,248.775132 C210.698,250.936591 210.023,252.724866 208.6705,254.147472 C207.318,255.565068 205.5605,256.276371 203.403,256.276371 C201.2905,256.276371 199.5705,255.565068 198.248,254.147472 C196.928,252.724866 196.2655,250.936591 196.2655,248.775132 L196.2655,245.594306 C196.2655,243.442866 196.928,241.654591 198.248,240.229481 C199.5705,238.804371 201.283,238.093068 203.393,238.093068 C205.548,238.093068 207.3055,238.804371 208.6605,240.229481 C210.0205,241.654591 210.698,243.442866 210.698,245.594306 L210.698,248.775132 Z"
id=
"Fill-43"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
<polygon
id=
"Fill-44"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"227.663 256.020402 224.728 256.020402 216.903 243.119273 216.828 243.141815 216.828 256.020402 213.8855 256.020402 213.8855 238.34553 216.828 238.34553 224.658 251.239145 224.728 251.214099 224.728 238.34553 227.663 238.34553"
/>
<polygon
id=
"Fill-45"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"242.1895 248.071343 234.4695 248.071343 234.4695 253.654068 243.4245 253.654068 243.4245 256.020903 231.527 256.020903 231.527 238.346031 243.3395 238.346031 243.3395 240.715371 234.4695 240.715371 234.4695 245.704508 242.1895 245.704508"
/>
<polygon
id=
"Fill-46"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"259.687 256.020402 256.752 256.020402 248.927 243.119273 248.8545 243.141815 248.8545 256.020402 245.912 256.020402 245.912 238.34553 248.8545 238.34553 256.682 251.239145 256.752 251.214099 256.752 238.34553 259.687 238.34553"
/>
<polygon
id=
"Fill-47"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
points=
"275.60975 240.716623 270.27475 240.716623 270.27475 256.01965 267.32975 256.01965 267.32975 240.716623 262.00225 240.716623 262.00225 238.347283 275.60975 238.347283"
/>
<path
d=
"M287.265,251.468816 C287.265,250.734972 286.9925,250.136375 286.4475,249.668017 C285.9,249.202164 284.9375,248.781394 283.5575,248.410715 C281.5875,247.892265 280.07,247.208513 279.005,246.354449 C277.945,245.49788 277.415,244.380834 277.415,242.998302 C277.415,241.573192 278,240.39854 279.18,239.476852 C280.3525,238.555164 281.87,238.091816 283.725,238.091816 C285.6625,238.091816 287.2225,238.617779 288.3975,239.664696 C289.5725,240.714118 290.1375,241.968917 290.1,243.4341 L290.075,243.506733 L287.2525,243.506733 C287.2525,242.600072 286.945,241.866228 286.33,241.302696 C285.7175,240.741669 284.8425,240.45865 283.7025,240.45865 C282.63,240.45865 281.8025,240.694082 281.225,241.162439 C280.65,241.630797 280.3575,242.234403 280.3575,242.978265 C280.3575,243.649494 280.67,244.205513 281.2975,244.648825 C281.9225,245.097146 282.9575,245.512907 284.405,245.911137 C286.3025,246.419568 287.745,247.125861 288.7325,248.022504 C289.715,248.919146 290.21,250.066247 290.21,251.456293 C290.21,252.92899 289.62,254.101137 288.445,254.970228 C287.27,255.83932 285.725,256.277623 283.8125,256.277623 C281.97,256.277623 280.3525,255.786724 278.965,254.802421 C277.575,253.815614 276.9,252.47566 276.9425,250.780054 L276.965,250.702412 L279.8025,250.702412 C279.8025,251.779384 280.1725,252.583357 280.915,253.111825 C281.66,253.645302 282.625,253.910788 283.8125,253.910788 C284.905,253.910788 285.7525,253.690384 286.3575,253.249577 C286.9625,252.813779 287.265,252.217687 287.265,251.468816"
id=
"Fill-48"
fill=
"#FFFFFF"
mask=
"url(#mask-8)"
/>
</g>
</g>
</svg>
</nav>
<div
class=
"error"
>
<h1>
Error
</h1>
</div>
<div
class=
"console"
>
Error during compilation
</div>
<style>
:root
{
--red
:
#fd4d4d
;
--tms-blue
:
#009ee3
;
}
@media
(
prefers-color-scheme
:
light
)
{
:root
{
--background
:
#ffffff
;
--background-console
:
#f6f6f6
;
--background-invert
:
#0b0e11
;
--console-shadow
:
0
1px
3px
rgba
(
0
,
0
,
0
,
0.2
);
}
nav
svg
#Fill-20
,
nav
svg
#Fill-21
,
nav
svg
#Fill-22
,
nav
svg
#Fill-23
,
nav
svg
#Fill-24
,
nav
svg
#Fill-25
,
nav
svg
#Fill-26
,
nav
svg
#Fill-27
,
nav
svg
#Fill-28
,
nav
svg
#Fill-29
,
nav
svg
#Fill-30
,
nav
svg
#Fill-31
,
nav
svg
#Fill-32
,
nav
svg
#Fill-33
,
nav
svg
#Fill-34
,
nav
svg
#Fill-35
{
fill
:
var
(
--background-invert
);
}
nav
svg
#Fill-36
,
nav
svg
#Fill-37
,
nav
svg
#Fill-38
,
nav
svg
#Fill-38
,
nav
svg
#Fill-39
,
nav
svg
#Fill-40
,
nav
svg
#Fill-41
,
nav
svg
#Fill-42
,
nav
svg
#Fill-43
,
nav
svg
#Fill-44
,
nav
svg
#Fill-45
,
nav
svg
#Fill-46
,
nav
svg
#Fill-47
,
nav
svg
#Fill-48
{
fill
:
var
(
--background-invert
);
}
}
@media
(
prefers-color-scheme
:
dark
)
{
:root
{
--background
:
#0b0e11
;
--background-console
:
#151a21
;
--background-invert
:
#ffffff
;
--console-shadow
:
0
1px
3px
rgba
(
0
,
0
,
0
,
0.5
);
}
}
::selection
{
background
:
var
(
--tms-blue
);
color
:
white
;
}
*
{
margin
:
0
;
padding
:
0
;
box-sizing
:
border-box
;
}
body
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
height
:
100vh
;
overflow
:
hidden
;
font-family
:
sans-serif
;
font-size
:
12px
;
font-weight
:
400
;
background
:
var
(
--background
);
padding
:
20px
;
}
nav
{
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
200px
;
padding
:
0
;
}
nav
svg
{
height
:
100%
;
width
:
auto
;
transform
:
translate
(
-25px
,
-40px
);
}
nav
svg
#Fill-1
,
nav
svg
#Fill-3
,
nav
svg
#Fill-5
,
nav
svg
#Fill-7
{
fill
:
var
(
--background-invert
);
}
.error
{
color
:
var
(
--red
);
z-index
:
1
;
}
.error
h1
{
font-size
:
7vmin
;
}
.console
{
background
:
var
(
--background-console
);
border-radius
:
8px
;
width
:
80vw
;
min-height
:
60px
;
max-height
:
calc
(
100%
-
20px
-
50px
-
60px
);
font-size
:
20px
;
color
:
var
(
--background-invert
);
padding
:
20px
;
transform
:
translateY
(
50px
);
box-shadow
:
var
(
--console-shadow
);
font-family
:
"Consolas"
,
sans-serif
;
overflow
:
auto
;
}
@media
only
screen
and
(
max-width
:
550px
)
{
.console
{
margin-top
:
50px
;
}
}
@media
only
screen
and
(
max-width
:
450px
)
{
.error
{
position
:
absolute
;
top
:
5vh
;
right
:
20vw
;
}
}
@media
only
screen
and
(
max-width
:
250px
)
{
.error
{
display
:
none
;
}
}
</style>
</body>
</html>
emT3XDataServer/emT3XDataServer.dproj
View file @
dd94c9fb
...
@@ -114,10 +114,11 @@
...
@@ -114,10 +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.4.
0
;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.4.
1
;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>1</VerInfo_Build>
<VerInfo_Release>4</VerInfo_Release>
<VerInfo_Release>4</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