Contacts and Commodities
This commit is contained in:
@@ -38,14 +38,15 @@
|
||||
|
||||
.sbm-panel-filter .sbm-header .sbm-action
|
||||
{
|
||||
margin: 2px 0 0 8px;
|
||||
border-radius: 4px;
|
||||
margin: 2px 4px 0 8px;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.sbm-panel-filter .sbm-header .sbm-action:hover
|
||||
{
|
||||
background-color: #b0b0b0;
|
||||
box-shadow: 0 0 4px 2px #80808080;
|
||||
background-color: #e0e0e0;
|
||||
/*box-shadow: 0 0 4px 2px #80808080;*/
|
||||
}
|
||||
|
||||
.sbm-panel-filter .sbm-content
|
||||
@@ -85,7 +86,7 @@
|
||||
|
||||
.sbm-results-paging .sbm-paging-info
|
||||
{
|
||||
font-size: .8rem;
|
||||
font-size: .67rem;
|
||||
}
|
||||
|
||||
.sbm-panel-filter .sbm-header .sbm-results-paging .sbm-action
|
||||
@@ -157,7 +158,7 @@
|
||||
|
||||
.sbm-panel-item > .sbm-header .sbm-action
|
||||
{
|
||||
border-radius: 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.sbm-panel-item > .sbm-header .sbm-caption .sbm-action:hover
|
||||
@@ -167,13 +168,14 @@
|
||||
|
||||
.sbm-panel-item > .sbm-header .sbm-actions .sbm-action
|
||||
{
|
||||
margin: 2px 0 0 8px;
|
||||
margin: 2px 4px 0 8px;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
.sbm-panel-item > .sbm-header .sbm-actions .sbm-action:hover
|
||||
{
|
||||
background-color: #c0c0c0;
|
||||
box-shadow: 0 0 4px 2px #c0c0c080;
|
||||
background-color: #e0e0e0;
|
||||
/*box-shadow: 0 0 4px 2px #c0c0c080;*/
|
||||
}
|
||||
|
||||
.sbm-panel-item > .sbm-content
|
||||
|
||||
@@ -94,6 +94,10 @@ body
|
||||
|
||||
/* Header */
|
||||
|
||||
#sbm-page-header
|
||||
{
|
||||
}
|
||||
|
||||
a.navbar-brand
|
||||
{
|
||||
white-space: normal;
|
||||
@@ -122,7 +126,15 @@ button.accept-policy
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
/* Footer */
|
||||
|
||||
#sbm-page-footer, #sbm-page-footer div
|
||||
{
|
||||
font-size: .8rem;
|
||||
}
|
||||
|
||||
/* Page caption */
|
||||
|
||||
.sbm-page-caption
|
||||
{
|
||||
margin: 0;
|
||||
|
||||
@@ -6,122 +6,136 @@
|
||||
{
|
||||
"use strict";
|
||||
sbm.itemIdPrefix = 'Itm_';
|
||||
var $results;
|
||||
let $pnl = sbm.$pnl;
|
||||
let $frm = sbm.$frm;
|
||||
let $dlg = sbm.$dlg;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.refreshResults = function (delay)
|
||||
{
|
||||
if (!sbm.awaitingRefreshResponse)
|
||||
{
|
||||
var $items = $('.sbm-panel-item-list', $results).fadeOut(200).empty();
|
||||
var $msgs = $('.sbm-panel-messages', $results).hide().empty().append($('<div class="sbm-message">' + sbm.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
$('.sbm-burger', $pnl.filter).hide();
|
||||
$('.sbm-panel-item-list', $pnl.results).fadeOut(200).empty();
|
||||
$('.sbm-panel-messages', $pnl.results).hide().empty().append($('<div class="sbm-message">' + sbm.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
}
|
||||
sbm.ajax.refreshResults = sbm.ajax.refreshResults || { url: sbm.url.base + 'Commodity/Ajax/List', formId: 'frmCommodityFilter', callbackFn: sbm.doRefreshResults };
|
||||
sbm.doAjaxRequest(sbm.ajax.refreshResults, delay || 50);
|
||||
sbm.awaitingRefreshResponse = true;
|
||||
}
|
||||
sbm.getFilterDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sbm-panel-item-template .sbm-dropdown-menu.CommodityFilter li.sbm-dropdown-item', $pnl.filter).clone();
|
||||
}
|
||||
sbm.getItemTemplate = function ()
|
||||
{
|
||||
return $('.sbm-panel-item-template .sbm-panel-item.Commodity', $results);
|
||||
return $('.sbm-panel-item-template .sbm-panel-item.Commodity', $pnl.results).clone();
|
||||
}
|
||||
sbm.getDropdownItemTemplate = function ()
|
||||
sbm.getItemDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sbm-panel-item-template .sbm-dropdown-menu.Commodity li.sbm-dropdown-item', $results);
|
||||
return $('.sbm-panel-item-template .sbm-dropdown-menu.Commodity li.sbm-dropdown-item', $pnl.results).clone();
|
||||
}
|
||||
sbm.doRefreshResults = function (response)
|
||||
{
|
||||
sbm.debug('doRefreshResults', response);
|
||||
//sbm.debug('doRefreshResults', response);
|
||||
delete sbm.awaitingRefreshResponse;
|
||||
sbm.refreshControlValues(response.controlValues);
|
||||
var $msgs = $('.sbm-panel-messages', $results).hide().empty();
|
||||
var $items = $('.sbm-panel-item-list', $results).hide().empty();
|
||||
var $tmpl = sbm.getItemTemplate();
|
||||
var $msgs = $('.sbm-panel-messages', $pnl.results).hide().empty();
|
||||
var $items = $('.sbm-panel-item-list', $pnl.results).hide().empty();
|
||||
sbm.refreshPaging(response, '#frmCommodityFilter', sbm.refreshResults);
|
||||
if (!response.success) return;
|
||||
// Reference data - Statuses.
|
||||
if (response.defaultStatusCode) sbm.data.defaultStatusCode = response.defaultStatusCode;
|
||||
if (response.statuses)
|
||||
sbm.populateSelectCodeDesc('#cbCommodityStatus', response.statuses);
|
||||
// Menu.
|
||||
var $bgr = $('.sbm-burger', $pnl.filter).hide();
|
||||
var $mnu = $('ul.sbm-dropdown-menu', $bgr).empty();
|
||||
$mnu.append(sbm.getFilterMenuOption(sbm.lbl.refresh, function () { sbm.refreshResults(); }));
|
||||
$mnu.append(sbm.getFilterMenuOption(sbm.lbl.create, function () { sbm.createItem(); }));
|
||||
$bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length);
|
||||
// Items.
|
||||
var items = response.commodies;
|
||||
var items = response.commodities;
|
||||
if (!items.length)
|
||||
return $msgs.append($('<div class="sbm-message">' + sbm.msg.dataNoneFound + '</div>')).fadeIn(500);
|
||||
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
|
||||
{
|
||||
let item = items[itemIdx];
|
||||
let $item = $tmpl.clone();
|
||||
sbm.populateItem($item, item);
|
||||
$items.append($item);
|
||||
}
|
||||
$items.append(sbm.populateItem(sbm.getItemTemplate(), items[itemIdx]));
|
||||
$items.fadeIn(50);
|
||||
}
|
||||
sbm.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
$item.prop('id', sbm.itemIdPrefix + item.id);
|
||||
$('.CommodityName', $item).text(item.displayName);
|
||||
$('.CommodityCode', $item).text(item.code);
|
||||
$('.CommodityDesc', $item).text(item.desc);
|
||||
$('.CommodityType', $item).text(item.typeDesc);
|
||||
$('.CommodityAssociationCount', $item).on('click', function () { sbm.onClickAssociationCount(item.id); }).toggle(item.associationCount).find('.AssociationCount').text(item.associationCount);
|
||||
$('.CommodityAddress', $item).text(item.addressSummary);
|
||||
$('.CommodityNotes', $item).text(item.notes);
|
||||
$('.StatusDesc', $item).text(item.statusDesc).addClass('sbm-status-' + item.statusCode.toLowerCase());
|
||||
$('.sbm-caption .sbm-action').toggleClass('sbm-action', !item.deleted);
|
||||
let $mnu = $('ul.sbm-dropdown-menu', $item);
|
||||
if (!item.deleted)
|
||||
{
|
||||
let $mnu = $('ul.sbm-dropdown-menu', $item);
|
||||
$mnu.append(sbm.getDropdownItemTemplate().clone().find('div.sbm-label').text(sbm.lbl.edit).end().on('click', function () { sbm.updateItem(item.id) }));
|
||||
if (item.awaiting)
|
||||
$mnu.append(sbm.getDropdownItemTemplate().clone().find('div.sbm-label').text(sbm.lbl.activate).end().on('click', function () { sbm.activateItem(item.id) }));
|
||||
$mnu.append(sbm.getItemMenuOption(sbm.lbl.edit, function () { sbm.updateItem(item.id) }));
|
||||
$('.sbm-header .sbm-action.sbm-item-update', $item).off('click').on('click', function () { sbm.updateItem(item.id) });
|
||||
$item.off('dblclick').on('dblclick', function () { sbm.updateItem(item.id) });
|
||||
}
|
||||
$('.sbm-burger', $item).toggle(!!$('.sbm-burger .sbm-dropdown-menu .sbm-dropdown-item', $item).length);
|
||||
$('.sbm-panel-messages', $results).hide().empty();
|
||||
$('.sbm-burger', $item).toggle(!!$('.sbm-dropdown-item', $mnu).length);
|
||||
$('.sbm-panel-messages', $pnl.results).hide().empty();
|
||||
return $item;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.getFilterMenuOption = function (lbl, fn)
|
||||
{
|
||||
return sbm.getMenuOption(sbm.getFilterDropdownTemplate(), lbl, fn);
|
||||
}
|
||||
sbm.getItemMenuOption = function (lbl, fn)
|
||||
{
|
||||
return sbm.getMenuOption(sbm.getItemDropdownTemplate(), lbl, fn);
|
||||
}
|
||||
sbm.getMenuOption = function ($opt, lbl, fn)
|
||||
{
|
||||
return $opt.find('div.sbm-label').text(lbl).end().on('click', fn);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.createItem = function ()
|
||||
{
|
||||
let $frm = sbm.$frm.commodity;
|
||||
$('.CommodityId,input[type="text"],textarea,select', $frm).val('');
|
||||
$('.CommodityStatus', $frm).val(sbm.data.defaultStatusCode);
|
||||
let frm = $frm.commodity;
|
||||
$('.CommodityId,.CommodityExists,input[type="text"],textarea,select', frm).val('');
|
||||
$('.CommodityStatus', frm).val(sbm.data.defaultStatusCode);
|
||||
sbm.clearControlErrors();
|
||||
sbm.$dlg.commodity.dialog('option', 'title', sbm.dlg.title.createCommodity);
|
||||
sbm.openDialog(sbm.$dlg.commodity, 600, 600);
|
||||
}
|
||||
sbm.doCreateItem = function ()
|
||||
{
|
||||
sbm.storeItem();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.updateItem = function (id)
|
||||
{
|
||||
$('.CommodityId', sbm.$frm.commodityId).val(id);
|
||||
$('.CommodityId', $frm.commodityId).val(id);
|
||||
sbm.ajax.updateItem = sbm.ajax.updateItem || { url: sbm.url.base + 'Commodity/Ajax/GetItem', formId: 'frmCommodityId', callbackFn: sbm.onUpdateItem };
|
||||
sbm.doAjaxRequest(sbm.ajax.updateItem, 50);
|
||||
}
|
||||
sbm.onUpdateItem = function (response)
|
||||
{
|
||||
//sbm.debug('onUpdateItem', response);
|
||||
let $frm = sbm.$frm.commodity;
|
||||
$('.CommodityId,input[type="text"],textarea,select', $frm).val('');
|
||||
sbm.debug('onUpdateItem', response);
|
||||
let frm = $frm.commodity;
|
||||
$('.CommodityId,input[type="text"],textarea,select', frm).val('');
|
||||
if (!response.success) return;
|
||||
let item = response.commodity;
|
||||
$('.CommodityId', $frm).val(item.id);
|
||||
$('.CommodityType', $frm).val(item.typeCode);
|
||||
$('.CommodityName', $frm).val(item.name);
|
||||
$('.CommodityNotes', $frm).val(item.notes);
|
||||
$('.CommodityStatus', $frm).val(item.statusCode);
|
||||
$('.CommodityId', frm).val(item.id);
|
||||
$('.CommodityExists', frm).val(1);
|
||||
$('.CommodityType', frm).val(item.typeCode);
|
||||
$('.CommodityCode', frm).val(item.code);
|
||||
$('.CommodityDesc', frm).val(item.desc);
|
||||
$('.CommodityNotes', frm).val(item.notes);
|
||||
$('.CommodityStatus', frm).val(item.statusCode);
|
||||
sbm.clearControlErrors();
|
||||
sbm.$dlg.commodity.dialog('option', 'title', sbm.dlg.title.updateCommodity);
|
||||
sbm.openDialog(sbm.$dlg.commodity, 600, 600);
|
||||
}
|
||||
sbm.doUpdateItem = function ()
|
||||
{
|
||||
sbm.storeItem();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.storeItem = function ()
|
||||
@@ -140,39 +154,30 @@
|
||||
var $item = $('#' + sbm.itemIdPrefix + item.id);
|
||||
if (!$item.length)
|
||||
{
|
||||
$item = $('.sbm-panel-item-template .sbm-panel-item.Commodity', $results).clone();
|
||||
$('.sbm-panel-item-list', $results).prepend($item).show();
|
||||
$item = sbm.getItemTemplate();
|
||||
$('.sbm-panel-item-list', $pnl.results).prepend($item).show();
|
||||
}
|
||||
$item.replaceWith(sbm.populateItem(sbm.getItemTemplate(), item));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.onClickAssociationCount = function (id)
|
||||
{
|
||||
if (!(id * 1)) return;
|
||||
sbm.doPleaseWait();
|
||||
let $frm = $('#frmCommodityId');
|
||||
$('.CommodityId', $frm).val(id);
|
||||
$frm.prop('action', sbm.url.base + 'Association').submit();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(function ()
|
||||
{
|
||||
$('.sbm-panel-filter .sbm-action.sbm-item-create').on('click', function () { sbm.createItem(); });
|
||||
$('.sbm-panel-filter .sbm-action.sbm-results-refresh').on('click', function () { sbm.refreshResults(); });
|
||||
$pnl.commodities = $('.sbm-panel.Commodities');
|
||||
$pnl.filter = $('.sbm-panel-filter', $pnl.commodities);
|
||||
$pnl.results = $('.sbm-panel-results', $pnl.commodities);
|
||||
|
||||
$('.sbm-input, .sbm-textarea').on('input', function () { sbm.clearControlError(this); });
|
||||
$('.sbm-select').on('change', function () { sbm.clearControlError(this); });
|
||||
|
||||
sbm.$frm.filter = $('#frmCommodityFilter');
|
||||
$('.FilterCommodity', sbm.$frm.filter).on('input', function () { sbm.refreshResults(250); });
|
||||
$('.FilterCommodityCategory,.FilterCommodityStatusCategory', sbm.$frm.filter).on('change', function () { sbm.refreshResults(50); });
|
||||
sbm.$frm.commodityId = $('#frmCommodityId');
|
||||
sbm.$frm.commodity = $('#frmCommodity');
|
||||
$results = $('.sbm-panel-results');
|
||||
$frm.filter = $('#frmCommodityFilter');
|
||||
$('.FilterCommodity', $frm.filter).on('input', function () { sbm.refreshResults(250); });
|
||||
$('.FilterCommodityType,.FilterCommodityStatusCategory', $frm.filter).on('change', function () { sbm.refreshResults(50); });
|
||||
$frm.commodityId = $('#frmCommodityId');
|
||||
$frm.commodity = $('#frmCommodity');
|
||||
|
||||
var opt = sbm.dlgOpts();
|
||||
opt.buttons[sbm.dlg.btn.ok] = function () { sbm.doCreateItem(); };
|
||||
opt.buttons[sbm.dlg.btn.ok] = function () { sbm.storeItem(); };
|
||||
opt.buttons[sbm.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
sbm.$dlg.commodity = $('#dlgCommodity').dialog(opt);
|
||||
|
||||
|
||||
@@ -6,127 +6,152 @@
|
||||
{
|
||||
"use strict";
|
||||
sbm.itemIdPrefix = 'Itm_';
|
||||
var $results;
|
||||
let $pnl = sbm.$pnl;
|
||||
let $frm = sbm.$frm;
|
||||
let $dlg = sbm.$dlg;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.refreshResults = function (delay)
|
||||
{
|
||||
if (!sbm.awaitingRefreshResponse)
|
||||
{
|
||||
var $items = $('.sbm-panel-item-list', $results).fadeOut(200).empty();
|
||||
var $msgs = $('.sbm-panel-messages', $results).hide().empty().append($('<div class="sbm-message">' + sbm.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
$('.sbm-burger', $pnl.filter).hide();
|
||||
$('.sbm-panel-item-list', $pnl.results).fadeOut(200).empty();
|
||||
$('.sbm-panel-messages', $pnl.results).hide().empty().append($('<div class="sbm-message">' + sbm.msg.dataQuerying + '</div>')).fadeIn(200);
|
||||
}
|
||||
sbm.ajax.refreshResults = sbm.ajax.refreshResults || { url: sbm.url.base + 'Contact/Ajax/List', formId: 'frmAffiliateFilter', callbackFn: sbm.doRefreshResults };
|
||||
sbm.ajax.refreshResults = sbm.ajax.refreshResults || { url: sbm.url.base + 'Contact/Ajax/List', formId: 'frmContactFilter', callbackFn: sbm.doRefreshResults };
|
||||
sbm.doAjaxRequest(sbm.ajax.refreshResults, delay || 50);
|
||||
sbm.awaitingRefreshResponse = true;
|
||||
}
|
||||
sbm.getFilterDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sbm-panel-item-template .sbm-dropdown-menu.ContactFilter li.sbm-dropdown-item', $pnl.filter).clone();
|
||||
}
|
||||
sbm.getItemTemplate = function ()
|
||||
{
|
||||
return $('.sbm-panel-item-template .sbm-panel-item.Affiliate', $results);
|
||||
return $('.sbm-panel-item-template .sbm-panel-item.Contact', $pnl.results).clone();
|
||||
}
|
||||
sbm.getDropdownItemTemplate = function ()
|
||||
sbm.getItemDropdownTemplate = function ()
|
||||
{
|
||||
return $('.sbm-panel-item-template .sbm-dropdown-menu.Affiliate li.sbm-dropdown-item', $results);
|
||||
return $('.sbm-panel-item-template .sbm-dropdown-menu.Contact li.sbm-dropdown-item', $pnl.results).clone();
|
||||
}
|
||||
sbm.doRefreshResults = function (response)
|
||||
{
|
||||
sbm.debug('doRefreshResults', response);
|
||||
//sbm.debug('doRefreshResults', response);
|
||||
delete sbm.awaitingRefreshResponse;
|
||||
sbm.refreshControlValues(response.controlValues);
|
||||
var $msgs = $('.sbm-panel-messages', $results).hide().empty();
|
||||
var $items = $('.sbm-panel-item-list', $results).hide().empty();
|
||||
var $tmpl = sbm.getItemTemplate();
|
||||
sbm.refreshPaging(response, '#frmAffiliateFilter', sbm.refreshResults);
|
||||
var $msgs = $('.sbm-panel-messages', $pnl.results).hide().empty();
|
||||
var $items = $('.sbm-panel-item-list', $pnl.results).hide().empty();
|
||||
sbm.refreshPaging(response, '#frmContactFilter', sbm.refreshResults);
|
||||
if (!response.success) return;
|
||||
// Reference data - Statuses.
|
||||
if (response.defaultStatusCode) sbm.data.defaultStatusCode = response.defaultStatusCode;
|
||||
if (response.statuses)
|
||||
sbm.populateSelectCodeDesc('#cbAffiliateStatus', response.statuses);
|
||||
sbm.populateSelectCodeDesc('#cbContactStatus', response.statuses);
|
||||
// Menu.
|
||||
var $bgr = $('.sbm-burger', $pnl.filter).hide();
|
||||
var $mnu = $('ul.sbm-dropdown-menu', $bgr).empty();
|
||||
$mnu.append(sbm.getFilterMenuOption(sbm.lbl.refresh, function () { sbm.refreshResults(); }));
|
||||
$mnu.append(sbm.getFilterMenuOption(sbm.lbl.createOrg, function () { sbm.createItem(); }));
|
||||
$mnu.append(sbm.getFilterMenuOption(sbm.lbl.createInd, function () { sbm.createItem(1); }));
|
||||
$bgr.toggle(!!$('.sbm-dropdown-item', $mnu).length);
|
||||
// Items.
|
||||
var items = response.affiliates;
|
||||
if (!items.length)
|
||||
return $msgs.append($('<div class="sbm-message">' + sbm.msg.dataNoneFound + '</div>')).fadeIn(500);
|
||||
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
|
||||
{
|
||||
let item = items[itemIdx];
|
||||
let $item = $tmpl.clone();
|
||||
sbm.populateItem($item, item);
|
||||
$items.append($item);
|
||||
}
|
||||
$items.append(sbm.populateItem(sbm.getItemTemplate(), items[itemIdx]));
|
||||
$items.fadeIn(50);
|
||||
}
|
||||
sbm.populateItem = function ($item, item)
|
||||
{
|
||||
if (!item) return;
|
||||
$item.prop('id', sbm.itemIdPrefix + item.id);
|
||||
$('.AffiliateName', $item).text(item.displayName);
|
||||
$('.AffiliateType', $item).text(item.typeDesc);
|
||||
$('.AffiliateAssociationCount', $item).on('click', function () { sbm.onClickAssociationCount(item.id); }).toggle(item.associationCount).find('.AssociationCount').text(item.associationCount);
|
||||
$('.AffiliateAddress', $item).text(item.addressSummary);
|
||||
$('.AffiliateNotes', $item).text(item.notes);
|
||||
$('.ContactName', $item).text(item.displayName);
|
||||
$('.ContactType', $item).text(item.typeDesc);
|
||||
$('.ContactAssociationCount', $item).on('click', function () { sbm.onClickAssociationCount(item.id); }).toggle(item.associationCount).find('.AssociationCount').text(item.associationCount);
|
||||
$('.ContactAddress', $item).text(item.addressSummary);
|
||||
$('.ContactNotes', $item).text(item.notes);
|
||||
$('.StatusDesc', $item).text(item.statusDesc).addClass('sbm-status-' + item.statusCode.toLowerCase());
|
||||
$('.sbm-caption .sbm-action').toggleClass('sbm-action', !item.deleted);
|
||||
let $mnu = $('ul.sbm-dropdown-menu', $item).empty();
|
||||
if (!item.deleted)
|
||||
{
|
||||
let $mnu = $('ul.sbm-dropdown-menu', $item);
|
||||
$mnu.append(sbm.getDropdownItemTemplate().clone().find('div.sbm-label').text(sbm.lbl.edit).end().on('click', function () { sbm.updateItem(item.id) }));
|
||||
if (item.awaiting)
|
||||
$mnu.append(sbm.getDropdownItemTemplate().clone().find('div.sbm-label').text(sbm.lbl.activate).end().on('click', function () { sbm.activateItem(item.id) }));
|
||||
$mnu.append(sbm.getItemMenuOption(sbm.lbl.edit, function () { sbm.updateItem(item.id) }));
|
||||
$('.sbm-header .sbm-action.sbm-item-update', $item).off('click').on('click', function () { sbm.updateItem(item.id) });
|
||||
$item.off('dblclick').on('dblclick', function () { sbm.updateItem(item.id) });
|
||||
}
|
||||
$('.sbm-burger', $item).toggle(!!$('.sbm-burger .sbm-dropdown-menu .sbm-dropdown-item', $item).length);
|
||||
$('.sbm-panel-messages', $results).hide().empty();
|
||||
$('.sbm-burger', $item).toggle(!!$('.sbm-dropdown-item', $mnu).length);
|
||||
$('.sbm-panel-messages', $pnl.results).hide().empty();
|
||||
return $item;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.createItem = function ()
|
||||
sbm.getFilterMenuOption = function (lbl, fn)
|
||||
{
|
||||
let $frm = sbm.$frm.affiliate;
|
||||
$('.AffiliateId,input[type="text"],textarea,select', $frm).val('');
|
||||
$('.AffiliateStatus', $frm).val(sbm.data.defaultStatusCode);
|
||||
sbm.clearControlErrors();
|
||||
sbm.$dlg.affiliate.dialog('option', 'title', sbm.dlg.title.createAffiliate);
|
||||
sbm.openDialog(sbm.$dlg.affiliate, 600, 600);
|
||||
return sbm.getMenuOption(sbm.getFilterDropdownTemplate(), lbl, fn);
|
||||
}
|
||||
sbm.doCreateItem = function ()
|
||||
sbm.getItemMenuOption = function (lbl, fn)
|
||||
{
|
||||
sbm.storeItem();
|
||||
return sbm.getMenuOption(sbm.getItemDropdownTemplate(), lbl, fn);
|
||||
}
|
||||
sbm.getMenuOption = function ($opt, lbl, fn)
|
||||
{
|
||||
return $opt.find('div.sbm-label').text(lbl).end().on('click', fn);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.createItem = function (ind)
|
||||
{
|
||||
let frm = $frm.contact;
|
||||
sbm.clearControlErrors(frm);
|
||||
$('.AffiliateId,.ContactExists,input[type="text"],textarea,select', frm).val('');
|
||||
$('.ContactIndividual', frm).val(!!ind ? 1 : null);
|
||||
$('.ContactStatus', frm).val(sbm.data.defaultStatusCode);
|
||||
sbm.toggleContactControls(ind);
|
||||
$dlg.contact.dialog('option', 'title', sbm.dlg.title.createContact);
|
||||
sbm.openDialog($dlg.contact, 600, 600);
|
||||
}
|
||||
sbm.toggleContactControls = function (ind)
|
||||
{
|
||||
let frm = $frm.contact;
|
||||
$('.sbm-form-control.ContactType,.sbm-form-control.ContactName', frm).toggle(!ind).find('input,select').prop('disabled', !!ind);
|
||||
$('.sbm-form-control.ContactFirstName,.sbm-form-control.ContactLastName', frm).toggle(!!ind).find('input,select').prop('disabled', !ind);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.updateItem = function (id)
|
||||
{
|
||||
$('.AffiliateId', sbm.$frm.affiliateId).val(id);
|
||||
sbm.ajax.updateItem = sbm.ajax.updateItem || { url: sbm.url.base + 'Contact/Ajax/GetItem', formId: 'frmAffiliateId', callbackFn: sbm.onUpdateItem };
|
||||
$('.AffiliateId', $frm.contactId).val(id);
|
||||
sbm.ajax.updateItem = sbm.ajax.updateItem || { url: sbm.url.base + 'Contact/Ajax/GetItem', formId: 'frmContactId', callbackFn: sbm.onUpdateItem };
|
||||
sbm.doAjaxRequest(sbm.ajax.updateItem, 50);
|
||||
}
|
||||
sbm.onUpdateItem = function (response)
|
||||
{
|
||||
//sbm.debug('onUpdateItem', response);
|
||||
let $frm = sbm.$frm.affiliate;
|
||||
$('.AffiliateId,input[type="text"],textarea,select', $frm).val('');
|
||||
let frm = $frm.contact;
|
||||
$('.AffiliateId,input[type="text"],textarea,select', frm).val('');
|
||||
if (!response.success) return;
|
||||
let item = response.affiliate;
|
||||
$('.AffiliateId', $frm).val(item.id);
|
||||
$('.AffiliateType', $frm).val(item.typeCode);
|
||||
$('.AffiliateName', $frm).val(item.name);
|
||||
$('.AffiliateNotes', $frm).val(item.notes);
|
||||
$('.AffiliateStatus', $frm).val(item.statusCode);
|
||||
sbm.toggleContactControls(item.individual);
|
||||
$('.AffiliateId', frm).val(item.id);
|
||||
$('.ContactExists', frm).val(1);
|
||||
$('.ContactIndividual', frm).val(!!item.individual ? 1 : null);
|
||||
$('.ContactType', frm).val(item.typeCode);
|
||||
$('.ContactName', frm).val(item.name);
|
||||
$('.ContactFirstName', frm).val(item.firstName);
|
||||
$('.ContactLastName', frm).val(item.lastName);
|
||||
$('.ContactNotes', frm).val(item.notes);
|
||||
$('.ContactStatus', frm).val(item.statusCode);
|
||||
sbm.clearControlErrors();
|
||||
sbm.$dlg.affiliate.dialog('option', 'title', sbm.dlg.title.updateAffiliate);
|
||||
sbm.openDialog(sbm.$dlg.affiliate, 600, 600);
|
||||
}
|
||||
sbm.doUpdateItem = function ()
|
||||
{
|
||||
sbm.storeItem();
|
||||
$dlg.contact.dialog('option', 'title', sbm.dlg.title.updateContact);
|
||||
sbm.openDialog($dlg.contact, 600, 600);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
sbm.storeItem = function ()
|
||||
{
|
||||
sbm.ajax.storeItem = sbm.ajax.storeItem || { url: sbm.url.base + 'Contact/Ajax/StoreItem', formId: 'frmAffiliate', callbackFn: sbm.onStoreItem };
|
||||
sbm.ajax.storeItem = sbm.ajax.storeItem || { url: sbm.url.base + 'Contact/Ajax/StoreItem', formId: 'frmContact', callbackFn: sbm.onStoreItem };
|
||||
sbm.doAjaxRequest(sbm.ajax.storeItem, 50);
|
||||
}
|
||||
sbm.onStoreItem = function (response)
|
||||
@@ -134,14 +159,14 @@
|
||||
//sbm.debug('onStoreItem', response);
|
||||
sbm.refreshControlValues(response.controlValues);
|
||||
if (!response.success) return;
|
||||
sbm.$dlg.affiliate.dialog('close');
|
||||
$dlg.contact.dialog('close');
|
||||
|
||||
var item = response.affiliate;
|
||||
var $item = $('#' + sbm.itemIdPrefix + item.id);
|
||||
if (!$item.length)
|
||||
{
|
||||
$item = $('.sbm-panel-item-template .sbm-panel-item.Affiliate', $results).clone();
|
||||
$('.sbm-panel-item-list', $results).prepend($item).show();
|
||||
$item = sbm.getItemTemplate();
|
||||
$('.sbm-panel-item-list', $pnl.results).prepend($item).show();
|
||||
}
|
||||
$item.replaceWith(sbm.populateItem(sbm.getItemTemplate(), item));
|
||||
}
|
||||
@@ -151,30 +176,31 @@
|
||||
{
|
||||
if (!(id * 1)) return;
|
||||
sbm.doPleaseWait();
|
||||
let $frm = $('#frmAffiliateId');
|
||||
$('.AffiliateId', $frm).val(id);
|
||||
$frm.prop('action', sbm.url.base + 'Association').submit();
|
||||
let frm = $frm.contactId;
|
||||
$('.AffiliateId', frm).val(id);
|
||||
frm.prop('action', sbm.url.base + 'Association').submit();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
$(function ()
|
||||
{
|
||||
$('.sbm-panel-filter .sbm-action.sbm-item-create').on('click', function () { sbm.createItem(); });
|
||||
$('.sbm-panel-filter .sbm-action.sbm-results-refresh').on('click', function () { sbm.refreshResults(); });
|
||||
$pnl.contacts = $('.sbm-panel.Contacts');
|
||||
$pnl.filter = $('.sbm-panel-filter', $pnl.contacts);
|
||||
$pnl.results = $('.sbm-panel-results', $pnl.contacts);
|
||||
|
||||
$('.sbm-input, .sbm-textarea').on('input', function () { sbm.clearControlError(this); });
|
||||
$('.sbm-select').on('change', function () { sbm.clearControlError(this); });
|
||||
|
||||
sbm.$frm.filter = $('#frmAffiliateFilter');
|
||||
$('.FilterAffiliate', sbm.$frm.filter).on('input', function () { sbm.refreshResults(250); });
|
||||
$('.FilterAffiliateCategory,.FilterAffiliateStatusCategory', sbm.$frm.filter).on('change', function () { sbm.refreshResults(50); });
|
||||
sbm.$frm.affiliateId = $('#frmAffiliateId');
|
||||
sbm.$frm.affiliate = $('#frmAffiliate');
|
||||
$results = $('.sbm-panel-results');
|
||||
$frm.filter = $('#frmContactFilter');
|
||||
$('.FilterContact', $frm.filter).on('input', function () { sbm.refreshResults(250); });
|
||||
$('.FilterContactType', $frm.filter).on('change', function () { sbm.refreshResults(50); });
|
||||
$frm.contactId = $('#frmContactId');
|
||||
$frm.contact = $('#frmContact');
|
||||
|
||||
var opt = sbm.dlgOpts();
|
||||
opt.buttons[sbm.dlg.btn.ok] = function () { sbm.doCreateItem(); };
|
||||
opt.buttons[sbm.dlg.btn.ok] = function () { sbm.storeItem(); };
|
||||
opt.buttons[sbm.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
sbm.$dlg.affiliate = $('#dlgAffiliate').dialog(opt);
|
||||
$dlg.contact = $('#dlgContact').dialog(opt);
|
||||
|
||||
setTimeout(sbm.refreshResults, 250);
|
||||
});
|
||||
|
||||
@@ -264,7 +264,7 @@
|
||||
//sbm.debug(sbm.topMargin($bdy));
|
||||
var fbr = $bdy[0].getBoundingClientRect();
|
||||
var fn = function () { $hdr.delay(2000).animate({ backgroundColor: '#f0f0f0' }, 1000); };
|
||||
$not.css({ 'top': Math.max(0, fbr.top - sbm.topMargin($bdy)), 'right': $win.width() - fbr.right }).slideDown(500, fn);
|
||||
$not.css({ 'top': Math.max(0, fbr.top /*- sbm.topMargin($bdy)*/), 'right': $win.width() - fbr.right }).slideDown(500, fn);
|
||||
sbm.toNotification = setTimeout(sbm.hideNotification, 6000);
|
||||
}
|
||||
sbm.hideNotification = function ()
|
||||
|
||||
Reference in New Issue
Block a user