Spaces:
Runtime error
Runtime error
fix(edit): stop showing 'Edit cancelled' after successful update; show ft units on map popup
Browse files- static/js/tree-track-app.js +8 -4
- static/map.js +2 -2
static/js/tree-track-app.js
CHANGED
|
@@ -105,7 +105,8 @@ export class TreeTrackApp {
|
|
| 105 |
}
|
| 106 |
|
| 107 |
if (e.target.matches('#cancelEdit')) {
|
| 108 |
-
|
|
|
|
| 109 |
}
|
| 110 |
});
|
| 111 |
}
|
|
@@ -156,7 +157,8 @@ export class TreeTrackApp {
|
|
| 156 |
if (this.formManager.isInEditMode()) {
|
| 157 |
result = await this.apiClient.updateTree(this.formManager.getCurrentEditId(), treeData);
|
| 158 |
this.uiManager.showMessage(`Tree #${result.id} updated successfully!`, 'success');
|
| 159 |
-
|
|
|
|
| 160 |
} else {
|
| 161 |
result = await this.apiClient.saveTree(treeData);
|
| 162 |
this.uiManager.showMessage(
|
|
@@ -216,11 +218,13 @@ export class TreeTrackApp {
|
|
| 216 |
}
|
| 217 |
}
|
| 218 |
|
| 219 |
-
handleCancelEdit() {
|
| 220 |
this.formManager.resetForm(true);
|
| 221 |
this.formManager.exitEditMode();
|
| 222 |
this.uiManager.clearFieldErrors();
|
| 223 |
-
|
|
|
|
|
|
|
| 224 |
}
|
| 225 |
|
| 226 |
async loadTrees() {
|
|
|
|
| 105 |
}
|
| 106 |
|
| 107 |
if (e.target.matches('#cancelEdit')) {
|
| 108 |
+
// User explicitly cancelled edit
|
| 109 |
+
this.handleCancelEdit(true);
|
| 110 |
}
|
| 111 |
});
|
| 112 |
}
|
|
|
|
| 157 |
if (this.formManager.isInEditMode()) {
|
| 158 |
result = await this.apiClient.updateTree(this.formManager.getCurrentEditId(), treeData);
|
| 159 |
this.uiManager.showMessage(`Tree #${result.id} updated successfully!`, 'success');
|
| 160 |
+
// Exit edit mode silently after successful update
|
| 161 |
+
this.handleCancelEdit(false);
|
| 162 |
} else {
|
| 163 |
result = await this.apiClient.saveTree(treeData);
|
| 164 |
this.uiManager.showMessage(
|
|
|
|
| 218 |
}
|
| 219 |
}
|
| 220 |
|
| 221 |
+
handleCancelEdit(showMessage = false) {
|
| 222 |
this.formManager.resetForm(true);
|
| 223 |
this.formManager.exitEditMode();
|
| 224 |
this.uiManager.clearFieldErrors();
|
| 225 |
+
if (showMessage) {
|
| 226 |
+
this.uiManager.showMessage('Edit cancelled. Form cleared.', 'success');
|
| 227 |
+
}
|
| 228 |
}
|
| 229 |
|
| 230 |
async loadTrees() {
|
static/map.js
CHANGED
|
@@ -626,8 +626,8 @@ class TreeTrackMap {
|
|
| 626 |
${tree.scientific_name ? `<strong style="color: #374151;">Scientific:</strong><span style="word-wrap: break-word;"><em>${tree.scientific_name}</em></span>` : ''}
|
| 627 |
${tree.common_name ? `<strong style="color: #374151;">Common:</strong><span style="word-wrap: break-word;">${tree.common_name}</span>` : ''}
|
| 628 |
<strong style="color: #374151;">Location:</strong><span style="font-family: monospace; font-size: 12px;">${tree.latitude.toFixed(4)}, ${tree.longitude.toFixed(4)}</span>
|
| 629 |
-
|
| 630 |
-
${tree.width ? `<strong style="color: #374151;">Girth:</strong><span>${tree.width}
|
| 631 |
<strong style="color: #374151;">Added by:</strong><span>${tree.created_by || 'Unknown'}</span>
|
| 632 |
<strong style="color: #374151;">Date:</strong><span>${new Date(tree.created_at).toLocaleDateString()}</span>
|
| 633 |
</div>
|
|
|
|
| 626 |
${tree.scientific_name ? `<strong style="color: #374151;">Scientific:</strong><span style="word-wrap: break-word;"><em>${tree.scientific_name}</em></span>` : ''}
|
| 627 |
${tree.common_name ? `<strong style="color: #374151;">Common:</strong><span style="word-wrap: break-word;">${tree.common_name}</span>` : ''}
|
| 628 |
<strong style="color: #374151;">Location:</strong><span style="font-family: monospace; font-size: 12px;">${tree.latitude.toFixed(4)}, ${tree.longitude.toFixed(4)}</span>
|
| 629 |
+
${tree.height ? `<strong style="color: #374151;">Height:</strong><span>${tree.height} ft</span>` : ''}
|
| 630 |
+
${tree.width ? `<strong style="color: #374151;">Girth:</strong><span>${tree.width} ft</span>` : ''}
|
| 631 |
<strong style="color: #374151;">Added by:</strong><span>${tree.created_by || 'Unknown'}</span>
|
| 632 |
<strong style="color: #374151;">Date:</strong><span>${new Date(tree.created_at).toLocaleDateString()}</span>
|
| 633 |
</div>
|