ws-voice-infinity-global-module 1.12.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var o=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var r,i,a={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return a;if(r=t?n:o){if(r.has(e))return r.get(e);r.set(e,a)}for(var s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?r(a,s,i):a[s]=e[s]);return a})(e,t)}function _regenerator(){function e(e,o,n,r){var s=o&&o.prototype instanceof t?o:t,u=Object.create(s.prototype);return _regeneratorDefine2(u,"_invoke",function(e,t,o){function n(e,t){for(s=e,u=t,a=0;!d&&c&&!o&&a<l.length;a++){var o,n=l[a],r=f.p,y=n[2];e>3?(o=y===t)&&(u=n[(s=n[4])?5:(s=3,3)],n[4]=n[5]=i):n[0]<=r&&((o=e<2&&r<n[1])?(s=0,f.v=t,f.n=n[1]):r<y&&(o=e<3||n[0]>t||t>y)&&(n[4]=e,n[5]=t,f.n=y,s=0))}if(o||e>1)return p;throw d=!0,t}var r,s,u,c=0,l=o||[],d=!1,f={p:0,n:0,v:i,a:n,f:n.bind(i,4),d:function(e,t){return r=e,s=0,u=i,f.n=t,p}};return function(o,a,l){if(c>1)throw TypeError("Generator is already running");for(d&&1===a&&n(a,l),s=a,u=l;(y=s<2?i:u)||!d;){r||(s?s<3?(s>1&&(f.n=-1),n(s,u)):f.n=u:f.v=u);try{if(c=2,r){if(s||(o="next"),y=r[o]){if(!(y=y.call(r,u)))throw TypeError("iterator result is not an object");if(!y.done)return y;u=y.value,s<2&&(s=0)}else 1===s&&(y=r["return"])&&y.call(r),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);r=i}else if((y=(d=f.n<0)?u:e.call(t,f))!==p)break}catch(y){r=i,s=1,u=y}finally{c=1}}return{value:y,done:d}}}(e,n,r),!0),u}function t(){}function o(){}function n(){}function r(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,n):(e.__proto__=n,_regeneratorDefine2(e,c,"GeneratorFunction")),e.prototype=Object.create(d),e}var i,a,s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.toStringTag||"@@toStringTag",p={};a=Object.getPrototypeOf;var l=[][u]?a(a([][u]())):(_regeneratorDefine2(a={},u,function(){return this}),a),d=n.prototype=t.prototype=Object.create(l);return o.prototype=n,_regeneratorDefine2(d,"constructor",n),_regeneratorDefine2(n,"constructor",o),o.displayName="GeneratorFunction",_regeneratorDefine2(n,c,"GeneratorFunction"),_regeneratorDefine2(d),_regeneratorDefine2(d,c,"Generator"),_regeneratorDefine2(d,u,function(){return this}),_regeneratorDefine2(d,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:e,m:r}})()}function _regeneratorDefine2(e,t,o,n){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}(_regeneratorDefine2=function(e,t,o,n){if(t)r?r(e,t,{value:o,enumerable:!n,configurable:!n,writable:!n}):e[t]=o;else{var i=function(t,o){_regeneratorDefine2(e,t,function(e){return this._invoke(t,o,e)})};i("next",0),i("throw",1),i("return",2)}})(e,t,o,n)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _callSuper(e,t,o){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,o||[],_getPrototypeOf(e).constructor):t.apply(e,o))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function _typeof(e){"@babel/helpers - typeof";return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _mobxReact=require("mobx-react"),_wsReactBaseComponents=require("ws-react-base-components"),_actions=require("../../../actions"),geoDataActions=_interopRequireWildcard(require("../../actions/geoActions")),routingActions=_interopRequireWildcard(require("../../actions/routingActions")),_globalConfig=require("../../config/globalConfig"),_baseStatus=require("../../enums/baseStatus"),_oktmoType=_interopRequireDefault(require("../../enums/oktmoType")),_municipality=require("../../models/municipality"),_authServices=require("../../services/authServices"),_mapComponentTemplate=_interopRequireDefault(require("./mapComponentTemplate")),__decorate=function(e,t,o,n){var r,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"===("undefined"==typeof Reflect?"undefined":_typeof(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(i<3?r(a):i>3?r(t,o,a):r(t,o))||a);return i>3&&a&&Object.defineProperty(t,o,a),a},__awaiter=function(e,t,o,n){return new(o||(o=Promise))(function(r,i){function a(e){try{u(n.next(e))}catch(t){i(t)}}function s(e){try{u(n["throw"](e))}catch(t){i(t)}}function u(e){e.done?r(e.value):new o(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Map=function(e){function t(){var e;return _classCallCheck(this,t),e=_callSuper(this,t,arguments),e.scale=67108864,e.latitude=parseFloat(_globalConfig.globalConfig.WS_VOICE_MAP_LAT),e.longitude=parseFloat(_globalConfig.globalConfig.WS_VOICE_MAP_LNG),e.defaultZoom=12,e.pointCoords=e.props.pointCoords?e.props.pointCoords:[e.latitude,e.longitude],e.zoom=e.props.zoom?e.props.zoom:e.defaultZoom,e.updateValidationAddress=!1,e.pointAddressee=e.props.pointAddressee?e.props.pointAddressee:"",e.parentLocation=_globalConfig.globalConfig.WS_VOICE_MAP_SEARCH_PREFIX,e.geocodeRequestId=0,e.state={addresseeText:e.pointAddressee?e.pointAddressee:"",mapId:"map-component".concat((new Date).getTime()),showLabel:!1,addresseeTextCoordinates:e.pointCoords,showMap:!1,municipality:e.props.municipality?e.props.municipality:null,selectedMunicipalityIsDefault:!1,defaultExecutor:null,oktmo:e.props.oktmo?e.props.oktmo:null,notFindMunicipality:!1,addressAfterUserInput:null,errorText:null},e.updateAddressee=function(){var t=e.geocodeRequestId,o=e.state.addresseeText.trim();o&&(e.initGeocoder(),e.geocoder.geocode(e.getAddressCoords(),function(n){if(t===e.geocodeRequestId&&o===e.state.addresseeText.trim()){if(!n.length)return void e.setState({notFindMunicipality:!0,errorText:"Адрес не найден. Укажите точку проблемы на карте"});e.pointCoords=[n[0].center.lat,n[0].center.lng],e.addressCheck(n[0].properties.address);try{e.point.setLatLng(n[0].center).addTo(e.markerLayer)}catch(r){e.createMarker(n[0].center)}e.map.setView(n[0].center),e.findMunicipality(),e.setState({addresseeTextCoordinates:e.pointCoords,errorText:null},function(){return e.runCallbackIfExist()})}}))},e.updateAddresseeText=function(t){e.geocodeRequestId+=1,e.runCallbackIfExist([],t),e.props.updateMunicipality&&e.props.updateMunicipality(null,[]),e.props.updateOktmo&&e.props.updateOktmo(null),e.setState({municipality:null,oktmo:null,notFindMunicipality:!1,selectedMunicipalityIsDefault:!1,defaultExecutor:null,errorText:null,addressAfterUserInput:null}),e.updateState(t,"addresseeText",e.updateAddressee)},e.toggleMap=function(){e.map||e.initMap(),e.setState(function(e){var t=e.showMap;return{showMap:!t}})},e.findMyLocation=function(){var t=++e.geocodeRequestId;navigator.geolocation.getCurrentPosition(function(o){t===e.geocodeRequestId&&(e.pointCoords=[o.coords.latitude,o.coords.longitude],e.initGeocoder(),e.geocoder.reverse({lat:e.pointCoords[0],lng:e.pointCoords[1]},e.scale,function(o){t===e.geocodeRequestId&&o.length&&e.applyGeocodeResult(o[0])}))},function(){if(t===e.geocodeRequestId){var o=_authServices.AuthService.getUserInfo();o&&o.localityId&&e.props.oktmoStore&&e.props.oktmoStore.addOktmo([o.localityId]).then(function(){if(t===e.geocodeRequestId&&e.props.oktmoStore){var n=e.props.oktmoStore.getEntityById(o.localityId);n&&(e.initGeocoder(),e.geocoder.geocode(n.fullName,function(o){t===e.geocodeRequestId&&o.length&&e.applyGeocodeResult(o[0])}))}})}})},e.applyGeocodeResult=function(t){e.pointCoords=[t.center.lat,t.center.lng];var o=t.properties.address;e.pointAddressee=e.getUnderstandAddressString(o);try{e.point.setLatLng(t.center).addTo(e.markerLayer)}catch(n){e.createMarker(t.center)}e.map.setView(t.center),e.findMunicipality(),e.applyPointAddressee()},e.selectMunicipalityFromExecutorProjection=function(t,o){e.setState({oktmo:t.locality,municipality:t.municipality?new _municipality.Municipality({id:t.municipality.id,name:t.municipality.name,status:_baseStatus.BaseStatusEnum.ACTIVE}):null,notFindMunicipality:!t.municipality,selectedMunicipalityIsDefault:t.defaultMunicipality,defaultExecutor:t.defaultMunicipality&&t.messageStations[0]?t.messageStations[0]:null},function(){e.props.updateMunicipality&&!o&&(e.props.updateMunicipality&&e.props.updateMunicipality(e.state.municipality,t.messageStations),e.props.updateOktmo&&e.props.updateOktmo(e.state.oktmo))})},e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){this.props.disabled||this.initMap(!0)}},{key:"componentWillReceiveProps",value:function(e){(e.oktmo&&!this.props.oktmo||e.oktmo&&this.props.oktmo&&e.oktmo.id!==this.props.oktmo.id)&&this.setState({oktmo:e.oktmo?e.oktmo:null}),(e.municipality&&!this.props.municipality||e.municipality&&this.props.municipality&&e.municipality.id!==this.props.municipality.id)&&this.setState({municipality:e.municipality?e.municipality:null})}},{key:"initMap",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{this.createMap(),!this.props.disabled&&this.props.pointAddressee&&this.findMunicipality(!this.props.alwaysCallCallback||!t),this.props.pointAddressee||this.props.disabled||this.props.pointCoords&&this.props.pointCoords.length&&t||this.findMyLocation()}catch(o){var n=100;window.setTimeout(function(){return e.initMap()},n)}}},{key:"initGeocoder",value:function(){var e=this;try{this.geocoderControl||(this.geocoderControl=L.Control.geocoder().addTo(this.map)),this.geocoder||(this.geocoder=new L.Control.Geocoder.Nominatim)}catch(t){var o=100;window.setTimeout(function(){return e.initMap()},o)}}},{key:"createMap",value:function(){var e=this;this.map=L.map("map-container",{center:this.pointCoords,zoom:this.zoom});var t=new L.tileLayer(_globalConfig.globalConfig.mapTileLayerUrl);this.map.addLayer(t),this.initGeocoder(),this.createMarker(),this.props.disabled||this.findMunicipality(),this.props.disabled||this.map.on({click:function(t){var o=++e.geocodeRequestId;e.pointCoords=[t.latlng.lat,t.latlng.lng],e.map.setView(t.latlng),e.findMunicipality(),e.updateState(null,"addressAfterUserInput");try{e.point.setLatLng(t.latlng).addTo(e.markerLayer)}catch(t){e.createMarker(t.latlng)}e.initGeocoder(),e.geocoder.reverse(t.latlng,e.scale,function(t){if(o===e.geocodeRequestId&&t.length){var n=t[0].properties.address;e.pointAddressee=e.getUnderstandAddressString(n),e.applyPointAddressee()}})}})}},{key:"getUnderstandAddressString",value:function(e){var t=e.village,o=e.city,n=e.town,r=e.county,i=e.country,a=e.road,s=e.house_number,u=t||o||n||r||i;return[u,a,s].filter(function(e){return!!e}).join(", ")}},{key:"createMarker",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.props.pointCoords&&(this.pointCoords=this.props.pointCoords),this.markerLayer=L.layerGroup().addTo(this.map),this.point=L.marker(t?[t.lat,t.lng]:this.pointCoords,{draggable:!this.props.disabled}).addTo(this.markerLayer),this.point.on({dragend:function(){var t=++e.geocodeRequestId;e.pointCoords=[e.point.getLatLng().lat,e.point.getLatLng().lng],e.findMunicipality(),e.map.setView(e.point.getLatLng()),e.initGeocoder(),e.geocoder.reverse(e.point.getLatLng(),e.scale,function(o){if(t===e.geocodeRequestId&&o.length){var n=o[0].properties.address;e.pointAddressee=e.getUnderstandAddressString(n),e.applyPointAddressee()}})}})}},{key:"applyPointAddressee",value:function(){var e=this;this.updateValidationAddress=!0,this.setState({addresseeText:this.pointAddressee,addresseeTextCoordinates:this.pointCoords,showLabel:!1},function(){return e.runCallbackIfExist()})}},{key:"getAddressCoords",value:function(){var e=this.municipality?"".concat(this.parentLocation).concat(this.municipality.name,", "):this.parentLocation;return"".concat(e).concat(this.state.addresseeText)}},{key:"addressCheck",value:function(e){this.setState({addressAfterUserInput:this.getUnderstandAddressString(e)})}},{key:"runCallbackIfExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pointCoords,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state.addresseeText;this.props.updateCallback&&this.props.updateCallback(t,e)}},{key:"findMunicipality",value:function(e){var t=this,o=this.geocodeRequestId;return this.setState({notFindMunicipality:!1}),this.props.subjectId?void this.promiseWithLoading(routingActions.executorsByCoords(this.pointCoords[0],this.pointCoords[1],this.props.subjectId?this.props.subjectId:"")).then(function(n){if(o===t.geocodeRequestId)return n?void t.selectMunicipalityFromExecutorProjection(n,e):t.setState({notFindMunicipality:!0})})["catch"](function(e){if(o===t.geocodeRequestId){var n=2001;t.setState({notFindMunicipality:!0,errorText:e.response.data.code===n?e.response.data.message:null})}}):(this.promiseWithLoading(this.findMunicipalityByCoords(this.pointCoords[0],this.pointCoords[1])).then(function(n){if(o===t.geocodeRequestId)return n?void t.selectMunicipality(n,e):void t.setState({notFindMunicipality:!0,errorText:"Выбранный адрес не относится к валидной области. Измените адрес"})}),void this.promiseWithLoading(this.findOktmoByCoords(this.pointCoords[0],this.pointCoords[1])).then(function(n){o===t.geocodeRequestId&&t.selectOktmo(n,e)}))}},{key:"findMunicipalityByCoords",value:function(e,t){return __awaiter(this,void 0,void 0,_regenerator().m(function o(){var n,r,i,a,s,u,c;return _regenerator().w(function(o){for(;;)switch(o.n){case 0:return n=6,o.p=1,o.n=2,geoDataActions.byCoordinates(e,t);case 2:if(r=o.v,i=r.find(function(e){return e.adminLevel===n})){o.n=3;break}return o.a(2,null);case 3:return a={code:i.oktmo,pageNo:0,pageSize:1,types:[_oktmoType["default"].MUNICIPALITY.value]},o.n=4,_actions.oktmoActions.listPage(a);case 4:return s=o.v,u=s.items[0],o.a(2,u?u:null);case 5:return o.p=5,c=o.v,o.a(2,null)}},o,null,[[1,5]])}))}},{key:"findOktmoByCoords",value:function(e,t){return __awaiter(this,void 0,void 0,_regenerator().m(function o(){var n,r,i,a,s,u,c;return _regenerator().w(function(o){for(;;)switch(o.n){case 0:return n=8,o.p=1,o.n=2,geoDataActions.byCoordinates(e,t);case 2:if(r=o.v,i=r.find(function(e){return e.adminLevel===n})){o.n=3;break}return o.a(2,null);case 3:return a={code:i.oktmo,pageNo:0,pageSize:1,types:[_oktmoType["default"].LOCALITY.value]},o.n=4,_actions.oktmoActions.listPage(a);case 4:return s=o.v,u=s.items[0],o.a(2,u?u:null);case 5:return o.p=5,c=o.v,o.a(2,null)}},o,null,[[1,5]])}))}},{key:"selectMunicipality",value:function(e,t){var o=this;this.setState({municipality:new _municipality.Municipality({id:e.id,name:e.name,status:_baseStatus.BaseStatusEnum.ACTIVE})},function(){o.props.updateMunicipality&&!t&&o.props.updateMunicipality(o.state.municipality,[])})}},{key:"selectOktmo",value:function(e,t){var o=this;this.setState({oktmo:e},function(){o.props.updateOktmo&&!t&&o.props.updateOktmo(o.state.oktmo)})}},{key:"render",value:function(){return(0,_mapComponentTemplate["default"])(this)}}])}(_wsReactBaseComponents.WsReactBaseComponent);Map=__decorate([_mobxReact.observer],Map);var _default=exports["default"]=Map;
1
+ "use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var o=new WeakMap,n=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var r,i,a={__proto__:null,"default":e};if(null===e||"object"!=_typeof(e)&&"function"!=typeof e)return a;if(r=t?n:o){if(r.has(e))return r.get(e);r.set(e,a)}for(var s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?r(a,s,i):a[s]=e[s]);return a})(e,t)}function _regenerator(){function e(e,o,n,r){var s=o&&o.prototype instanceof t?o:t,u=Object.create(s.prototype);return _regeneratorDefine2(u,"_invoke",function(e,t,o){function n(e,t){for(s=e,u=t,a=0;!d&&c&&!o&&a<l.length;a++){var o,n=l[a],r=f.p,y=n[2];e>3?(o=y===t)&&(u=n[(s=n[4])?5:(s=3,3)],n[4]=n[5]=i):n[0]<=r&&((o=e<2&&r<n[1])?(s=0,f.v=t,f.n=n[1]):r<y&&(o=e<3||n[0]>t||t>y)&&(n[4]=e,n[5]=t,f.n=y,s=0))}if(o||e>1)return p;throw d=!0,t}var r,s,u,c=0,l=o||[],d=!1,f={p:0,n:0,v:i,a:n,f:n.bind(i,4),d:function(e,t){return r=e,s=0,u=i,f.n=t,p}};return function(o,a,l){if(c>1)throw TypeError("Generator is already running");for(d&&1===a&&n(a,l),s=a,u=l;(y=s<2?i:u)||!d;){r||(s?s<3?(s>1&&(f.n=-1),n(s,u)):f.n=u:f.v=u);try{if(c=2,r){if(s||(o="next"),y=r[o]){if(!(y=y.call(r,u)))throw TypeError("iterator result is not an object");if(!y.done)return y;u=y.value,s<2&&(s=0)}else 1===s&&(y=r["return"])&&y.call(r),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);r=i}else if((y=(d=f.n<0)?u:e.call(t,f))!==p)break}catch(y){r=i,s=1,u=y}finally{c=1}}return{value:y,done:d}}}(e,n,r),!0),u}function t(){}function o(){}function n(){}function r(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,n):(e.__proto__=n,_regeneratorDefine2(e,c,"GeneratorFunction")),e.prototype=Object.create(d),e}var i,a,s="function"==typeof Symbol?Symbol:{},u=s.iterator||"@@iterator",c=s.toStringTag||"@@toStringTag",p={};a=Object.getPrototypeOf;var l=[][u]?a(a([][u]())):(_regeneratorDefine2(a={},u,function(){return this}),a),d=n.prototype=t.prototype=Object.create(l);return o.prototype=n,_regeneratorDefine2(d,"constructor",n),_regeneratorDefine2(n,"constructor",o),o.displayName="GeneratorFunction",_regeneratorDefine2(n,c,"GeneratorFunction"),_regeneratorDefine2(d),_regeneratorDefine2(d,c,"Generator"),_regeneratorDefine2(d,u,function(){return this}),_regeneratorDefine2(d,"toString",function(){return"[object Generator]"}),(_regenerator=function(){return{w:e,m:r}})()}function _regeneratorDefine2(e,t,o,n){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}(_regeneratorDefine2=function(e,t,o,n){function i(t,o){_regeneratorDefine2(e,t,function(e){return this._invoke(t,o,e)})}t?r?r(e,t,{value:o,enumerable:!n,configurable:!n,writable:!n}):e[t]=o:(i("next",0),i("throw",1),i("return",2))})(e,t,o,n)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _callSuper(e,t,o){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,o||[],_getPrototypeOf(e).constructor):t.apply(e,o))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function _typeof(e){"@babel/helpers - typeof";return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _mobxReact=require("mobx-react"),_wsReactBaseComponents=require("ws-react-base-components"),_actions=require("../../../actions"),geoDataActions=_interopRequireWildcard(require("../../actions/geoActions")),routingActions=_interopRequireWildcard(require("../../actions/routingActions")),_globalConfig=require("../../config/globalConfig"),_baseStatus=require("../../enums/baseStatus"),_oktmoType=_interopRequireDefault(require("../../enums/oktmoType")),_municipality=require("../../models/municipality"),_authServices=require("../../services/authServices"),_mapComponentTemplate=_interopRequireDefault(require("./mapComponentTemplate")),__decorate=function(e,t,o,n){var r,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"===("undefined"==typeof Reflect?"undefined":_typeof(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(i<3?r(a):i>3?r(t,o,a):r(t,o))||a);return i>3&&a&&Object.defineProperty(t,o,a),a},__awaiter=function(e,t,o,n){return new(o||(o=Promise))(function(r,i){function a(e){try{u(n.next(e))}catch(t){i(t)}}function s(e){try{u(n["throw"](e))}catch(t){i(t)}}function u(e){e.done?r(e.value):new o(function(t){t(e.value)}).then(a,s)}u((n=n.apply(e,t||[])).next())})},Map=function(e){function t(){var e;return _classCallCheck(this,t),e=_callSuper(this,t,arguments),e.scale=67108864,e.latitude=parseFloat(_globalConfig.globalConfig.WS_VOICE_MAP_LAT),e.longitude=parseFloat(_globalConfig.globalConfig.WS_VOICE_MAP_LNG),e.defaultZoom=12,e.pointCoords=e.props.pointCoords?e.props.pointCoords:[e.latitude,e.longitude],e.zoom=e.props.zoom?e.props.zoom:e.defaultZoom,e.updateValidationAddress=!1,e.pointAddressee=e.props.pointAddressee?e.props.pointAddressee:"",e.parentLocation=_globalConfig.globalConfig.WS_VOICE_MAP_SEARCH_PREFIX,e.geocodeRequestId=0,e.state={addresseeText:e.pointAddressee?e.pointAddressee:"",mapId:"map-component".concat((new Date).getTime()),showLabel:!1,addresseeTextCoordinates:e.pointCoords,showMap:!1,municipality:e.props.municipality?e.props.municipality:null,selectedMunicipalityIsDefault:!1,defaultExecutor:null,oktmo:e.props.oktmo?e.props.oktmo:null,notFindMunicipality:!1,addressAfterUserInput:null,errorText:null},e.updateAddressee=function(){var t=e.geocodeRequestId,o=e.state.addresseeText.trim();o&&(e.initGeocoder(),e.geocoder.geocode(e.getAddressCoords(),function(n){if(t===e.geocodeRequestId&&o===e.state.addresseeText.trim()){if(!n.length)return void e.setState({notFindMunicipality:!0,errorText:"Адрес не найден. Укажите точку проблемы на карте"});e.pointCoords=[n[0].center.lat,n[0].center.lng],e.addressCheck(n[0].properties.address);try{e.point.setLatLng(n[0].center).addTo(e.markerLayer)}catch(r){e.createMarker(n[0].center)}e.map.setView(n[0].center),e.findMunicipality(),e.setState({addresseeTextCoordinates:e.pointCoords,errorText:null},function(){return e.runCallbackIfExist()})}}))},e.updateAddresseeText=function(t){e.geocodeRequestId+=1,e.runCallbackIfExist([],t),e.props.updateMunicipality&&e.props.updateMunicipality(null,[]),e.props.updateOktmo&&e.props.updateOktmo(null),e.setState({municipality:null,oktmo:null,notFindMunicipality:!1,selectedMunicipalityIsDefault:!1,defaultExecutor:null,errorText:null,addressAfterUserInput:null}),e.updateState(t,"addresseeText",e.updateAddressee)},e.toggleMap=function(){e.map||e.initMap(),e.setState(function(e){var t=e.showMap;return{showMap:!t}})},e.findMyLocation=function(){var t=++e.geocodeRequestId;navigator.geolocation.getCurrentPosition(function(o){t===e.geocodeRequestId&&(e.pointCoords=[o.coords.latitude,o.coords.longitude],e.initGeocoder(),e.geocoder.reverse({lat:e.pointCoords[0],lng:e.pointCoords[1]},e.scale,function(o){t===e.geocodeRequestId&&o.length&&e.applyGeocodeResult(o[0])}))},function(){if(t===e.geocodeRequestId){var o=_authServices.AuthService.getUserInfo();o&&o.localityId&&e.props.oktmoStore&&e.props.oktmoStore.addOktmo([o.localityId]).then(function(){if(t===e.geocodeRequestId&&e.props.oktmoStore){var n=e.props.oktmoStore.getEntityById(o.localityId);n&&(e.initGeocoder(),e.geocoder.geocode(n.fullName,function(o){t===e.geocodeRequestId&&o.length&&e.applyGeocodeResult(o[0])}))}})}})},e.applyGeocodeResult=function(t){e.pointCoords=[t.center.lat,t.center.lng];var o=t.properties.address;e.pointAddressee=e.getUnderstandAddressString(o);try{e.point.setLatLng(t.center).addTo(e.markerLayer)}catch(n){e.createMarker(t.center)}e.map.setView(t.center),e.findMunicipality(),e.applyPointAddressee()},e.selectMunicipalityFromExecutorProjection=function(t,o){e.setState({oktmo:t.locality,municipality:t.municipality?new _municipality.Municipality({id:t.municipality.id,name:t.municipality.name,status:_baseStatus.BaseStatusEnum.ACTIVE}):null,notFindMunicipality:!t.municipality,selectedMunicipalityIsDefault:t.defaultMunicipality,defaultExecutor:t.defaultMunicipality&&t.messageStations[0]?t.messageStations[0]:null},function(){e.props.updateMunicipality&&!o&&(e.props.updateMunicipality&&e.props.updateMunicipality(e.state.municipality,t.messageStations),e.props.updateOktmo&&e.props.updateOktmo(e.state.oktmo))})},e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){this.props.disabled||this.initMap(!0)}},{key:"componentWillReceiveProps",value:function(e){(e.oktmo&&!this.props.oktmo||e.oktmo&&this.props.oktmo&&e.oktmo.id!==this.props.oktmo.id)&&this.setState({oktmo:e.oktmo?e.oktmo:null}),(e.municipality&&!this.props.municipality||e.municipality&&this.props.municipality&&e.municipality.id!==this.props.municipality.id)&&this.setState({municipality:e.municipality?e.municipality:null})}},{key:"initMap",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{this.createMap(),!this.props.disabled&&this.props.pointAddressee&&this.findMunicipality(!this.props.alwaysCallCallback||!t),this.props.pointAddressee||this.props.disabled||this.props.pointCoords&&this.props.pointCoords.length&&t||this.findMyLocation()}catch(o){var n=100;window.setTimeout(function(){return e.initMap()},n)}}},{key:"initGeocoder",value:function(){var e=this;try{this.geocoderControl||(this.geocoderControl=L.Control.geocoder().addTo(this.map)),this.geocoder||(this.geocoder=new L.Control.Geocoder.Nominatim)}catch(t){var o=100;window.setTimeout(function(){return e.initMap()},o)}}},{key:"createMap",value:function(){var e=this;this.map=L.map("map-container",{center:this.pointCoords,zoom:this.zoom});var t=new L.tileLayer(_globalConfig.globalConfig.mapTileLayerUrl);this.map.addLayer(t),this.initGeocoder(),this.createMarker(),this.props.disabled||this.findMunicipality(),this.props.disabled||this.map.on({click:function(t){var o=++e.geocodeRequestId;e.pointCoords=[t.latlng.lat,t.latlng.lng],e.map.setView(t.latlng),e.findMunicipality(),e.updateState(null,"addressAfterUserInput");try{e.point.setLatLng(t.latlng).addTo(e.markerLayer)}catch(t){e.createMarker(t.latlng)}e.initGeocoder(),e.geocoder.reverse(t.latlng,e.scale,function(t){if(o===e.geocodeRequestId&&t.length){var n=t[0].properties.address;e.pointAddressee=e.getUnderstandAddressString(n),e.applyPointAddressee()}})}})}},{key:"getUnderstandAddressString",value:function(e){var t=e.village,o=e.city,n=e.town,r=e.county,i=e.country,a=e.road,s=e.house_number,u=t||o||n||r||i;return[u,a,s].filter(function(e){return!!e}).join(", ")}},{key:"createMarker",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.props.pointCoords&&(this.pointCoords=this.props.pointCoords),this.markerLayer=L.layerGroup().addTo(this.map),this.point=L.marker(t?[t.lat,t.lng]:this.pointCoords,{draggable:!this.props.disabled}).addTo(this.markerLayer),this.point.on({dragend:function(){var t=++e.geocodeRequestId;e.pointCoords=[e.point.getLatLng().lat,e.point.getLatLng().lng],e.findMunicipality(),e.map.setView(e.point.getLatLng()),e.initGeocoder(),e.geocoder.reverse(e.point.getLatLng(),e.scale,function(o){if(t===e.geocodeRequestId&&o.length){var n=o[0].properties.address;e.pointAddressee=e.getUnderstandAddressString(n),e.applyPointAddressee()}})}})}},{key:"applyPointAddressee",value:function(){var e=this;this.updateValidationAddress=!0,this.setState({addresseeText:this.pointAddressee,addresseeTextCoordinates:this.pointCoords,showLabel:!1},function(){return e.runCallbackIfExist()})}},{key:"getAddressCoords",value:function(){var e=this.municipality?"".concat(this.parentLocation).concat(this.municipality.name,", "):this.parentLocation;return"".concat(e).concat(this.state.addresseeText)}},{key:"addressCheck",value:function(e){this.setState({addressAfterUserInput:this.getUnderstandAddressString(e)})}},{key:"runCallbackIfExist",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.pointCoords,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state.addresseeText;this.props.updateCallback&&this.props.updateCallback(t,e)}},{key:"findMunicipality",value:function(e){var t=this,o=this.geocodeRequestId;return this.setState({notFindMunicipality:!1}),this.props.subjectId?void this.promiseWithLoading(routingActions.executorsByCoords(this.pointCoords[0],this.pointCoords[1],this.props.subjectId?this.props.subjectId:"")).then(function(n){if(o===t.geocodeRequestId)return n?void t.selectMunicipalityFromExecutorProjection(n,e):t.setState({notFindMunicipality:!0})})["catch"](function(e){if(o===t.geocodeRequestId){var n=2001;t.setState({notFindMunicipality:!0,errorText:e.response.data.code===n?e.response.data.message:null})}}):(this.promiseWithLoading(this.findMunicipalityByCoords(this.pointCoords[0],this.pointCoords[1])).then(function(n){if(o===t.geocodeRequestId)return n?void t.selectMunicipality(n,e):void t.setState({notFindMunicipality:!0,errorText:"Выбранный адрес не относится к валидной области. Измените адрес"})}),void this.promiseWithLoading(this.findOktmoByCoords(this.pointCoords[0],this.pointCoords[1])).then(function(n){o===t.geocodeRequestId&&t.selectOktmo(n,e)}))}},{key:"findMunicipalityByCoords",value:function(e,t){return __awaiter(this,void 0,void 0,_regenerator().m(function o(){var n,r,i,a,s,u,c;return _regenerator().w(function(o){for(;;)switch(o.p=o.n){case 0:return n=6,o.p=1,o.n=2,geoDataActions.byCoordinates(e,t);case 2:if(r=o.v,i=r.find(function(e){return e.adminLevel===n})){o.n=3;break}return o.a(2,null);case 3:return a={code:i.oktmo,pageNo:0,pageSize:1,types:[_oktmoType["default"].MUNICIPALITY.value]},o.n=4,_actions.oktmoActions.listPage(a);case 4:return s=o.v,u=s.items[0],o.a(2,u?u:null);case 5:return o.p=5,c=o.v,o.a(2,null)}},o,null,[[1,5]])}))}},{key:"findOktmoByCoords",value:function(e,t){return __awaiter(this,void 0,void 0,_regenerator().m(function o(){var n,r,i,a,s,u,c;return _regenerator().w(function(o){for(;;)switch(o.p=o.n){case 0:return n=8,o.p=1,o.n=2,geoDataActions.byCoordinates(e,t);case 2:if(r=o.v,i=r.find(function(e){return e.adminLevel===n})){o.n=3;break}return o.a(2,null);case 3:return a={code:i.oktmo,pageNo:0,pageSize:1,types:[_oktmoType["default"].LOCALITY.value]},o.n=4,_actions.oktmoActions.listPage(a);case 4:return s=o.v,u=s.items[0],o.a(2,u?u:null);case 5:return o.p=5,c=o.v,o.a(2,null)}},o,null,[[1,5]])}))}},{key:"selectMunicipality",value:function(e,t){var o=this;this.setState({municipality:new _municipality.Municipality({id:e.id,name:e.name,status:_baseStatus.BaseStatusEnum.ACTIVE})},function(){o.props.updateMunicipality&&!t&&o.props.updateMunicipality(o.state.municipality,[])})}},{key:"selectOktmo",value:function(e,t){var o=this;this.setState({oktmo:e},function(){o.props.updateOktmo&&!t&&o.props.updateOktmo(o.state.oktmo)})}},{key:"render",value:function(){return(0,_mapComponentTemplate["default"])(this)}}])}(_wsReactBaseComponents.WsReactBaseComponent);Map=__decorate([_mobxReact.observer],Map);var _default=exports["default"]=Map;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ws-voice-infinity-global-module",
3
- "version": "1.12.0",
3
+ "version": "1.12.2",
4
4
  "description": "ws-voice-infinity-global-module",
5
5
  "repository": {
6
6
  "type": "git",