ikinci temizlik tamamlandı
This commit is contained in:
@@ -0,0 +1,309 @@
|
||||
<div id="rfiPopup"></div>
|
||||
|
||||
<style>
|
||||
.rfi-popup-cell {
|
||||
position: relative;
|
||||
padding-right: 26px !important;
|
||||
}
|
||||
|
||||
.rfi-popup-trigger {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 4px;
|
||||
transform: translateY(-50%);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
font-size: 11px;
|
||||
color: #1e88e5;
|
||||
cursor: pointer;
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
border: 1px solid rgba(30, 136, 229, 0.4);
|
||||
}
|
||||
|
||||
.rfi-popup-trigger:hover {
|
||||
color: #0d47a1;
|
||||
border-color: #0d47a1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var popupState = {
|
||||
popup: null,
|
||||
grid: null,
|
||||
dataSource: null,
|
||||
callback: null,
|
||||
params: null
|
||||
};
|
||||
|
||||
function buildRequestUrl(params) {
|
||||
var query = [];
|
||||
if (params.rfiNo) {
|
||||
query.push("rfi_no=" + encodeURIComponent(params.rfiNo));
|
||||
}
|
||||
if (params.discipline) {
|
||||
query.push("discipline=" + encodeURIComponent(params.discipline));
|
||||
}
|
||||
if (params.projectNo) {
|
||||
query.push("project_no=" + encodeURIComponent(params.projectNo));
|
||||
}
|
||||
return "{{url('admin-ajax/get-rfi-for-release-log')}}" + "?" + query.join("&");
|
||||
}
|
||||
|
||||
function ensureDataSource() {
|
||||
popupState.dataSource = new DevExpress.data.CustomStore({
|
||||
key: "id",
|
||||
load: function (loadOptions) {
|
||||
var deferred = $.Deferred();
|
||||
var params = popupState.params || {};
|
||||
|
||||
// Build request URL with pagination parameters
|
||||
var requestUrl = buildRequestUrl(params);
|
||||
|
||||
// Add pagination parameters if provided
|
||||
if (loadOptions && loadOptions.skip !== undefined && loadOptions.take !== undefined) {
|
||||
var separator = requestUrl.indexOf('?') === -1 ? '?' : '&';
|
||||
requestUrl += separator + 'skip=' + loadOptions.skip + '&take=' + loadOptions.take;
|
||||
}
|
||||
|
||||
$.getJSON(requestUrl).then(function (result) {
|
||||
var data = [];
|
||||
var totalCount = 0;
|
||||
|
||||
if (Array.isArray(result)) {
|
||||
data = result;
|
||||
totalCount = result.length;
|
||||
} else if (result && Array.isArray(result.data)) {
|
||||
data = result.data;
|
||||
totalCount = result.totalCount !== undefined ? result.totalCount : result.data.length;
|
||||
} else if (result && typeof result === "object") {
|
||||
data = [result];
|
||||
totalCount = 1;
|
||||
}
|
||||
|
||||
deferred.resolve({ data: data, totalCount: totalCount });
|
||||
}, function (error) {
|
||||
var message = (error && (error.responseText || error.statusText)) || "Unknown error";
|
||||
if (window.Swal) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "{{e2('RFI Logs')}}",
|
||||
text: message
|
||||
});
|
||||
}
|
||||
deferred.resolve({ data: [], totalCount: 0 });
|
||||
});
|
||||
return deferred.promise();
|
||||
}
|
||||
});
|
||||
return popupState.dataSource;
|
||||
}
|
||||
|
||||
function applySelection(rowData) {
|
||||
if (!rowData) {
|
||||
return;
|
||||
}
|
||||
if (typeof popupState.callback === "function") {
|
||||
popupState.callback(rowData);
|
||||
}
|
||||
if (popupState.popup) {
|
||||
popupState.popup.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function ensurePopup() {
|
||||
if (popupState.popup) {
|
||||
return popupState.popup;
|
||||
}
|
||||
var $popup = $("#rfiPopup");
|
||||
$popup.dxPopup({
|
||||
title: "{{e2('RFI Logs')}}",
|
||||
width: 1250,
|
||||
height: 720,
|
||||
visible: false,
|
||||
showCloseButton: true,
|
||||
shading: true,
|
||||
resizeEnabled: true,
|
||||
contentTemplate: function (contentElement) {
|
||||
var $grid = $('<div class="rfi-control-grid" style="height: 100%;"></div>');
|
||||
contentElement.append($grid);
|
||||
popupState.grid = $grid.dxDataGrid({
|
||||
dataSource: ensureDataSource(),
|
||||
remoteOperations: {
|
||||
paging: true,
|
||||
filtering: false,
|
||||
sorting: false
|
||||
},
|
||||
keyExpr: "id",
|
||||
showBorders: true,
|
||||
hoverStateEnabled: true,
|
||||
height: "100%",
|
||||
columnAutoWidth: true,
|
||||
allowColumnResizing: true,
|
||||
searchPanel: {
|
||||
visible: true,
|
||||
width: 260
|
||||
},
|
||||
filterRow: {
|
||||
visible: true
|
||||
},
|
||||
scrolling: {
|
||||
mode: "virtual",
|
||||
rowRenderingMode: "virtual",
|
||||
useNative: false,
|
||||
preloadEnabled: true
|
||||
},
|
||||
paging: {
|
||||
pageSize: 50,
|
||||
enabled: true
|
||||
},
|
||||
pager: {
|
||||
visible: false
|
||||
},
|
||||
selection: {
|
||||
mode: "single"
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
dataField: "rfi_no",
|
||||
caption: "RFI No",
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
dataField: "inspection_date",
|
||||
caption: "Inspection Date",
|
||||
dataType: "date",
|
||||
format: "dd/MM/yyyy",
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
dataField: "discipline",
|
||||
caption: "Discipline",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
dataField: "project_no",
|
||||
caption: "Project No",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
dataField: "itp",
|
||||
caption: "ITP",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
dataField: "status",
|
||||
caption: "Status",
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
dataField: "subcontractor",
|
||||
caption: "Subcontractor",
|
||||
width: 150
|
||||
},
|
||||
|
||||
{
|
||||
dataField: "unit",
|
||||
caption: "Unit",
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
dataField: "area",
|
||||
caption: "Area",
|
||||
width: 100
|
||||
},
|
||||
|
||||
{
|
||||
dataField: "description",
|
||||
caption: "Description",
|
||||
width: 200
|
||||
}
|
||||
],
|
||||
onRowDblClick: function (e) {
|
||||
applySelection(e.data);
|
||||
},
|
||||
onSelectionChanged: function (e) {
|
||||
if (e.selectedRowsData && e.selectedRowsData.length > 0) {
|
||||
applySelection(e.selectedRowsData[0]);
|
||||
}
|
||||
}
|
||||
}).dxDataGrid("instance");
|
||||
},
|
||||
onShowing: function () {
|
||||
if (popupState.grid) {
|
||||
popupState.grid.clearSelection();
|
||||
// Recreate dataSource with fresh parameters
|
||||
popupState.dataSource = null;
|
||||
var newDataSource = ensureDataSource();
|
||||
popupState.grid.option('dataSource', newDataSource);
|
||||
popupState.grid.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
popupState.popup = $popup.dxPopup("instance");
|
||||
return popupState.popup;
|
||||
}
|
||||
|
||||
window.showRFIPopup = function (options) {
|
||||
options = options || {};
|
||||
popupState.params = {
|
||||
rfiNo: options.rfiNo || "",
|
||||
discipline: options.discipline || "",
|
||||
projectNo: options.projectNo || ""
|
||||
};
|
||||
popupState.callback = typeof options.onSelect === "function" ? options.onSelect : null;
|
||||
var popup = ensurePopup();
|
||||
var titleSuffix = popupState.params.rfiNo ? " (" + popupState.params.rfiNo + ")" : "";
|
||||
popup.option("title", "{{e2('RFI Logs')}}" + titleSuffix);
|
||||
if (popupState.grid) {
|
||||
// Recreate dataSource with fresh parameters before refresh
|
||||
popupState.dataSource = null;
|
||||
var newDataSource = ensureDataSource();
|
||||
popupState.grid.option('dataSource', newDataSource);
|
||||
popupState.grid.clearSelection();
|
||||
popupState.grid.refresh();
|
||||
}
|
||||
popup.show();
|
||||
};
|
||||
|
||||
window.setupRFIPopupHelpers = function (dataGrid) {
|
||||
if (!dataGrid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Helper function to attach magnifier to RFI no cells
|
||||
window.attachRFIMagnifier = function (columnDataField, dateDataField) {
|
||||
dataGrid.on("cellPrepared", function (e) {
|
||||
if (e.rowType === "data" && e.column && e.column.dataField === columnDataField) {
|
||||
var $cell = $(e.cellElement);
|
||||
if (!$cell.hasClass("rfi-popup-cell")) {
|
||||
$cell.addClass("rfi-popup-cell");
|
||||
var $trigger = $('<span class="rfi-popup-trigger" title="Search RFI">🔍</span>');
|
||||
$cell.append($trigger);
|
||||
|
||||
$trigger.on("click", function (event) {
|
||||
event.stopPropagation();
|
||||
var rowData = e.data;
|
||||
window.showRFIPopup({
|
||||
rfiNo: rowData[columnDataField] || "",
|
||||
onSelect: function (selectedRFI) {
|
||||
if (selectedRFI) {
|
||||
dataGrid.cellValue(e.row.rowIndex, columnDataField, selectedRFI.rfi_no);
|
||||
if (dateDataField && selectedRFI.inspection_date) {
|
||||
dataGrid.cellValue(e.row.rowIndex, dateDataField, selectedRFI.inspection_date);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
})();
|
||||
</script>
|
||||
Reference in New Issue
Block a user