df-ae-forms-package 1.1.9 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -3
- package/dist/index.esm.js +84 -23
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +84 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -712,10 +712,11 @@ interface DfFormSectionProps {
|
|
|
712
712
|
firstName?: string;
|
|
713
713
|
lastName?: string;
|
|
714
714
|
};
|
|
715
|
-
onCreateIssue?: (issueData: any, attachments:
|
|
715
|
+
onCreateIssue?: (issueData: any, attachments: any[]) => Promise<any>;
|
|
716
716
|
onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
|
|
717
717
|
allowWorkflowActions?: boolean;
|
|
718
718
|
inEditMode?: boolean;
|
|
719
|
+
isStandalone?: boolean;
|
|
719
720
|
}
|
|
720
721
|
declare const DfFormSection: React.FC<DfFormSectionProps>;
|
|
721
722
|
|
|
@@ -789,10 +790,11 @@ interface DfFormTableProps {
|
|
|
789
790
|
firstName?: string;
|
|
790
791
|
lastName?: string;
|
|
791
792
|
};
|
|
792
|
-
onCreateIssue?: (issueData: any, attachments:
|
|
793
|
+
onCreateIssue?: (issueData: any, attachments: any[]) => Promise<any>;
|
|
793
794
|
onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
|
|
794
795
|
allowWorkflowActions?: boolean;
|
|
795
796
|
inEditMode?: boolean;
|
|
797
|
+
isStandalone?: boolean;
|
|
796
798
|
}
|
|
797
799
|
declare const DfFormTable: React.FC<DfFormTableProps>;
|
|
798
800
|
|
|
@@ -876,7 +878,7 @@ interface IRaiseIssueModalProps {
|
|
|
876
878
|
notes?: string;
|
|
877
879
|
attachments?: File[] | null;
|
|
878
880
|
issue?: IIssue | null;
|
|
879
|
-
onCreateIssue?: (issueData: any, attachments:
|
|
881
|
+
onCreateIssue?: (issueData: any, attachments: any[]) => Promise<IIssue>;
|
|
880
882
|
onUpdateIssue?: (issueId: string, updateData: any) => Promise<void>;
|
|
881
883
|
user?: {
|
|
882
884
|
firstName?: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -333,6 +333,8 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
333
333
|
'John Smith',
|
|
334
334
|
'Sarah Johnson'
|
|
335
335
|
], workOrderNumber: initialWorkOrderNumber, assetNumber: initialAssetNumber, isStandalone, allowWorkflowActions, inEditMode = false, isEdit }) => {
|
|
336
|
+
// DEBUG: Log the isStandalone value
|
|
337
|
+
console.log('RaiseIssueModal - isStandalone:', isStandalone, 'type:', typeof isStandalone);
|
|
336
338
|
const [title, setTitle] = useState('');
|
|
337
339
|
const [description, setDescription] = useState('');
|
|
338
340
|
const [workOrderNumber, setWorkOrderNumber] = useState('');
|
|
@@ -406,6 +408,14 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
406
408
|
setLocalAttachments(prev => [...prev, ...newFiles]);
|
|
407
409
|
}
|
|
408
410
|
};
|
|
411
|
+
const convertFileToBase64 = (file) => {
|
|
412
|
+
return new Promise((resolve, reject) => {
|
|
413
|
+
const reader = new FileReader();
|
|
414
|
+
reader.readAsDataURL(file);
|
|
415
|
+
reader.onload = () => resolve(reader.result);
|
|
416
|
+
reader.onerror = error => reject(error);
|
|
417
|
+
});
|
|
418
|
+
};
|
|
409
419
|
const getAttachmentName = (file) => {
|
|
410
420
|
if (!file)
|
|
411
421
|
return 'Attachment';
|
|
@@ -436,10 +446,25 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
436
446
|
}
|
|
437
447
|
return null;
|
|
438
448
|
}
|
|
439
|
-
if (file.data
|
|
440
|
-
|
|
441
|
-
|
|
449
|
+
if (file.data) {
|
|
450
|
+
if (isDataUrlImage(file.data))
|
|
451
|
+
return file.data;
|
|
452
|
+
// Handle raw base64 data from API
|
|
453
|
+
if (file.fileName && isImage(file.fileName)) {
|
|
454
|
+
const fileName = String(file.fileName).toLowerCase();
|
|
455
|
+
let mimeType = 'image/png'; // Default
|
|
456
|
+
if (fileName.endsWith('.jpg') || fileName.endsWith('.jpeg'))
|
|
457
|
+
mimeType = 'image/jpeg';
|
|
458
|
+
else if (fileName.endsWith('.png'))
|
|
459
|
+
mimeType = 'image/png';
|
|
460
|
+
else if (fileName.endsWith('.gif'))
|
|
461
|
+
mimeType = 'image/gif';
|
|
462
|
+
else if (fileName.endsWith('.webp'))
|
|
463
|
+
mimeType = 'image/webp';
|
|
464
|
+
return `data:${mimeType};base64,${file.data}`;
|
|
465
|
+
}
|
|
442
466
|
return file.data;
|
|
467
|
+
}
|
|
443
468
|
return null;
|
|
444
469
|
};
|
|
445
470
|
useEffect(() => {
|
|
@@ -451,12 +476,22 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
451
476
|
setWorkOrderNumber(issue?.workOrderNumber || initialWorkOrderNumber || '');
|
|
452
477
|
setAssetNumber(issue?.assetNumber || initialAssetNumber || '');
|
|
453
478
|
setPriority(issue?.priority || 'Medium');
|
|
454
|
-
// Use enum value or default to OPEN
|
|
455
479
|
const issueStatus = issue?.status || EIssueStatus.OPEN;
|
|
456
480
|
// Normalize to enum values if needed (handle legacy values)
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
481
|
+
let normalizedStatus = EIssueStatus.OPEN;
|
|
482
|
+
if (issueStatus) {
|
|
483
|
+
const statusLower = String(issueStatus).toLowerCase().trim();
|
|
484
|
+
if (statusLower === 'open')
|
|
485
|
+
normalizedStatus = EIssueStatus.OPEN;
|
|
486
|
+
else if (statusLower === 'in-progress' || statusLower === 'in progress' || statusLower === 'inprogress')
|
|
487
|
+
normalizedStatus = EIssueStatus.IN_PROGRESS;
|
|
488
|
+
else if (statusLower === 'rejected')
|
|
489
|
+
normalizedStatus = EIssueStatus.REJECTED;
|
|
490
|
+
else if (statusLower === 'resolved' || statusLower === 'resolve')
|
|
491
|
+
normalizedStatus = EIssueStatus.RESOLVE;
|
|
492
|
+
else
|
|
493
|
+
normalizedStatus = issueStatus; // Fallback to whatever it is if it's not matched but it might be valid
|
|
494
|
+
}
|
|
460
495
|
setStatus(normalizedStatus);
|
|
461
496
|
// Correctly map assignTo or fallback to assignee
|
|
462
497
|
setAssignee(issue?.assignTo || '');
|
|
@@ -575,6 +610,17 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
575
610
|
try {
|
|
576
611
|
if (isEditMode && issue) {
|
|
577
612
|
// Update existing issue
|
|
613
|
+
// Convert attachments to base64 objects for API
|
|
614
|
+
const attachmentObjects = await Promise.all(localAttachments.map(async (file) => {
|
|
615
|
+
if (file instanceof File) {
|
|
616
|
+
const base64 = await convertFileToBase64(file);
|
|
617
|
+
return {
|
|
618
|
+
fileName: file.name,
|
|
619
|
+
data: base64
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
return file; // Already a data object
|
|
623
|
+
}));
|
|
578
624
|
const updateData = {
|
|
579
625
|
title: String(title || '').trim(),
|
|
580
626
|
description: String(description || '').trim(),
|
|
@@ -587,7 +633,9 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
587
633
|
status: status,
|
|
588
634
|
comments: String(comments || '').trim() || '',
|
|
589
635
|
task: issue.component?.basic?.label || '',
|
|
590
|
-
taskValue: issue.component?.basic?.value || ''
|
|
636
|
+
taskValue: issue.component?.basic?.value || '',
|
|
637
|
+
isStandalone: !!isStandalone,
|
|
638
|
+
attachments: attachmentObjects
|
|
591
639
|
};
|
|
592
640
|
if (onUpdateIssue && issue._id) {
|
|
593
641
|
await onUpdateIssue(issue._id, updateData);
|
|
@@ -619,6 +667,17 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
619
667
|
comments: String(notes || '')
|
|
620
668
|
}
|
|
621
669
|
};
|
|
670
|
+
// Convert attachments to base64 objects for API
|
|
671
|
+
const attachmentObjects = await Promise.all(localAttachments.map(async (file) => {
|
|
672
|
+
if (file instanceof File) {
|
|
673
|
+
const base64 = await convertFileToBase64(file);
|
|
674
|
+
return {
|
|
675
|
+
fileName: file.name,
|
|
676
|
+
data: base64
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
return file; // Already a data object
|
|
680
|
+
}));
|
|
622
681
|
const createdBy = user ? `${user.firstName || ''} ${user.lastName || ''}`.trim() : 'User';
|
|
623
682
|
const issueData = {
|
|
624
683
|
title: String(title || '').trim(),
|
|
@@ -633,11 +692,13 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
633
692
|
comments: String(comments || '').trim() || '',
|
|
634
693
|
createdBy,
|
|
635
694
|
task: component?.basic?.label || '',
|
|
636
|
-
taskValue: component?.basic?.value || ''
|
|
695
|
+
taskValue: component?.basic?.value || '',
|
|
696
|
+
isStandalone: !!isStandalone,
|
|
697
|
+
attachments: attachmentObjects // Include in data as well
|
|
637
698
|
};
|
|
638
|
-
let createdIssueResponse;
|
|
699
|
+
let createdIssueResponse;
|
|
639
700
|
if (onCreateIssue) {
|
|
640
|
-
createdIssueResponse = await onCreateIssue(issueData,
|
|
701
|
+
createdIssueResponse = await onCreateIssue(issueData, attachmentObjects);
|
|
641
702
|
}
|
|
642
703
|
toastService.showSuccess('Issue raised successfully');
|
|
643
704
|
if (onSuccess) {
|
|
@@ -691,7 +752,7 @@ const RaiseIssueModal = ({ isOpen, onClose, onSuccess, component, formTemplateId
|
|
|
691
752
|
hour: '2-digit',
|
|
692
753
|
minute: '2-digit',
|
|
693
754
|
hour12: true
|
|
694
|
-
}) })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Description ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("textarea", { className: `raise-issue-field-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Enter issue description", rows: 4, readOnly: isEditMode && isViewMode })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Status ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: status, readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Assign to ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("select", { className: "raise-issue-field-select", value: assignee, onChange: (e) => setAssignee(e.target.value), disabled: isEditMode && isViewMode, children: [jsx("option", { value: "", children: "Unassigned" }), availableUsers.map(userName => (jsx("option", { value: userName, children: userName }, userName)))] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Priority ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("div", { className: "raise-issue-priority-buttons", children: [jsx("button", { type: "button", className: `priority-button priority-low ${priority === 'Low' ? 'active' : ''}`, onClick: () => setPriority('Low'), disabled: isEditMode && isViewMode, children: "Low" }), jsx("button", { type: "button", className: `priority-button priority-medium ${priority === 'Medium' ? 'active' : ''}`, onClick: () => setPriority('Medium'), disabled: isEditMode && isViewMode, children: "Medium" }), jsx("button", { type: "button", className: `priority-button priority-high ${priority === 'High' ? 'active' : ''}`, onClick: () => setPriority('High'), disabled: isEditMode && isViewMode, children: "High" })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label-with-icon", children: [jsx(MessageSquare, { size: 16 }), jsx("span", { children: "Comments" })] }), !comments && (jsx("div", { className: "raise-issue-no-comments", children: "No comments yet" })), jsx("textarea", { className: `raise-issue-field-textarea raise-issue-comments-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: comments, onChange: (e) => setComments(e.target.value), placeholder: "Add a comment...", rows: 4, readOnly: isEditMode })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", style: { marginTop: '1rem' }, children: [jsx("label", { className: "raise-issue-field-label", children: "Attachments" }), jsxs("div", { className: "raise-issue-attachments-container", children: [!isEditMode && (jsxs("div", { className: `raise-issue-dropzone ${isDragging ? 'dragging' : ''}`, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: () => fileInputRef.current?.click(), children: [jsx("input", { type: "file", ref: fileInputRef, style: { display: 'none' }, onChange: handleFileChange, multiple: true }), jsx("div", { className: "raise-issue-dropzone-icon", children: jsx(UploadCloud, { size: 24 }) }), jsx("div", { className: "raise-issue-dropzone-text", children: "Click to upload or drag and drop" }), jsx("div", { className: "raise-issue-dropzone-hint", children: "PNG, JPG up to 10MB" })] })), localAttachments.length > 0 && (jsx("div", { className: "raise-issue-attachments-list", children: localAttachments.map((file, index) => (jsxs("div", { className: "raise-issue-attachment-item", children: [jsx("div", { className: "raise-issue-attachment-thumbnail", children: getAttachmentPreview(file) ? (jsx("img", { src: getAttachmentPreview(file), alt: "Thumbnail" })) : (jsx(Paperclip, { size: 20, color: "#9ca3af" })) }), jsxs("div", { className: "raise-issue-attachment-info", children: [jsx("span", { className: "attachment-name", title: getAttachmentName(file), children: getAttachmentName(file) }), file instanceof File && (jsxs("span", { className: "attachment-size", children: [(file.size / 1024).toFixed(1), " KB"] }))] }), !isEditMode && (jsx("button", { type: "button", className: "attachment-remove-btn", onClick: () => handleRemoveAttachment(index), title: "Remove", children: jsx(X$1, { size: 12 }) }))] }, index))) }))] })] })] }) }), jsx("div", { className: "raise-issue-modal-actions", children: jsxs("div", { className: "raise-issue-modal-actions-buttons", children: [(showWorkflowActions && issue) && (jsxs(Fragment, { children: [status === EIssueStatus.OPEN && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-accept", onClick: handleAccept, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Accept' })), status === EIssueStatus.IN_PROGRESS && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-resolve", onClick: handleResolve, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Resolve' })), (status === EIssueStatus.OPEN) && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-reject", onClick: handleReject, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Reject' }))] })), !isEditMode && (jsx("button", { className: `raise-issue-modal-button raise-issue-modal-button-save ${!isFormValid ? 'disabled' : ''}`, onClick: handleSubmit, disabled: isSubmitting || !isFormValid, children: isSubmitting ? 'Creating...' : 'Create Issue' }))] }) })] }) }));
|
|
755
|
+
}) })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Description ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("textarea", { className: `raise-issue-field-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: description, onChange: (e) => setDescription(e.target.value), placeholder: "Enter issue description", rows: 4, readOnly: isEditMode && isViewMode })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Status ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: status, readOnly: true })] }), jsxs("div", { className: "raise-issue-field", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Assign to ", jsx("span", { className: "raise-issue-required", children: "*" })] }), isEditMode ? (jsx("input", { type: "text", className: "raise-issue-field-input raise-issue-field-readonly", value: assignee || 'Unassigned', readOnly: true })) : (jsxs("select", { className: "raise-issue-field-select", value: assignee, onChange: (e) => setAssignee(e.target.value), disabled: isEditMode && isViewMode, children: [jsx("option", { value: "", children: "Unassigned" }), availableUsers.map((userName) => (jsx("option", { value: userName, children: userName }, userName)))] }))] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label", children: ["Priority ", jsx("span", { className: "raise-issue-required", children: "*" })] }), jsxs("div", { className: "raise-issue-priority-buttons", children: [jsx("button", { type: "button", className: `priority-button priority-low ${priority === 'Low' ? 'active' : ''}`, onClick: () => setPriority('Low'), disabled: isEditMode && isViewMode, children: "Low" }), jsx("button", { type: "button", className: `priority-button priority-medium ${priority === 'Medium' ? 'active' : ''}`, onClick: () => setPriority('Medium'), disabled: isEditMode && isViewMode, children: "Medium" }), jsx("button", { type: "button", className: `priority-button priority-high ${priority === 'High' ? 'active' : ''}`, onClick: () => setPriority('High'), disabled: isEditMode && isViewMode, children: "High" })] })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", children: [jsxs("label", { className: "raise-issue-field-label-with-icon", children: [jsx(MessageSquare, { size: 16 }), jsx("span", { children: "Comments" })] }), !comments && (jsx("div", { className: "raise-issue-no-comments", children: "No comments yet" })), jsx("textarea", { className: `raise-issue-field-textarea raise-issue-comments-textarea ${isEditMode ? 'raise-issue-field-readonly' : ''}`, value: comments, onChange: (e) => setComments(e.target.value), placeholder: "Add a comment...", rows: 4, readOnly: isEditMode })] }), jsxs("div", { className: "raise-issue-field raise-issue-field-full-width", style: { marginTop: '1rem' }, children: [jsx("label", { className: "raise-issue-field-label", children: "Attachments" }), jsxs("div", { className: "raise-issue-attachments-container", children: [!isEditMode && (jsxs("div", { className: `raise-issue-dropzone ${isDragging ? 'dragging' : ''}`, onDragOver: handleDragOver, onDragLeave: handleDragLeave, onDrop: handleDrop, onClick: () => fileInputRef.current?.click(), children: [jsx("input", { type: "file", ref: fileInputRef, style: { display: 'none' }, onChange: handleFileChange, multiple: true }), jsx("div", { className: "raise-issue-dropzone-icon", children: jsx(UploadCloud, { size: 24 }) }), jsx("div", { className: "raise-issue-dropzone-text", children: "Click to upload or drag and drop" }), jsx("div", { className: "raise-issue-dropzone-hint", children: "PNG, JPG up to 10MB" })] })), localAttachments.length > 0 && (jsx("div", { className: "raise-issue-attachments-list", children: localAttachments.map((file, index) => (jsxs("div", { className: "raise-issue-attachment-item", children: [jsx("div", { className: "raise-issue-attachment-thumbnail", children: getAttachmentPreview(file) ? (jsx("img", { src: getAttachmentPreview(file), alt: "Thumbnail" })) : (jsx(Paperclip, { size: 20, color: "#9ca3af" })) }), jsxs("div", { className: "raise-issue-attachment-info", children: [jsx("span", { className: "attachment-name", title: getAttachmentName(file), children: getAttachmentName(file) }), file instanceof File && (jsxs("span", { className: "attachment-size", children: [(file.size / 1024).toFixed(1), " KB"] }))] }), !isEditMode && (jsx("button", { type: "button", className: "attachment-remove-btn", onClick: () => handleRemoveAttachment(index), title: "Remove", children: jsx(X$1, { size: 12 }) }))] }, index))) }))] })] })] }) }), jsx("div", { className: "raise-issue-modal-actions", children: jsxs("div", { className: "raise-issue-modal-actions-buttons", children: [(showWorkflowActions && issue) && (jsxs(Fragment, { children: [status === EIssueStatus.OPEN && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-accept", onClick: handleAccept, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Accept' })), status === EIssueStatus.IN_PROGRESS && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-resolve", onClick: handleResolve, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Resolve' })), (status === EIssueStatus.OPEN) && (jsx("button", { className: "raise-issue-modal-button raise-issue-modal-button-reject", onClick: handleReject, disabled: isSubmitting, children: isSubmitting ? 'Processing...' : 'Reject' }))] })), !isEditMode && (jsx("button", { className: `raise-issue-modal-button raise-issue-modal-button-save ${!isFormValid ? 'disabled' : ''}`, onClick: handleSubmit, disabled: isSubmitting || !isFormValid, children: isSubmitting ? 'Creating...' : 'Create Issue' }))] }) })] }) }));
|
|
695
756
|
// Render modal using portal to document body for full-page overlay
|
|
696
757
|
return createPortal(modalContent, document.body);
|
|
697
758
|
};
|
|
@@ -4234,7 +4295,7 @@ const ComponentActionFeatures = ({ component, mode, formTemplateId, formValue, f
|
|
|
4234
4295
|
modalComponent.basic.value = selectedOption.value || effectiveValue;
|
|
4235
4296
|
}
|
|
4236
4297
|
return modalComponent;
|
|
4237
|
-
})(), formTemplateId: formTemplateId || '', notes: localNotes, attachments: localAttachments, isStandalone: isStandalone, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }))] }));
|
|
4298
|
+
})(), formTemplateId: formTemplateId || '', notes: localNotes, attachments: localAttachments, isStandalone: isStandalone, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })), console.log('ComponentActionFeatures - isStandalone:', isStandalone, 'workOrderNumber:', workOrderNumber, 'assetNumber:', assetNumber)] }));
|
|
4238
4299
|
};
|
|
4239
4300
|
|
|
4240
4301
|
// Attachment Thumbnails Component for Submission View
|
|
@@ -5138,7 +5199,7 @@ const DfFormDataGrid = ({ id, properties, mode = 'edit', formData = {}, onValueC
|
|
|
5138
5199
|
templateComponents: gridComponents, dataEntries: dataEntries, renderFormComponent: renderFormComponent || renderComponent, mode: mode, allowAddRemoveEntries: properties.datagrid?.allowAddRemoveEntries ?? true, addAnotherText: properties.datagrid?.addAnotherText ?? 'Add Entry', removeText: properties.datagrid?.removeText ?? 'Remove', maxEntries: properties.datagrid?.maxEntries ?? 10, minEntries: properties.datagrid?.minEntries ?? 1, displayAsGrid: properties.datagrid?.displayAsGrid ?? true, onAddEntry: handleAddEntry, onRemoveEntry: handleRemoveEntry, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, columnView: properties.datagrid?.columnView, shouldShowComponent: shouldShowComponent })) }))] }));
|
|
5139
5200
|
};
|
|
5140
5201
|
|
|
5141
|
-
const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDelete, renderFormComponent, isOverlay = false, isChildrenEditMode = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
|
|
5202
|
+
const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDelete, renderFormComponent, isOverlay = false, isChildrenEditMode = false, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode, isStandalone }) => {
|
|
5142
5203
|
const formValue = formData[child.id];
|
|
5143
5204
|
// Check if component has notes or attachments for submission view
|
|
5144
5205
|
const hasSubmissionData = mode === 'preview' && ((child.basic?.notes && child.basic.notes.trim().length > 0) ||
|
|
@@ -5156,9 +5217,9 @@ const DraggableChild = ({ child, selectedChild, mode, onChildSelect, onChildDele
|
|
|
5156
5217
|
return (jsxs("div", { ref: setNodeRef, style: style, className: `form-component section-child ${selectedChild?.id === child.id ? 'selected' : ''} ${isDragging ? 'dragging' : ''} ${isSorting ? 'sorting' : ''} ${isChildrenEditMode ? 'children-edit-active' : ''}`, onClick: () => !isDragging && onChildSelect(child), role: "button", tabIndex: 0, children: [(mode === 'edit' || isChildrenEditMode) && (jsx("div", { className: "child-drag-handle", ...listeners, ...attributes, onClick: (e) => e.stopPropagation(), onMouseDown: (e) => e.stopPropagation(), children: jsx(GripVertical, { size: 14 }) })), jsxs("div", { className: "form-component-content section-child-content", children: [(mode === 'edit' || isChildrenEditMode) && (jsxs("div", { className: "component-actions child-actions", children: [jsx("button", { className: "btn edit-btn", onClick: (e) => {
|
|
5157
5218
|
e.stopPropagation();
|
|
5158
5219
|
onChildSelect(child);
|
|
5159
|
-
}, onMouseDown: (e) => e.stopPropagation(), title: "Edit properties", children: jsx(Edit, { size: 12 }) }), jsx("button", { className: "btn delete-btn", onClick: (e) => onChildDelete(child, e), onMouseDown: (e) => e.stopPropagation(), title: "Delete component", children: jsx(Trash2, { size: 12 }) })] })), jsxs("div", { className: "component-preview child-preview", children: [renderFormComponent(child), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(child.name) && (jsx(ComponentActionFeatures, { component: child, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(child.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(child.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: child }))] })] })] }));
|
|
5220
|
+
}, onMouseDown: (e) => e.stopPropagation(), title: "Edit properties", children: jsx(Edit, { size: 12 }) }), jsx("button", { className: "btn delete-btn", onClick: (e) => onChildDelete(child, e), onMouseDown: (e) => e.stopPropagation(), title: "Delete component", children: jsx(Trash2, { size: 12 }) })] })), jsxs("div", { className: "component-preview child-preview", children: [renderFormComponent(child), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(child.name) && (jsx(ComponentActionFeatures, { component: child, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(child.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(child.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, isStandalone: isStandalone })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: child }))] })] })] }));
|
|
5160
5221
|
};
|
|
5161
|
-
const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueChange, onSelect, isSelected = false, className = '', onSectionSelect, onChildSelect, onChildDelete, selectedChild, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
|
|
5222
|
+
const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueChange, onSelect, isSelected = false, className = '', onSectionSelect, onChildSelect, onChildDelete, selectedChild, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode, isStandalone }) => {
|
|
5162
5223
|
const [isCollapsed, setIsCollapsed] = useState(properties.basic.collapsed);
|
|
5163
5224
|
const [isEditingTitle, setIsEditingTitle] = useState(false);
|
|
5164
5225
|
const [isEditingDescription, setIsEditingDescription] = useState(false);
|
|
@@ -5371,7 +5432,7 @@ const DfFormSection = ({ id, properties, mode = 'edit', formData = {}, onValueCh
|
|
|
5371
5432
|
}, children: isOver ? 'Drop components here' : 'Empty Section' }), jsx("div", { style: {
|
|
5372
5433
|
fontSize: '12px',
|
|
5373
5434
|
color: '#9ca3af'
|
|
5374
|
-
}, children: "Drag and drop components here to create your section" })] })) : (children.map((child) => (jsx(DraggableChild, { child: child, selectedChild: selectedChild || null, mode: mode, onChildSelect: handleChildSelect, onChildDelete: handleChildDelete, renderFormComponent: renderComponent, isChildrenEditMode: isChildrenEditMode, formData: formData, formTemplateId: formTemplateId, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, child.id)))) }) }))] }));
|
|
5435
|
+
}, children: "Drag and drop components here to create your section" })] })) : (children.map((child) => (jsx(DraggableChild, { child: child, selectedChild: selectedChild || null, mode: mode, onChildSelect: handleChildSelect, onChildDelete: handleChildDelete, renderFormComponent: renderComponent, isChildrenEditMode: isChildrenEditMode, formData: formData, formTemplateId: formTemplateId, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, isStandalone: isStandalone }, child.id)))) }) }))] }));
|
|
5375
5436
|
};
|
|
5376
5437
|
|
|
5377
5438
|
// Dynamic imports to avoid circular dependencies
|
|
@@ -7281,12 +7342,12 @@ const ensureComponentHasId = (component) => {
|
|
|
7281
7342
|
}
|
|
7282
7343
|
return component;
|
|
7283
7344
|
};
|
|
7284
|
-
const SimpleTableComponent = ({ component, mode, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
|
|
7345
|
+
const SimpleTableComponent = ({ component, mode, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode, isStandalone }) => {
|
|
7285
7346
|
const formValue = formData[component.id];
|
|
7286
7347
|
// Check if component has notes or attachments for submission view
|
|
7287
7348
|
const hasSubmissionData = mode === 'preview' && ((component.basic?.notes && component.basic.notes.trim().length > 0) ||
|
|
7288
7349
|
(component.basic?.attachments && Array.isArray(component.basic.attachments) && component.basic.attachments.length > 0));
|
|
7289
|
-
return (jsxs("div", { className: "simple-table-component", children: [renderFormComponent(component), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(component.name) && (jsx(ComponentActionFeatures, { component: component, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(component.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(component.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }));
|
|
7350
|
+
return (jsxs("div", { className: "simple-table-component", children: [renderFormComponent(component), !['section', 'table', 'heading', 'file', 'instructions', 'signature', 'location', 'datagrid'].includes(component.name) && (jsx(ComponentActionFeatures, { component: component, mode: "test", formTemplateId: formTemplateId, formValue: formValue, formData: formData, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange ? (notes) => onNotesChange(component.id, notes) : undefined, onAttachmentChange: onAttachmentChange ? (attachments) => onAttachmentChange(component.id, attachments) : undefined, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, isStandalone: isStandalone })), hasSubmissionData && (jsx(ComponentSubmissionActions, { component: component }))] }));
|
|
7290
7351
|
};
|
|
7291
7352
|
const DraggableTableComponent = ({ component, selectedComponent, mode, onComponentSelect, onComponentDelete, onComponentEdit, renderFormComponent, isOverlay = false, }) => {
|
|
7292
7353
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging, isSorting, } = useSortable({
|
|
@@ -7307,7 +7368,7 @@ const DraggableTableComponent = ({ component, selectedComponent, mode, onCompone
|
|
|
7307
7368
|
onComponentDelete(component, e);
|
|
7308
7369
|
}, type: "button", title: "Delete Component", children: jsx(Trash2, { size: 12 }) })] }))] }));
|
|
7309
7370
|
};
|
|
7310
|
-
const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, tableId, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
|
|
7371
|
+
const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formData = {}, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, tableId, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode, isStandalone }) => {
|
|
7311
7372
|
const dropZoneId = `table-cell-${tableId}-${cell.row}-${cell.column}`;
|
|
7312
7373
|
const { setNodeRef, isOver } = useDroppable({
|
|
7313
7374
|
id: dropZoneId,
|
|
@@ -7342,7 +7403,7 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7342
7403
|
cell.components.map((component) => {
|
|
7343
7404
|
// Only ensure ID if it's truly missing - don't regenerate existing IDs
|
|
7344
7405
|
const componentWithId = component.id ? component : ensureComponentHasId(component);
|
|
7345
|
-
return (jsx(SimpleTableComponent, { component: componentWithId, mode: mode, renderFormComponent: renderFormComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, componentWithId.id));
|
|
7406
|
+
return (jsx(SimpleTableComponent, { component: componentWithId, mode: mode, renderFormComponent: renderFormComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, isStandalone: isStandalone }, componentWithId.id));
|
|
7346
7407
|
}))) : (
|
|
7347
7408
|
// Only show drop zone content in edit mode
|
|
7348
7409
|
mode === 'edit' ? (jsx("div", { className: "empty-cell-placeholder", children: jsxs("div", { className: "cell-info", children: [jsx("span", { className: "drop-zone-text", children: "Drag and Drop a form component" }), jsxs("span", { className: "cell-coordinates", children: ["Cell (", cell.row + 1, ", ", cell.column + 1, ")"] })] }) })) : (
|
|
@@ -7353,7 +7414,7 @@ const TableCellComponent = ({ cell, mode, onComponentSelect, onComponentDelete,
|
|
|
7353
7414
|
visibility: 'hidden' // Hide content but maintain space
|
|
7354
7415
|
}, children: "\u00A0" }))) }) }));
|
|
7355
7416
|
};
|
|
7356
|
-
const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationErrors = {}, touchedFields = {}, formSubmitted = false, onValueChange, onSelect, isSelected = false, className = '', onTableSelect, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode }) => {
|
|
7417
|
+
const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationErrors = {}, touchedFields = {}, formSubmitted = false, onValueChange, onSelect, isSelected = false, className = '', onTableSelect, onComponentSelect, onComponentDelete, onComponentEdit, selectedComponent, renderFormComponent, formTemplateId, onThresholdActionCompletion, onThresholdIssueRaised, onNotesChange, onAttachmentChange, workOrderNumber, assetNumber, user, onCreateIssue, onUpdateIssue, allowWorkflowActions, inEditMode, isStandalone }) => {
|
|
7357
7418
|
const [isCollapsed, setIsCollapsed] = useState(false); // Always start expanded to show drop zones
|
|
7358
7419
|
// CRITICAL: Normalize cells from API format (object with numeric keys) to proper 2D array
|
|
7359
7420
|
// The API may return cells as [{"0": {cell}, "1": {cell}}, ...] instead of [[cell, cell], ...]
|
|
@@ -7591,7 +7652,7 @@ const DfFormTable = ({ id, properties, mode = 'edit', formData = {}, validationE
|
|
|
7591
7652
|
fontSize: '14px',
|
|
7592
7653
|
textAlign: 'center'
|
|
7593
7654
|
}, children: columnName }, `header-${colIndex}`));
|
|
7594
|
-
}) }) })), jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.map((cell) => (jsx(TableCellComponent, { cell: cell, mode: mode, onComponentSelect: onComponentSelect || (() => { }), onComponentDelete: handleComponentDelete, onComponentEdit: onComponentEdit, selectedComponent: selectedComponent || null, renderFormComponent: renderComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, tableId: id, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode }, cell.id))) }, rowIndex))) })] })] }))] }));
|
|
7655
|
+
}) }) })), jsx("tbody", { children: cellsWithIds.map((row, rowIndex) => (jsx("tr", { className: "table-row", children: row.map((cell) => (jsx(TableCellComponent, { cell: cell, mode: mode, onComponentSelect: onComponentSelect || (() => { }), onComponentDelete: handleComponentDelete, onComponentEdit: onComponentEdit, selectedComponent: selectedComponent || null, renderFormComponent: renderComponent, formData: formData, formTemplateId: formTemplateId, onThresholdActionCompletion: onThresholdActionCompletion, onThresholdIssueRaised: onThresholdIssueRaised, tableId: id, onNotesChange: onNotesChange, onAttachmentChange: onAttachmentChange, workOrderNumber: workOrderNumber, assetNumber: assetNumber, user: user, onCreateIssue: onCreateIssue, onUpdateIssue: onUpdateIssue, allowWorkflowActions: allowWorkflowActions, inEditMode: inEditMode, isStandalone: isStandalone }, cell.id))) }, rowIndex))) })] })] }))] }));
|
|
7595
7656
|
};
|
|
7596
7657
|
|
|
7597
7658
|
var dfFormTable = /*#__PURE__*/Object.freeze({
|