78 lines
2.9 KiB
JavaScript
78 lines
2.9 KiB
JavaScript
/*
|
|
* Organisation Request.
|
|
*/
|
|
|
|
(function (win, doc, undef)
|
|
{
|
|
"use strict";
|
|
let or = sax.orgReq;
|
|
or.fn = {}; or.ajax = {};
|
|
|
|
//--------------------------------------------------------------
|
|
or.fn.requestOrganisation = function ()
|
|
{
|
|
or.fn.init();
|
|
$('input[type="text"],textarea,select,.OrganisationSportId,.OrganisationRegionIdCountry', or.$frm).val('');
|
|
$('.OrganisationRegionIdCountry', or.$frm).val(sax.data.regionIdCountryDefault);
|
|
$('.OrganisationRegionCaptionCountry', or.$frm).val(sax.data.regionNameCountryDefault);
|
|
sax.clearControlErrors(or.$frm);
|
|
sax.openDialog(or.$dlg, 640, 760);
|
|
}
|
|
or.fn.storeOrganisation = function ()
|
|
{
|
|
//sax.debug('refreshResults');
|
|
or.ajax.registerOrg = or.ajax.registerOrg || { url: sax.url.base + 'Organisation/Ajax/Request', formId: 'frmOrganisationRequest', callbackFn: or.fn.handleRequestOrganisationResponse };
|
|
sax.doAjaxRequest(or.ajax.registerOrg, 50);
|
|
}
|
|
or.fn.handleRequestOrganisationResponse = function (response)
|
|
{
|
|
//sax.debug('or.handleRequestOrganisationResponse', response);
|
|
if (!response) return;
|
|
sax.refreshControlValues(response.controlValues, or.$frm);
|
|
if (!response.success) return;
|
|
or.$dlg.dialog('close');
|
|
or.fn.cleanUp();
|
|
}
|
|
or.fn.cleanUp = function ()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
sax.selectOrgSport = function ()
|
|
{
|
|
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: sax.onSelectOrgSport })
|
|
}
|
|
sax.onSelectOrgSport = function (sport)
|
|
{
|
|
sax.clearControlError($('.OrganisationSportId', or.$frm).val(sport.id));
|
|
$('.OrganisationSportCaption', or.$frm).val(sport ? sport.name : '');
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
sax.selectOrgRegion = function ()
|
|
{
|
|
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', or.$frm).val(), typesInc:[30], fnCallback: sax.onSelectOrgRegion })
|
|
}
|
|
sax.onSelectOrgRegion = function (region)
|
|
{
|
|
sax.clearControlError($('.OrganisationRegionIdCountry', or.$frm).val(region.id));
|
|
$('.OrganisationRegionCaptionCountry', or.$frm).val(region ? region.name : '');
|
|
}
|
|
|
|
//--------------------------------------------------------------
|
|
or.fn.init = function ()
|
|
{
|
|
if (or.$dlg) return;
|
|
var opt = sax.dlgOpts();
|
|
opt.title = sax.orgReq.dlgTitleRequestOrganisation;
|
|
opt.buttons[sax.dlg.btn.ok] = function () { or.fn.storeOrganisation(); };
|
|
opt.buttons[sax.dlg.btn.cancel] = function () { $(this).dialog('close'); or.fn.cleanUp(); };
|
|
or.$dlg = $('#dlgOrganisationRequest').dialog(opt);
|
|
or.$frm = $('#frmOrganisationRequest', or.$dlg);
|
|
$('.sax-input, .sax-textarea', or.$frm).on('input', function () { sax.clearControlError(this); });
|
|
$('.sax-select', or.$frm).on('change', function () { sax.clearControlError(this); });
|
|
}
|
|
|
|
}(window, window.document));
|
|
|
|
/* The End */ |