/* * 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('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)); $('.OrganisationSportCaption', or.$frm).val(sport ? sport.name : ''); } //-------------------------------------------------------------- or.selectOrgRegionCountry = 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.onSelectOrgRegionCountry }) } or.onSelectOrgRegionCountry = 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); or.$frm.on('dblclick', 'input.OrganisationSportCaption', or.selectOrgSport).on('click', 'button.SelectSport', or.selectOrgSport); or.$frm.on('dblclick', 'input.OrganisationRegionCaptionCountry', or.selectOrgRegionCountry).on('click', 'button.SelectRegionCountry', or.selectOrgRegionCountry); $('.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 */