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:
Aissa
2026-07-19 18:47:12 +00:00
parent 6856d09cd1
commit 8d2766efb6
6 changed files with 263 additions and 14 deletions
+70 -2
View File
@@ -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) {