Commit dd94c9fb by Daniel Barker

Deal with copy directory

parent 236fcdca
...@@ -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);
......
...@@ -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);
......
...@@ -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('main_errormodal'); var modal = document.getElementById('mdl_error');
var label = document.getElementById('main_lblmodal_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('main_notification_modal'); var modal = document.getElementById('mdl_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;
......
...@@ -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
......
...@@ -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>
......
...@@ -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 // Time Entries always opens on the current week, so no date goes in the URL
newUrl := window.location.pathname + '?time_entries=true&date=' + edtDate.Text
else
newUrl := window.location.pathname + '?time_entries=true'; 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
......
...@@ -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>
......
...@@ -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
......
...@@ -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
......
<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">
......
...@@ -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;
......
...@@ -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
OnExit = edtWeekOfExit OnChange = edtWeekOfChange
end end
object edtStartDate: TWebEdit object edtStartDate: TWebEdit
Left = 245 Left = 245
......
...@@ -43,45 +43,75 @@ ...@@ -43,45 +43,75 @@
<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">
<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> </div>
<div class="offcanvas-body"> <div class="modal-body">
<div class="mb-3"> <div class="row g-2 mb-3">
<div class="col-md-4">
<label for="task_picker_date" class="form-label">Work Date</label>
<input type="date" id="task_picker_date" class="form-control form-control-sm"
title="Select also sets the row's date. Only projects and tasks open on this date are listed." />
</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> <label for="task_picker_customer" class="form-label">Customer</label>
<select id="task_picker_customer" class="form-select form-select-sm"> <select id="task_picker_customer" class="form-select form-select-sm">
<option value=""></option> <option value=""></option>
</select> </select>
</div> </div>
<div class="mb-3"> <div class="col-md">
<label for="task_picker_project" class="form-label">Project</label> <label for="task_picker_project" class="form-label">Project</label>
<select id="task_picker_project" class="form-select form-select-sm" disabled> <select id="task_picker_project" class="form-select form-select-sm" disabled>
<option value=""></option> <option value=""></option>
</select> </select>
</div> </div>
</div>
<div class="mb-3"> <div class="row g-2 align-items-end mb-3">
<div class="col-md">
<label for="task_picker_task" class="form-label">Task</label> <label for="task_picker_task" class="form-label">Task</label>
<select id="task_picker_task" class="form-select form-select-sm" disabled> <select id="task_picker_task" class="form-select form-select-sm" disabled>
<option value=""></option> <option value=""></option>
</select> </select>
</div> </div>
</div>
<div id="task_picker_status" class="alert alert-danger py-1 px-2 mb-3 d-none small"></div> <div id="task_picker_status" class="alert alert-danger py-1 px-2 mb-0 d-none small"></div>
</div>
<div class="modal-footer">
<div class="d-flex align-items-center gap-2"> <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" /> <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"> <label class="form-check-label mb-0" for="task_picker_add_focus">
Focused Task Focused Task
</label> </label>
</div> </div>
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="offcanvas"> <!-- 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 Cancel
</button> </button>
...@@ -95,4 +125,5 @@ ...@@ -95,4 +125,5 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
...@@ -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 edtWeekOfExit(Sender: TObject); procedure edtWeekOfChange(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
// Back from Task Items: reopen on the range (and kept entries) that was showing
FUpdatingDates := True;
try
edtWeekOf.Text := DMConnection.timeEntriesWeekOf;
edtStartDate.Text := DMConnection.timeEntriesStartDate;
edtEndDate.Text := DMConnection.timeEntriesEndDate;
if anchorDate = '' then FStartDate := edtStartDate.Text;
anchorDate := Application.Parameters.Values['date']; 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:500px">' + // Task '<col style="width:540px">' + // Task
'<col style="width:90px">' + // Hours '<col style="width:90px">' + // Hours
'<col style="width:150px">' + // Time '<col style="width:140px">' + // Time
'<col style="width:160px">' + // Place '<col style="width:160px">' + // Place
'<col style="width:190px">' + // Category '<col style="width:190px">' + // Category
'<col style="width:480px">' + // Summary '<col style="width:450px">' + // 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.EditedDateSaveClick(Event: TJSEvent); [async] procedure TFTimeEntries.EntryDraftSaveClick(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.EditedDateCancelClick(Event: TJSEvent); procedure TFTimeEntries.EntryDraftCancelClick(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(@EditedDateCancelClick)); el.addEventListener('click', TJSEventHandler(@EntryDraftCancelClick));
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(@EditedDateSaveClick)); el.addEventListener('click', TJSEventHandler(@EntryDraftSaveClick));
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
SaveField(idx, fieldName); ShowEntryDraftActions(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 := '';
taskDate := '';
GotoRowIndex(idx);
if not xdwdsTimeEntries.Eof then
begin
taskId := xdwdsTimeEntriestaskId.AsString;
taskDate := xdwdsTimeEntriestaskDate.AsString;
end;
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 := ''; taskId := '';
GotoRowIndex(idx); GotoRowIndex(idx);
if not xdwdsTimeEntries.Eof then if not xdwdsTimeEntries.Eof then
taskId := xdwdsTimeEntriestaskId.AsString; taskId := xdwdsTimeEntriestaskId.AsString;
await(FTaskPickerOffCanvas.Open(FUserId, idx, FTaskOptions, taskId)); 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;
......
...@@ -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;
}
...@@ -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>
......
...@@ -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;
// 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; end;
if not projectFound then // 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; focus changes happen through Save // Sends the task and work date to the grid only; focus and status 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,42 +1020,76 @@ begin ...@@ -568,42 +1020,76 @@ 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');
statusSaved := False;
focusFailed := False;
ClearStatus;
FSaving := True;
UpdateButtons;
try
// Status first: closing the task decides whether it can still be focused
if statusChanged then
begin
try
await(FClient.RawInvokeAsync('ITimeEntryService.SetTaskStatus',
[taskId, newStatus, PickerDate]));
statusSaved := True;
except
on E: EXDataClientRequestException do
SetStatus(E.ErrorResult.ErrorMessage);
on E: Exception do
SetStatus('Unable to save task status.');
end;
if not statusSaved then
Exit;
if SelectedValue('task_picker_task') = taskId then
FSavedTaskStatus := newStatus;
end;
if focusChanged then
begin
if focused then if focused then
methodName := 'ITimeEntryService.AddTaskToFocus' methodName := 'ITimeEntryService.AddTaskToFocus'
else else
methodName := 'ITimeEntryService.RemoveTaskFromFocus'; methodName := 'ITimeEntryService.RemoveTaskFromFocus';
ClearStatus;
FSaving := True;
UpdateButtons;
try
try try
await(FClient.RawInvokeAsync(methodName, [FUserId, taskId])); await(FClient.RawInvokeAsync(methodName, [FUserId, taskId]));
except except
on E: EXDataClientRequestException do on E: EXDataClientRequestException do
begin begin
SetStatus(E.ErrorResult.ErrorMessage); SetStatus(E.ErrorResult.ErrorMessage);
Exit; focusFailed := True;
end; end;
on E: Exception do on E: Exception do
begin begin
SetStatus('Unable to save focused task.'); SetStatus('Unable to save focused task.');
Exit; focusFailed := True;
end; end;
end; end;
if not focusFailed then
begin
SetTaskFocused(taskId, taskDisplay, focused); 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
...@@ -612,24 +1098,66 @@ begin ...@@ -612,24 +1098,66 @@ begin
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;
......
...@@ -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
......
...@@ -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;
......
...@@ -226,6 +226,7 @@ var ...@@ -226,6 +226,7 @@ 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]));
try
apiDB.uqGetTaskMaxItemNum.Close; apiDB.uqGetTaskMaxItemNum.Close;
apiDB.uqGetTaskMaxItemNum.ParamByName('TASK_ID').AsString := taskId; apiDB.uqGetTaskMaxItemNum.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqGetTaskMaxItemNum.Open; apiDB.uqGetTaskMaxItemNum.Open;
...@@ -243,7 +244,7 @@ begin ...@@ -243,7 +244,7 @@ begin
newItemNum := insertAfterItemNum + 1; newItemNum := insertAfterItemNum + 1;
apiDB.uqAddTaskRow.Connection.StartTransaction; 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]));
q := TUniQuery.Create(nil);
try
q.Connection := apiDB.ucETaskApi;
try
apiDB.uqGetTaskRowPosition.Close; apiDB.uqGetTaskRowPosition.Close;
apiDB.uqGetTaskRowPosition.ParamByName('TASK_ID').AsString := taskId; apiDB.uqGetTaskRowPosition.ParamByName('TASK_ID').AsString := taskId;
apiDB.uqGetTaskRowPosition.ParamByName('TASK_ITEM_ID').AsInteger := sourceTaskItemId; apiDB.uqGetTaskRowPosition.ParamByName('TASK_ITEM_ID').AsInteger := sourceTaskItemId;
apiDB.uqGetTaskRowPosition.Open; apiDB.uqGetTaskRowPosition.Open;
if apiDB.uqGetTaskRowPosition.IsEmpty then 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.'); raise Exception.Create('Task row not found.');
end;
sourceItemNum := apiDB.uqGetTaskRowPositionITEM_NUM.AsInteger; sourceItemNum := apiDB.uqGetTaskRowPositionITEM_NUM.AsInteger;
q := TUniQuery.Create(nil);
try
q.Connection := apiDB.ucETaskApi;
apiDB.ucETaskApi.StartTransaction; apiDB.ucETaskApi.StartTransaction;
try
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,17 +344,14 @@ begin ...@@ -345,17 +344,14 @@ begin
' TASK_ITEM_ID=' + IntToStr(taskItemId) + ' TASK_ITEM_ID=' + IntToStr(taskItemId) +
' NEW_ITEM_NUM=' + IntToStr(newItemNum)); ' NEW_ITEM_NUM=' + IntToStr(newItemNum));
try
apiDB.uqGetTaskRowPosition.Close; apiDB.uqGetTaskRowPosition.Close;
apiDB.uqGetTaskRowPosition.ParamByName('TASK_ID').AsInteger := taskId; apiDB.uqGetTaskRowPosition.ParamByName('TASK_ID').AsInteger := taskId;
apiDB.uqGetTaskRowPosition.ParamByName('TASK_ITEM_ID').AsInteger := taskItemId; apiDB.uqGetTaskRowPosition.ParamByName('TASK_ITEM_ID').AsInteger := taskItemId;
apiDB.uqGetTaskRowPosition.Open; apiDB.uqGetTaskRowPosition.Open;
if apiDB.uqGetTaskRowPosition.IsEmpty then if apiDB.uqGetTaskRowPosition.IsEmpty then
begin
logger.log(2, 'MoveTaskRow row not found TASK_ID=' + IntToStr(taskId) +
' TASK_ITEM_ID=' + IntToStr(taskItemId));
raise Exception.Create('Task row not found.'); raise Exception.Create('Task row not found.');
end;
oldItemNum := apiDB.uqGetTaskRowPositionITEM_NUM.AsInteger; oldItemNum := apiDB.uqGetTaskRowPositionITEM_NUM.AsInteger;
...@@ -384,7 +380,7 @@ begin ...@@ -384,7 +380,7 @@ begin
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,6 +492,7 @@ var ...@@ -496,6 +492,7 @@ var
end; end;
begin begin
try
Result := False; Result := False;
if not Assigned(Item) then if not Assigned(Item) then
...@@ -538,6 +535,13 @@ begin ...@@ -538,6 +535,13 @@ begin
finally finally
uqSaveField.Free; uqSaveField.Free;
end; end;
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.SaveTaskItemField - ERROR: ' + E.Message);
raise;
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]));
try
apiDB.uqGetTaskRowPosition.Close; apiDB.uqGetTaskRowPosition.Close;
apiDB.uqGetTaskRowPosition.ParamByName('TASK_ID').AsInteger := taskId; apiDB.uqGetTaskRowPosition.ParamByName('TASK_ID').AsInteger := taskId;
apiDB.uqGetTaskRowPosition.ParamByName('TASK_ITEM_ID').AsInteger := taskItemId; apiDB.uqGetTaskRowPosition.ParamByName('TASK_ITEM_ID').AsInteger := taskItemId;
apiDB.uqGetTaskRowPosition.Open; apiDB.uqGetTaskRowPosition.Open;
if apiDB.uqGetTaskRowPosition.IsEmpty then if apiDB.uqGetTaskRowPosition.IsEmpty then
begin
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.'); 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,6 +680,7 @@ var ...@@ -678,6 +680,7 @@ var
existingName: string; existingName: string;
newGuid: TGuid; newGuid: TGuid;
begin begin
try
newName := Trim(name); newName := Trim(name);
if newName = '' then if newName = '' then
raise Exception.Create('Assigned name cannot be blank.'); raise Exception.Create('Assigned name cannot be blank.');
...@@ -707,6 +710,13 @@ begin ...@@ -707,6 +710,13 @@ begin
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,6 +727,7 @@ var ...@@ -717,6 +727,7 @@ var
trimmedOldName: string; trimmedOldName: string;
trimmedNewName: string; trimmedNewName: string;
begin begin
try
trimmedOldName := Trim(oldName); trimmedOldName := Trim(oldName);
trimmedNewName := Trim(newName); trimmedNewName := Trim(newName);
...@@ -767,6 +778,13 @@ begin ...@@ -767,6 +778,13 @@ begin
end; end;
Result := BuildAssignedOptionsResponse(taskId); Result := BuildAssignedOptionsResponse(taskId);
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.RenameAssignedName - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
...@@ -775,6 +793,7 @@ var ...@@ -775,6 +793,7 @@ var
assignedId: string; assignedId: string;
assignedName: string; assignedName: string;
begin begin
try
assignedId := FindAssignedOptionId(taskId, name); assignedId := FindAssignedOptionId(taskId, name);
assignedName := FindAssignedOptionName(taskId, name); assignedName := FindAssignedOptionName(taskId, name);
...@@ -804,6 +823,13 @@ begin ...@@ -804,6 +823,13 @@ begin
end; end;
Result := BuildAssignedOptionsResponse(taskId); Result := BuildAssignedOptionsResponse(taskId);
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.DeleteAssignedName - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
...@@ -916,6 +942,7 @@ var ...@@ -916,6 +942,7 @@ var
newName: string; newName: string;
existingName: string; existingName: string;
begin begin
try
newName := Trim(name); newName := Trim(name);
if newName = '' then if newName = '' then
raise Exception.Create('Application name cannot be blank.'); raise Exception.Create('Application name cannot be blank.');
...@@ -946,6 +973,13 @@ begin ...@@ -946,6 +973,13 @@ begin
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,6 +991,7 @@ var ...@@ -957,6 +991,7 @@ var
trimmedOldName: string; trimmedOldName: string;
trimmedNewName: string; trimmedNewName: string;
begin begin
try
trimmedOldName := Trim(oldName); trimmedOldName := Trim(oldName);
trimmedNewName := Trim(newName); trimmedNewName := Trim(newName);
...@@ -1011,6 +1046,13 @@ begin ...@@ -1011,6 +1046,13 @@ begin
end; end;
Result := BuildApplicationOptionsResponse(taskId); Result := BuildApplicationOptionsResponse(taskId);
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.RenameApplicationName - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
...@@ -1020,6 +1062,7 @@ var ...@@ -1020,6 +1062,7 @@ var
applicationId: Integer; applicationId: Integer;
applicationName: string; applicationName: string;
begin begin
try
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.');
...@@ -1053,6 +1096,13 @@ begin ...@@ -1053,6 +1096,13 @@ begin
end; end;
Result := BuildApplicationOptionsResponse(taskId); Result := BuildApplicationOptionsResponse(taskId);
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.DeleteApplicationName - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
...@@ -1128,6 +1178,7 @@ var ...@@ -1128,6 +1178,7 @@ var
existingName: string; existingName: string;
newGuid: TGuid; newGuid: TGuid;
begin begin
try
newName := Trim(name); newName := Trim(name);
if newName = '' then if newName = '' then
raise Exception.Create('Reported name cannot be blank.'); raise Exception.Create('Reported name cannot be blank.');
...@@ -1157,6 +1208,13 @@ begin ...@@ -1157,6 +1208,13 @@ begin
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,6 +1225,7 @@ var ...@@ -1167,6 +1225,7 @@ var
trimmedOldName: string; trimmedOldName: string;
trimmedNewName: string; trimmedNewName: string;
begin begin
try
trimmedOldName := Trim(oldName); trimmedOldName := Trim(oldName);
trimmedNewName := Trim(newName); trimmedNewName := Trim(newName);
...@@ -1217,6 +1276,13 @@ begin ...@@ -1217,6 +1276,13 @@ begin
end; end;
Result := BuildReportedOptionsResponse(taskId); Result := BuildReportedOptionsResponse(taskId);
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.RenameReportedName - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
...@@ -1225,6 +1291,7 @@ var ...@@ -1225,6 +1291,7 @@ var
reportedId: string; reportedId: string;
reportedName: string; reportedName: string;
begin begin
try
reportedId := FindReportedOptionId(taskId, name); reportedId := FindReportedOptionId(taskId, name);
reportedName := FindReportedOptionName(taskId, name); reportedName := FindReportedOptionName(taskId, name);
...@@ -1254,6 +1321,13 @@ begin ...@@ -1254,6 +1321,13 @@ begin
end; end;
Result := BuildReportedOptionsResponse(taskId); Result := BuildReportedOptionsResponse(taskId);
except
on E: Exception do
begin
Logger.Log(2, 'TaskItemService.DeleteReportedName - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
initialization initialization
......
...@@ -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;
......
...@@ -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,23 +525,24 @@ begin ...@@ -400,23 +525,24 @@ 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);
try
startDateValue := ParseIsoDate(startDate); startDateValue := ParseIsoDate(startDate);
endDateValue := ParseIsoDate(endDate); endDateValue := ParseIsoDate(endDate);
exclusiveEndDateValue := IncDay(endDateValue, 1); 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);
...@@ -424,6 +550,13 @@ begin ...@@ -424,6 +550,13 @@ begin
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,10 +594,19 @@ function TTimeEntryService.AddTimeEntry(userId, taskDate: string): string; ...@@ -461,10 +594,19 @@ 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]));
try
taskDateValue := ParseIsoDate(taskDate); taskDateValue := ParseIsoDate(taskDate);
problem := TimeEntryDateProblem(FormatDateTime('yyyy-mm-dd', taskDateValue), '', '', '', '');
if problem <> '' then
raise Exception.Create(problem);
apiDB.ucETaskApi.StartTransaction;
entryId := GetNextIdValue('TimeEntryId'); entryId := GetNextIdValue('TimeEntryId');
apiDB.uqAddTimeEntry.Close; apiDB.uqAddTimeEntry.Close;
...@@ -475,9 +617,21 @@ begin ...@@ -475,9 +617,21 @@ begin
apiDB.uqAddTimeEntry.ParamByName('MODIFIED_BY').AsString := userId; apiDB.uqAddTimeEntry.ParamByName('MODIFIED_BY').AsString := userId;
apiDB.uqAddTimeEntry.ExecSQL; apiDB.uqAddTimeEntry.ExecSQL;
apiDB.ucETaskApi.Commit;
Result := entryId; Result := entryId;
Logger.Log(4, 'TimeEntryService.AddTimeEntry - new ENTRY_ID=' + Result); 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,6 +642,7 @@ var ...@@ -488,6 +642,7 @@ var
isNewEntry: Boolean; isNewEntry: Boolean;
q: TUniQuery; q: TUniQuery;
begin begin
try
if not Assigned(Item) then if not Assigned(Item) then
raise Exception.Create('SaveTimeEntry: Item is nil.'); raise Exception.Create('SaveTimeEntry: Item is nil.');
...@@ -515,8 +670,11 @@ begin ...@@ -515,8 +670,11 @@ begin
)); ));
taskDateValue := ParseIsoDate(Item.taskDate); taskDateValue := ParseIsoDate(Item.taskDate);
CheckTimeEntryDate(Item.userId, Item.taskId, taskDateValue);
isNewEntry := StrToIntDef(Item.entryId, 0) <= 0; isNewEntry := StrToIntDef(Item.entryId, 0) <= 0;
apiDB.ucETaskApi.StartTransaction;
if isNewEntry then if isNewEntry then
begin begin
entryId := GetNextIdValue('TimeEntryId'); entryId := GetNextIdValue('TimeEntryId');
...@@ -575,6 +733,7 @@ begin ...@@ -575,6 +733,7 @@ begin
q.ParamByName('CATEGORY').AsString := Item.category; q.ParamByName('CATEGORY').AsString := Item.category;
q.ParamByName('SUMMARY').AsString := Item.summary; q.ParamByName('SUMMARY').AsString := Item.summary;
q.ParamByName('CREATED_BY').AsString := Item.userId; q.ParamByName('CREATED_BY').AsString := Item.userId;
q.ParamByName('MODIFIED_BY').AsString := Item.userId; q.ParamByName('MODIFIED_BY').AsString := Item.userId;
...@@ -606,212 +765,154 @@ begin ...@@ -606,212 +765,154 @@ begin
apiDB.uqSaveTimeEntry.ParamByName('CATEGORY').AsString := Item.category; apiDB.uqSaveTimeEntry.ParamByName('CATEGORY').AsString := Item.category;
apiDB.uqSaveTimeEntry.ParamByName('SUMMARY').AsString := Item.summary; apiDB.uqSaveTimeEntry.ParamByName('SUMMARY').AsString := Item.summary;
apiDB.uqSaveTimeEntry.ParamByName('MODIFIED_BY').AsString := Item.userId; apiDB.uqSaveTimeEntry.ParamByName('MODIFIED_BY').AsString := Item.userId;
apiDB.uqSaveTimeEntry.ExecSQL; apiDB.uqSaveTimeEntry.ExecSQL;
end; end;
apiDB.ucETaskApi.Commit;
Result := entryId; Result := entryId;
Logger.Log(4, 'TimeEntryService.SaveTimeEntry - saved ENTRY_ID=' + Result); Logger.Log(4, 'TimeEntryService.SaveTimeEntry - saved ENTRY_ID=' + Result);
end; except
on E: Exception do
function TTimeEntryService.SaveTimeEntryField(Item: TTimeEntryFieldSave): Boolean;
var
uqSaveField: TUniQuery;
columnName: string;
d: TDateTime;
function MapFieldNameToColumn(AFieldName: string): string;
begin
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;
var
y: Integer;
m: Integer;
dInt: Integer;
begin begin
Result := False; if apiDB.ucETaskApi.InTransaction then
ADate := 0; apiDB.ucETaskApi.Rollback;
if Length(Trim(S)) <> 10 then
Exit;
y := StrToIntDef(Copy(S, 1, 4), 0);
m := StrToIntDef(Copy(S, 6, 2), 0);
dInt := StrToIntDef(Copy(S, 9, 2), 0);
if (y > 0) and (m > 0) and (dInt > 0) then Logger.Log(2, 'TimeEntryService.SaveTimeEntry - ERROR: ' + E.Message);
begin raise;
try
ADate := EncodeDate(y, m, dInt);
Result := True;
except
Result := False;
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; apiDB.uqTaskPickerCustomers.Next;
end; end;
end finally
else apiDB.uqTaskPickerCustomers.Close;
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
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;
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.GetTaskPickerCustomers Start'); Logger.Log(4, 'TimeEntryService.GetTaskPickerStatuses 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);
try
q.Connection := apiDB.ucETaskApi;
q.SQL.Text :=
'select CODE, CODE_DESC ' +
'from codes ' +
'where CATEGORY = ''TASK'' ' +
' and CODE_TYPE = ''STATUS'' ' +
'order by CODE_DESC';
q.Open;
while not q.Eof do
begin begin
AddTaskPickerOption( AddTaskPickerOption(
Result, Result,
FieldText(apiDB.uqTaskPickerCustomers, 'CUSTOMER_ID'), FieldText(q, 'CODE'),
FieldText(apiDB.uqTaskPickerCustomers, 'CUSTOMER_NAME') FieldText(q, 'CODE_DESC')
); );
apiDB.uqTaskPickerCustomers.Next; q.Next;
end; end;
finally finally
apiDB.uqTaskPickerCustomers.Close; q.Free;
end;
except
on E: Exception do
begin
Logger.Log(2, 'TimeEntryService.GetTaskPickerStatuses - ERROR: ' + E.Message);
raise;
end;
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);
scope := UpperCase(Trim(scope));
if (scope <> 'MY') and (scope <> 'ACTIVE') then
scope := 'ALL';
try
if Trim(taskDate) = '' then
dateValue := ''
else
dateValue := FormatDateTime('yyyy-mm-dd', ParseIsoDate(Trim(taskDate)));
apiDB.uqTaskPickerProjects.Close; apiDB.uqTaskPickerProjects.Close;
apiDB.uqTaskPickerProjects.ParamByName('CUSTOMER_ID').AsString := customerId; 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; apiDB.uqTaskPickerProjects.Open;
try try
while not apiDB.uqTaskPickerProjects.Eof do while not apiDB.uqTaskPickerProjects.Eof do
begin begin
projectDisplay :=
FieldText(apiDB.uqTaskPickerProjects, 'CUSTOMER_SHORT_NAME') + ' - ' +
FieldText(apiDB.uqTaskPickerProjects, 'PROJECT_NAME');
AddTaskPickerOption( AddTaskPickerOption(
Result, Result,
FieldText(apiDB.uqTaskPickerProjects, 'PROJECT_ID'), FieldText(apiDB.uqTaskPickerProjects, 'PROJECT_ID'),
FieldText(apiDB.uqTaskPickerProjects, 'PROJECT_NAME') projectDisplay
); );
Result.options[Result.options.Count - 1].customerId := Result.options[Result.options.Count - 1].customerId :=
...@@ -822,32 +923,120 @@ begin ...@@ -822,32 +923,120 @@ begin
finally finally
apiDB.uqTaskPickerProjects.Close; apiDB.uqTaskPickerProjects.Close;
end; end;
except
on E: Exception do
begin
Logger.Log(2, 'TimeEntryService.GetTaskPickerProjects - ERROR: ' + E.Message);
raise;
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"',
[projectId, userId, taskDate]));
try
if Trim(taskDate) = '' then
dateValue := ''
else
dateValue := FormatDateTime('yyyy-mm-dd', ParseIsoDate(Trim(taskDate)));
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; Result := TTaskPickerOptionsResponse.Create;
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
apiDB.uqTaskPickerTasks.Close; q := TUniQuery.Create(nil);
apiDB.uqTaskPickerTasks.ParamByName('PROJECT_ID').AsString := projectId;
apiDB.uqTaskPickerTasks.Open;
try try
while not apiDB.uqTaskPickerTasks.Eof do 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 begin
AddTaskPickerOption( userStart := DateText(q, 'START_DATE');
Result, userEnd := DateText(q, 'END_DATE');
FieldText(apiDB.uqTaskPickerTasks, 'TASK_ID'), end;
BuildTaskDisplay(apiDB.uqTaskPickerTasks) q.Close;
);
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');
apiDB.uqTaskPickerTasks.Next; Result.options.Add(option);
q.Next;
end; end;
finally finally
apiDB.uqTaskPickerTasks.Close; q.Free;
end;
except
on E: Exception do
begin
Logger.Log(2, 'TimeEntryService.GetTaskPickerTasks - ERROR: ' + E.Message);
raise;
end;
end; end;
end; end;
...@@ -862,6 +1051,7 @@ begin ...@@ -862,6 +1051,7 @@ begin
TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result); TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
Result.taskId := taskId; Result.taskId := taskId;
try
// Read-only lookup; an unknown task returns blank ids so the picker opens empty // Read-only lookup; an unknown task returns blank ids so the picker opens empty
q := TUniQuery.Create(nil); q := TUniQuery.Create(nil);
try try
...@@ -882,6 +1072,13 @@ begin ...@@ -882,6 +1072,13 @@ begin
finally finally
q.Free; q.Free;
end; end;
except
on E: Exception do
begin
Logger.Log(2, 'TimeEntryService.GetTaskPickerTaskContext - ERROR: ' + E.Message);
raise;
end;
end;
end; end;
...@@ -891,6 +1088,10 @@ var ...@@ -891,6 +1088,10 @@ var
begin begin
Result := False; Result := False;
q := TUniQuery.Create(nil);
try
q.Connection := apiDB.ucETaskApi;
try
if Trim(userId) = '' then if Trim(userId) = '' then
raise Exception.Create('DeleteTimeEntry: Invalid userId.'); raise Exception.Create('DeleteTimeEntry: Invalid userId.');
...@@ -902,9 +1103,8 @@ begin ...@@ -902,9 +1103,8 @@ begin
[userId, entryId] [userId, entryId]
)); ));
q := TUniQuery.Create(nil); q.Connection.StartTransaction;
try
q.Connection := apiDB.ucETaskApi;
q.SQL.Text := q.SQL.Text :=
'delete from time_items ' + 'delete from time_items ' +
'where ENTRY_ID = :ENTRY_ID ' + 'where ENTRY_ID = :ENTRY_ID ' +
...@@ -917,12 +1117,24 @@ begin ...@@ -917,12 +1117,24 @@ begin
if q.RowsAffected <= 0 then if q.RowsAffected <= 0 then
raise Exception.Create('Time entry was not found or does not belong to this user.'); raise Exception.Create('Time entry was not found or does not belong to this user.');
q.Connection.Commit;
Result := True; Result := True;
Logger.Log(4, Format( Logger.Log(4, Format(
'TimeEntryService.DeleteTimeEntry - deleted ENTRY_ID="%d"', 'TimeEntryService.DeleteTimeEntry - deleted ENTRY_ID="%d"',
[entryId] [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);
......
[Settings] [Settings]
MemoLogLevel=5 MemoLogLevel=5
FileLogLevel=5 FileLogLevel=5
webClientVersion=0.9.4.0 webClientVersion=0.9.4.1
LogFileNum=218 LogFileNum=243
[Database] [Database]
--Server=192.168.102.131 --Server=192.168.102.131
......
<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>
<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>
<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>
<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>
<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>
<!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>
...@@ -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)'!=''">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment