Commit f7e6f7f0 by Cam Hayes

WIP changes to fix shipping address grid bug

parent 2eb52536
......@@ -181,47 +181,6 @@ object FViewAddCustomer: TFViewAddCustomer
DataField = 'QB_LIST_ID'
DataSource = WebDataSource1
end
object wdbtcAddresses: TWebDBTableControl
Left = 190
Top = 196
Width = 631
Height = 200
ElementClassName = 'table'
ElementId = 'tblPhoneGrid'
BorderColor = clSilver
ChildOrder = 11
ElementFont = efCSS
ElementHeaderClassName = 'thead-light sticky-top bg-light border-light'
ElementPosition = epRelative
ElementTableClassName = 'table table-striped table-hover table-bordered text-sm'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
WordWrap = True
OnClickCell = wdbtcAddressesDblClickCell
OnDblClickCell = wdbtcAddressesDblClickCell
Columns = <
item
DataField = 'ship_block'
Title = 'Address'
end>
DataSource = wdsShipTo
end
object edtShippingAddress: TWebEdit
Left = 190
Top = 460
......@@ -437,6 +396,47 @@ object FViewAddCustomer: TFViewAddCustomer
DataField = 'QB_TYPE'
DataSource = WebDataSource1
end
object wdbtcAddresses: TWebDBTableControl
Left = 310
Top = 196
Width = 524
Height = 200
ElementId = 'tblShippingAddress'
BorderColor = clSilver
ChildOrder = 31
ElementFont = efCSS
ElementHeaderClassName = 'thead-light'
ElementTableClassName = 'table table-striped table-bordered table-hover'
Footer.ButtonActiveElementClassName = 'btn btn-primary'
Footer.ButtonElementClassName = 'btn btn-light'
Footer.DropDownElementClassName = 'form-control'
Footer.InputElementClassName = 'form-control'
Footer.LinkActiveElementClassName = 'link-primary'
Footer.LinkElementClassName = 'link-secondary'
Footer.ListElementClassName = 'pagination'
Footer.ListItemElementClassName = 'page-item'
Footer.ListLinkElementClassName = 'page-link'
Header.ButtonActiveElementClassName = 'btn btn-primary'
Header.ButtonElementClassName = 'btn btn-light'
Header.DropDownElementClassName = 'form-control'
Header.InputElementClassName = 'form-control'
Header.LinkActiveElementClassName = 'link-primary'
Header.LinkElementClassName = 'link-secondary'
Header.ListElementClassName = 'pagination'
Header.ListItemElementClassName = 'page-item'
Header.ListLinkElementClassName = 'page-link'
OnClickCell = wdbtcAddressesClickCell
Columns = <
item
DataField = 'ship_id'
Title = 'ID'
end
item
DataField = 'ship_block'
Title = 'Address'
end>
DataSource = wdsShipTo
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
Left = 454
......
......@@ -121,7 +121,7 @@
<div class="row">
<div class="overflow-auto mt-2"
style="max-height: calc(100vh - 250px); padding-bottom: 0; width: 100%;">
<table id="tblPhoneGrid" class="table table-striped table-bordered" style="width: 100%;">
<table id="tblShippingAddress" class="table table-striped table-bordered" style="width: 100%;">
<thead class="sticky-top thead-light">
<tr style="font-size: 0.875rem;">
<!-- headers -->
......
......@@ -33,7 +33,6 @@ type
XDataWebDataSet1BILL_CITY: TStringField;
edtCustomerID: TWebDBEdit;
edtQBID: TWebDBEdit;
wdbtcAddresses: TWebDBTableControl;
wdsShipTo: TWebDataSource;
xdwdsShipTo: TXDataWebDataSet;
XDataWebDataSet1BILL_STATE: TStringField;
......@@ -75,11 +74,11 @@ type
edtRepUser: TWebDBEdit;
xdwdsUsersQBID: TStringField;
xdwdsShipToship_block: TStringField;
XDataWebDataSet1QB_TYPE: TStringField; procedure btnSaveClick(Sender: TObject);
XDataWebDataSet1QB_TYPE: TStringField;
wdbtcAddresses: TWebDBTableControl; procedure btnSaveClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
procedure wdbtcAddressesDblClickCell(Sender: TObject; ACol, ARow: Integer);
procedure btnClearClick(Sender: TObject);
procedure AddressEditMode();
procedure edtShippingAddressChange(Sender: TObject);
......@@ -95,6 +94,7 @@ type
procedure btnUpdateClick(Sender: TObject);
procedure wdblcbRepChange(Sender: TObject);
procedure edtShortNameChange(Sender: TObject);
procedure wdbtcAddressesClickCell(Sender: TObject; ACol, ARow: Integer);
private
{ Private declarations }
procedure ViewMode();
......@@ -156,7 +156,6 @@ var
JSONStr: string;
input: TJSHTMLInputElement;
begin
console.log('init');
if customerID = '' then
begin
mode := 'ADD';
......@@ -164,8 +163,6 @@ begin
try
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.GetQBCustomer', [QB_ID]));
qbCustJSON := string(TJSJSON.stringify(xdcResponse.Result));
console.log(qbCustJSON);
JSONObj := TJSONObject.ParseJSONValue(qbCustJSON) as TJSONObject;
//JSONObj := TJSONObject.ParseJSONValue(qbCustJSON) as TJSONObject;
XDataWebDataSet1.Open;
......@@ -283,10 +280,12 @@ procedure TFViewAddCustomer.SendAddressToServer;
// Creates an Address JSON and then sends it to the server for the address to be
// Added or edited.
var
AddressJSON: TJSONObject;
AddressJSON, JSONObj: TJSONObject;
Response: TXDataClientResponse;
notification: TJSObject;
notification, RowData: TJSObject;
DataArray: TJSArray;
ship_block: string;
i: integer;
begin
AddressJSON := TJSONObject.Create;
......@@ -308,15 +307,50 @@ begin
AddressJSON.AddPair('customer_ship_id', xdwdsShipTo.FieldByName('ship_id').AsString);
AddressJSON.AddPair('mode', shipmode);
console.log(AddressJSON);
Response := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddShippingAddress',
[AddressJSON.ToString]));
notification := TJSObject(Response.Result);
ShowToast(string(notification['status']));
// DataArray := TJSArray(notification['ADDRESS']);
//
// xdwdsShipTo.Close;
// xdwdsShipTo.Open;
//
// xdwdsShipTo.First;
// while not xdwdsShipTo.Eof do xdwdsShipTo.Delete;
//
// for i := 0 to DataArray.length - 1 do
// begin
// RowData := TJSObject(DataArray[i]);
//
// xdwdsShipTo.Append;
// xdwdsShipTo.FieldByName('state').AsString := String(RowData['state']);
// xdwdsShipTo.FieldByName('city').AsString := String(RowData['city']);
// xdwdsShipTo.FieldByName('ship_id').AsString := String(RowData['ship_id']);
// xdwdsShipTo.FieldByName('shipping_address').AsString := String(RowData['shipping_address']);
// xdwdsShipTo.FieldByName('zip').AsString := String(RowData['zip']);
// xdwdsShipTo.FieldByName('ship_block').AsString := String(RowData['ship_block']);
// xdwdsShipTo.FieldByName('contact').AsString := String(RowData['contact']);
//
// xdwdsShipTo.Post;
// end;
xdwdsShipTo.Close;
xdwdsShipTo.SetJSONData(notification['ADDRESS']);
xdwdsShipTo.Open;
console.log(xdwdsShipTo.RecordCount);
console.log(xdwdsShipTo.FieldByName('state').AsString);
edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString;
edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString;
edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString;
edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString;
edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString;
memoShipBlock.Text := xdwdsShipTo.FieldByName('ship_block').AsString;
// GetCustomer();
end;
procedure TFViewAddCustomer.btnAddClick(Sender: TObject);
......@@ -429,9 +463,8 @@ begin
EditMode();
end;
procedure TFViewAddCustomer.wdbtcAddressesDblClickCell(Sender: TObject; ACol,
procedure TFViewAddCustomer.wdbtcAddressesClickCell(Sender: TObject; ACol,
ARow: Integer);
// Retrieves the shipping address allowing it to be edited.
begin
xdwdsShipTo.Locate('ship_id', wdbtcAddresses.Cells[0, ARow], []);
......@@ -714,8 +747,8 @@ begin
if VerifyAddress() then
begin
await(SendAddressToServer);
Clear();
await(GetCustomer); // Ensures xdwdsShipTo is refreshed with server data
//Clear();
//await(GetCustomer); // Ensures xdwdsShipTo is refreshed with server data
ViewMode();
end;
end;
......@@ -742,13 +775,13 @@ begin
xdwdsShipTo.Open;
memoAddressBlock.Text := string(customer['staff_fields_invoice_to']);
console.log(customer['SHIPPING_ADDRESS_LIST']);
edtShippingAddress.Text := xdwdsShipTo.FieldByName('shipping_address').AsString;
edtShippingCity.Text := xdwdsShipTo.FieldByName('city').AsString;
edtShippingState.Text := xdwdsShipTo.FieldByName('state').AsString;
edtShippingZip.Text := xdwdsShipTo.FieldByName('zip').AsString;
edtShippingContact.Text := xdwdsShipTo.FieldByName('contact').AsString;
memoShipBlock.Text := xdwdsShipTo.FieldByName('ship_block').AsString;
if memoShipBlock.Lines.Count > 0 then
edtFirstLine.Text := memoShipBlock.Lines[0]
else
......
[Paths]
HtmlPath=C:\Projects\kgOrders\kgOrders\kgOrdersClient\TMSWeb\Debug
HtmlFile=index.html
DefaultURL=http://127.0.0.1:8000/webKGOrders
SingleInstance=0
Debug=0
DebugManager=C:\RADTools\TMS\Products\tms.webcore\Bin\Win32\TMSDBGManager.exe
URL=http://127.0.0.1:8000/$(ProjectName)
URLParams=
Browser=1
BrowserBin=
BrowserParams=
Electron=0
ElectronBuild=0
JSDebugger=0
......@@ -812,7 +812,7 @@ begin
while not ordersDB.UniQuery1.Eof do
begin
ADDRESS := TJSONObject.Create;
ADDRESS.AddPair('ADDRESS', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('ship_block', ordersDB.UniQuery1.FieldByName('ship_block').AsString);
ADDRESS.AddPair('shipping_address', ordersDB.UniQuery1.FieldByName('address').AsString);
ADDRESS.AddPair('city', ordersDB.UniQuery1.FieldByName('city').AsString);
ADDRESS.AddPair('state', ordersDB.UniQuery1.FieldByName('state').AsString);
......
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