This commit is contained in:
Andy Howard
2024-11-26 11:33:22 +00:00
parent 8b872cc8f3
commit c8b5df5909
56 changed files with 1122 additions and 860 deletions
@@ -2,6 +2,17 @@
BusMgr Portal - Base stylesheet.
*/
:root
{
--color-OldGold: #d4af37;
--color-OliveGreen: #808000;
--color-CornflowerBlue: #6495ed;
--color-RoyalBlue: #4169e1;
--color-NavyBlue: #000080;
--color-DarkBlue: #00008B;
--color-Indigo: #4b0082;
}
body
{
margin: 0;
@@ -195,7 +206,32 @@ td.action
text-align: center;
}
.fullwidth
.width5pc
{
width: 5%;
}
.width10pc
{
width: 10%;
}
.width20pc
{
width: 20%;
}
.width25pc
{
width: 25%;
}
.width50pc
{
width: 50%;
}
.fullwidth, .width100pc
{
width: 100%;
}
@@ -389,9 +425,9 @@ td.action
z-index: 99;
}
.hidden
.hidden, .sbm-hidden
{
display: none;
display: none !important;
}
.shadow
@@ -2,14 +2,13 @@
BusMgr Portal - Data stylesheet.
*/
/* Data panel */
:root
{
--color-OliveGreen: #808000;
--color-DataPanel-main: var(--color-OliveGreen);
}
/* Data panel */
.sbm-panel-data
{
margin: 6px auto;
@@ -133,6 +133,11 @@
margin: 0 0 16px 0;
}
.sbm-form .sbm-form-control .sbm-form-control
{
margin-bottom: 0;
}
.sbm-form .sbm-form-control .sbm-label
{
margin: 0 0 8px 0;
@@ -224,8 +229,8 @@
font-size: 1rem;
text-align: center;
color: #fff;
background-color: #d4af37;
border: 1px solid #d4af37;
background-color: var(--color-OldGold);
border: 1px solid var(--color-OldGold);
border-radius: 4px;
}
@@ -11,10 +11,6 @@
--color-primary: #4b0082;
--color-light: #9b71b9;
--color-pale: #ebe2f1;
/* Tetrad/Square colors */
--color-alt1: #820a00;
--color-alt2: #378200;
--color-alt3: #007882;
}
/* Document */
@@ -166,7 +162,7 @@ button.accept-policy
a, a:hover
{
text-decoration: underline;
color: #d4af37;
color: var(--color-OldGold);
}
a:focus
@@ -326,6 +322,17 @@ a:focus
}
/* Dialogs */
:root
{
--color-dialog: var(--color-OldGold);
}
.ui-dialog.sbm-dark-blue
{
--color-dialog: var(--color-DarkBlue);
}
.sbm-dialog
{
display: none;
@@ -350,7 +357,7 @@ a:focus
.ui-dialog.ui-widget.ui-widget-content
{
border-width: 2px;
border-color: #d4af37;
border-color: var(--color-dialog);
-moz-box-shadow: 4px 4px 6px #ccc;
-webkit-box-shadow: 4px 4px 6px #ccc;
overflow: hidden;
@@ -365,8 +372,8 @@ a:focus
{
font-size: 1.1rem;
color: #fff;
background-color: #d4af37;
border-color: #d4af37;
background-color: var(--color-dialog);
border-color: var(--color-dialog);
}
.ui-widget-content
@@ -383,12 +390,12 @@ a:focus
.ui-dialog.no-close .ui-dialog-titlebar-close
{
/*display: none;*/
display: none;
}
.ui-dialog .ui-dialog-buttonpane
{
border-color: #d4af37;
border-color: var(--color-dialog);
margin-top: .25em;
padding: .2em 1em .2em .5em;
}
@@ -398,8 +405,8 @@ a:focus
min-width: 80px;
margin: .5em .25em .5em .5em;
color: #fff;
background-color: #d4af37;
border-color: #d4af37;
background-color: var(--color-dialog);
border-color: var(--color-dialog);
outline: none;
}
@@ -417,7 +424,7 @@ a:focus
.ui-datepicker .ui-datepicker-header
{
background-color: #fff;
border: 1px solid #d4af37;
border: 1px solid var(--color-OldGold);
}
/* The End */
@@ -23,7 +23,7 @@
}
as.doRefreshResults = function (response)
{
sbm.debug('doRefreshResults', response);
//sbm.debug('doRefreshResults', response);
delete sbm.awaitingRefreshResponse;
$pnl.msgs.hide().empty();
let $table = $('table', $pnl.table).find('tbody tr').remove().end();
@@ -31,6 +31,9 @@
if (!response.success) return;
// Reference data.
as.config = response.config;
as.configCust = response.configCust;
as.configSupp = response.configSupp;
as.data.associationTypes = response.associationTypes;
as.data.statuses = response.statuses;
as.data.defaultStatusCode = response.defaultStatusCode;
@@ -39,26 +42,25 @@
$pnl.bgr.invisible();
$pnl.mnu.empty();
$pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.refresh, function () { as.refreshResults(); }, 'sbm-refresh'));
$pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.create, function () { as.createItem(); }, 'sbm-add'));
$pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.createCust, function () { as.createItem(as.configCust, sbm.lbl.createCust); }, 'sbm-add'));
$pnl.mnu.append(as.getFilterMenuOption(sbm.lbl.createSupp, function () { as.createItem(as.configSupp, sbm.lbl.createSupp); }, 'sbm-add'));
$pnl.bgr.toggleVisibility(!!$('.sbm-dropdown-item', $pnl.mnu).length);
// Items.
var items = response.associations || [];
if (!items.length)
return $pnl.msgs.append($('<div class="sbm-message">' + sbm.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
$table.append(as.populateItem(as.getItemTemplate(), items[itemIdx]));
sbm.configureItemTable(as.config, $table);
}
as.populateItem = function ($item, item)
{
if (!item) return;
$pnl.msgs.hide().empty();
$item.prop('id', as.getItemId(item));
$('.AssociationCode', $item).text(item.code);
$('.AssociationTargetName', $item).text(item.targetName);
$('.AssociationType', $item).text(item.typeDesc);
$('.AssociationAddress', $item).text(item.addressSummary);
$('.AssociationNotes', $item).text(item.notes);
$('.AssociationStatusDesc', $item).text(item.statusDesc).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase());
sbm.populateItemValues(as.config, $item, item.field.value);
let prefix = as.config.column.prefix;
$('.' + prefix + 'Status', $item).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase());
// Actions.
var $bgr = $('.sbm-burger', $item).hide();
let $mnu = $('ul.sbm-dropdown-menu', $bgr).empty();
@@ -66,7 +68,7 @@
{
let fnUpd = function () { as.updateItem(item) };
$mnu.append(as.getItemMenuOption(sbm.lbl.edit, fnUpd, 'sbm-edit'));
$('.AssociationTargetName', $item).off('click').on('click', fnUpd).addClass('sbm-action-text');
$('.' + prefix + 'Target', $item).off('click').on('click', fnUpd).addClass('sbm-action-text');
$item.off('dblclick').on('dblclick', fnUpd);
}
$bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length);
@@ -74,7 +76,7 @@
}
as.getItemId = function (item)
{
return 'Ass_' + (item || {}).id;
return 'Asn_' + (item || {}).id;
}
//--------------------------------------------------------------
@@ -106,25 +108,25 @@
}
//--------------------------------------------------------------
as.createItem = function ()
as.createItem = function (cfg, title)
{
as.clearItem();
as.clearItem(cfg);
let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item);
$ctrls.filter('.AssociationType').val('').prop('disabled', false);
$ctrls.filter('.AssociationStatus').val(as.data.defaultStatusCode);
$dlg.item.dialog('option', 'title', sbm.dlg.title.createAssociation);
as.openItemDlg();
as.openItemDlg(cfg, title);
}
as.clearItem = function ()
as.clearItem = function (cfg)
{
sbm.clearControlErrors($frm.item);
$('.sbm-input,.sbm-textarea,.sbm-select', $frm.item).val('');
sbm.clearItemForm($frm.item);
sbm.populateSelectCodeDesc('#cbAssociationType', as.data.associationTypes);
sbm.populateSelectCodeDesc('#cbAssociationStatus', as.data.statuses);
}
as.openItemDlg = function ()
as.openItemDlg = function (cfg, title)
{
sbm.openDialog($dlg.item, 600, 640);
sbm.configureItemControls(cfg, $frm.item);
$dlg.item.dialog('option', 'title', title);
sbm.openDialog($dlg.item, 640, 600);
}
//--------------------------------------------------------------
@@ -137,23 +139,22 @@
as.onUpdateItem = function (response)
{
//sbm.debug('onUpdateItem', response);
as.clearItem();
if (!response.success) return;
let cfg = response.config || {};
let prefix = cfg.field.prefix;
as.clearItem(cfg);
let item = response.association;
sbm.populateFormValues(cfg, $frm.item, item.field.value);
let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item);
$ctrls.filter('.AssociationId').val(item.id);
$ctrls.filter('.AssociationExists').val(1);
let $ctrlType = $ctrls.filter('.AssociationType');
sbm.selectOrAdd($ctrlType, item.typeCode, item.typeDesc)
if ($ctrlType.val()) $ctrlType.prop('disabled', true);
//if ($ctrlType.val()) $ctrlType.prop('disabled', true);
$ctrls.filter('.AssociationOwnerId').val(item.ownerId);
$ctrls.filter('.AssociationTargetId').val(item.targetId);
$ctrls.filter('.AssociationTarget').val(item.targetName);
$ctrls.filter('.AssociationCode').val(item.code);
$ctrls.filter('.AssociationDesc').val(item.desc);
$ctrls.filter('.AssociationNotes').val(item.notes);
sbm.selectOrAdd($ctrls.filter('.AssociationStatus'), item.statusCode, item.statusDesc)
$dlg.item.dialog('option', 'title', sbm.dlg.title.updateAssociation);
as.openItemDlg();
as.openItemDlg(cfg, cfg.title || sbm.dlg.title.updateAssociation);
}
//--------------------------------------------------------------
@@ -168,6 +169,7 @@
sbm.refreshControlValues(response.controlValues);
if (!response.success) return;
$dlg.item.dialog('close');
$pnl.msgs.hide().empty();
var item = response.association;
var $item = $('#' + as.getItemId(item), $pnl.table);
@@ -176,6 +178,7 @@
$item = as.getItemTemplate();
$('table tbody', $pnl.table).prepend($item).show();
}
let cfg = response.config || {};
as.populateItem($item, item);
}
@@ -56,21 +56,17 @@
return $pnl.msgs.append($('<div class="sbm-message">' + sbm.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
$table.append(co.populateItem(co.getItemTemplate(), items[itemIdx]));
sbm.configureItemTable(co.config, $table);
}
co.populateItem = function ($item, item)
{
if (!item) return;
$pnl.msgs.hide().empty();
$item.prop('id', co.getItemId(item));
$('.ContactName', $item).text(item.displayName);
$('.ContactType', $item).text(item.typeDesc);
sbm.populateItemValues(co.config, $item, item.field.value);
let prefix = co.config.column.prefix;
if (item.associationCount)
$('.ContactAssociationCount', $item).text(item.associationCount).on('click', function () { co.onClickAssociationCount(item); }).addClass('sbm-action-text');
$('.ContactAddress', $item).text(item.addressSummary);
$('.ContactContact', $item).text(item.contact);
$('.ContactPhone', $item).text(item.phone);
$('.ContactNotes', $item).text(item.notes);
$('.ContactStatusDesc', $item).text(item.statusDesc).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase());
$('.' + prefix + 'Associations', $item).text(item.associationCount).off('click').on('click', function () { co.onClickAssociationCount(item); }).addClass('sbm-action-text');
$('.' + prefix + 'Status', $item).removeStatusClasses().addClass('sbm-status-' + item.statusCode.toLowerCase());
// Actions.
var $bgr = $('.sbm-burger', $item).hide();
let $mnu = $('ul.sbm-dropdown-menu', $bgr).empty();
@@ -78,7 +74,7 @@
{
let fnUpd = function () { co.updateItem(item) };
$mnu.append(co.getItemMenuOption(sbm.lbl.edit, fnUpd, 'sbm-edit'));
$('.ContactName', $item).off('click').on('click', fnUpd).addClass('sbm-action-text');
$('.' + prefix + 'Name', $item).off('click').on('click', fnUpd).addClass('sbm-action-text');
$item.off('dblclick').on('dblclick', fnUpd);
}
$bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length);
@@ -121,10 +117,9 @@
co.createItem = function (cfg, title)
{
co.clearItem(cfg);
let frm = $frm.item;
$('.ContactStatus', frm).val(co.data.defaultStatusCode).prop('readonly', false);
co.configureItemControls(cfg);
co.openItemDlg(title);
let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select', $frm.item);
$ctrls.filter('.ContactStatus').val(co.data.defaultStatusCode);
co.openItemDlg(cfg, title);
}
co.clearItem = function (cfg)
{
@@ -135,30 +130,13 @@
if (cfg.isGroup) $('.ContactIsGroup', frm).val(1);
sbm.populateSelectCodeDesc('#cbContactType', co.data.organisationTypes);
sbm.populateSelectCodeDesc('#cbContactTitle', co.data.titles);
sbm.selectOrAdd('#cbContactTitle', "", "")
sbm.populateSelectCodeDesc('#cbContactSalutation', co.data.salutations);
sbm.populateSelectCodeDesc('#cbContactStatus', co.data.statuses);
}
sbm.clearItemForm = function ($frm)
co.openItemDlg = function (cfg, title)
{
sbm.clearControlErrors($frm);
$('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox', $frm).val('').prop('readonly', false).prop('disabled', false).removeAttr('checked');
}
co.configureItemControls = function (cfg)
{
sbm.configureItemControls($frm.item, cfg);
}
sbm.configureItemControls = function ($frm, cfg)
{
//sbm.debug('configureItemControls', cfg);
let fld = cfg.field || {};
let $ctrl = $('.sbm-form-control', $frm.item).show();
(fld.hide || []).forEach(function (v, i, a) { $ctrl.filter('.' + cfg.field.prefix + v).hide().find('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox').prop('disabled', true); });
(fld.readonly || []).forEach(function (v, i, a) { $ctrl.filter('.' + cfg.field.prefix + v).find('.sbm-input,.sbm.textarea,.sbm-select,.sbm-checkbox').prop('readonly', true).prop('disabled', true); });
}
co.openItemDlg = function (title)
{
if (title)$dlg.item.dialog('option', 'title', title);
sbm.configureItemControls(cfg, $frm.item);
$dlg.item.dialog('option', 'title', title);
sbm.openDialog($dlg.item, 640, 600);
}
@@ -172,25 +150,18 @@
co.onUpdateItem = function (response)
{
//sbm.debug('onUpdateItem', response);
co.clearItem(response.config);
if (!response.success) return;
let cfg = response.config || {};
co.clearItem(cfg);
let item = response.contact;
sbm.populateFormValues(cfg, $frm.item, item.field.value);
let $ctrls = $('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox', $frm.item);
$ctrls.filter('.ContactId').val(item.id);
$ctrls.filter('.ContactExists').val(1);
$ctrls.filter('.ContactType').val(item.typeCode);
$ctrls.filter('.ContactProspect').prop('checked', !!item.prospect);
$ctrls.filter('.ContactNotes').val(item.notes);
$ctrls.filter('.ContactStatus').val(item.statusCode);
sbm.populateFieldValues(response.config, $frm.item, item.field);
co.configureItemControls(response.config);
co.openItemDlg(sbm.dlg.title.updateContact);
}
sbm.populateFieldValues = function (cfg, $frm, fld)
{
let val = (fld || {}).value || [];
let $ctrl = $('.sbm-form-control', $frm.item).show();
for (var name in val) { $ctrl.filter('.' + cfg.field.prefix + name).find('.sbm-input,.sbm-textarea,.sbm-select').val(val[name]).end().find('.sbm-checkbox').prop('checked',!!val[name]); };
co.openItemDlg(cfg, sbm.dlg.title.updateContact);
}
//--------------------------------------------------------------
@@ -205,6 +176,7 @@
sbm.refreshControlValues(response.controlValues);
if (!response.success) return;
$dlg.item.dialog('close');
$pnl.msgs.hide().empty();
var item = response.contact;
var $item = $('#' + co.getItemId(item), $pnl.table);
@@ -219,11 +191,12 @@
//--------------------------------------------------------------
co.onClickAssociationCount = function (item)
{
sbm.debug('onClickAssociationCount');
if (!item.id) return;
sbm.doPleaseWait();
let frm = $frm.itemId;
$('.ContactId', frm).val(item.id);
frm.prop('action', sbm.url.base + 'Association').submit();
//sbm.doPleaseWait();
//let frm = $frm.itemId;
//$('.ContactId', frm).val(item.id);
//frm.prop('action', sbm.url.base + 'Association').submit();
}
//--------------------------------------------------------------
@@ -154,6 +154,41 @@
sbm.resultsPaging.fn.refreshPaging(response.paging, context, refreshFn);
}
//--------------------------------------------------------------
sbm.configureItemTable = function (cfg, $sel)
{
//sbm.debug('configureItemTable', cfg, $sel);
let col = cfg.column || {};
let $cell = $('th,td', $sel).removeClass('hidden');
(col.hide || []).forEach(function (v, i, a) { $cell.filter('.' + col.prefix + v).addClass('hidden'); });
}
sbm.populateItemValues = function (cfg, $item, val)
{
//sbm.debug('populateItemValues', cfg, $item, val);
for (var name in val || []) { $item.find('.' + cfg.column.prefix + name).text(val[name]); };
}
sbm.clearItemForm = function ($frm)
{
//sbm.clearControlErrors($frm);
$('.sbm-input,.sbm-textarea,.sbm-select', $frm).val('').prop('readonly', false).prop('disabled', false);
$('.sbm-checkbox', $frm).prop('readonly', false).prop('disabled', false).removeAttr('checked');
}
sbm.configureItemControls = function (cfg, $frm)
{
//sbm.debug('configureItemControls', cfg);
let fld = cfg.field || {};
let $ctrl = $('.sbm-form-control', $frm).show();
for (var name in fld.label || {}) { /* ... */ };
(fld.hide || []).forEach(function (v, i, a) { $ctrl.filter('.' + fld.prefix + v).hide().find('.sbm-input,.sbm-textarea,.sbm-select,.sbm-checkbox').prop('disabled', true); });
(fld.readonly || []).forEach(function (v, i, a) { $ctrl.filter('.' + fld.prefix + v).find('.sbm-input,.sbm.textarea,.sbm-select,.sbm-checkbox').prop('readonly', true).prop('disabled', true); });
}
sbm.populateFormValues = function (cfg, $frm, val)
{
//sbm.debug('populateFormValues', cfg, $frm, val);
let $ctrl = $('.sbm-form-control', $frm);
for (var name in val || {}) { $ctrl.filter('.' + cfg.field.prefix + name).find('.sbm-input,.sbm-textarea,.sbm-select').filter('.sbm-auto-val').val(val[name]).end().find('.sbm-checkbox').prop('checked', !!val[name]); };
}
//--------------------------------------------------------------
// Page navigation.
sbm.navigateTo = function (action)
@@ -221,7 +256,7 @@
sbm.$dlg.alert = $('<div id="dlgAlert"><div id="dlgAlertMsg"></div></div>').dialog(opt);
}
$('#dlgAlertMsg', sbm.$dlg.alert).html(msg.replace(/\\n/g, '<br>'));
let btns = [];
let btns = {};
btns[sbm.lbl.ok] = function () { $(this).dialog('close'); if (onOk) onOk(); };
sbm.$dlg.alert.dialog('option', { title: title || sbm.dlg.title.alert, buttons: btns });
sbm.openDialog(sbm.$dlg.alert);
@@ -236,9 +271,10 @@
if (!sbm.isDef(sbm.$dlg.confirm))
{
var opt = sbm.dlgOpts();
opt.dialogClass += " sbm-dark-blue";
sbm.$dlg.confirm = $('<div id="dlgConfirm"><div class="spacer2"></div><div id="dlgConfirmMsg"></div></div>').dialog(opt);
}
var btns = [];
let btns = {};
btns[sbm.lbl.yes] = function () { $(this).dialog('close'); if (onOk) onOk(); };
btns[sbm.lbl.no] = function () { $(this).dialog('close'); if (onCancel) onCancel(); };
sbm.$dlg.confirm.dialog('option', { title: title || sbm.dlg.title.confirm, buttons: btns });