diff --git a/src/Views/Home/Assets.cshtml b/src/Views/Home/Assets.cshtml index a2887af..850a080 100644 --- a/src/Views/Home/Assets.cshtml +++ b/src/Views/Home/Assets.cshtml @@ -30,17 +30,17 @@ - - - - + + + + - - - - + + + + @@ -48,8 +48,8 @@ @{ foreach (AssetsTableViewModel assetsTableViewModel in Model.AssetsTableViewModels) { - - + + @@ -711,7 +711,7 @@ document.addEventListener('DOMContentLoaded', () => { .asset-row > td { transition: 0.1s ease; } -.asset-row:has(td:not(:last-child):hover) > td { +.asset-row:has(td:not(:last-child):is(:hover, :focus)) > td { background-color: #17a2b8; } @@ -725,145 +725,152 @@ document.addEventListener('DOMContentLoaded', () => { }); function registerRowDetailviewClick(row) { - const viewModal = document.getElementById('viewAssetModal'); - const viewContent = document.getElementById('viewAssetContent'); - row.addEventListener('click', async (e) => { - // Avoid clicks on buttons inside the row - if (e.target.closest('button')) return; - - const assetId = row.getAttribute('data-asset-id'); - viewContent.innerHTML = '

@T["Loading..."]

'; - - const modal = new bootstrap.Modal(viewModal); - modal.show(); - - try { - const response = await fetch(`/Assets/Get?cn=${assetId}`); - const json = await response.json(); - const asset = json.assetsModel; - - if (!asset) { - viewContent.innerHTML = `

@T["Asset not found."]

`; - return; - } - - const html = ` -
-

@T["Barcode"]

-
- -
-
- - -
-
-
-
-

@T["Inventory"]

-
- - -
-
- - -
-
-
-
-

@T["Information"]

-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-

@T["Description"]

-
- - -
-
- - -
-
- - -
-
- ${asset.Description?.Attributes ? ` -
-
-

@T["Attributes"]

- ${Object.entries(asset.Description.Attributes) - .map(([k,v]) => ` -
- : - -
`) - .join('')} -
` : ''} - - ${asset.Description?.Purchase ? ` -
-
-

@T["Purchase Information"]

-
- - -
-
- - -
-
- - -
-
- - -
-
` : ''} - `; - viewContent.innerHTML = html; - JsBarcode("#@barcodeType", getBarcodeValue("@barcodeType", asset.Cn), { - format: "@barcodeType", - lineColor: "#000", - width: 2, - height: 80, - displayValue: true - }); - document.getElementById("downloadBtn").addEventListener("click", () => { - downloadBarcode("@barcodeType", getBarcodeValue("@barcodeType", asset.Cn)); - }); - document.getElementById("printBtn").addEventListener("click", () => { - addAssetIdToBatch(asset.Cn); - showToast("@T["Successfully added barcode to print batch"]", "success"); - bootstrap.Modal.getInstance('#viewAssetModal').hide(); - }); - } catch (err) { - console.error(err); - viewContent.innerHTML = `

@T["Error loading asset details"]

`; + row.addEventListener('click', async (e) => handleRowDetailViewEvent(e, row)); + row.addEventListener('keydown', e => { + if (e.key === 'Enter' || e.key === ' ') { + row.click(); } }); } +async function handleRowDetailViewEvent(e, row) { + const viewModal = document.getElementById('viewAssetModal'); + const viewContent = document.getElementById('viewAssetContent'); + // Avoid clicks on buttons inside the row + if (e.target.closest('button')) return; + + const assetId = row.getAttribute('data-asset-id'); + viewContent.innerHTML = '

@T["Loading..."]

'; + + const modal = new bootstrap.Modal(viewModal); + modal.show(); + + try { + const response = await fetch(`/Assets/Get?cn=${assetId}`); + const json = await response.json(); + const asset = json.assetsModel; + + if (!asset) { + viewContent.innerHTML = `

@T["Asset not found."]

`; + return; + } + let i = 0; + const html = ` +
+

@T["Barcode"]

+
+ +
+
+ + +
+
+
+
+

@T["Inventory"]

+
+ + +
+
+ + +
+
+
+
+

@T["Information"]

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+

@T["Description"]

+
+ + +
+
+ + +
+
+ + +
+
+ ${asset.Description?.Attributes ? ` +
+
+

@T["Attributes"]

+ ${Object.entries(asset.Description.Attributes) + .map(([k,v]) => ` +
+ : + +
`) + .join('')} +
` : ''} + + ${asset.Description?.Purchase ? ` +
+
+

@T["Purchase Information"]

+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
` : ''} + `; + viewContent.innerHTML = html; + JsBarcode("#@barcodeType", getBarcodeValue("@barcodeType", asset.Cn), { + format: "@barcodeType", + lineColor: "#000", + width: 2, + height: 80, + displayValue: true + }); + document.getElementById("downloadBtn").addEventListener("click", () => { + downloadBarcode("@barcodeType", getBarcodeValue("@barcodeType", asset.Cn)); + }); + document.getElementById("printBtn").addEventListener("click", () => { + addAssetIdToBatch(asset.Cn); + showToast("@T["Successfully added barcode to print batch"]", "success"); + bootstrap.Modal.getInstance('#viewAssetModal').hide(); + }); + } catch (err) { + console.error(err); + viewContent.innerHTML = `

@T["Error loading asset details"]

`; + } +} + document.addEventListener('DOMContentLoaded', () => { const presetApplyButton = document.getElementById('createPresetApply');
@T["Owner"]@T["Asset ID"]@T["Asset Name"]@T["Location"]@T["Owner"]@T["Asset ID"]@T["Asset Name"]@T["Location"] @T["Action"]
-
@assetsTableViewModel.UserUID
@assetsTableViewModel.UserUID @assetsTableViewModel.AssetCn @assetsTableViewModel.AssetName @assetsTableViewModel.LocationName