{% extends "admin/base_site_grid.html" %} {% load i18n %} {% load static %} {% block extrastyle %}{{block.super}} {% endblock %} {% block extrahead %} {{block.super}} {% if debug_js %} {% else %} {% endif %} {% endblock %} {% block extracontainer %}{% endblock %} {% block tools %}{% if args %}{% include "common/snippet_follow.html" %}{% endif %}{% endblock %} {% block tabs %}{% if args %}{% tabs model %}{% endif %}{% endblock %} {% block actions %}
{% if showGantt %} {% endif %}
{% if hasaddperm %} {% endif %}{% if hasaddperm and not is_popup and reportclass.canDuplicate %} {% endif %} {% if hasdeleteperm and not is_popup %} {% endif %}{% if reportclass.hasTimeBuckets %} {% endif %} {% if hasaddperm %} {% endif %} {% endblock %} {% block afterPageLoad %} displayGrid({% if preferences.mode != "kanban" and preferences.mode != "gantt" and preferences.mode != "calendarday" and preferences.mode != "calendarweek" and preferences.mode != "calendarmonth" %}true{% else %}false{% endif %}); {% endblock %} {% block extra_grid %} onSelectRow: function(rowid, status) { const rowData = jQuery("#grid").getRowData(rowid); const reference = rowData.operationplan__reference ? rowData.operationplan__reference : rowid; const references = jQuery("#grid").jqGrid('getGridParam', 'selarrrow').filter(x => x.id !== 'cb').map(x => x.operationplan__reference ? x.operationplan__reference : x); const event = new CustomEvent("singleSelect", { detail: { execute: 'displayInfo', reference: reference, status: status, selectedRows: references, } }); document.getElementById('app').dispatchEvent(event); var sel = jQuery("#grid").jqGrid('getGridParam', 'selarrrow') || []; upload.selectedRows = sel.filter(x => x.id !== 'cb'); var visibleIds = (jQuery("#grid").jqGrid && jQuery("#grid").jqGrid('getDataIDs')) || []; var selectedIds = sel.map(function(x){ return (x && typeof x === 'object') ? (x.id || x.operationplan__reference || String(x)) : String(x); }); var hasVisible = selectedIds.filter(function(id){ return id !== 'cb' && visibleIds.indexOf(id) !== -1; }).length > 0; ['#actions1','#actions2','#segments1','#copy_selected','#delete_selected'].forEach(function(s){ var el=jQuery(s); if (el.length) el.prop('disabled', !hasVisible); }); }, onSelectAll: function(aRowids, status){ const event = new CustomEvent('allSelect', { detail: { execute: 'displayInfo', status: status, selectedRows: aRowids, } }); document.getElementById('app').dispatchEvent(event); if (jQuery("#actions").length) jQuery("#actions1").prop('disabled', !status); var sel = jQuery("#grid").jqGrid('getGridParam', 'selarrrow') || []; upload.selectedRows = sel.filter(x => x.id !== 'cb'); if (sel.length !== 0 && status) { var visibleIds = (jQuery("#grid").jqGrid && jQuery("#grid").jqGrid('getDataIDs')) || []; var selectedIds = sel.map(function(x){ return (x && typeof x === 'object') ? (x.id || x.operationplan__reference || String(x)) : String(x); }); var hasVisible = selectedIds.filter(function(id){ return id !== 'cb' && visibleIds.indexOf(id) !== -1; }).length > 0; ['#actions1','#actions2','#segments1','#copy_selected','#delete_selected'].forEach(function(s){ var el=jQuery(s); if (el.length) el.prop('disabled', !hasVisible); }); } }, afterSaveCell: function(rowid, cellname, value, iRow, iCol) { const rowData = jQuery("#grid").getRowData(rowid); const reference = rowData.operationplan__reference ? rowData.operationplan__reference : rowid; const event = new CustomEvent('displayonpanel', { detail: { rowid: rowid, reference: reference, field: cellname, value: value } }); document.getElementById('app').dispatchEvent(event); isDataSaved = false; }, multiboxonly: false, loadComplete: function(data) { const pageSelectedIDs = getVisibleSelectedIds(); const changedOperationplanReferences = Object.keys(window.operationplanChanges); if (changedOperationplanReferences.length > 0) { changedOperationplanReferences.forEach((reference) => { if (pageSelectedIDs.includes(reference)) { const changedCellsKeys = Object.keys(window.operationplanChanges[reference]); changedCellsKeys.forEach((field) => { try { displayongrid(reference, null, field, window.operationplanChanges[reference][field]); } catch (e) { // ignore } }); } }); } const IDs = Object.keys(window.operationplanChanges); jQuery('#curerror').html(""); getVisibleSelectedIds().forEach(function(op) { jQuery("#grid").jqGrid('setSelection', op, false); }) const references = jQuery("#grid").jqGrid('getGridParam', 'selarrrow').filter(x => x.id !== 'cb').map(x => x.operationplan__reference ? x.operationplan__reference : x); if (getVisibleSelectedIds().length === 1) { let event = new CustomEvent('displayonpanel', jQuery("#grid").getRowData(getVisibleSelectedIds()[0])); document.getElementById('app').dispatchEvent(event); event = new CustomEvent("singleSelect", { detail: { execute: 'displayInfo', reference: getVisibleSelectedIds()[0], status: status, selectedRows: references, } }); document.getElementById('app').dispatchEvent(event); } else if (getVisibleSelectedIds().length > 1) { var selectiondata = []; for (var x of getVisibleSelectedIds()) selectiondata.push(jQuery("#grid").getRowData(x)); event = new CustomEvent('processAggregatedInfo', { detail: { selectiondata: selectiondata, colModel: jQuery("#grid").jqGrid ('getGridParam', 'colModel') } }); document.getElementById('app').dispatchEvent(event); } else { const event = new CustomEvent('allSelect', { detail: { execute: 'displayInfo', status: false, selectedRows: [], } }); document.getElementById('app').dispatchEvent(event); } // Initialize actions buttons state based on visible-page selection after load var sel = jQuery("#grid").jqGrid('getGridParam', 'selarrrow') || []; var visibleIds = (jQuery("#grid").jqGrid && jQuery("#grid").jqGrid('getDataIDs')) || []; var selectedIds = sel.map(function(x){ return (x && typeof x === 'object') ? (x.id || x.operationplan__reference || String(x)) : String(x); }); var hasVisible = selectedIds.filter(function(id){ return id !== 'cb' && visibleIds.indexOf(id) !== -1; }).length > 0; ['#actions1','#actions2','#segments1','#copy_selected','#delete_selected'].forEach(function(s){ var el=jQuery(s); if (el.length) el.prop('disabled', !hasVisible); }); if (window.preferences && window.preferences.height) { setHeights(); } }, {% endblock %} {% block table %}
{% endblock %} {% block after_table %}
{% endblock %}