Iniit
This commit is contained in:
@@ -0,0 +1,350 @@
|
||||
var Bizgaze;
|
||||
(function (Bizgaze) {
|
||||
let Apps;
|
||||
(function (Apps) {
|
||||
let Crm;
|
||||
(function (Crm) {
|
||||
let Components;
|
||||
(function (Components) {
|
||||
class Address extends Unibase.Platform.Core.BaseComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.oldcontactaddressid = 0;
|
||||
this.contactaddressid = 0;
|
||||
this.latd = 0;
|
||||
this.lngd = 0;
|
||||
this.isEmployeeDashboardRoute = false;
|
||||
}
|
||||
cssFiles() {
|
||||
return [];
|
||||
}
|
||||
jsFiles() {
|
||||
return ['apps/crm/contacts/managers/contactmanager.js', 'tenants/themes/compact/components/details/details.js'];
|
||||
}
|
||||
html(id, containerid) {
|
||||
return "";
|
||||
}
|
||||
init(containerid) {
|
||||
var instance = this;
|
||||
}
|
||||
load(id, containerid, callback) {
|
||||
var instance = this;
|
||||
}
|
||||
changeDefaultAddress(addressid) {
|
||||
var instance = this;
|
||||
var _recordId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_recordid").Value);
|
||||
var postdata = {
|
||||
ContactAddressId: addressid,
|
||||
ContactId: _recordId
|
||||
};
|
||||
instance.fileCacheHelper.loadJsFile('apps/crm/contacts/managers/contactmanager.js', function () {
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().ChangeDefaultAddress(postdata).then(function (response) {
|
||||
var detail_instance = Unibase.Themes.Compact.Components.Details.Instance();
|
||||
var containerid = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
|
||||
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
|
||||
var portletid = detail_instance.unibase_core_activeportletid;
|
||||
detail_instance.loadWidgets(_installedAppId, portletid, "#" + containerid + "");
|
||||
MessageHelper.Instance().showSuccess(response.message, '');
|
||||
});
|
||||
});
|
||||
}
|
||||
changeDefaultAddress_phonebook(addressid) {
|
||||
var instance = this;
|
||||
var _recordId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_organizationid").Value);
|
||||
var postdata = {
|
||||
ContactAddressId: addressid,
|
||||
ContactId: _recordId
|
||||
};
|
||||
instance.fileCacheHelper.loadJsFile('apps/crm/contacts/managers/contactmanager.js', function () {
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().ChangeDefaultAddress(postdata).then(function (response) {
|
||||
var detail_instance = Unibase.Themes.Compact.Components.Details.Instance();
|
||||
var containerid = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
|
||||
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
|
||||
var portletid = detail_instance.unibase_core_activeportletid;
|
||||
detail_instance.loadWidgets(_installedAppId, portletid, "#" + containerid + "");
|
||||
MessageHelper.Instance().showSuccess(response.message, '');
|
||||
});
|
||||
});
|
||||
}
|
||||
changeAddressStatus(addressid, status) {
|
||||
var instance = this;
|
||||
if (status == 2)
|
||||
var msg = "Are you sure you want to De-Activate ?";
|
||||
else
|
||||
var msg = "Are you sure you want to Activate ?";
|
||||
bootbox.confirm({
|
||||
message: msg,
|
||||
closeButton: false,
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
className: 'btn-success'
|
||||
},
|
||||
cancel: {
|
||||
label: 'No',
|
||||
className: 'btn-danger'
|
||||
}
|
||||
},
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
var Status = "";
|
||||
var Statusid;
|
||||
if (status == 2) {
|
||||
Status = "Activate";
|
||||
Statusid = 2;
|
||||
$("#Id_" + addressid + "").removeClass('text-danger');
|
||||
$("#Id_" + addressid + "").addClass('text-success');
|
||||
}
|
||||
else {
|
||||
Status = "activate";
|
||||
Statusid = 1;
|
||||
$("#Id_" + addressid + "").removeClass('text-success');
|
||||
$("#Id_" + addressid + "").addClass('text-danger');
|
||||
}
|
||||
var _recordId = Number(Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_recordid").Value);
|
||||
var postdata = {
|
||||
ContactAddressId: addressid,
|
||||
Status: Statusid,
|
||||
ContactId: _recordId
|
||||
};
|
||||
instance.fileCacheHelper.loadJsFile('apps/crm/contacts/managers/contactmanager.js', function () {
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().ChangeAddressStatus(postdata).then(function (response) {
|
||||
if (response.errors == null) {
|
||||
var detail_instance = Unibase.Themes.Compact.Components.Details.Instance();
|
||||
var containerid = Unibase.Platform.Helpers.NavigationHelper.Instance().getLastContainerId();
|
||||
var _installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
|
||||
var portletid = detail_instance.unibase_core_activeportletid;
|
||||
detail_instance.loadWidgets(_installedAppId, portletid, "#" + containerid + "");
|
||||
MessageHelper.Instance().showSuccess(response.message, '');
|
||||
}
|
||||
else {
|
||||
alert("You Can't De-Active Default Address");
|
||||
}
|
||||
});
|
||||
});
|
||||
if (status == "De-activate") { }
|
||||
}
|
||||
else { }
|
||||
}
|
||||
});
|
||||
}
|
||||
editmap_1(contactAddressId) {
|
||||
let instance = this;
|
||||
Bizgaze.Apps.Crm.Components.Address.Instance().contactaddressid = contactAddressId;
|
||||
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/crm/address/components/w_address.js", function () {
|
||||
Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("platform/core/helpers/mobile/interfaces/imobilehelper.js", function () {
|
||||
if (isMobileApp()) {
|
||||
Unibase.Platform.Helpers.MobileHelper.Instance().grantPermission(Unibase.Platform.Helpers.Enums.MobilePermissionType.Location, Bizgaze.Apps.Crm.Components.Address.Instance().edidmap_mobile);
|
||||
}
|
||||
else {
|
||||
Bizgaze.Apps.Crm.Components.Address.Instance().navigationHelper.popup(0, "", Bizgaze.Apps.Crm.Components.Address.Instance(), function () {
|
||||
Bizgaze.Apps.Crm.Components.Address.Instance().editmap(contactAddressId);
|
||||
}, Unibase.Platform.Helpers.Size.Auto);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
edidmap_mobile() {
|
||||
Bizgaze.Apps.Crm.Components.Address.Instance().navigationHelper.popup(0, "", Bizgaze.Apps.Crm.Components.Address.Instance(), function () {
|
||||
Bizgaze.Apps.Crm.Components.Address.Instance().editmap(Bizgaze.Apps.Crm.Components.Address.Instance().contactaddressid);
|
||||
}, Unibase.Platform.Helpers.Size.Auto);
|
||||
}
|
||||
editmap(contactAddressId) {
|
||||
var instance = this;
|
||||
instance.fileCacheHelper.loadJsFile('apps/crm/contacts/managers/contactmanager.js', function () {
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getAddressById(contactAddressId).then(function (response) {
|
||||
let now = new Date();
|
||||
if ((response.result.AddrLatd != null) && (response.result.AddrLgtd != null) && (response.result.AddrLatd != "0") && (response.result.AddrLgtd != "0")) {
|
||||
instance.latd = response.result.AddrLatd;
|
||||
instance.lngd = response.result.AddrLgtd;
|
||||
instance.geotaggeddate = response.result.GeoTaggeddate;
|
||||
instance.editmap1(contactAddressId);
|
||||
}
|
||||
else {
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
instance.latd = position.coords.latitude;
|
||||
instance.lngd = position.coords.longitude;
|
||||
instance.editmap1(contactAddressId);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
currentCoordinates() {
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
$(".txt_addrlatd").val(position.coords.latitude);
|
||||
$(".txt_addrlgtd").val(position.coords.longitude);
|
||||
});
|
||||
}
|
||||
editmap1(contactAddressId) {
|
||||
var instance = this;
|
||||
const containerId = this.navigationHelper.getLastContainerId();
|
||||
if ($('#meetingAddressMap-' + contactAddressId).length > 0) {
|
||||
if ($('#meetingAddressMap-' + contactAddressId).is(':hidden') != true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
;
|
||||
$(`#${containerId}`).append("<form id='FormIds'><style type='text/css'>.pac-container{z-index:9999 !important;}</style><div id='mapaddress" + contactAddressId + "' class='floating-label-form-group pl-0 bg-white d-flex align-items-center justify-content-between ' style='border-top:1px solid #ccc;border-right: 1px solid #ccc;'><div class='input-group'><input type='hidden' data-geo='lat1 value='' id='latitude' name='latitude'><input type='hidden' data-geo='lng' value='' id='longitude' name='setting_longitude'><input type='text' id='mapaddress-" + contactAddressId + "' class='form-control value-control floating-label-control px-2' data-isdefault='true' data-placeholder='Select Address' data-label='Address'><input type='hidden' id='myfieldname' value=" + contactAddressId + " /></div><div class=''><button class='btn btn-outline-primary btn-xs d-sm-none capture-btn'><span class='fa-solid fa-location-dot'></span><span>Current Location</span></button></div></div><div id='meetingAddressMap-" + contactAddressId + "' class='text-center modal-body pa-0' style='height:100%;'></div></div></form>");
|
||||
$(`#${containerId}`).find('#FormIds').after(`<div class="bg-white modal-footer find-match-footer pa-10"><a class="btn btn-light btn-sm btn-center mr-auto" href="javascript:;" id="btnClose">Close</a><a href="javascript:;" id='btn_map' class='btn btn-primary btn-sm' onclick='Bizgaze.Apps.Crm.Components.Address.Instance().getMobileLocation(${contactAddressId})'>Save</a></div>`);
|
||||
$(`#${containerId}`).find(".capture-btn").click(function () {
|
||||
instance.navigationHelper.showLoading();
|
||||
if (isMobileApp()) {
|
||||
Unibase.Platform.Helpers.MobileHelper.Instance().getCurrentLocation(contactAddressId, 2);
|
||||
}
|
||||
else {
|
||||
navigator.geolocation.getCurrentPosition(function (position) {
|
||||
instance.latd = position.coords.latitude;
|
||||
instance.lngd = position.coords.longitude;
|
||||
instance.getselectedcity(contactAddressId);
|
||||
});
|
||||
}
|
||||
});
|
||||
$(`#${containerId}`).find("#btnClose").click(function () {
|
||||
instance.navigationHelper.closePopUp();
|
||||
});
|
||||
var id = $(`#${containerId}`).find("#mapaddress-" + contactAddressId);
|
||||
id.geocomplete({ details: "form#FormIds" }).bind("geocode:result", function (event, result) {
|
||||
$(`#${containerId}`).find($("#latitude").val(result.geometry.location.lat()));
|
||||
$(`#${containerId}`).find($("#longitude").val(result.geometry.location.lng()));
|
||||
instance.latd = result.geometry.location.lat();
|
||||
instance.lngd = result.geometry.location.lng();
|
||||
instance.getselectedcity(contactAddressId);
|
||||
});
|
||||
if (contactAddressId != instance.oldcontactaddressid) {
|
||||
$(`#${containerId}`).find("#meetingAddressMap-" + instance.oldcontactaddressid).addClass('hidden');
|
||||
$(`#${containerId}`).find("#mapaddress" + instance.oldcontactaddressid).addClass('hidden');
|
||||
$(`#${containerId}`).find("#mapaddress-" + instance.oldcontactaddressid).addClass('hidden');
|
||||
}
|
||||
$(`#${containerId}`).find("#meetingAddressMap-" + contactAddressId).html('');
|
||||
$(`#${containerId}`).find("#mapaddress-" + contactAddressId).html('');
|
||||
instance.getselectedcity(contactAddressId);
|
||||
instance.oldcontactaddressid = contactAddressId;
|
||||
let deductHeight = 0;
|
||||
deductHeight += $(`#${containerId}`).find(`#mapaddress${contactAddressId}`).outerHeight(true);
|
||||
deductHeight += $(`#${containerId}`).find('.find-match-footer').outerHeight(true);
|
||||
$(`#${containerId}`).find('#meetingAddressMap-' + contactAddressId).css("height", `${$(window).innerHeight() - deductHeight}px`).attr('data-deductheight', deductHeight);
|
||||
}
|
||||
getselectedcity(contactAddressId) {
|
||||
let instance = this;
|
||||
const containerId = this.navigationHelper.getLastContainerId();
|
||||
$(`#${containerId}`).find($("#meetingAddressMap").html(''));
|
||||
$(`#${containerId}`).find($("#mapaddress-").html(''));
|
||||
var myLatlng = new google.maps.LatLng(instance.latd, instance.lngd);
|
||||
var mapOptions = {
|
||||
zoom: 8,
|
||||
center: myLatlng,
|
||||
};
|
||||
var map = new google.maps.Map($(`#${containerId}`).find("#meetingAddressMap-" + contactAddressId)[0], mapOptions);
|
||||
var marker = new google.maps.Marker({
|
||||
position: myLatlng,
|
||||
title: "Hello World!",
|
||||
draggable: true
|
||||
});
|
||||
google.maps.event.addListener(marker, 'dragend', function () {
|
||||
instance.latd = marker.getPosition().lat();
|
||||
instance.lngd = marker.getPosition().lng();
|
||||
instance.getselectedcity(contactAddressId);
|
||||
});
|
||||
marker.setMap(map);
|
||||
var url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + instance.latd + "," + instance.lngd + "&key=" + _mapsettings.key() + "&sensor=false";
|
||||
var xhr = instance.createCORSRequest1('Get', url);
|
||||
if (!xhr) {
|
||||
bootbox.alert('CORS not supported');
|
||||
return;
|
||||
}
|
||||
xhr.onload = function () {
|
||||
var text = xhr.responseText;
|
||||
var json = JSON.parse(text);
|
||||
$(`#${containerId}`).find("#mapaddress-" + contactAddressId).val(json.results[0].formatted_address);
|
||||
instance.navigationHelper.hideLoading();
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
bootbox.alert('Woops, there was an error making the request.');
|
||||
instance.navigationHelper.hideLoading();
|
||||
};
|
||||
xhr.send();
|
||||
}
|
||||
createCORSRequest1(method, url) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
if ("withCredentials" in xhr) {
|
||||
xhr.open(method, url, true);
|
||||
}
|
||||
else {
|
||||
xhr = null;
|
||||
}
|
||||
return xhr;
|
||||
}
|
||||
getMobileLocation(contactAddressId) {
|
||||
var instance = this;
|
||||
const containerId = this.navigationHelper.getLastContainerId();
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
setTimeout(function () {
|
||||
var address = $(`#${containerId}`).find('#mapaddress-' + contactAddressId);
|
||||
geocoder.geocode({ 'address': address.val() }, function (results, status) {
|
||||
if (status == google.maps.GeocoderStatus.OK) {
|
||||
var latitude = results[0].geometry.location.lat();
|
||||
var longitude = results[0].geometry.location.lng();
|
||||
var postdata = {
|
||||
ContactAddressId: contactAddressId,
|
||||
Latd: parseFloat(instance.latd),
|
||||
Lgtd: parseFloat(instance.lngd),
|
||||
GeoTaggedDate: instance.geotaggeddate
|
||||
};
|
||||
instance.fileCacheHelper.loadJsFile('apps/crm/contacts/managers/contactmanager.js', function () {
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().saveAddressCoordinates(postdata).then(function (response) {
|
||||
instance.navigationHelper.closePopUp();
|
||||
MessageHelper.Instance().showSuccess(response.message, 'div_ValidationSummary');
|
||||
var detailobj = Unibase.Themes.Compact.Components.Details.Instance();
|
||||
if (instance.isEmployeeDashboardRoute) {
|
||||
const portletid = +$("#hf_DashboardPortletId").val();
|
||||
Unibase.Themes.Compact.Components.Nav.Instance().loadDashboard(portletid, '');
|
||||
instance.isEmployeeDashboardRoute = false;
|
||||
}
|
||||
else {
|
||||
detailobj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
|
||||
detailobj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
|
||||
detailobj._containerId = instance.navigationHelper.getLastContainerId();
|
||||
var idetailObj = detailobj;
|
||||
detailobj.loadPortlets(idetailObj);
|
||||
if ($('#hf_tripgroupid').length) {
|
||||
Unibase.Platform.Helpers.NavigationHelper.IsListRefresh = true;
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
});
|
||||
}
|
||||
else {
|
||||
instance.fileCacheHelper.loadJsFile('apps/crm/contacts/managers/contactmanager.js', function () {
|
||||
Bizgaze.Apps.Crm.Contacts.Managers.ContactManager.Instance().getLatLongByAddress(address).then(function (response) {
|
||||
if (response.result != "") {
|
||||
var lat = JSON.parse(response.result).results[0].geometry.location.lat;
|
||||
$('#hfLattitude').val(lat);
|
||||
alert(lat);
|
||||
var lng = JSON.parse(response.result).results[0].geometry.location.lng;
|
||||
$('#hfLongitude').val(lng);
|
||||
}
|
||||
});
|
||||
});
|
||||
alert('Please Select Address');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
LoadMapInMobile(contactAddressId, latid, lngid) {
|
||||
var instance = this;
|
||||
instance.latd = latid;
|
||||
instance.lngd = lngid;
|
||||
instance.getselectedcity(contactAddressId);
|
||||
}
|
||||
static Instance() {
|
||||
if (this._instance === undefined)
|
||||
this._instance = new Address();
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
Components.Address = Address;
|
||||
})(Components = Crm.Components || (Crm.Components = {}));
|
||||
})(Crm = Apps.Crm || (Apps.Crm = {}));
|
||||
})(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
|
||||
})(Bizgaze || (Bizgaze = {}));
|
||||
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user