Commit 32d4033d by Cam Hayes

Got QB ID to be unique and fixed the error modal to hide the spinner and remain on the form

parent 151f60b4
......@@ -91,6 +91,7 @@ end;
procedure ShowErrorModal(msg: string);
begin
HideSpinner('spinner');
asm
var modal = document.getElementById('main_errormodal');
var label = document.getElementById('main_lblmodal_body');
......@@ -106,7 +107,8 @@ begin
// Bind hard reload to button
if (reloadBtn) {
reloadBtn.onclick = function () {
window.location.reload(true); // hard reload, bypass cache
//window.location.reload(true); // hard reload, bypass cache
bsModal.hide();
};
}
......
......@@ -61,10 +61,10 @@
</div>
</div>
<div class="col-auto">
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Territory:</label>
<label for="wdbe_first_name" style="font-weight: 700; font-size: 15px;" class="form-label mt-2">Representative:</label>
<input id="edtrepuser"type="text" class="form-control" style="width: 150px"/>
<div class="invalid-feedback" id="territorywarning" style="font-size: 15px;">
Territory not found in kgOrders
Representative not found in kgOrders
</div>
</div>
</div>
......
......@@ -9,8 +9,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 95
Height = 15
Caption = 'Search Customers'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel2: TWebLabel
Left = 279
......@@ -18,8 +18,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 134
Height = 15
Caption = 'Selected Customer Name'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object WebLabel3: TWebLabel
Left = 131
......@@ -27,8 +27,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 113
Height = 15
Caption = 'Selected Customer ID'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtSearch: TWebEdit
Left = 4
......@@ -36,8 +36,8 @@ object FSelectCustomer: TFSelectCustomer
Width = 121
Height = 22
ChildOrder = 2
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtSearchChange
end
object edtName: TWebEdit
......@@ -47,8 +47,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 22
ChildOrder = 1
Enabled = False
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object TMSFNCGrid1: TTMSFNCGrid
Left = 0
......@@ -59,7 +59,7 @@ object FSelectCustomer: TFSelectCustomer
ParentDoubleBuffered = False
DoubleBuffered = True
TabOrder = 2
DefaultRowHeight = 40.00000000000000000
DefaultRowHeight = 40.000000000000000000
FixedColumns = 0
ColumnCount = 4
Options.Bands.Enabled = True
......@@ -85,7 +85,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 90.00000000000000000
Width = 90.000000000000000000
end
item
BorderWidth = 1
......@@ -100,7 +100,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 150.00000000000000000
Width = 150.000000000000000000
end
item
BorderWidth = 1
......@@ -115,7 +115,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 400.00000000000000000
Width = 400.000000000000000000
end
item
BorderWidth = 1
......@@ -130,7 +130,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 106.00000000000000000
Width = 106.000000000000000000
end
item
BorderWidth = 1
......@@ -145,7 +145,7 @@ object FSelectCustomer: TFSelectCustomer
Font.Name = 'Segoe UI'
Font.Style = []
ID = ''
Width = 1.00000000000000000
Width = 1.000000000000000000
end>
DefaultFont.Charset = DEFAULT_CHARSET
DefaultFont.Color = clWindowText
......@@ -215,8 +215,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 25
Caption = 'Cancel'
ChildOrder = 5
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCancelClick
end
object btnConfirm: TWebButton
......@@ -226,8 +226,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 25
Caption = 'Select'
ChildOrder = 5
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnConfirmClick
end
object edtID: TWebEdit
......@@ -237,8 +237,8 @@ object FSelectCustomer: TFSelectCustomer
Height = 22
ChildOrder = 1
Enabled = False
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object XDataWebClient1: TXDataWebClient
Connection = DMConnection.ApiConnection
......
......@@ -125,7 +125,10 @@ begin
PopulateGridManually;
except
on E: EXDataClientRequestException do
begin
Close();
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
end;
......
......@@ -13,8 +13,8 @@ object FViewCustomers: TFViewCustomers
ElementID = 'lblentries'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnAddCustomer: TWebButton
Left = 12
......@@ -26,10 +26,10 @@ object FViewCustomers: TFViewCustomers
ElementID = 'btnaddcustomer'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
TabOrder = 6
TabStop = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnAddCustomerClick
end
object wcbPageSize: TWebComboBox
......@@ -41,9 +41,9 @@ object FViewCustomers: TFViewCustomers
ElementID = 'wcbpagesize'
ElementFont = efCSS
HeightStyle = ssAuto
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
Text = '50'
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
OnChange = wcbPageSizeChange
ItemIndex = -1
Items.Strings = (
......@@ -66,8 +66,8 @@ object FViewCustomers: TFViewCustomers
Height = 15
Caption = 'Message'
ElementID = 'view.login.message.label'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object btnCloseNotification: TWebButton
Left = 96
......@@ -76,8 +76,8 @@ object FViewCustomers: TFViewCustomers
Height = 25
ChildOrder = 1
ElementID = 'view.login.message.button'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
end
object wdbtcCustomers: TWebDBTableControl
......@@ -139,8 +139,8 @@ object FViewCustomers: TFViewCustomers
Height = 22
ChildOrder = 5
ElementID = 'edtfilter'
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnChange = edtFilterChange
end
object XDataWebClient1: TXDataWebClient
......
......@@ -177,10 +177,7 @@ end;
procedure TFViewCustomers.btnAddCustomerClick(Sender: TObject);
begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
ShowSelectCustomerForm()
else
ShowNotificationModal('QuickBooks interface is not currently active');
ShowSelectCustomerForm()
end;
procedure TFViewCustomers.edtFilterChange(Sender: TObject);
......
......@@ -123,7 +123,10 @@ begin
//Utils.HideSpinner('spinner');
except
on E: EXDataClientRequestException do
begin
Close();
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
Utils.HideSpinner('spinner');
end;
......
......@@ -442,39 +442,35 @@ var
itemOptions: string;
newform: TFViewAddItem;
begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
begin
newform := TFViewAddItem.CreateNew;
newform := TFViewAddItem.CreateNew;
newform.Caption := 'Select Item to Add';
newForm.Popup := True;
newForm.position:= poScreenCenter;
newForm.Border := fbDialog;
newform.Caption := 'Select Item to Add';
newForm.Popup := True;
newForm.position:= poScreenCenter;
newForm.Border := fbDialog;
// used to manage Back button handling to close subform
window.location.hash := 'subform';
// used to manage Back button handling to close subform
window.location.hash := 'subform';
newform.ShowModal(
procedure(AValue: TModalResult)
newform.ShowModal(
procedure(AValue: TModalResult)
begin
if newform.confirm then
begin
if newform.confirm then
begin
xdwdsItems.Append;
xdwdsItems.Append;
xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID;
xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status;
xdwdsItems.FieldByName('QB_ID').AsString := newform.QB_ID;
xdwdsItems.FieldByName('name').AsString := newform.name;
xdwdsItems.FieldByName('description').AsString := newform.description;
xdwdsItems.FieldByName('status').AsString := newform.status;
xdwdsItems.Post;
EditMode();
lblFormState.Caption := 'Add Mode';
end;
end
);
end
else
ShowNotificationModal('QuickBooks interface is not currently active.');
xdwdsItems.Post;
EditMode();
lblFormState.Caption := 'Add Mode';
end;
end
);
end
end;
procedure TFViewItems.btnCancelClick(Sender: TObject);
......@@ -511,12 +507,7 @@ var
itemOptions: string;
newform: TFViewAddItem;
begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
begin
UpdateItem();
end
else
ShowNotificationModal('QuickBooks interface is not currently active.');
UpdateItem();
end;
procedure TFViewItems.UpdateItem();
......
......@@ -95,7 +95,7 @@
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>
<button type="button" id="btn_modal_restart" class="btn btn-primary">Close</button>
</div>
</div>
</div>
......
......@@ -391,14 +391,6 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
qbEnabled := boolean(AuthService.TokenPayload.Properties['qb_enabled']);
if not qbEnabled then
begin
ShowToast('QB interface not currently active', 'info');
Exit;
end;
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
......
......@@ -195,14 +195,6 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
qbEnabled := boolean(AuthService.TokenPayload.Properties['qb_enabled']);
if not qbEnabled then
begin
ShowToast('QB interface not currently active', 'info');
Exit;
end;
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
......
......@@ -455,14 +455,6 @@ var
orderJSON: TJSONObject;
qbEnabled: boolean;
begin
qbEnabled := boolean(AuthService.TokenPayload.Properties['qb_enabled']);
if not qbEnabled then
begin
ShowToast('QB interface not currently active', 'info');
Exit;
end;
if JS.toString(AuthService.TokenPayload.Properties['user_qb_id']) <> '' then
begin
if ( VerifyQBOrder() )then
......
......@@ -13,9 +13,9 @@ object FQBInfo: TFQBInfo
Font.Height = -24
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object lblCompanyName: TWebLabel
Left = 16
......@@ -28,9 +28,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object lblCompanyID: TWebLabel
Left = 15
......@@ -43,9 +43,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object lblLastRefresh: TWebLabel
Left = 16
......@@ -58,9 +58,9 @@ object FQBInfo: TFQBInfo
Font.Height = -16
Font.Name = 'Segoe UI'
Font.Style = []
HeightPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
ParentFont = False
WidthPercent = 100.00000000000000000
WidthPercent = 100.000000000000000000
end
object btnLinkToQB: TWebButton
Left = 235
......@@ -69,8 +69,8 @@ object FQBInfo: TFQBInfo
Height = 25
Caption = 'Link to QB'
ChildOrder = 3
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnLinkToQBClick
end
object btnClose: TWebButton
......@@ -80,8 +80,8 @@ object FQBInfo: TFQBInfo
Height = 25
Caption = 'Close'
ChildOrder = 3
HeightPercent = 100.00000000000000000
WidthPercent = 100.00000000000000000
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
OnClick = btnCloseClick
end
object XDataWebClient1: TXDataWebClient
......
......@@ -86,7 +86,10 @@ begin
except
on E: EXDataClientRequestException do
begin
Close();
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
end;
end;
end;
......
......@@ -99,7 +99,10 @@ begin
xdcResponse := await(XDataWebClient1.RawInvokeAsync('ILookupService.AddUser', [userInfo]));
responseString := TJSObject(xdcResponse.Result);
Info := string(responseString['value']);
FViewMain.ShowUserForm(Info);
if Info.ToLower.Contains('failure') then
ShowToast(Info)
else
FViewMain.ShowUserForm(Info);
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
......@@ -129,7 +132,10 @@ begin
[editOptions]));
responseString := TJSObject(xdcResponse.Result);
Info := string(responseString['value']);
FViewMain.ShowUserForm(Info);
if Info.ToLower.Contains('failure') then
ShowToast(Info)
else
FViewMain.ShowUserForm(Info);
except
on E: EXDataClientRequestException do
Utils.ShowErrorModal(E.ErrorResult.ErrorMessage);
......
......@@ -127,14 +127,6 @@ begin
raise EXDataHttpUnauthorized.Create('User not active!');
end;
iniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
try
qbEnabled := iniFile.ReadBool('Quickbooks', 'Enabled', true);
finally
iniFile.Free;
end;
JWT := TJWT.Create;
try
JWT.Claims.JWTId := LowerCase(Copy(TUtils.GuidToVariant(TUtils.NewGuid), 2, 36));
......@@ -147,7 +139,6 @@ begin
JWT.Claims.SetClaimOfType<string>('user_email', authDB.uq.FieldByName('EMAIL').AsString);
JWT.Claims.SetClaimOfType<string>('user_qb_id', authDB.uq.FieldByName('QB_ID').AsString);
JWT.Claims.SetClaimOfType<string>('user_access_type', authDB.uq.FieldByName('ACCESS_TYPE').AsString);
JWT.Claims.SetClaimOfType<boolean>('qb_enabled', qbEnabled);
Result := TJOSE.SHA256CompactToken(serverConfig.jwtTokenSecret, JWT);
finally
......
......@@ -193,11 +193,6 @@ begin
Logger.Log( 1, '----Database->Password: xxxxxxxx' );
Logger.Log(1, '---Quickbooks---');
iniStr := IniFile.ReadString( 'Quickbooks', 'Enabled', '' );
if iniStr.IsEmpty then
Logger.Log( 1, '--Quickbooks->Enabled: Entry not found - default: true' )
else
Logger.Log( 1, '--Quickbooks->Enabled: ' + iniStr );
iniStr := IniFile.ReadString( 'Quickbooks', 'CompanyID', '' );
if iniStr.IsEmpty then
......
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