diff --git a/src/extensions/savetoLaserfiche/CommonDialogs.tsx b/src/extensions/savetoLaserfiche/CommonDialogs.tsx
index 8c1bd7c..b7dcc52 100644
--- a/src/extensions/savetoLaserfiche/CommonDialogs.tsx
+++ b/src/extensions/savetoLaserfiche/CommonDialogs.tsx
@@ -18,12 +18,12 @@ export default function LoadingDialog(): JSX.Element {
const DOCUMENT_SUCCESSFULLY_UPLOADED_TO_LASERFICHE_WITH_NAME =
'Document successfully uploaded to Laserfiche with name:';
const METADATA_FAILED_TO_SAVE_INVALID_FIELD =
- 'All metadata failed to save due to at least one invalid field';
-const TEMPLATE_FIELDS_NOT_APPLIED =
- 'The Laserfiche template and fields were not applied to this document.';
+ 'All metadata failed to save due to at least one invalid field.';
const CLOSE = 'Close';
const VIEW_FILE_IN_LASERFICHE = 'View file in Laserfiche';
+const WARNING = 'Warning: ';
+const ERROR_DETAILS = 'Error details';
export function SavedToLaserficheSuccessDialogText(props: {
successfulSave: SavedToLaserficheDocumentData;
}): JSX.Element {
@@ -37,22 +37,61 @@ export function SavedToLaserficheSuccessDialogText(props: {
}, []);
const metadataFailedNotice: JSX.Element = (
-
- {METADATA_FAILED_TO_SAVE_INVALID_FIELD}
-
+
+ {isOpen && props.children}
+ >
+ );
+}
+
export function SavedToLaserficheSuccessDialogButtons(props: {
closeClick: () => Promise;
successfulSave: SavedToLaserficheDocumentData;
diff --git a/src/extensions/savetoLaserfiche/GetDocumentDataDialog.tsx b/src/extensions/savetoLaserfiche/GetDocumentDataDialog.tsx
index 9717eab..ae99b1b 100644
--- a/src/extensions/savetoLaserfiche/GetDocumentDataDialog.tsx
+++ b/src/extensions/savetoLaserfiche/GetDocumentDataDialog.tsx
@@ -87,10 +87,10 @@ export class GetDocumentDataCustomDialog extends BaseDialog {
}
}
-const FOLLOWING_SP_FIELDS_BLANK_MAPPED_TO_REQUIRED_LF_FIELDS =
- 'The following SharePoint field values are blank and are mapped to required Laserfiche fields:';
-const PLEASE_FILL_OUT_REQUIRED_FIELDS_TRY_AGAIN =
- 'Please fill out these required fields and try again.';
+const FOLLOWING_SP_FIELDS_NO_VALUE_FOR_DOC_BUT_REQUIRED_IN_LASERFICHE_BASED_ON_MAPPINGS =
+ 'The following SharePoint fields do not have a value for this document, but are required to save to Laserfiche, based on configured mappings:';
+const PLEASE_ENSURE_FIELDS_EXIST_FOR_DOCUMENT_AND_TRY_AGAIN =
+ 'Please ensure these fields exist for this document and try again.';
const CANCEL = 'Cancel';
@@ -111,15 +111,15 @@ function GetDocumentDialogData(props: {
if (missingFields) {
- {FOLLOWING_SP_FIELDS_BLANK_MAPPED_TO_REQUIRED_LF_FIELDS}
+ {FOLLOWING_SP_FIELDS_NO_VALUE_FOR_DOC_BUT_REQUIRED_IN_LASERFICHE_BASED_ON_MAPPINGS}
{missingFields}
- {PLEASE_FILL_OUT_REQUIRED_FIELDS_TRY_AGAIN}
+ {PLEASE_ENSURE_FIELDS_EXIST_FOR_DOCUMENT_AND_TRY_AGAIN}
;
}
- const listFields = missingFields?.map((field) => (
-
- {field.Title}
- ));
+ const listFields =
{missingFields?.map((field) => (
+
{field.Title}
+ ))}
;
React.useEffect(() => {
SPComponentLoader.loadCss(
@@ -367,8 +367,9 @@ function GetDocumentDialogData(props: {
fields: { [key: string]: FieldToUpdate }
): void {
for (const mapping of matchingLFConfig.mappedFields) {
- const spFieldName = mapping.spField.Title;
- let spDocFieldValue: string = allSpFieldValues[spFieldName];
+ const spFieldName = mapping.spField.InternalName;
+ // TODO which one to use?
+ let spDocFieldValue: string = allSpFieldValues[spFieldName] ?? allSpFieldValues[mapping.spField.Title];
if (spDocFieldValue?.length > 0) {
const lfField = mapping.lfField;
@@ -486,7 +487,7 @@ function GetDocumentDialogData(props: {
);
}
-function MissingFieldsDialog(props: { missingFields: JSX.Element[] }): JSX.Element {
+function MissingFieldsDialog(props: { missingFields: JSX.Element }): JSX.Element {
const textInside = (
The following SharePoint field values are blank and are mapped to required
diff --git a/src/extensions/savetoLaserfiche/SaveDocumentToLaserfiche.ts b/src/extensions/savetoLaserfiche/SaveDocumentToLaserfiche.tsx
similarity index 90%
rename from src/extensions/savetoLaserfiche/SaveDocumentToLaserfiche.ts
rename to src/extensions/savetoLaserfiche/SaveDocumentToLaserfiche.tsx
index 231cb5b..54a4b82 100644
--- a/src/extensions/savetoLaserfiche/SaveDocumentToLaserfiche.ts
+++ b/src/extensions/savetoLaserfiche/SaveDocumentToLaserfiche.tsx
@@ -7,6 +7,8 @@ import {
ValueToUpdate,
PutFieldValsRequest,
Entry,
+ SetFields,
+ APIServerException,
} from '@laserfiche/lf-repository-api-client';
import { RepositoryClientExInternal } from '../../repository-client/repository-client';
import { IRepositoryApiClientExInternal } from '../../repository-client/repository-client-types';
@@ -17,11 +19,14 @@ import { PathUtils } from '@laserfiche/lf-js-utils';
import { NgElement, WithProperties } from '@angular/elements';
import { LfLoginComponent } from '@laserfiche/types-lf-ui-components';
import { SP_LOCAL_STORAGE_KEY } from '../../webparts/constants';
+import * as React from 'react';
+import styles from './SendToLaserFiche.module.scss';
export interface SavedToLaserficheDocumentData {
fileLink: string;
pathBack: string;
metadataSaved: boolean;
+ failedMetadata?: JSX.Element;
fileName: string;
}
@@ -215,9 +220,16 @@ export class SaveDocumentToLaserfiche {
return fileInfo;
} catch (error) {
const conflict409 =
- error.operations.setFields.exceptions[0].statusCode === 409;
+ error.problemDetails.extensions.createEntryResult.operations.setFields
+ .exceptions[0].statusCode === 409;
if (conflict409) {
- const entryId = error.operations.entryCreate.entryId;
+ const setFields: SetFields = error.problemDetails.extensions.createEntryResult.operations.setFields;
+ const errorMessages = setFields.exceptions.map((value: APIServerException, index: number) => {
+ return