73 lines
3.3 KiB
JavaScript
73 lines
3.3 KiB
JavaScript
/*
|
|
* Organisation Request.
|
|
*/
|
|
(function (win, doc, undef)
|
|
{
|
|
"use strict";
|
|
let or = sax.orgReq;
|
|
or.fn = {}; or.ajax = {};
|
|
//--------------------------------------------------------------
|
|
or.fn.requestOrganisation = function ()
|
|
{
|
|
$('input[type="text"],textarea,select,.OrganisationSportId,.OrganisationRegionIdCountry', or.$frm).val('');
|
|
$('.OrganisationRegionIdPrimary', or.$frm).val(sax.data.regionIdCountryDefault);
|
|
$('.OrganisationRegionNamePrimary', or.$frm).val(sax.data.regionNameCountryDefault);
|
|
sax.clearControlErrors(or.$frm);
|
|
sax.openDialog(or.$dlg, 640, 760);
|
|
}
|
|
or.fn.storeOrganisation = function ()
|
|
{
|
|
//sax.debug('storeOrganisation');
|
|
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('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 ()
|
|
{
|
|
}
|
|
//--------------------------------------------------------------
|
|
or.selectOrgSport = function ()
|
|
{
|
|
sax.mdl.selectSport.fn.selectSport({ caption: sax.dlg.title.selectSport, sportId: $('.OrganisationSportId', or.$frm).val(), fnCallback: or.onSelectOrgSport })
|
|
}
|
|
or.onSelectOrgSport = function (sport)
|
|
{
|
|
sax.clearControlError($('.OrganisationSportId', or.$frm).val(sport.id));
|
|
$('.OrganisationSportName', or.$frm).val(sport ? sport.name : '');
|
|
}
|
|
//--------------------------------------------------------------
|
|
or.selectOrgRegionPrimary = function ()
|
|
{
|
|
//sax.debug($('.OrganisationRegionIdCountry', or.$frm).val());
|
|
sax.mdl.selectRegion.fn.selectRegion({ caption: sax.dlg.title.selectRegion, regionId: $('.OrganisationRegionIdCountry', or.$frm).val(), typesInc: [30], fnCallback: or.onSelectOrgRegionPrimary })
|
|
}
|
|
or.onSelectOrgRegionPrimary = function (region)
|
|
{
|
|
sax.clearControlError($('.OrganisationRegionIdPrimary', or.$frm).val(region.id));
|
|
$('.OrganisationRegionNamePrimary', or.$frm).val(region ? region.name : '');
|
|
}
|
|
//--------------------------------------------------------------
|
|
$(function ()
|
|
{
|
|
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);
|
|
or.$frm.on('dblclick', 'input.OrganisationSportName', or.selectOrgSport).on('click', 'button.SelectOrganisationSport', or.selectOrgSport);
|
|
or.$frm.on('dblclick', 'input.OrganisationRegionNamePrimary', or.selectOrgRegionPrimary).on('click', 'button.SelectOrganisationRegionPrimary', or.selectOrgRegionPrimary);
|
|
$('.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 */ |