Commit e3cf4538 by Mac Stephens

Updated orders list form to use twebdbtablecontrol, started filtering logic, added selection logic

parent 8d360d08
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.3.0",
"configurations": [
{
"preLaunchTask": "Build",
"type": "chrome",
"request": "launch",
"name": "Run",
"url": "http://localhost:${command:rad4.tms.web.port.debug}/${command:rad4.tms.getcurrentproject.html.file}",
"webRoot": "${workspaceFolder}",
"timeout": 20000
},
{
"preLaunchTask": "Build",
"type": "chrome",
"request": "launch",
"name": "Run Without Debugging",
"url": "http://localhost:${command:rad4.tms.web.port.release}/${command:rad4.tms.getcurrentproject.html.file}",
"webRoot": "${workspaceFolder}",
"timeout": 20000
}
]
}
\ No newline at end of file
{
"version": "2.0.0",
"runner": "terminal",
"tasks": [
{
"label": "Build",
"dependsOrder": "sequence",
"dependsOn": [
"Echo",
"Active"
]
},
{
"label": "Echo",
"type": "shell",
"command": "echo 'Building...'",
"problemMatcher": []
},
{
"label": "Sleepdelay",
"type": "shell",
"command": "sleep ${config:TMS.options.electron.debug.delay}",
"windows": {
"command": "ping 127.0.0.1 -n ${config:TMS.options.electron.debug.delay} > '${workspaceFolder}\\.vscode\\null.txt'"
},
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "new"
}
},
{
"label": "Active",
"type": "build",
"operation": "compile",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$tmswebcoreerror",
"$tmswebcorewarning"
]
},
{
"label": "Debug",
"type": "build",
"operation": "compile",
"buildconfiguration": "Debug",
"group": "build",
"problemMatcher": [
"$tmswebcoreerror",
"$tmswebcorewarning"
]
},
{
"label": "Release",
"type": "build",
"operation": "compile",
"buildconfiguration": "Release",
"group": "build",
"problemMatcher": [
"$tmswebcoreerror",
"$tmswebcorewarning"
]
}
]
}
\ No newline at end of file
......@@ -7,7 +7,6 @@ object FOrderList: TFOrderList
Font.Name = 'Arial'
Font.Style = []
ParentFont = False
OnShow = WebFormShow
object lblEntries: TWebLabel
Left = 0
Top = 336
......@@ -48,8 +47,8 @@ object FOrderList: TFOrderList
WidthPercent = 100.000000000000000000
end
object pnlMessage: TWebPanel
Left = 24
Top = 57
Left = 370
Top = 558
Width = 121
Height = 33
ElementClassName = 'card'
......@@ -90,18 +89,19 @@ object FOrderList: TFOrderList
WidthPercent = 100.000000000000000000
end
end
object WebDBTableControl: TWebDBTableControl
Left = 172
Top = 287
Width = 530
Height = 265
ElementClassName = 'table-responsive'
ElementId = 'customer_list'
object tblOrders: TWebDBTableControl
Left = 0
Top = 142
Width = 1016
Height = 289
ElementClassName = 'table'
ElementId = 'tbl_orders'
BorderColor = clSilver
ChildOrder = 5
ColHeader = False
ElementTableClassName = 'table table-striped table-bordered table-hover dataTable'
ElementTableClassName = 'table table-striped table-hover table-bordered'
Options.ResizeColumns = True
OnClickCell = tblOrdersClickCell
Columns = <
item
DataField = 'ID'
......@@ -124,56 +124,63 @@ object FOrderList: TFOrderList
DataSource = wdsCustomers
end
object cbCorrugatedPlate: TWebCheckBox
Left = 172
Top = 210
Left = 190
Top = 26
Width = 113
Height = 22
Caption = 'Corrugated Plate'
Checked = True
ChildOrder = 5
ElementID = 'cb_corrugatedplate'
HeightPercent = 100.000000000000000000
State = cbChecked
WidthPercent = 100.000000000000000000
OnClick = cbCorrugatedPlateClick
end
object cbWebPlate: TWebCheckBox
Left = 304
Top = 210
Left = 324
Top = 26
Width = 113
Height = 22
Caption = 'Web Plate'
ChildOrder = 5
ElementID = 'cb_webplate'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = cbWebPlateClick
end
object edtCompanyName: TWebEdit
Left = 302
Top = 252
Width = 121
Height = 22
ChildOrder = 7
object btnConfirm: TWebButton
Left = 674
Top = 51
Width = 96
Height = 25
Caption = 'Confirm'
ChildOrder = 9
ElementID = 'btn_confirm'
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtID: TWebEdit
Left = 172
Top = 252
object edtCompanyName: TWebEdit
Left = 170
Top = 66
Width = 121
Height = 22
ChildOrder = 8
ElementID = 'edt_companyname'
HeightPercent = 100.000000000000000000
Text = 'edtCompanyName'
WidthPercent = 100.000000000000000000
OnChange = edtCompanyNameChange
end
object btnConfirm: TWebButton
Left = 564
Top = 251
Width = 96
Height = 25
Caption = 'Confirm'
object edtID: TWebEdit
Left = 334
Top = 66
Width = 121
Height = 22
ChildOrder = 9
ElementID = 'edt_id'
HeightPercent = 100.000000000000000000
Text = 'edtID'
WidthPercent = 100.000000000000000000
OnChange = edtIDChange
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
......@@ -181,7 +188,6 @@ object FOrderList: TFOrderList
Top = 434
end
object xdwdsCustomers: TXDataWebDataSet
Connection = DMConnection.ApiConnection
Left = 84
Top = 490
object xdwdsCustomersID: TIntegerField
......
<div class="row">
<div class="col-12">
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-12 col-md-8">
<div class="row">
<div class="col-sm">
<div id="pnl_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 class="container pb-5 mt-5 orders-modal rounded-sm shadow border border-secondary bg-white">
<div class="row sticky-top bg-white">
<div class="col-auto">
<h4 class="custom-h4 mt-4">Order List</h4>
<p>Review the list of orders below.</p>
<hr class="custom-hr">
</div>
</div>
<!-- Input Controls -->
<div class="row mb-3">
<div class="col-md-4">
<label for="edt_companyname" class="form-label">Company Name</label>
<input type="text" class="form-control" id="edt_companyname" placeholder="Enter company name">
</div>
<div class="col-md-4">
<label for="edt_id" class="form-label">Order ID</label>
<input type="text" class="form-control" id="edt_id" placeholder="Enter order ID">
</div>
<div class="col-md-2 d-flex align-items-center">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="cb_corrugatedplate">
<label class="form-check-label" for="cb_corrugatedplate">
Corrugated Plate
</label>
</div>
</div>
<div class="col-md-2 d-flex align-items-center">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="cb_webplate">
<label class="form-check-label" for="cb_webplate">
Web Plate
</label>
</div>
</div>
<div class="row">
<label id="lblentries"></label>
</div>
<label id="lblentries2"></label>
<!-- Orders Table -->
<div id="tbl_orders_container" class="overflow-auto" style="max-height: 400px;">
<table id="tbl_orders" class="table table-striped table-hover table-bordered">
<!-- TWebDBTableControl will render dynamically here -->
</table>
</div>
<!-- Pagination and Additional Labels -->
<div class="row mt-3">
<label id="lblentries" class="col-auto"></label>
<label id="lblentries2" class="col-auto"></label>
</div>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center" id="pagination">
<!-- Pagination items will be added dynamically via Delphi code -->
</ul>
</nav>
<!-- Confirm Button -->
<div class="row mt-3">
<div class="col-auto">
<button type="button" id="btn_confirm" class="btn btn-primary">Confirm</button>
</div>
</div>
</div>
</div>
</div>
......@@ -25,23 +25,18 @@ type
xdwdsCustomersNAME: TStringField;
xdwdsCustomersSHORT_NAME: TStringField;
xdwdsCustomersADDRESS: TStringField;
WebDBTableControl: TWebDBTableControl;
tblOrders: TWebDBTableControl;
cbCorrugatedPlate: TWebCheckBox;
cbWebPlate: TWebCheckBox;
btnConfirm: TWebButton;
edtCompanyName: TWebEdit;
edtID: TWebEdit;
btnConfirm: TWebButton;
procedure WebFormShow(Sender: TObject);
procedure WebDBTableControlGetCellChildren(Sender: TObject; ACol,
ARow: Integer; AField: TField; AValue: string;
AElement: TJSHTMLElementRecord);
procedure cbCorrugatedPlateClick(Sender: TObject);
procedure cbWebPlateClick(Sender: TObject);
procedure edtIDChange(Sender: TObject);
procedure edtCompanyNameChange(Sender: TObject);
procedure tblOrdersClickCell(Sender: TObject; ACol, ARow: Integer);
private
//FJSONProc: TJSONProc;
procedure AddRowToTable();
procedure ClearTable();
[async] procedure getCustomers();
[async] procedure GetCustomers;
procedure FilterDataset;
public
class function CreateForm(AElementID: string): TWebForm;
end;
......@@ -53,6 +48,8 @@ implementation
{$R *.dfm}
{ TFOrderList }
class function TFOrderList.CreateForm(AElementID: string): TWebForm;
begin
Application.CreateForm(TFOrderList, AElementID, Result,
......@@ -60,118 +57,133 @@ begin
begin
with TFOrderList(AForm) do
begin
// Initialize or configure form properties as needed
console.log('TFOrderList created and bound to ElementID:', AElementID);
GetCustomers;
end;
end
);
end;
procedure TFOrderList.WebDBTableControlGetCellChildren(Sender: TObject; ACol,
ARow: Integer; AField: TField; AValue: string;
AElement: TJSHTMLElementRecord);
begin
//WebDBTableControl.WidthStyle := TSizeStyle.ssAuto;
console.log(AValue);
WebDBTableControl.ColWidths[ACol] := AValue.Length * 12;
end;
procedure TFOrderList.WebFormShow(Sender: TObject);
procedure TFOrderList.edtCompanyNameChange(Sender: TObject);
begin
getCustomers();
// FilterDataset;
console.log('Filtering data logic WIP');
end;
procedure TFOrderList.cbCorrugatedPlateClick(Sender: TObject);
begin
cbWebPlate.Checked := false;
end;
procedure TFOrderList.cbWebPlateClick(Sender: TObject);
begin
cbCorrugatedPlate.Checked := false;
end;
procedure TFOrderList.ClearTable();
// clears the table
var
tbody: TJSHTMLElement;
procedure TFOrderList.edtIDChange(Sender: TObject);
begin
tbody := TJSHTMLElement(document.getElementById('tblCustomerGrid').getElementsByTagName('tbody')[0]);
tbody.innerHTML := '';
// FilterDataset;
console.log('Filtering data logic WIP');
end;
procedure TFOrderList.getCustomers();
procedure TFOrderList.GetCustomers;
var
xdcResponse: TXDataClientResponse;
customerList: TJSObject;
data: TJSArray;
i, count: integer;
temp: TJSONObject;
customer: TJSObject;
ResponseObject: TJSObject;
DataArray: TJSArray;
begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers',
[]));
customerList := TJSObject(xdcResponse.Result);
data := TJSArray(customerList['data']);
count := integer(customerList['count']);
try
asm
startSpinner();
end;
// Fetch data from the server
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetCustomers', []));
// Log the raw JSON response to verify its structure
console.log('Raw JSON Response:' + TJSJSON.stringify(xdcResponse.Result));
// Extract the "data" array from the JSON response
ResponseObject := TJSObject(xdcResponse.Result);
DataArray := TJSArray(ResponseObject['data']);
// Load the extracted array into the dataset
xdwdsCustomers.Close;
xdwdsCustomers.SetJsonData(customerList['data']);
xdwdsCustomers.SetJsonData(DataArray);
xdwdsCustomers.Open;
// Log record count and dataset status
console.log('Dataset Record Count: ' + IntToStr(xdwdsCustomers.RecordCount));
if xdwdsCustomers.RecordCount = 0 then
console.log('Dataset is empty.')
else
console.log('Dataset loaded successfully with records.');
finally
asm
setTimeout(endSpinner, 2000);
end;
end;
end;
procedure TFOrderList.AddRowToTable();
procedure TFOrderList.tblOrdersClickCell(Sender: TObject; ACol, ARow: Integer);
begin
asm
startSpinner();
end;
try
// Ensure the dataset is active and the row index is valid
if xdwdsCustomers.Active and (ARow >= 0) and (ARow < xdwdsCustomers.RecordCount) then
begin
xdwdsCustomers.RecNo := ARow + 1; // Set the dataset to the selected row
// Populate the edit boxes with the dataset field values
edtCompanyName.Text := xdwdsCustomers.FieldByName('NAME').AsString;
edtID.Text := xdwdsCustomers.FieldByName('ID').AsString;
console.log('Row clicked: ARow=' + IntToStr(ARow) + ', Company=' + edtCompanyName.Text + ', ID=' + edtID.Text);
end;
finally
asm
setTimeout(endSpinner, 2000);
end;
end;
end;
procedure TFOrderList.FilterDataset;
var
NewRow, Cell, P, Button, Audio: TJSHTMLElement;
ClickHandler: TJSFunction;
//strColorList: string;
id: integer;
FilterTextCompany, FilterTextID: string;
FilterCondition: string;
begin
NewRow := TJSHTMLElement(document.createElement('tr'));
//NewRow.Attrs['orderType'] := XDataWebDataSet1orderType.Value;
NewRow.addEventListener('click', procedure
try
// Get the current filter inputs
FilterTextCompany := Trim(edtCompanyName.Text);
FilterTextID := Trim(edtID.Text);
// Build the filter condition
FilterCondition := '';
if FilterTextCompany <> '' then
FilterCondition := Format('NAME LIKE ''%%%s%%''', [FilterTextCompany]);
if FilterTextID <> '' then
begin
//orderEntry(NewRow.Attrs['id'], 'EDIT');
end);
// Company ID Cell
NewRow.Attrs['id'] := xdwdsCustomersID.AsString;
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order ID');
if xdwdsCustomersID.AsString = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersID.AsString;
NewRow.appendChild(Cell);
// Company Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Company Name');
if xdwdsCustomersNAME.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersNAME.Value;
NewRow.appendChild(Cell);
// Short Name Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Job Name');
if xdwdsCustomersSHORT_NAME.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersSHORT_NAME.Value;
NewRow.appendChild(Cell);
// Address Cell
Cell := TJSHTMLElement(document.createElement('td'));
Cell.setAttribute('data-label', 'Order Date');
if xdwdsCustomersADDRESS.Value = '' then
Cell.innerText := 'None'
else
Cell.innerText := xdwdsCustomersADDRESS.Value;
NewRow.appendChild(Cell);
if FilterCondition <> '' then
FilterCondition := FilterCondition + ' AND ';
FilterCondition := FilterCondition + Format('ID LIKE ''%%%s%%''', [FilterTextID]);
end;
// Appends new rows to the table body
TJSHTMLElement(document.getElementById('tblCustomerGrid').getElementsByTagName('tbody')[0]).appendChild(NewRow);
// Apply the filter condition
xdwdsCustomers.Filtered := False; // Disable existing filter
xdwdsCustomers.Filter := FilterCondition; // Set new filter
xdwdsCustomers.Filtered := True; // Enable filtering
console.log('Filter applied:', FilterCondition);
except
on E: Exception do
begin
// Handle any errors gracefully
console.error('Error applying filter:', E.Message);
ShowMessage('An error occurred while applying the filter. Please check your input.');
end;
end;
end;
end.
......@@ -274,6 +274,20 @@ object FViewOrders: TFViewOrders
ListField = 'NAME'
ListSource = wdsCustomers
end
object pnlOrders: TWebPanel
Left = 38
Top = 132
Width = 461
Height = 181
ElementClassName = 'card'
ElementID = 'pnl_orders'
Caption = 'pnlOrders'
ChildOrder = 15
ElementBodyClassName = 'card-body'
ElementFont = efCSS
TabOrder = 13
Visible = False
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 8
......
......@@ -120,3 +120,18 @@
</div>
</div>
</div>
<!-- pnl_orders Div -->
<div id="pnl_orders"
style="display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1050;
padding: 20px;
border-radius: 10px;
width: 75%;
background-color: white;
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);">
</div>
......@@ -63,6 +63,7 @@ type
xdwdsSave: TXDataWebDataSet;
wdsSave: TWebDataSource;
xdwdsSaveCURR_ID: TIntegerField;
pnlOrders: TWebPanel;
procedure WebFormCreate(Sender: TObject);
procedure btnApplyClick(Sender: TObject);
procedure btnSearchClick(Sender: TObject);
......@@ -167,34 +168,30 @@ begin
);
end;
procedure TFViewOrders.ShowOrderListForm();
var
newform: TFOrderList;
formattedBkNum: string;
OrdersPanel: TJSHTMLElement;
begin
newform := TFOrderList.CreateNew;
{newform.FUserInfo := AUserInfo;
newform.FBKNum := ABKNum;
newform.FSource := ASource;
newform.FViewImages := AViewImages;}
// Get the panel element for orders
OrdersPanel := TJSHTMLElement(document.getElementById('pnl_orders'));
newform.Caption := 'Select Company an Order Type';
newForm.Popup := True;
newForm.Border := fbDialog;
console.log(newForm.GetElementHandle);
// Hide the panel before loading the form
if Assigned(OrdersPanel) then
OrdersPanel.style.setProperty('display', 'none');
// used to manage Back button handling to close subform
window.location.hash := 'subform';
// Create the order list form, passing the ElementID
TFOrderList.CreateForm(pnlOrders.ElementID);
newform.ShowModal(
procedure(AValue: TModalResult)
begin
//ShowMessage('View Booking Details Form closed');
end
);
// Show the panel after the form is created
if Assigned(OrdersPanel) then
OrdersPanel.style.setProperty('display', 'block');
end;
procedure TFViewOrders.AddRowToTable(temp: string);
// Adds rows to the table
// PhoneNumber: phone number of the location
......
......@@ -22,10 +22,9 @@ object AuthDatabase: TAuthDatabase
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
Username = 'root'
Server = '192.168.159.132'
Connected = True
Server = '192.168.75.133'
LoginPrompt = False
Left = 67
Left = 69
Top = 131
EncryptedPassword = '9AFF92FF8CFF86FF8CFFCFFFCEFF'
end
......
......@@ -8,8 +8,7 @@ object FDatabaseModule: TFDatabaseModule
SpecificOptions.Strings = (
'PostgreSQL.Schema=envoy')
Username = 'root'
Server = '192.168.159.132'
Connected = True
Server = '192.168.75.133'
LoginPrompt = False
Left = 75
Top = 139
......
......@@ -60,13 +60,6 @@ object FMain: TFMain
TabOrder = 4
OnClick = btnAuthSwaggerUIClick
end
object tmrTwilio: TTimer
Enabled = False
Interval = 300000
OnTimer = tmrTwilioTimer
Left = 167
Top = 399
end
object initTimer: TTimer
OnTimer = initTimerTimer
Left = 58
......
......@@ -17,13 +17,11 @@ type
btnApiSwaggerUI: TButton;
btnData: TButton;
btnExit: TButton;
tmrTwilio: TTimer;
initTimer: TTimer;
btnAuthSwaggerUI: TButton;
procedure btnApiSwaggerUIClick(Sender: TObject);
procedure btnDataClick(Sender: TObject);
procedure btnExitClick(Sender: TObject);
procedure tmrTwilioTimer(Sender: TObject);
procedure ContactFormData(AText: String);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure initTimerTimer(Sender: TObject);
......@@ -128,28 +126,6 @@ begin
Logger.Log( 1, '--Database->Server: Entry not found' )
else
Logger.Log( 1, '--Database->Server: ' + iniStr );
iniStr := IniFile.ReadString( 'Options', 'TwilioUpdateTime', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Options->TwilioUpdateTime: Entry not found' )
else
begin
Logger.Log( 1, '--Options->TwilioUpdateTime: ' + iniStr );
if iniStr = '0' then
begin
Logger.Log( 1, '--Twilio Update Timer not enabled due to timer length of ' +
'0. Edit the ini file to enable auto updates.');
tmrTwilio.Enabled := False;
end
else
begin
Logger.Log( 1, '--Twilio Update Timer enabled and set to update every '+ iniStr + ' minutes.');
tmrTwilio.Interval := StrToInt(IniStr) * 60000;
tmrTwilio.Enabled := True;
end;
end;
Logger.Log(1, '');
finally
IniFile.Free;
......@@ -165,17 +141,6 @@ begin
AppServerModule.StartAppServer( serverConfig.url );
end;
procedure TFMain.tmrTwilioTimer(Sender: TObject);
var
key: string;
phoneNum: string;
begin
memoInfo.Lines.Add('Timer set off');
tmrTwilio.Enabled := False;
tmrTwilio.Enabled := True;
end;
procedure TFMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
phoneDict.Free;
......
[Options]
LogFileNum=223
LogFileNum=226
UpdateTimerLength=0
[Database]
Server=192.168.159.132
--Server=192.168.159.132
--Server=192.168.102.129
Server=192.168.75.133
[Twilio]
AccountSID=AC37aeef9c36a2cccbaecbadafc172b2ff
......
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