v1.2.6.2
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Contact Methods script.
|
||||
*/
|
||||
|
||||
(function (win, doc, undef)
|
||||
{
|
||||
"use strict";
|
||||
let cm = sax.mdl.contactMethods = { fn: {}, data: {}, ajax: {} };
|
||||
let $dlg = cm.$dlg = {};
|
||||
|
||||
//--------------------------------------------------------------
|
||||
/*
|
||||
* Config:
|
||||
* fnCallback Method to call to apply changes.
|
||||
* methods Full list of methods.
|
||||
* methodsUsed List of methods already in use.
|
||||
* method Current selected method (if updating).
|
||||
* value Current value.
|
||||
*/
|
||||
sax.editContactMethod = cm.fn.edit = function (cfg)
|
||||
{
|
||||
cm.fn.init();
|
||||
cm.data.cfg = cfg || {};
|
||||
cm.$mth.empty();
|
||||
for (let mth of cfg.methods || [])
|
||||
{
|
||||
if (mth.code && mth.code == cfg.method || !(cfg.methodsUsed || []).includes(mth.code))
|
||||
cm.$mth.append($('<option>').prop('value', mth.code).text(mth.desc));
|
||||
}
|
||||
cm.$mth.val(cfg.method).attr('disabled', cfg.method && cm.$mth.val() == cfg.method ? true : null);
|
||||
cm.$val.val(cfg.value);
|
||||
sax.openDialog($dlg.conMth, 600, 240);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
cm.fn.applyChanges = function ()
|
||||
{
|
||||
cm.ajax.applyChanges = cm.ajax.applyChanges || { url: sax.url.base + 'Reference/Ajax/ValidateContactMethod', callbackFn: cm.fn.onApplyChanges };
|
||||
cm.ajax.applyChanges.formData = new FormData();
|
||||
cm.ajax.applyChanges.formData.append("__RequestVerificationToken", $('#frmNavigate input[name="__RequestVerificationToken"]').val());
|
||||
cm.ajax.applyChanges.formData.append("ContactMethod", $('select[name="ContactMethod"]', $dlg.conMth).val());
|
||||
cm.ajax.applyChanges.formData.append("ContactValue", $('input[name="ContactValue"]', $dlg.conMth).val());
|
||||
sax.doAjaxRequest(cm.ajax.applyChanges, 50);
|
||||
}
|
||||
cm.fn.onApplyChanges = function (response)
|
||||
{
|
||||
if (!response) return;
|
||||
sax.refreshControlValues(response.controlValues, $dlg.conMth);
|
||||
if (!response.success) return;
|
||||
$dlg.conMth.dialog('close');
|
||||
if (cm.data.cfg.fnCallback) cm.data.cfg.fnCallback(cm.$mth.val(), $('option:selected', cm.$mth).text(), cm.$val.val());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
cm.fn.init = function ()
|
||||
{
|
||||
if ($dlg.conMth) return;
|
||||
var opt = sax.dlgOpts();
|
||||
opt.buttons[sax.dlg.btn.ok] = function () { cm.fn.applyChanges(); };
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
$dlg.conMth = $('#dlgContactMethod').dialog(opt);
|
||||
cm.$mth = $('.sax-select.ContactMethod', $dlg.conMth);
|
||||
cm.$val = $('.sax-input.ContactValue', $dlg.conMth);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
}(window, window.document));
|
||||
|
||||
/* The End */
|
||||
@@ -206,8 +206,8 @@
|
||||
if (!response || !response.success || !response.user) return;
|
||||
$mbrName.val(response.user.displayName);
|
||||
}
|
||||
om.ajax.userByEmail = om.ajax.userByEmail || { url: sax.url.base + 'User/Ajax/GetUserByEmail', formId: 'frmUserEmail', callbackFn: fn };
|
||||
sax.doAjaxRequest(om.ajax.userByEmail, 100);
|
||||
om.ajax.userByEmail = om.ajax.userByEmail || { url: sax.url.base + 'User/Ajax/GetUserByEmail', formId: 'frmUserEmail', callbackFn: fn, noWaitIcon: true };
|
||||
sax.doAjaxRequest(om.ajax.userByEmail, 500);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
@@ -243,9 +243,8 @@
|
||||
}
|
||||
om.onRemoveItem = function (response)
|
||||
{
|
||||
sax.debug('onRemoveItem', response);
|
||||
//sax.debug('onRemoveItem', response);
|
||||
if (!response.success) return;
|
||||
|
||||
var item = response.member;
|
||||
$('#' + om.itemIdPrefix + item.id).remove();
|
||||
}
|
||||
@@ -265,7 +264,7 @@
|
||||
$frm.mbr = $('#frmMember');
|
||||
$frm.mbr.on('input', '.sax-input', function () { sax.clearControlError(this); });
|
||||
$frm.mbr.on('change', '.sax-select', function () { sax.clearControlError(this); });
|
||||
$frm.mbr.on('change', '#ifMemberUserEmailAddress', function () { om.onChangeEmail(); });
|
||||
$frm.mbr.on('input', '#ifMemberUserEmailAddress', function () { om.onChangeEmail(); });
|
||||
$frm.mbr.on('dblclick', '#ifMemberRoles', om.selectMemberRoles);
|
||||
$frm.mbr.on('click', '#pbMemberRolesSelect', om.selectMemberRoles);
|
||||
|
||||
|
||||
@@ -30,8 +30,9 @@
|
||||
var $items = $('.sax-panel-item-list', $pnl.results).hide().empty();
|
||||
sax.refreshPaging(response, '#frmOrganisationFilter', op.refreshResults);
|
||||
if (!response.success) return;
|
||||
// Reference data - Statuses.
|
||||
if (response.defaultStatusCode) sax.data.defaultStatusCode = response.defaultStatusCode;
|
||||
// Reference data.
|
||||
op.data.contactMethods = response.contactMethods;
|
||||
if (response.defaultStatusCode) op.data.defaultStatusCode = response.defaultStatusCode;
|
||||
if (response.statuses)
|
||||
sax.populateSelectCodeDesc('#cbOrganisationStatus', response.statuses);
|
||||
// Menu.
|
||||
@@ -241,7 +242,7 @@
|
||||
{
|
||||
let frm = $frm.org;
|
||||
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdCountry,input[type="text"],textarea,select', frm).val('');
|
||||
$('.OrganisationStatus', frm).val(sax.data.defaultStatusCode);
|
||||
$('.OrganisationStatus', frm).val(op.data.defaultStatusCode);
|
||||
sax.clearControlErrors();
|
||||
}
|
||||
sax.openOrgDialog = function ()
|
||||
@@ -279,11 +280,83 @@
|
||||
$('.OrganisationFacilities', frm).val(item.facilities);
|
||||
$('.OrganisationNotes', frm).val(item.notes);
|
||||
$('.OrganisationStatus', frm).val(item.statusCode);
|
||||
// Contact methods.
|
||||
$pnl.tblconMths.empty();
|
||||
let conMths = item.contactMethods || [];
|
||||
for (let idx = 0; idx < conMths.length; idx++)
|
||||
{
|
||||
let conMth = conMths[idx];
|
||||
$pnl.tblconMths.append(op.getConMthEl(conMth.method, conMth.methodCaption, conMth.value));
|
||||
}
|
||||
op.sortConMths();
|
||||
// Address.
|
||||
let address = item.address || {};
|
||||
$('input.OrganisationAddressId', $frm.org).val(address.id);
|
||||
$('input.OrganisationAddressLine1', $frm.org).val(address.line1);
|
||||
$('input.OrganisationAddressLine2', $frm.org).val(address.line2);
|
||||
$('input.OrganisationAddressLine3', $frm.org).val(address.line3);
|
||||
$('input.OrganisationAddressTown', $frm.org).val(address.town);
|
||||
$('input.OrganisationAddressProvince', $frm.org).val(address.province);
|
||||
$('input.OrganisationAddressCountry', $frm.org).val(address.country);
|
||||
$('input.OrganisationAddressPostalCode', $frm.org).val(address.postalCode);
|
||||
sax.clearControlErrors();
|
||||
$dlg.organisation.dialog('option', 'title', sax.dlg.title.updateOrganisation);
|
||||
sax.openOrgDialog();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.getConMthCfg = function (usedMths, mth, val)
|
||||
{
|
||||
let cfg = { fnCallback: op.applyConMth, methods: op.data.contactMethods, methodsUsed: usedMths, method: mth, value: val };
|
||||
return cfg;
|
||||
}
|
||||
op.getUsedMths = function ()
|
||||
{
|
||||
return $('input[name="Organisation.ContactMethod"]', $frm.org).map(function () { return $(this).val(); }).get();
|
||||
}
|
||||
op.addConMth = function ()
|
||||
{
|
||||
sax.editContactMethod(op.getConMthCfg(op.getUsedMths()));
|
||||
}
|
||||
op.editConMth = function (mth, val)
|
||||
{
|
||||
sax.editContactMethod(op.getConMthCfg(op.getUsedMths(), mth, val));
|
||||
}
|
||||
op.getConMthId = function (mth)
|
||||
{
|
||||
return 'ConMth_' + mth;
|
||||
}
|
||||
op.applyConMth = function (mth, mthDsc, val)
|
||||
{
|
||||
//sax.debug('applyConMth(\'' + mth + '\',\'' + mthDsc + '\',\'' + val + '\')');
|
||||
$('#' + op.getConMthId(mth), $pnl.conMths).remove();
|
||||
$pnl.tblconMths.append(op.getConMthEl(mth, mthDsc, val));
|
||||
op.sortConMths();
|
||||
}
|
||||
op.sortConMths = function ()
|
||||
{
|
||||
let $rows = $pnl.tblconMths.find('tr').detach().sort(function (a, b)
|
||||
{
|
||||
return $('.sax-label', a).text().localeCompare($('.sax-label', b).text());
|
||||
}).appendTo($pnl.tblconMths);
|
||||
$('input[name="ContactMethods"]', $pnl.conMths).val($rows.length);
|
||||
}
|
||||
op.getConMthEl = function (mth, mthDsc, val)
|
||||
{
|
||||
let $conMth = $('.sax-panel-item-template .ContactMethod', $pnl.conMths).clone().prop('id', op.getConMthId(mth));
|
||||
$('.sax-label', $conMth).text(mthDsc);
|
||||
$('.sax-value', $conMth).text(val);
|
||||
$('input[name="ContactMethod"]', $conMth).val(mth);
|
||||
$('input[name="ContactValue"]', $conMth).val(val);
|
||||
$conMth.on('click', '.sax-action.sax-edit', function () { op.editConMth(mth, val); });
|
||||
$conMth.on('click', '.sax-action.sax-remove', function () { op.clearConMth(mth); });
|
||||
return $conMth;
|
||||
}
|
||||
op.clearConMth = function (mth)
|
||||
{
|
||||
$('#' + op.getConMthId(mth), $pnl.conMths).remove();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------
|
||||
op.storeItem = function ()
|
||||
{
|
||||
@@ -336,7 +409,6 @@
|
||||
let $orgMbrs = $('.OrganisationMembers', $dlg.activate).empty();
|
||||
let $mbrTmpl = $('.sax-panel-item-template tr.sax-item.Member');
|
||||
let members = response.members;
|
||||
//sax.debug(members, $orgMbrs, $mbrTmpl);
|
||||
for (let idx = 0; idx < members.length; idx++)
|
||||
{
|
||||
let item = members[idx];
|
||||
@@ -346,7 +418,6 @@
|
||||
$('.MemberEmail', $item).text(item.emailAddress);
|
||||
$('.MemberName', $item).text(item.displayName);
|
||||
$orgMbrs.append($item);
|
||||
//sax.debug($item);
|
||||
}
|
||||
$('.MembersAwaitingActivation', $dlg.activate).toggle(!!members.length);
|
||||
sax.openDialog($dlg.activate, 480, 420);
|
||||
@@ -387,11 +458,6 @@
|
||||
$('.FilterOrganisationCategory,.FilterOrganisationStatusCategory', $frm.filter).on('change', function () { op.refreshResults(50); });
|
||||
$frm.filter.on('dblclick', '.FilterOrganisationSportCaption', op.selectFilterSport).on('click', '.FilterSportSelect', op.selectFilterSport).on('click', '.FilterSportClear', op.clearFilterSport);
|
||||
$frm.filter.on('dblclick', '.FilterOrganisationRegionCaption', op.selectFilterRegion).on('click', '.FilterRegionSelect', op.selectFilterRegion).on('click', '.FilterRegionClear', op.clearFilterRegion);
|
||||
$frm.orgId = $('#frmOrganisationId');
|
||||
$frm.org = $('#frmOrganisation');
|
||||
$frm.org.on('input', '.sax-input, .sax-textarea', function () { sax.clearControlError(this); }).on('change', '.sax-select', function () { sax.clearControlError(this); });
|
||||
$frm.org.on('dblclick', '.OrganisationSportCaption', op.selectOrgSport).on('click', '#pbSelectSport', op.selectOrgSport).on('click', '.OrganisationSportClear', op.clearOrgSport);
|
||||
$frm.org.on('dblclick', '.OrganisationRegionCaptionCountry', op.selectOrgRegion).on('click', '#pbSelectRegion', op.selectOrgRegion);
|
||||
|
||||
var opt = sax.dlgOpts();
|
||||
opt.open = sax.onOpenOrgDialog;
|
||||
@@ -399,6 +465,15 @@
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
$dlg.organisation = $('#dlgOrganisation').dialog(opt);
|
||||
|
||||
$frm.orgId = $('#frmOrganisationId');
|
||||
$frm.org = $('#frmOrganisation');
|
||||
$frm.org.on('input', '.sax-input, .sax-textarea', function () { sax.clearControlError(this); }).on('change', '.sax-select', function () { sax.clearControlError(this); });
|
||||
$frm.org.on('dblclick', '.OrganisationSportCaption', op.selectOrgSport).on('click', '#pbSelectSport', op.selectOrgSport).on('click', '.OrganisationSportClear', op.clearOrgSport);
|
||||
$frm.org.on('dblclick', '.OrganisationRegionCaptionCountry', op.selectOrgRegion).on('click', '#pbSelectRegion', op.selectOrgRegion);
|
||||
$frm.org.on('click', '.ItemContactMethods .sax-action.sax-add', op.addConMth);
|
||||
$pnl.conMths = $('.ItemContactMethods', $frm.org);
|
||||
$pnl.tblconMths = $('table.sax-data', $pnl.conMths);
|
||||
|
||||
var opt = sax.dlgOpts();
|
||||
opt.buttons[sax.dlg.btn.ok] = function () { op.activateOrganisation(); };
|
||||
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); };
|
||||
|
||||
Reference in New Issue
Block a user