Fix map layout jump, CRM/edit distributeurs, progress overlay.
Stable map grid, no fitBounds on world view, entity PATCH edit form, CRM buttons on distributors, and loading animation for sync/wait states.
This commit is contained in:
@@ -221,7 +221,8 @@ window.ExportIntelMap = (function () {
|
||||
return map;
|
||||
}
|
||||
|
||||
function setFeatures(geojson) {
|
||||
function setFeatures(geojson, opts) {
|
||||
opts = opts || {};
|
||||
if (!map || !clusterLayer) return;
|
||||
clusterLayer.clearLayers();
|
||||
markersById = {};
|
||||
@@ -247,10 +248,12 @@ window.ExportIntelMap = (function () {
|
||||
|
||||
invalidateMapSize();
|
||||
|
||||
if (features.length === 1) {
|
||||
if (opts.autoFit === false) {
|
||||
map.setView([20, 10], 2);
|
||||
} else if (features.length === 1) {
|
||||
var c = features[0].geometry.coordinates;
|
||||
map.setView([c[1], c[0]], 10);
|
||||
} else if (markers.length > 1 && clusterLayer.getBounds) {
|
||||
} else if (opts.autoFit && markers.length > 1 && clusterLayer.getBounds) {
|
||||
try {
|
||||
map.fitBounds(clusterLayer.getBounds(), { padding: [40, 40], maxZoom: 12 });
|
||||
} catch (e) { /* empty */ }
|
||||
|
||||
@@ -42,6 +42,8 @@ function exportIntelApp() {
|
||||
crmModalOpen: false,
|
||||
crmCreateDeals: true,
|
||||
crmPushBusy: false,
|
||||
editMode: false,
|
||||
editForm: {},
|
||||
resultCount: 0,
|
||||
_searchTimer: null,
|
||||
|
||||
@@ -193,7 +195,19 @@ function exportIntelApp() {
|
||||
},
|
||||
|
||||
showSelectionBar() {
|
||||
return this.tab === 'map' || this.tab === 'contacts';
|
||||
return ['map', 'contacts', 'distributors', 'customers', 'caterers'].indexOf(this.tab) >= 0;
|
||||
},
|
||||
|
||||
isWorking() {
|
||||
return this.busy || this.crmPushBusy || this.mapLoading || this.drawerLoading;
|
||||
},
|
||||
|
||||
progressLabel() {
|
||||
if (this.busy && this.syncMsg) return this.syncMsg;
|
||||
if (this.crmPushBusy) return 'CRM import bezig…';
|
||||
if (this.mapLoading) return 'Kaart laden…';
|
||||
if (this.drawerLoading) return 'Profiel laden…';
|
||||
return 'Bezig…';
|
||||
},
|
||||
|
||||
entityTypeOptions() {
|
||||
@@ -343,7 +357,8 @@ function exportIntelApp() {
|
||||
window.ExportIntelMap.init('ei-map');
|
||||
window.ExportIntelMap.setOnEntityClick(function (id) { self.openEntity(id); });
|
||||
window.ExportIntelMap.setHalalMode(this.mapHalalMode);
|
||||
window.ExportIntelMap.setFeatures(bundle.entities || { features: [] });
|
||||
var autoFit = !!(this.country || this.region);
|
||||
window.ExportIntelMap.setFeatures(bundle.entities || { features: [] }, { autoFit: autoFit });
|
||||
if (this.country) {
|
||||
var t = this.territories.find((x) => x.country_iso2 === this.country);
|
||||
if (t && t.lat && t.lon) window.ExportIntelMap.flyTo(t.lat, t.lon, t.map_zoom || 6);
|
||||
@@ -456,6 +471,59 @@ function exportIntelApp() {
|
||||
this.drawerOpen = false;
|
||||
this.selected = null;
|
||||
this.drawerLoading = false;
|
||||
this.editMode = false;
|
||||
this.editForm = {};
|
||||
},
|
||||
|
||||
startEdit() {
|
||||
if (!this.selected) return;
|
||||
var s = this.selected;
|
||||
this.editForm = {
|
||||
name: s.name || '',
|
||||
entity_type: s.entity_type || '',
|
||||
country_iso2: s.country_iso2 || '',
|
||||
city: s.city || '',
|
||||
address_line: s.address_line || '',
|
||||
postal_code: s.postal_code || '',
|
||||
phone: s.phone || '',
|
||||
email: s.email || '',
|
||||
website: s.website || '',
|
||||
volume_band: s.volume_band || '',
|
||||
pipeline_stage: s.pipeline_stage || 'identified',
|
||||
confidence: s.confidence != null ? s.confidence : 50,
|
||||
halal_cert_notes: s.halal_cert_notes || '',
|
||||
cold_chain: !!s.cold_chain,
|
||||
};
|
||||
this.editMode = true;
|
||||
},
|
||||
|
||||
cancelEdit() {
|
||||
this.editMode = false;
|
||||
this.editForm = {};
|
||||
},
|
||||
|
||||
async saveEdit() {
|
||||
if (!this.selected || !this.selected.id) return;
|
||||
this.busy = true;
|
||||
this.syncMsg = 'Opslaan…';
|
||||
try {
|
||||
var r = await fetch('/api/export-intel/entities/' + this.selected.id, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(this.editForm),
|
||||
});
|
||||
if (!r.ok) {
|
||||
var err = await r.json().catch(function () { return {}; });
|
||||
throw new Error(err.detail || err.error || 'Opslaan mislukt');
|
||||
}
|
||||
this.selected = await r.json();
|
||||
this.editMode = false;
|
||||
this.syncMsg = 'Opgeslagen';
|
||||
await this.refresh();
|
||||
} catch (e) {
|
||||
this.syncMsg = 'Opslaan mislukt: ' + e.message;
|
||||
}
|
||||
this.busy = false;
|
||||
},
|
||||
|
||||
async syncKind(kind) {
|
||||
|
||||
Reference in New Issue
Block a user