From 05d305d6ac83f1d6ab405e5049f1654292061431 Mon Sep 17 00:00:00 2001 From: Saurabh Date: Mon, 7 Oct 2024 17:29:52 +0200 Subject: [PATCH] Lib Samp table columns --- .../app/components/BaseGridController.js | 4 +- .../app/view/invoicing/InvoicingController.js | 4 +- .../main-hub/app/view/libraries/Libraries.js | 58 ++++++++++++------- .../app/view/libraries/LibrariesController.js | 4 +- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/backend/static/main-hub/app/components/BaseGridController.js b/backend/static/main-hub/app/components/BaseGridController.js index 842f25772..64c29cbc9 100644 --- a/backend/static/main-hub/app/components/BaseGridController.js +++ b/backend/static/main-hub/app/components/BaseGridController.js @@ -312,7 +312,9 @@ Ext.define("MainHub.components.BaseGridController", { }, gridCellTooltipRenderer: function (value, meta) { - meta.tdAttr = Ext.String.format('data-qtip="{0}"', value); + if (value) { + meta.tdAttr = 'data-qtip="' + value + '"'; + } else meta.tdAttr = "data-qtip=Empty"; return value; }, diff --git a/backend/static/main-hub/app/view/invoicing/InvoicingController.js b/backend/static/main-hub/app/view/invoicing/InvoicingController.js index 18a9ac453..84b0ef5ff 100644 --- a/backend/static/main-hub/app/view/invoicing/InvoicingController.js +++ b/backend/static/main-hub/app/view/invoicing/InvoicingController.js @@ -117,7 +117,9 @@ Ext.define("MainHub.view.invoicing.InvoicingController", { }, gridCellTooltipRenderer: function (value, meta) { - meta.tdAttr = Ext.String.format('data-qtip="{0}"', value); + if (value) { + meta.tdAttr = 'data-qtip="' + value + '"'; + } else meta.tdAttr = "data-qtip=Empty"; return value; }, diff --git a/backend/static/main-hub/app/view/libraries/Libraries.js b/backend/static/main-hub/app/view/libraries/Libraries.js index 075ffd254..554db6f84 100644 --- a/backend/static/main-hub/app/view/libraries/Libraries.js +++ b/backend/static/main-hub/app/view/libraries/Libraries.js @@ -441,7 +441,13 @@ Ext.define("MainHub.view.libraries.Libraries", { text: "GMO", tooltip: "Genetically Modified Organism", dataIndex: "gmo", - renderer: "gridCellTooltipRenderer" + renderer: function (value, meta, record) { + if (record.get("leaf")) { + return value ? "Yes" : "No"; + } else { + return ""; + } + } }, { text: "Date", @@ -472,16 +478,21 @@ Ext.define("MainHub.view.libraries.Libraries", { dataIndex: "concentration" }, { - text: "Measuring Unit", - tooltip: "Measuring Unit", - dataIndex: "measuring_unit", - renderer: "gridCellTooltipRenderer" - }, - { - text: "Measured Value", - tooltip: "Measured Value", - dataIndex: "measured_value", - renderer: "gridCellTooltipRenderer" + text: "Measurement", + tooltip: "Measured value along with its unit", + renderer: function (value, meta, record) { + var measuringUnit = record.get("measuring_unit"); + var measuredValue = record.get("measured_value"); + + if (measuringUnit === "-") { + return "Requires Measurement"; + } else + return Ext.String.format( + "{0}{1}", + measuredValue, + measuringUnit + ); + } }, { text: "Starting Amount", @@ -502,16 +513,21 @@ Ext.define("MainHub.view.libraries.Libraries", { renderer: "gridCellTooltipRenderer" }, { - text: "Measuring Unit (Output)", - tooltip: "Measuring Unit (Output)", - dataIndex: "measuring_unit_facility", - renderer: "gridCellTooltipRenderer" - }, - { - text: "Measured Value (Output)", - tooltip: "Measured Value (Output)", - dataIndex: "measured_value_facility", - renderer: "gridCellTooltipRenderer" + text: "Measurement (Output)", + tooltip: "Measured value along with its unit", + renderer: function (value, meta, record) { + var measuringUnit = record.get("measuring_unit_facility"); + var measuredValue = record.get("measured_value_facility"); + + if (measuringUnit === "-") { + return "Requires Measurement"; + } else + return Ext.String.format( + "{0}{1}", + measuredValue, + measuringUnit + ); + } }, { text: "Index Type", diff --git a/backend/static/main-hub/app/view/libraries/LibrariesController.js b/backend/static/main-hub/app/view/libraries/LibrariesController.js index 10895d498..45a8b69b8 100644 --- a/backend/static/main-hub/app/view/libraries/LibrariesController.js +++ b/backend/static/main-hub/app/view/libraries/LibrariesController.js @@ -115,7 +115,9 @@ Ext.define("MainHub.view.libraries.LibrariesController", { }, gridCellTooltipRenderer: function (value, meta) { - meta.tdAttr = 'data-qtip="' + value + '"'; + if (value) { + meta.tdAttr = 'data-qtip="' + value + '"'; + } else meta.tdAttr = "data-qtip=Empty"; return value; } });