Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: open PDF documents in a new tab on click instead of downloading

Rob Carringtonc25e353cc7fe
diff --git a/apps/erp/app/components/Documents.tsx b/apps/erp/app/components/Documents.tsx
index ef5f408928..7d12c56164 100644
--- a/apps/erp/app/components/Documents.tsx
+++ b/apps/erp/app/components/Documents.tsx
@@ -353,7 +353,18 @@ const Documents = ({
<DocumentIcon type={type} />
<span
className="font-medium"
- onClick={() => download(file)}
+ onClick={() => {
+ if (["PDF", "Image"].includes(type)) {
+ window.open(
+ path.to.file.previewFile(
+ `${"private"}/${getReadPath(file)}`
+ ),
+ "_blank"
+ );
+ } else {
+ download(file);
+ }
+ }}
>
{isPreviewable ? (
<DocumentPreview
diff --git a/apps/erp/app/modules/items/ui/Item/ItemDocuments.tsx b/apps/erp/app/modules/items/ui/Item/ItemDocuments.tsx
index 642358d30b..bcb6f1330e 100644
--- a/apps/erp/app/modules/items/ui/Item/ItemDocuments.tsx
+++ b/apps/erp/app/modules/items/ui/Item/ItemDocuments.tsx
@@ -165,7 +165,18 @@ const ItemDocuments = ({
<DocumentIcon type={type} />
<span
className="font-medium"
- onClick={() => download(file)}
+ onClick={() => {
+ if (["PDF", "Image"].includes(type)) {
+ window.open(
+ path.to.file.previewFile(
+ `${"private"}/${getPath(file)}`
+ ),
+ "_blank"
+ );
+ } else {
+ download(file);
+ }
+ }}
>
{["PDF", "Image"].includes(type) ? (
<DocumentPreview
diff --git a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineDocuments.tsx b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineDocuments.tsx
index 153cbce6f7..1d272ec38d 100644
--- a/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineDocuments.tsx
+++ b/apps/erp/app/modules/purchasing/ui/SupplierInteraction/SupplierInteractionLineDocuments.tsx
@@ -259,7 +259,18 @@ const SupplierInteractionLineDocuments = ({
<DocumentIcon type={type} />
<span
className="font-medium"
- onClick={() => download(file)}
+ onClick={() => {
+ if (["PDF", "Image"].includes(type)) {
+ window.open(
+ path.to.file.previewFile(
+ `${"private"}/${getPath(file)}`
+ ),
+ "_blank"
+ );
+ } else {
+ download(file);
+ }
+ }}
>
{["PDF", "Image"].includes(type) ? (
<DocumentPreview
diff --git a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx
index 381ec85fef..6151ebf462 100644
--- a/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx
+++ b/apps/erp/app/modules/sales/ui/Opportunity/OpportunityLineDocuments.tsx
@@ -388,7 +388,18 @@ const OpportunityLineDocuments = ({
<DocumentIcon type={type} />
<span
className="font-medium"
- onClick={() => download(file)}
+ onClick={() => {
+ if (["PDF", "Image"].includes(type)) {
+ window.open(
+ path.to.file.previewFile(
+ `${"private"}/${getPath(file)}`
+ ),
+ "_blank"
+ );
+ } else {
+ download(file);
+ }
+ }}
>
{["PDF", "Image"].includes(type) ? (
<DocumentPreview