changes
This commit is contained in:
@@ -164,8 +164,13 @@ function classifyDate(dateStr) {
|
||||
return GROUP_LATER;
|
||||
}
|
||||
|
||||
const SOURCE_COLORS = {
|
||||
westin: "#0d6efd",
|
||||
mobility: "#198754",
|
||||
};
|
||||
|
||||
/** Group + sort tasks, returning { groupKey: { label, tasks[], count } } */
|
||||
function groupTasks(tasksData) {
|
||||
function groupTasks(tasksData, localInstanceId) {
|
||||
// Sort by date ASC, time ASC
|
||||
const sorted = [...tasksData].sort((a, b) => {
|
||||
const da = a.scheduled_date || "";
|
||||
@@ -197,12 +202,16 @@ function groupTasks(tasksData) {
|
||||
task._statusColor = STATUS_COLORS[task.status] || "#6b7280";
|
||||
task._statusLabel = STATUS_LABELS[task.status] || task.status || "";
|
||||
task._statusIcon = STATUS_ICONS[task.status] || "fa-circle";
|
||||
task._clientName = task.partner_id ? task.partner_id[1] : "N/A";
|
||||
task._clientName = task.x_fc_sync_client_name || (task.partner_id ? task.partner_id[1] : "N/A");
|
||||
task._techName = task.technician_id ? task.technician_id[1] : "Unassigned";
|
||||
task._typeLbl = task.task_type
|
||||
? task.task_type.charAt(0).toUpperCase() + task.task_type.slice(1).replace("_", " ")
|
||||
: "Task";
|
||||
task._timeRange = `${task.time_start_display || floatToTime12(task.time_start)} - ${task.time_end_display || ""}`;
|
||||
const src = task.x_fc_sync_source || localInstanceId || "";
|
||||
task._sourceLabel = src ? src.charAt(0).toUpperCase() + src.slice(1) : "";
|
||||
task._sourceColor = SOURCE_COLORS[src] || "#6c757d";
|
||||
task._hasCoords = task.address_lat && task.address_lng && task.address_lat !== 0 && task.address_lng !== 0;
|
||||
groups[g].tasks.push(task);
|
||||
groups[g].count++;
|
||||
}
|
||||
@@ -312,11 +321,12 @@ export class FusionTaskMapController extends Component {
|
||||
const domain = this._getDomain();
|
||||
const result = await this.orm.call("fusion.technician.task", "get_map_data", [domain]);
|
||||
this.apiKey = result.api_key;
|
||||
this.localInstanceId = result.local_instance_id || "";
|
||||
this.tasksData = result.tasks || [];
|
||||
this.locationsData = result.locations || [];
|
||||
this.state.taskCount = this.tasksData.length;
|
||||
this.state.techCount = this.locationsData.length;
|
||||
this.state.groups = groupTasks(this.tasksData);
|
||||
this.state.groups = groupTasks(this.tasksData, this.localInstanceId);
|
||||
|
||||
if (!this.apiKey) {
|
||||
this.state.error = _t("Google Maps API key not configured. Go to Settings > Fusion Claims.");
|
||||
@@ -338,11 +348,12 @@ export class FusionTaskMapController extends Component {
|
||||
try {
|
||||
const domain = this._getDomain();
|
||||
const result = await this.orm.call("fusion.technician.task", "get_map_data", [domain]);
|
||||
this.localInstanceId = result.local_instance_id || this.localInstanceId || "";
|
||||
this.tasksData = result.tasks || [];
|
||||
this.locationsData = result.locations || [];
|
||||
this.state.taskCount = this.tasksData.length;
|
||||
this.state.techCount = this.locationsData.length;
|
||||
this.state.groups = groupTasks(this.tasksData);
|
||||
this.state.groups = groupTasks(this.tasksData, this.localInstanceId);
|
||||
this._renderMarkers();
|
||||
} catch (e) {
|
||||
console.error("FusionTaskMap update error:", e);
|
||||
|
||||
Reference in New Issue
Block a user