From 6669565df12e367d4d4d224e20e0a2c639704666 Mon Sep 17 00:00:00 2001 From: rocketdebris Date: Thu, 30 Oct 2025 13:48:20 -0400 Subject: [PATCH] Custom table for the dashboard. --- uberleben_custom/fixtures/custom_html_block.json | 8 ++++---- uberleben_custom/fixtures/warehouse.json | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/uberleben_custom/fixtures/custom_html_block.json b/uberleben_custom/fixtures/custom_html_block.json index a7264e0..7b5d97f 100644 --- a/uberleben_custom/fixtures/custom_html_block.json +++ b/uberleben_custom/fixtures/custom_html_block.json @@ -2,12 +2,12 @@ { "docstatus": 0, "doctype": "Custom HTML Block", - "html": "
\n
\n

Filters

\n \n
\n
\n

Items

\n
\n
\n
", - "modified": "2025-10-30 00:31:58.654374", + "html": "
\n
\n

Filters

\n \n
\n
\n

Items

\n
\n
\n
", + "modified": "2025-10-30 13:42:13.557964", "name": "Inventory Status Workspace", "private": 0, "roles": [], - "script": "var warehouse_data;\n\nfrappe.call({\n method: \"uberleben_custom.api.get_warehouse_data\",\n callback: function(r) {\n warehouse_data = r.message;\n }\n});\nfrappe.call({\n method: \"uberleben_custom.api.get_item_per_wh\",\n callback: function(r){\n if (r.message) {\n populateItemTable(r.message);\n }\n }\n});\n\nfunction toggleDetails($rowId) {\n console.log($rowId.attr(\"detail\"));\n if ($rowId.attr(\"detail\")) {\n $rowId.removeAttr(\"detail\");\n }\n else {\n $rowId.attr(\"detail\", true);\n }\n}\n\nfunction toggleInnerTable($tableId) {\n if ($tableId.attr(\"hidden\") != null) {\n $tableId.removeAttr(\"hidden\");\n } else {\n $tableId.attr(\"hidden\", \"\");\n }\n}\n\nfunction generateInnerTableRow(warehouse, number) {\n if (number == 0)\n return \"\"\n return \"\"+warehouse+\"\"+number+\"\";\n}\n\nfunction populateItemTable(items) {\n console.log(\"Prior to building table.\")\n console.log(warehouse_data);\n let $itemTable = $(\"#item_table\", root_element);\n let itemNum = 0;\n let rowNum = 0;\n let tableHTML = \"\";\n tableHTML += \"\";\n tableHTML += \"\";\n\n for (const[item, stock_data] of Object.entries(items)) {\n let rowId = rowNum + \"-row\";\n let rowButtonId = rowId + \"-button\";\n tableHTML += ``;\n tableHTML += ''+item+'';\n tableHTML += \"\";\n for (const[warehouse, number] of Object.entries(stock_data)) {\n let wh = warehouse_data[warehouse]\n if (wh.disabled == 1 || number == 0)\n continue;\n rowId = ++rowNum +\"-row\";\n rowButtonId = rowId + \"-button\";\n if (wh.is_substatus_warehouse == 0) {\n tableHTML += ``;\n tableHTML += ''+warehouse+'Total: '+number;\n if (wh.is_group_warehouse)\n tableHTML += '';\n tableHTML += ''\n tableHTML += '';\n }\n }\n // Generate Inner Nested Table\n let innerTableId = rowNum + \"-table\";\n let innerHTML = ``;\n innerHTML += \"StatusNumber\"\n innerHTML += ``;\n for (const[warehouse, number] of Object.entries(stock_data)) {\n let wh = warehouse_data[warehouse]\n if (wh.disabled == 1)\n continue;\n if (wh.is_substatus_warehouse == 1 && number > 0) {\n innerHTML += '';\n innerHTML += generateInnerTableRow(warehouse, number);\n innerHTML += '';\n }\n }\n innerHTML += \"\";\n tableHTML += innerHTML;\n console.log(innerHTML);\n itemNum++;\n rowNum++;\n }\n\n tableHTML += \"\";\n\n $itemTable.html(tableHTML);\n \n for (let i=0;i {toggleInnerTable($innerTable)});\n }\n }\n }", - "style": ".info-button {\n border-radius: 5px;\n}\n.table-container {\n display:flex;\n}\n\n.table {\n display: flex;\n flex-direction: column;\n}\n\n.outer-table-row {\n display: flex;\n}\n\n.inner-table-row {\n display: flex;\n}" + "script": "var warehouse_data;\n\nfrappe.call({\n method: \"uberleben_custom.api.get_warehouse_data\",\n callback: function(r) {\n warehouse_data = r.message;\n }\n});\nfrappe.call({\n method: \"uberleben_custom.api.get_item_per_wh\",\n callback: function(r){\n if (r.message) {\n populateItemTable(r.message);\n }\n }\n});\n\nfunction toggleDetails($rowId) {\n console.log($rowId.attr(\"detail\"));\n if ($rowId.attr(\"detail\")) {\n $rowId.removeAttr(\"detail\");\n }\n else {\n $rowId.attr(\"detail\", true);\n }\n}\n\nfunction toggleInnerTable($tableId) {\n if ($tableId.attr(\"hidden\") != null) {\n $tableId.removeAttr(\"hidden\");\n } else {\n $tableId.attr(\"hidden\", \"\");\n }\n}\n\nfunction generateInnerTableRow(warehouse, number) {\n if (number == 0)\n return \"\"\n return \"
\"+warehouse+\"
\"+number+\"
\";\n}\n\nfunction populateItemTable(items) {\n console.log(\"Prior to building table.\")\n console.log(warehouse_data);\n let $itemTable = $(\"#item_table\", root_element);\n let itemNum = 0;\n let rowNum = 0;\n //let tableHTML = \"\";\n //tableHTML += \"\";\n //tableHTML += \"\";\n let tableHTML = \"
\"\n\n for (const[item, stock_data] of Object.entries(items)) {\n let rowId = rowNum + \"-row\";\n let rowButtonId = rowId + \"-button\";\n tableHTML += `
`;\n tableHTML += ''+item+'';\n tableHTML += \"
\";\n for (const[warehouse, number] of Object.entries(stock_data)) {\n let wh = warehouse_data[warehouse]\n if (wh.disabled == 1 || number == 0)\n continue;\n rowId = ++rowNum +\"-row\";\n rowButtonId = rowId + \"-button\";\n if (wh.is_substatus_warehouse == 0) {\n tableHTML += `
`;\n tableHTML += `
${warehouse}
`;\n tableHTML += `
Sellable Units: ${number}
`;\n if (wh.is_group_warehouse)\n tableHTML += `
`;\n tableHTML += '
';\n }\n }\n // Generate Inner Nested Table\n let innerTableId = rowNum + \"-table\";\n let innerHTML = `
\"\n //innerHTML += `
StatusNumber
\";\n innerHTML += \"\";\n tableHTML += innerHTML;\n console.log(innerHTML);\n itemNum++;\n rowNum++;\n }\n\n //tableHTML += \"\";\n\n $itemTable.html(tableHTML);\n \n for (let i=0;i {toggleInnerTable($innerTable)});\n }\n }\n }", + "style": ".info-button {\n border: none;\n color: white;\n background-color: var(--btn-primary);\n box-shadow: none;\n font-size: var(--text-base);\n font-weight: var(--weight-regular);\n letter-spacing: 0.02em;\n height: var(--btn-height);\n margin-left: var(--margin-sm, 8px);\n border-radius: var(--border-radius);\n line-height: 1;\n padding: 2px 8px;\n}\n.table-container {\n}\n\n.table {\n display: flex;\n flex-direction: column;\n margin: 10px;\n border: 1px solid;\n border-radius: var(--border-radius);\n}\n\n.table-cell {\n flex: 1;\n padding: 5px;\n border-right: 1px solid;\n}\n\n.table-cell .button-cell {\n align-self: flex-end;\n}\n\n.table-cell:last-child {\n border-right: none;\n}\n\n.inner-table {\n display: flex;\n flex-direction: column;\n margin: 10px;\n border: 1px solid;\n border-radius: var(--border-radius);\n}\n\n.item-table-row {\n display: flex;\n margin: 5px;\n border-bottom: 1px solid;\n}\n.item-table-row:hover {\n background-color: var(--highlight-color);\n}\n.outer-table-row {\n display: flex;\n margin: 5px;\n}\n.outer-table-row:hover {\n background-color: var(--highlight-color);\n border-radius: var(--border-radius);\n}\n.inner-table-row {\n display: flex;\n margin: 10px;\n}\n.inner-table-row:hover {\n background-color: var(--highlight-color);\n border-radius: var(--border-radius);\n}" } ] \ No newline at end of file diff --git a/uberleben_custom/fixtures/warehouse.json b/uberleben_custom/fixtures/warehouse.json index 09ab27d..2e516da 100644 --- a/uberleben_custom/fixtures/warehouse.json +++ b/uberleben_custom/fixtures/warehouse.json @@ -239,14 +239,14 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-29 21:29:26.476951", - "name": "Inbound - U", + "modified": "2025-10-29 21:27:40.296954", + "name": "Finished Goods - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", "phone_no": null, "pin": null, "state": null, - "warehouse_name": "Inbound", + "warehouse_name": "Finished Goods", "warehouse_type": null }, { @@ -264,14 +264,14 @@ "is_group": 0, "is_rejected_warehouse": 0, "mobile_no": null, - "modified": "2025-10-29 21:27:40.296954", - "name": "Finished Goods - U", + "modified": "2025-10-29 21:29:26.476951", + "name": "Inbound - U", "old_parent": "Uberleben HQ - U", "parent_warehouse": "Uberleben HQ - U", "phone_no": null, "pin": null, "state": null, - "warehouse_name": "Finished Goods", + "warehouse_name": "Inbound", "warehouse_type": null }, {