Commit 5bb5fcb9 by Daniel Barker

Pick Task Items mode from the task's category

GetTaskItem now returns t.TYPE and Task Items screen will now determine what mode to open in based upon that. Testing or Support open in Testing mode, all others including blank will open in Task mode. Testing mode checkbox is a temporary override. Updated SQL script.
parent 9cd9d1ea
......@@ -172,7 +172,6 @@ procedure TAuthService.Logout;
begin
DeleteToken;
DMConnection.currentTaskId := '';
DMConnection.taskItemsTestingMode := False;
DMConnection.timeEntriesWeekOf := '';
DMConnection.timeEntriesStartDate := '';
DMConnection.timeEntriesEndDate := '';
......
......@@ -21,10 +21,6 @@ type
public
currentTaskId: string;
// Task Items view: True = Testing Items mode (every column), False = Task Items mode
// (App, Version, Date and Testing Status hidden). Set by the screen's Testing Mode
// checkbox and kept until logout or refresh; a direct task_id link always opens in Testing mode.
taskItemsTestingMode: Boolean;
// Time Entries range saved when a row opens Task Items, restored by Back ('' = none)
timeEntriesWeekOf: string;
timeEntriesStartDate: string;
......
......@@ -63,8 +63,8 @@ begin
end
else
begin
// A direct task_id link opens Task Items in Testing mode
SetTaskItemsTitle(True);
// Task Items sets the title from the task's category once the task loads
SetTaskItemsTitle(False);
ShowForm(TFTaskItems);
end;
end;
......@@ -83,15 +83,15 @@ begin
end;
// Opened from a Time Entries row; the URL is left as-is, so a refresh lands back on Time Entries.
// Opens in the mode last picked with the screen's Testing Mode checkbox (Task Items at first).
// Task Items sets the title from the task's category once the task loads.
procedure TFViewMain.ShowTaskItems(const ATaskId: string);
begin
DMConnection.currentTaskId := ATaskId;
SetTaskItemsTitle(DMConnection.taskItemsTestingMode);
SetTaskItemsTitle(False);
ShowForm(TFTaskItems);
end;
// Page title for the Task Items screen's mode; also called when its Testing Mode checkbox changes
// Page title for the Task Items screen's mode; called when the task loads and when its Testing Mode checkbox changes
procedure TFViewMain.SetTaskItemsTitle(const ATestingMode: Boolean);
begin
if ATestingMode then
......
......@@ -79,6 +79,10 @@ type
FNameManager: TNameManager;
FCopyingRow: Boolean;
FTaskMode: Boolean;
// The mode comes from the task's category on the first load only; later reloads
// (after add, move, delete) keep the current mode, so a checkbox override lasts
// until the screen is closed or refreshed
FModeSet: Boolean;
FUserId: string;
// Selected filter values per column ('' list = no filter); FILTER_BLANK matches an empty value
FAssignedFilter: TJSArray;
......@@ -87,6 +91,7 @@ type
[async] function CopyTaskRow: Boolean;
function FirstEditField: string;
procedure BindFilterControls;
procedure SetTestingMode(const ATestingMode: Boolean);
procedure TestingItemsChanged(Event: TJSEvent);
procedure FillFilterLists;
procedure FilterCheckChange(Event: TJSEvent);
......@@ -181,15 +186,15 @@ begin
if FTaskId = '' then
FTaskId := DMConnection.currentTaskId;
// From a Time Entries row: the mode last picked with the Testing Mode checkbox
// (Task Items at first). A direct task_id link (emT3 desktop) opens in Testing mode.
FTaskMode := (Application.Parameters.Values['task_id'] = '') and
(not DMConnection.taskItemsTestingMode);
// Task mode until the task loads; LoadTasks then sets the mode from the task's
// category (tasks.TYPE), however the screen was opened
FTaskMode := True;
FModeSet := False;
testingItems := TJSHTMLInputElement(document.getElementById('chk_testing_items'));
if Assigned(testingItems) then
begin
testingItems.checked := not FTaskMode;
testingItems.checked := False;
testingItems.addEventListener('change', TJSEventHandler(@TestingItemsChanged));
end;
......@@ -810,23 +815,32 @@ begin
end;
// Testing Mode checkbox: switches between Testing Items mode (every column) and
// Task Items mode (App, Version, Date and Testing Status hidden). The rows are the
// same in both, so this only re-renders; the choice is kept for the next time
// Task Items opens this session.
procedure TFTaskItems.TestingItemsChanged(Event: TJSEvent);
// Sets Testing Items mode (every column) or Task Items mode (App, Version, Date and
// Testing Status hidden), with the checkbox and page title to match. Doesn't re-render.
procedure TFTaskItems.SetTestingMode(const ATestingMode: Boolean);
var
testingMode: Boolean;
testingItems: TJSHTMLInputElement;
begin
testingMode := TJSHTMLInputElement(Event.target).checked;
FTaskMode := not testingMode;
DMConnection.taskItemsTestingMode := testingMode;
FTaskMode := not ATestingMode;
testingItems := TJSHTMLInputElement(document.getElementById('chk_testing_items'));
if Assigned(testingItems) then
testingItems.checked := ATestingMode;
if Assigned(FViewMain) then
FViewMain.SetTaskItemsTitle(testingMode);
FViewMain.SetTaskItemsTitle(ATestingMode);
// Shows or hides the Testing Status filter; Task mode ignores any it has
FillFilterLists;
end;
// Testing Mode checkbox: a temporary override of the mode the task's category
// picked. The rows are the same in both, so this only re-renders. It lasts until
// the screen is closed or refreshed; the next open goes by the category again.
procedure TFTaskItems.TestingItemsChanged(Event: TJSEvent);
begin
SetTestingMode(TJSHTMLInputElement(Event.target).checked);
if xdwdsTasks.Active then
begin
......@@ -1268,6 +1282,14 @@ begin
FStatusOptions := TJSArray(resultObj['statusOptions']);
FItemStatusOptions := TJSArray(resultObj['itemStatusOptions']);
// Testing (TEST) and Support (SUPP) tasks open in Testing mode, any other
// category in Task mode (the server decides: task.testingMode)
if not FModeSet then
begin
FModeSet := True;
SetTestingMode(Assigned(taskObj) and (taskObj['testingMode'] = True));
end;
itemsArray := TJSArray(resultObj['items']);
if not Assigned(itemsArray) then
itemsArray := TJSArray.new;
......
......@@ -2682,8 +2682,8 @@ begin
Exit;
end;
// The mode isn't tied to the category: Task Items opens in the mode last picked
// with its Testing Mode checkbox
// Task Items picks its mode from the task's own category (tasks.TYPE), not
// from this time entry's category
taskId := '';
GotoRowIndex(idx);
if not xdwdsTimeEntries.Eof then
......
......@@ -378,6 +378,7 @@ object ApiDatabase: TApiDatabase
' t.TASK_NUM_6,'
' t.PROJECT_ID,'
' t.SUBJECT,'
' t.TYPE,'
' p.NAME as PROJECT_NAME'
'from tasks t'
'left join project p'
......@@ -426,6 +427,10 @@ object ApiDatabase: TApiDatabase
FieldName = 'SUBJECT'
Size = 80
end
object uqTaskHeaderTYPE: TStringField
FieldName = 'TYPE'
Size = 7
end
object uqTaskHeaderPROJECT_NAME: TStringField
FieldName = 'PROJECT_NAME'
ReadOnly = True
......
......@@ -50,6 +50,7 @@ type
uqTaskHeaderTASK_NUM_6: TIntegerField;
uqTaskHeaderPROJECT_ID: TStringField;
uqTaskHeaderSUBJECT: TStringField;
uqTaskHeaderTYPE: TStringField;
uqTaskHeaderPROJECT_NAME: TStringField;
uqTaskItemCodes: TUniQuery;
uqTaskItemCodesCODE: TStringField;
......
......@@ -45,6 +45,10 @@ type
projectName: string;
subject: string;
title: string;
category: string; // tasks.TYPE (codes TASK / CATGRY)
// The task's own category is Testing (TEST) or Support (SUPP): Task Items opens
// in Testing mode; any other category, including blank, opens in Task mode
testingMode: Boolean;
end;
TTaskUserOption = class
......
......@@ -105,6 +105,12 @@ begin
taskHeader.subject
);
// The task's own category decides the mode (a subtask doesn't inherit its parent's)
taskHeader.category := Trim(apiDB.uqTaskHeaderTYPE.AsString);
taskHeader.testingMode :=
SameText(taskHeader.category, 'TEST') or
SameText(taskHeader.category, 'SUPP');
Result.task := taskHeader;
apiDB.uqProjectApplications.Close;
......
......@@ -2,7 +2,7 @@
MemoLogLevel=5
FileLogLevel=5
webClientVersion=0.9.5.0
LogFileNum=270
LogFileNum=272
[Database]
--Server=192.168.102.131
......
......@@ -6,7 +6,7 @@
-- To undo the status conversion, restore task_items from task_items_bak_20261126.
-- 1. Back up task_items before converting Testing Status values
CREATE TABLE IF NOT EXISTS task_items_bak_20261126 AS
CREATE TABLE IF NOT EXISTS task_items_bak_20261127 AS
SELECT * FROM task_items;
-- 2. New columns
......@@ -18,10 +18,6 @@ ALTER TABLE task_items
ALTER TABLE users
ADD COLUMN IF NOT EXISTS HIDE_TIME_ENTRIES_FIELDS varchar(1) DEFAULT 'F' AFTER AUTO_LAUNCH_TASK_TRACKER;
-- Time Entry Details offcanvas
ALTER TABLE time_items
ADD COLUMN IF NOT EXISTS DETAILS text DEFAULT NULL AFTER SUMMARY;
-- 3. Testing Status codes (codes TASK / STATUS2)
INSERT IGNORE INTO codes (CATEGORY, CODE_TYPE, CODE, CODE_DESC, CREATE_DATE) VALUES
('TASK', 'STATUS2', 'CD', 'Cannot Duplicate', NOW()),
......@@ -34,6 +30,13 @@ INSERT IGNORE INTO codes (CATEGORY, CODE_TYPE, CODE, CODE_DESC, CREATE_DATE) VAL
('TASK', 'STATUS2', 'NI', 'Non-Issue', NOW()),
('TASK', 'STATUS2', 'PP', 'Possibly a Problem', NOW());
-- 3b. Testing task category (codes TASK / CATGRY, stored in tasks.TYPE)
-- Tasks whose own category is Testing (TEST) or Support (SUPP) open Task Items in
-- Testing mode; every other category, including blank, opens in Task mode.
-- CATGRY is also the Time Entries Category list, so Testing shows there too.
INSERT IGNORE INTO codes (CATEGORY, CODE_TYPE, CODE, CODE_DESC, CREATE_DATE)
VALUES ('TASK', 'CATGRY', 'TEST', 'Testing', NOW());
-- 4. Convert existing Testing Status descriptions to their codes
-- Only rows whose STATUS matches a STATUS2 description change. The filter is in
-- WHERE (not just the JOIN) so HeidiSQL doesn't flag it as an unsafe UPDATE.
......
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