Commit 56284871 by Mac Stephens

Added login version label, removed green validation, button color updates, and…

Added login version label, removed green validation, button color updates, and added notification modal helper
parent dc71971e
......@@ -19,7 +19,7 @@ type
FUnauthorizedAccessProc: TUnauthorizedAccessProc;
public
const clientVersion = '1.0.0';
const clientVersion = '0.9.11';
procedure InitApp(SuccessProc: TSuccessProc;
UnauthorizedAccessProc: TUnauthorizedAccessProc);
procedure SetClientConfig(Callback: TVersionCheckCallback);
......
......@@ -15,6 +15,7 @@ function FormatPhoneNumber(PhoneNumber: string): string;
procedure ApplyReportTitle(CurrentReportType: string);
procedure ShowToast(const MessageText: string; const ToastType: string = 'success');
procedure ShowConfirmationModal(msg, leftLabel, rightLabel: string; ConfirmProc: TProc<Boolean>);
procedure ShowNotificationModal(msg: string);
// function FormatDollarValue(ValueStr: string): string;
......@@ -121,6 +122,37 @@ begin
end;
procedure ShowNotificationModal(msg: string);
begin
asm
var modal = document.getElementById('main_notification_modal');
var label = document.getElementById('main_notification_modal_body');
var closeBtn = document.getElementById('btn_modal_close');
if (label) label.innerText = msg;
// Ensure modal is a direct child of <body>
if (modal && modal.parentNode !== document.body) {
document.body.appendChild(modal);
}
// Button simply closes the modal
if (closeBtn) {
closeBtn.onclick = function () {
var existing = bootstrap.Modal.getInstance(modal);
if (existing) {
existing.hide();
}
};
}
// Show the Bootstrap modal
var bsModal = new bootstrap.Modal(modal, { keyboard: false });
bsModal.show();
end;
end;
// ShowConfirmationModal displays a two-button modal with custom labels.
// Params:
// - messageText: text shown in the modal body
......@@ -255,7 +287,7 @@ begin
toastBody.innerText = ParsedText;
toastEl.classList.remove('bg-success', 'bg-danger', 'bg-warning', 'bg-info');
toastEl.classList.remove('bg-success', 'bg-danger', 'bg-warning', 'bg-primary');
toastEl.classList.remove('slide-in');
switch (ToastKind) {
......@@ -266,7 +298,7 @@ begin
toastEl.classList.add('bg-warning');
break;
case 'info':
toastEl.classList.add('bg-info');
toastEl.classList.add('bg-primary');
break;
default:
toastEl.classList.add('bg-success');
......
......@@ -184,7 +184,7 @@ begin
if AuthService.TokenPayload.Properties['qb_enabled'] then
ShowSelectCustomerForm()
else
ShowToast('QB interface not currently active', 'info');
ShowNotificationModal('Quickbooks interface not currently active');
end;
procedure TFViewCustomers.edtFilterChange(Sender: TObject);
......
......@@ -115,7 +115,6 @@ object FViewEditUser: TFViewEditUser
Height = 25
Caption = 'Save'
ChildOrder = 9
ElementClassName = 'btn btn-light'
ElementID = 'btnconfirm'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
......@@ -154,7 +153,6 @@ object FViewEditUser: TFViewEditUser
Height = 25
Caption = 'Cancel'
ChildOrder = 9
ElementClassName = 'btn btn-light'
ElementID = 'btncancel'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
......
......@@ -3,7 +3,7 @@
<!-- Edit-User form -->
<div class="row">
<div class="col-lg-10 col-xl-8 mx-auto">
<form id="edituserform" class="row g-3 needs-validation" novalidate>
<form id="edituserform" class="row g-3" novalidate>
<div class="col-md-6">
<label id="lblusername" for="edtusername" class="form-label">Username</label>
......@@ -52,11 +52,11 @@
</select>
</div>
<div class="d-flex gap-2 mt-4">
<button id="btnconfirm" type="button" class="btn btn-primary flex-grow-1">
<div class="gap-2 mt-4">
<button id="btnconfirm" type="button" class="btn btn-primary">
Confirm
</button>
<button id="btncancel" type="button" class="btn btn-outline-secondary flex-grow-1">
<button id="btncancel" type="button" class="btn btn-danger">
Cancel
</button>
</div>
......
......@@ -191,23 +191,51 @@ end;
procedure TFViewEditUser.btnConfirmClick(Sender: TObject);
var
FormEl: TJSHTMLFormElement;
AllValid: Boolean;
begin
FormEl := TJSHTMLFormElement(document.getElementById('edituserform'));
FormEl := TJSHTMLFormElement(document.getElementById('userprofileform'));
if not FormEl.checkValidity then
// Clear previous invalid state
edtUsername.ElementHandle.classList.remove('is-invalid');
edtFullName.ElementHandle.classList.remove('is-invalid');
edtEmail.ElementHandle.classList.remove('is-invalid');
if Assigned(FormEl) then
FormEl.classList.remove('was-validated');
AllValid := True;
if edtUsername.Text.Trim = '' then
begin
FormEl.classList.add('was-validated');
Exit;
edtUsername.ElementHandle.classList.add('is-invalid');
AllValid := False;
end;
Utils.ShowSpinner('spinner');
if edtFullName.Text.Trim = '' then
begin
edtFullName.ElementHandle.classList.add('is-invalid');
AllValid := False;
end;
if Mode = 'Edit' then
EditUser
else
AddUser;
if not TJSHTMLInputElement(edtEmail.ElementHandle).checkValidity then
begin
edtEmail.ElementHandle.classList.add('is-invalid');
AllValid := False;
end;
WebTimer1.Enabled := True;
if not AllValid then
Exit;
ShowConfirmationModal(
'Are you sure you want to save changes to your profile?',
'Save',
'Cancel',
procedure(confirmed: Boolean)
begin
if confirmed then
EditUser;
end
);
end;
end.
......@@ -477,7 +477,7 @@ begin
);
end
else
ShowToast('QB interface not currently active', 'info');
ShowNotificationModal('Quickbooks interface not currently active.');
end;
procedure TFViewItems.btnCancelClick(Sender: TObject);
......@@ -503,7 +503,7 @@ end;
procedure TFViewItems.btnDeleteClick(Sender: TObject);
begin
ShowToast('Deleting items is not yet implemented.', 'info');
ShowNotificationModal('Deleting items is not yet implemented.');
end;
procedure TFViewItems.btnEditClick(Sender: TObject);
......
object FViewLogin: TFViewLogin
Width = 1322
Height = 764
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
OnShow = WebFormShow
object WebLabel1: TWebLabel
Left = 240
Top = 112
......@@ -46524,6 +46527,19 @@ object FViewLogin: TFViewLogin
15BCA2C7441041288CDA38EF006C6D7669C7FF01B763F67F594E0DF800000000
49454E44AE426082}
end
object lblClientVersion: TWebLabel
Left = 272
Top = 229
Width = 72
Height = 13
Caption = 'lblClientVersion'
ElementID = 'lbl_client_version'
ElementFont = efCSS
ElementPosition = epRelative
HeightStyle = ssAuto
HeightPercent = 100.000000000000000000
WidthPercent = 100.000000000000000000
end
object edtUsername: TWebEdit
Left = 240
Top = 136
<nav class="navbar navbar-light bg-light login-navbar">
<div class="container-fluid">
<a class="navbar-brand" href="#">Koehler-Gibson Orders</a>
<div class="container-fluid">
<a class="navbar-brand" href="#">Koehler-Gibson Orders</a>
</div>
</nav>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-auto">
<img id="kgpicture" style="width: 250px; height: 250px;">
</div>
</nav>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-auto">
<img id="kgpicture"style="width: 250px; height: 250px;">
</div>
<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 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 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 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>
<div class="text-end text-muted small mt-1">
<span id="lbl_client_version"></span>
</div>
</fieldset>
</div>
</div>
</div>
</div>
</div>
</div>
......@@ -19,9 +19,10 @@ type
btnCloseNotification: TWebButton;
XDataWebClient: TXDataWebClient;
WebImageControl1: TWebImageControl;
lblClientVersion: TWebLabel;
procedure btnLoginClick(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject);
procedure WebFormCreate(Sender: TObject);
procedure WebFormShow(Sender: TObject);
private
FLoginProc: TSuccessProc;
FMessage: string;
......@@ -98,18 +99,20 @@ begin
end;
end;
procedure TFViewLogin.WebFormCreate(Sender: TObject);
procedure TFViewLogin.btnCloseNotificationClick(Sender: TObject);
begin
HideNotification;
end;
procedure TFViewLogin.WebFormShow(Sender: TObject);
begin
console.log(DMConnection.clientVersion);
FViewLogin.lblClientVersion.Caption := 'v' + DMConnection.clientVersion;
if FMessage <> '' then
ShowNotification(FMessage)
else
HideNotification;
end;
procedure TFViewLogin.btnCloseNotificationClick(Sender: TObject);
begin
HideNotification;
end;
end.
......@@ -116,6 +116,23 @@
</div>
</div>
<div class="modal fade" id="main_notification_modal" tabindex="-1" aria-labelledby="main_lblmodal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content shadow-lg">
<div class="modal-header">
<h5 class="modal-title" id="main_notification_modal">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="main_notification_modal_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>
......
......@@ -98,6 +98,7 @@ begin
if (not (JS.toString(AuthService.TokenPayload.Properties['user_access_type']) = 'ADMIN')) then
begin
lblUsers.enabled := false;
lblCustomers.Enabled := false;
end;
......@@ -333,5 +334,4 @@ begin
FChildForm := TFViewUsers.CreateForm(WebPanel1.ElementID, Info);
end;
end.
object FViewUserProfile: TFViewUserProfile
Width = 604
Height = 434
CSSLibrary = cssBootstrap
ElementFont = efCSS
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
......@@ -206,7 +208,7 @@ object FViewUserProfile: TFViewUserProfile
end
object btnConfirm: TWebButton
Left = 85
Top = 210
Top = 207
Width = 96
Height = 25
Caption = 'Confirm Changes'
......
......@@ -61,7 +61,7 @@
Confirm&nbsp;Changes
</button>
<button id="view.userprofile.form.btncancel"
class="btn btn-outline-secondary flex-grow-1"
class="btn btn-danger flex-grow-1"
type="button">
Cancel&nbsp;Changes
</button>
......
......@@ -51,11 +51,6 @@ var
FormEl: TJSHTMLFormElement;
begin
FormEl := TJSHTMLFormElement(document.querySelector('form'));
if not FormEl.checkValidity then
begin
FormEl.classList.add('was-validated');
Exit;
end;
ShowConfirmationModal(
'Are you sure you want to save changes to your profile?',
......
object FViewUsers: TFViewUsers
Width = 640
Height = 480
CSSLibrary = cssBootstrap
ElementFont = efCSS
OnShow = WebFormCreate
object lblEntries: TWebLabel
Left = 8
......@@ -21,7 +23,6 @@ object FViewUsers: TFViewUsers
Height = 25
Caption = 'Add User'
ChildOrder = 9
ElementClassName = 'btn btn-light'
ElementID = 'btnadduser'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
......@@ -30,6 +31,7 @@ object FViewUsers: TFViewUsers
Font.Style = []
HeightPercent = 100.000000000000000000
ParentFont = False
TabStop = False
WidthPercent = 100.000000000000000000
OnClick = btnAddUserClick
end
......
......@@ -402,3 +402,5 @@ is-invalid .form-check-input {
......@@ -78,7 +78,7 @@ object FMain: TFMain
end
object initTimer: TTimer
OnTimer = initTimerTimer
Left = 58
Left = 60
Top = 398
end
object ExeInfo1: TExeInfo
......
[Settings]
MemoLogLevel=4
FileLogLevel=4
webClientVersion=1.0.0
LogFileNum=158
webClientVersion=0.9.11
LogFileNum=160
[Database]
--Server=192.168.116.138
--Server=192.168.102.130
Server=192.168.102.129
--Server=192.168.75.133
Server=192.168.159.10
--Server=192.168.159.10
Database=kg_order_entry
Username=root
Password=emsys01
......
......@@ -114,7 +114,10 @@
<VerInfo_Locale>1033</VerInfo_Locale>
<DCC_ExeOutput>.\bin</DCC_ExeOutput>
<DCC_UnitSearchPath>C:\RADTOOLS\FastMM4;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<VerInfo_Keys>CompanyName=EM Systems;FileDescription=$(MSBuildProjectName);FileVersion=0.9.11.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=0.9.11;Comments=</VerInfo_Keys>
<VerInfo_MajorVer>0</VerInfo_MajorVer>
<VerInfo_MinorVer>9</VerInfo_MinorVer>
<VerInfo_Release>11</VerInfo_Release>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
......
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