v1.2.11.0

This commit is contained in:
2023-07-06 18:36:52 +01:00
parent a4da299248
commit fbac433f63
19 changed files with 526 additions and 109 deletions
+58 -20
View File
@@ -5,9 +5,8 @@
(function (win, doc, undef)
{
"use strict";
let oa = sax.mdl.organisationAssociations = { data: {}, ajax: {} };
let oa = sax.mdl.organisationAssociations = { data: {}, ajax: {}, itemIdPrefix: 'oa_' };
let $pnl = oa.$pnl = {}, $frm = oa.$frm = {}, $dlg = oa.$dlg = {};
let mdlOrg = function () { return sax.mdl.organisations; }
//--------------------------------------------------------------
oa.refreshResults = function (delay)
@@ -48,19 +47,19 @@
if (!items.length)
return $msgs.append($('<div class="sax-message">' + sax.msg.dataNoneFound + '</div>')).fadeIn(500);
for (let itemIdx = 0; itemIdx < items.length; itemIdx++)
$items.append(sax.populateItem(oa.getItemTemplate(), items[itemIdx]));
$items.append(oa.populateItem(oa.getItemTemplate(), items[itemIdx]));
$items.fadeIn(50);
}
sax.populateItem = function ($item, item)
oa.populateItem = function ($item, item)
{
if (!item) return;
$item.prop('id', oa.itemIdPrefix + item.id);
$('.UserEmailAddress', $item).text(item.emailAddress);
$('.UserStatusDesc', $item).text(item.userStatusDesc).addClass('sax-status-' + (item.userStatusCode || '').toLowerCase());
$('.UserStatus', $item).toggle(!item.userActive);
$('.UserDisplayName', $item).text(item.displayName);
$('.AssociationRoleCount .RoleCount', $item).text(item.roleCount);
$('.StatusDesc', $item).text(item.statusDesc).addClass('sax-status-' + (item.statusCode || '').toLowerCase());
$item.prop('id', oa.getItemIdProp(item.id));
let assoc = item.assoc || {};
let org = item.organisationAssoc || {};
$('.OrganisationName', $item).text(org.name);
$('.AssociationLabel', $item).text(assoc.label);
$('.Sport', $item).text(org.sport);
$('.Region', $item).text(org.region);
$('.sax-caption .sax-action').toggleClass('sax-action', !item.deleted);
let $mnu = $('ul.sax-dropdown-menu', $item).empty();
if (!item.deleted)
@@ -68,8 +67,7 @@
let fnUpdItm = function () { oa.updateItem(item, $item) };
$mnu.append(oa.getItemMenuOption(sax.lbl.edit, fnUpdItm, 'sax-edit'));
$item.on('click', '.sax-header .sax-caption', fnUpdItm).on('dblclick', fnUpdItm);
if (item.association)
$mnu.append(oa.getItemMenuOption(sax.lbl.remove, function () { oa.removeItem(item, $item) }, 'sax-remove'));
$mnu.append(oa.getItemMenuOption(sax.lbl.remove, function () { oa.removeItem(item, $item) }, 'sax-remove'));
}
$('.sax-burger', $item).toggle(!!$('.sax-dropdown-item', $mnu).length);
$('.sax-panel-messages', $pnl.results).hide().empty();
@@ -77,6 +75,10 @@
}
//--------------------------------------------------------------
oa.getItemIdProp = function (id)
{
return oa.itemIdPrefix + id;
}
oa.getFilterDropdownTemplate = function ()
{
return $('.sax-panel-item-template .sax-dropdown-menu.AssociationFilter li.sax-dropdown-item', $pnl.filter).clone();
@@ -150,8 +152,9 @@
//--------------------------------------------------------------
oa.updateItem = function (item, $item)
{
$('.OrganisationId', $frm.orgId).val(item.id);
oa.ajax.getItemAssoc = oa.ajax.getItemAssoc || { url: sax.url.base + 'Organisation/Ajax/GetAssociation', formId: 'frmOrganisationId', callbackFn: oa.onUpdateItem };
$('.ItemAssociationId', $frm.assocId).val(item.id);
$('.OrganisationId', $frm.assocId).val($('.OrganisationId', $frm.filter).val());
oa.ajax.getItemAssoc = oa.ajax.getItemAssoc || { url: sax.url.base + 'Organisation/Ajax/GetAssociation', formId: 'frmAssociationId', callbackFn: oa.onUpdateItem };
sax.doAjaxRequest(oa.ajax.getItemAssoc, 50);
}
oa.onUpdateItem = function (response)
@@ -160,13 +163,19 @@
if (!response.success) return;
oa.clearItem();
// Association.
let item = response.organisation;
let assoc = item.association || {};
let item = response.association || {};
let assoc = item.assoc || {};
let org = item.organisation || {};
let orgAssoc = item.organisationAssoc || {};
let frm = $frm.assoc;
$('input.ItemAssociationId', frm).val(item.id);
$('input.OrganisationId', frm).val(item.organisationId);
$('.OrganisationName', frm).val(item.name);
$('input.NewItem', frm).val(0);
$('input.OrganisationId', frm).val(org.id);
$('.OrganisationName input.OrganisationName', frm).val(org.name);
$('.AssociationTypeOption select.AssociationTypeOption', frm).val(assoc.type);
$('.OrganisationIdAssoc input.OrganisationIdAssoc', frm).val(orgAssoc.id);
$('.OrganisationIdAssoc .OrganisationNameAssoc', frm).val(orgAssoc.name);
sax.openAssocDialog();
}
@@ -183,7 +192,36 @@
sax.refreshControlValues(response.controlValues, $frm.assoc);
if (!response.success) return;
$dlg.assoc.dialog('close');
mdlOrg().refreshItem(response.organisation);
oa.refreshItem(response.association);
}
oa.refreshItem = function (item)
{
var $item = $('#' + oa.getItemIdProp(item.id));
if (!$item.length)
{
$item = oa.getItemTemplate();
$('.sax-panel-item-list', $pnl.results).prepend($item).show();
}
oa.populateItem($item, item);
}
//--------------------------------------------------------------
oa.removeItem = function (item, $item)
{
sax.debug('removeItem')
oa.clearItem();
let frm = $frm.assoc;
$('.ItemAssociationId', frm).val(item.id);
$('.OrganisationId', frm).val(item.organisation.id);
$('.OrganisationIdAssoc', frm).val(item.organisationAssoc.id);
oa.ajax.getRemoveItem = oa.ajax.getRemoveItem || { url: sax.url.base + 'Organisation/Ajax/RemoveAssociation', formId: frm.prop('id'), callbackFn: oa.onRemoveItem };
sax.doAjaxRequest(oa.ajax.getRemoveItem, 50);
}
oa.onRemoveItem = function (response)
{
sax.debug('', response)
if (!response.success) return;
oa.refreshResults();
}
//--------------------------------------------------------------
+1 -1
View File
@@ -247,7 +247,7 @@
op.clearItem = function ()
{
let frm = $frm.org;
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdPrimary,input[type="text"],textarea,select', frm).val('');
$('.OrganisationId,.OrganisationSportId,.OrganisationRegionIdPrimary,input[name="ContactMethods"],input[type="text"],textarea,select', frm).val('');
$pnl.tblconMths.empty();
$('.OrganisationStatus', frm).val(op.data.defaultStatusCode);
sax.clearControlErrors();