fix(interventions): translate modal status and apply assigned color on interventions list and map
This commit is contained in:
parent
37c1016b57
commit
c00212f79e
8 changed files with 76 additions and 11 deletions
|
|
@ -378,7 +378,19 @@ function statusFormatter(value, row) {
|
||||||
const entry = icons[value];
|
const entry = icons[value];
|
||||||
if (!entry) return value;
|
if (!entry) return value;
|
||||||
|
|
||||||
return `<span class="badge text-bg-${entry.color}"><i class="bi ${entry.icon} me-2"></i>${entry.label}</span>`;
|
const isAssignedToBeProcessed = (value === 'to_be_processed') && Boolean(
|
||||||
|
row && (
|
||||||
|
row.is_assigned ||
|
||||||
|
row.assigned_team_id ||
|
||||||
|
row.assigned_member_id ||
|
||||||
|
(row.team && row.team !== '-') ||
|
||||||
|
(row.member && row.member !== '-')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const statusClass = isAssignedToBeProcessed ? 'status-to_be_processed_assigned' : `status-${value}`;
|
||||||
|
const badgeStyle = isAssignedToBeProcessed ? 'style="background-color: #d81b60 !important; color: #ffffff !important;"' : '';
|
||||||
|
|
||||||
|
return `<span class="badge text-bg-${entry.color} ${statusClass}" ${badgeStyle}><i class="bi ${entry.icon} me-2"></i>${entry.label}</span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4805,13 +4805,43 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||||
modalInterventionPriority.className = priorityClasses[priorityCode] || 'badge text-bg-light border text-dark';
|
modalInterventionPriority.className = priorityClasses[priorityCode] || 'badge text-bg-light border text-dark';
|
||||||
}
|
}
|
||||||
|
|
||||||
const status = record.status || record.extendedProps?.status || '';
|
const STATUS_LABELS = {
|
||||||
const statusCode = record.status_code || record.extendedProps?.status_code || '';
|
'in_preparation': gettext('En prépa'),
|
||||||
const isAssigned = Boolean(record.is_assigned || record.extendedProps?.is_assigned || record.member_name || record.extendedProps?.member_name || record.team_name || record.extendedProps?.team_name);
|
'to_be_approved': gettext('À approuver'),
|
||||||
|
'to_be_planned': gettext('À planifier'),
|
||||||
|
'to_be_processed': gettext('À traiter'),
|
||||||
|
'assigned': gettext('Pris en charge'),
|
||||||
|
'in_progress': gettext('Démarré'),
|
||||||
|
'on_pause': gettext('En pause'),
|
||||||
|
'finished': gettext('Terminé'),
|
||||||
|
'processed': gettext('Traité'),
|
||||||
|
'to_be_corrected': gettext('À corriger'),
|
||||||
|
'corrected': gettext('Corrigé'),
|
||||||
|
'validated': gettext('Validé'),
|
||||||
|
'invoiced': gettext('Comptabilisé'),
|
||||||
|
'closed': gettext('Finalisé'),
|
||||||
|
'canceled': gettext('Annulé'),
|
||||||
|
};
|
||||||
|
|
||||||
|
const rawStatus = record.status || record.extendedProps?.status || '';
|
||||||
|
const statusCode = record.status_code || record.extendedProps?.status_code || (STATUS_LABELS[rawStatus] ? rawStatus : '') || rawStatus;
|
||||||
|
const statusDisplay = record.status_display || record.extendedProps?.status_display || STATUS_LABELS[statusCode] || STATUS_LABELS[rawStatus] || rawStatus;
|
||||||
|
const isAssigned = Boolean(
|
||||||
|
record.is_assigned ||
|
||||||
|
record.extendedProps?.is_assigned ||
|
||||||
|
record.assigned_team_id ||
|
||||||
|
record.assigned_member_id ||
|
||||||
|
record.extendedProps?.assigned_team_id ||
|
||||||
|
record.extendedProps?.assigned_member_id ||
|
||||||
|
(record.member_name && record.member_name !== gettext('Non assigné')) ||
|
||||||
|
(record.extendedProps?.member_name && record.extendedProps?.member_name !== gettext('Non assigné')) ||
|
||||||
|
(record.team_name && record.team_name !== gettext('Non assignée')) ||
|
||||||
|
(record.extendedProps?.team_name && record.extendedProps?.team_name !== gettext('Non assignée'))
|
||||||
|
);
|
||||||
const color = getInterventionColor(statusCode, isAssigned);
|
const color = getInterventionColor(statusCode, isAssigned);
|
||||||
const textColor = idealTextColor(color);
|
const textColor = idealTextColor(color);
|
||||||
|
|
||||||
modalInterventionStatus.textContent = status;
|
modalInterventionStatus.textContent = statusDisplay;
|
||||||
modalInterventionStatus.style.backgroundColor = color;
|
modalInterventionStatus.style.backgroundColor = color;
|
||||||
modalInterventionStatus.style.color = textColor;
|
modalInterventionStatus.style.color = textColor;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,6 +400,9 @@ function loadDataIntoInterventionsTable(features) {
|
||||||
contract_provider: feature.properties.contract_provider || '',
|
contract_provider: feature.properties.contract_provider || '',
|
||||||
origin_type: feature.properties.origin_type || '',
|
origin_type: feature.properties.origin_type || '',
|
||||||
source_category: feature.properties.source_category || '',
|
source_category: feature.properties.source_category || '',
|
||||||
|
is_assigned: Boolean(feature.properties.is_assigned),
|
||||||
|
team: feature.properties.team || '',
|
||||||
|
member: feature.properties.member || '',
|
||||||
lon: feature.geometry && feature.geometry.coordinates ? feature.geometry.coordinates[0] : null, // Longitude
|
lon: feature.geometry && feature.geometry.coordinates ? feature.geometry.coordinates[0] : null, // Longitude
|
||||||
lat: feature.geometry && feature.geometry.coordinates ? feature.geometry.coordinates[1] : null // Latitude
|
lat: feature.geometry && feature.geometry.coordinates ? feature.geometry.coordinates[1] : null // Latitude
|
||||||
};
|
};
|
||||||
|
|
@ -488,7 +491,19 @@ function statusFormatter(value, row) {
|
||||||
const entry = icons[value];
|
const entry = icons[value];
|
||||||
if (!entry) return value;
|
if (!entry) return value;
|
||||||
|
|
||||||
let html = `<span class="badge text-bg-${entry.color} status-${value}"><i class="bi ${entry.icon} me-2"></i>${entry.label}</span>`;
|
const isAssignedToBeProcessed = (value === 'to_be_processed') && Boolean(
|
||||||
|
row && (
|
||||||
|
row.is_assigned ||
|
||||||
|
row.assigned_team_id ||
|
||||||
|
row.assigned_member_id ||
|
||||||
|
(row.team && row.team !== '-') ||
|
||||||
|
(row.member && row.member !== '-')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const statusClass = isAssignedToBeProcessed ? 'status-to_be_processed_assigned' : `status-${value}`;
|
||||||
|
const badgeStyle = isAssignedToBeProcessed ? 'style="background-color: #d81b60 !important; color: #ffffff !important;"' : '';
|
||||||
|
|
||||||
|
let html = `<span class="badge text-bg-${entry.color} ${statusClass}" ${badgeStyle}><i class="bi ${entry.icon} me-2"></i>${entry.label}</span>`;
|
||||||
|
|
||||||
// Add preparation state indicator if present
|
// Add preparation state indicator if present
|
||||||
if (row && row.prep_state && row.prep_state !== 'none' && prepStateIcons[row.prep_state]) {
|
if (row && row.prep_state && row.prep_state !== 'none' && prepStateIcons[row.prep_state]) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ const INTERVENTION_STATUS_COLOR_EXPR = (() => {
|
||||||
['==', ['get', 'status'], 'to_be_processed'],
|
['==', ['get', 'status'], 'to_be_processed'],
|
||||||
[
|
[
|
||||||
'any',
|
'any',
|
||||||
|
['==', ['get', 'is_assigned'], true],
|
||||||
|
['==', ['get', 'is_assigned'], 1],
|
||||||
['boolean', ['get', 'is_assigned'], false],
|
['boolean', ['get', 'is_assigned'], false],
|
||||||
['!=', ['coalesce', ['get', 'team'], ''], ''],
|
['!=', ['coalesce', ['get', 'team'], ''], ''],
|
||||||
['!=', ['coalesce', ['get', 'member'], ''], '']
|
['!=', ['coalesce', ['get', 'member'], ''], '']
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
></i>
|
></i>
|
||||||
<a href="{% url 'mobile:intervention_detail_mobile' intervention.id %}" class="me-2">{{ intervention.code }}</a> {{ intervention.title }}
|
<a href="{% url 'mobile:intervention_detail_mobile' intervention.id %}" class="me-2">{{ intervention.code }}</a> {{ intervention.title }}
|
||||||
</h6>
|
</h6>
|
||||||
<span class="badge bg-{{ intervention.get_status_color }} status-{{ intervention.status }}">{{ intervention.get_status_display }}</span>
|
<span class="badge bg-{{ intervention.get_status_color }} status-{{ intervention.status }}{% if intervention.status == 'to_be_processed' and intervention.is_assigned %} status-to_be_processed_assigned{% endif %}">{{ intervention.get_status_display }}</span>
|
||||||
{% if intervention.show_contract_blocked_warning %}
|
{% if intervention.show_contract_blocked_warning %}
|
||||||
<span class="badge bg-danger" title="{% translate 'Marché temporairement bloqué' %}">
|
<span class="badge bg-danger" title="{% translate 'Marché temporairement bloqué' %}">
|
||||||
<i class="bi bi-slash-circle"></i> {% translate "Marché bloqué" %}
|
<i class="bi bi-slash-circle"></i> {% translate "Marché bloqué" %}
|
||||||
|
|
|
||||||
|
|
@ -589,7 +589,10 @@
|
||||||
const SOURCE_ID = 'interventions-points';
|
const SOURCE_ID = 'interventions-points';
|
||||||
const LAYER_ID = 'interventions-circles';
|
const LAYER_ID = 'interventions-circles';
|
||||||
|
|
||||||
function hexColor(status, bsColor) {
|
function hexColor(status, bsColor, isAssigned) {
|
||||||
|
if (status === 'to_be_processed' && isAssigned) {
|
||||||
|
return INTERVENTION_STATUS_COLORS.to_be_processed_assigned || '#d81b60';
|
||||||
|
}
|
||||||
if (status && INTERVENTION_STATUS_COLORS[status]) {
|
if (status && INTERVENTION_STATUS_COLORS[status]) {
|
||||||
return INTERVENTION_STATUS_COLORS[status];
|
return INTERVENTION_STATUS_COLORS[status];
|
||||||
}
|
}
|
||||||
|
|
@ -626,9 +629,10 @@
|
||||||
status_label: m.status_label,
|
status_label: m.status_label,
|
||||||
status_color: m.status_color,
|
status_color: m.status_color,
|
||||||
status: m.status,
|
status: m.status,
|
||||||
|
is_assigned: m.is_assigned,
|
||||||
maintain_type: m.maintain_type,
|
maintain_type: m.maintain_type,
|
||||||
url: m.url,
|
url: m.url,
|
||||||
fill: hexColor(m.status, m.status_color),
|
fill: hexColor(m.status, m.status_color, m.is_assigned),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
|
@ -638,7 +642,7 @@
|
||||||
function buildPopupHtml(features) {
|
function buildPopupHtml(features) {
|
||||||
return features.map((f, idx) => {
|
return features.map((f, idx) => {
|
||||||
const p = f.properties;
|
const p = f.properties;
|
||||||
const fill = hexColor(p.status, p.status_color);
|
const fill = hexColor(p.status, p.status_color, p.is_assigned);
|
||||||
const txtCol = isTextDark(p.status, p.status_color) ? '#000' : '#fff';
|
const txtCol = isTextDark(p.status, p.status_color) ? '#000' : '#fff';
|
||||||
const sep = idx > 0 ? '<hr style="margin:5px 0">' : '';
|
const sep = idx > 0 ? '<hr style="margin:5px 0">' : '';
|
||||||
const coords = f.geometry && f.geometry.coordinates ? f.geometry.coordinates : null;
|
const coords = f.geometry && f.geometry.coordinates ? f.geometry.coordinates : null;
|
||||||
|
|
|
||||||
|
|
@ -1491,9 +1491,10 @@ def intervention_planning_data_ajax(request, intervention_id):
|
||||||
'id': intervention.id,
|
'id': intervention.id,
|
||||||
'code': intervention.code,
|
'code': intervention.code,
|
||||||
'title': intervention.title,
|
'title': intervention.title,
|
||||||
'status': intervention.status,
|
'status': intervention.get_status_display(),
|
||||||
'status_code': intervention.status,
|
'status_code': intervention.status,
|
||||||
'status_display': intervention.get_status_display(),
|
'status_display': intervention.get_status_display(),
|
||||||
|
'is_assigned': intervention.is_assigned,
|
||||||
'prep_state': intervention.get_preparation_orders_status(),
|
'prep_state': intervention.get_preparation_orders_status(),
|
||||||
'priority': intervention.get_priority_display(),
|
'priority': intervention.get_priority_display(),
|
||||||
'type': intervention.get_type_display(),
|
'type': intervention.get_type_display(),
|
||||||
|
|
|
||||||
|
|
@ -389,6 +389,7 @@ def interventions_index_mobile(request):
|
||||||
'status_label': i.get_status_display(),
|
'status_label': i.get_status_display(),
|
||||||
'status': i.status,
|
'status': i.status,
|
||||||
'status_color': i.get_status_color(),
|
'status_color': i.get_status_color(),
|
||||||
|
'is_assigned': i.is_assigned,
|
||||||
'maintain_type': i.maintain_type,
|
'maintain_type': i.maintain_type,
|
||||||
'lat': i.lat,
|
'lat': i.lat,
|
||||||
'lon': i.lon,
|
'lon': i.lon,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue