@leav/ui 1.7.0-67b86ab9 → 1.7.0-bba65313
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/_gqlTypes/index.d.ts +47 -2
- package/dist/_gqlTypes/index.js +21 -1
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js +2 -0
- package/dist/components/RecordEdition/EditRecordContent/antdUtils.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js +2 -0
- package/dist/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js +10 -2
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
- package/dist/components/RecordHistory/_queries/recordHistoryQuery.d.ts +7 -0
- package/dist/components/RecordHistory/_queries/recordHistoryQuery.js +64 -0
- package/dist/components/RecordHistory/_queries/recordHistoryQuery.js.map +1 -0
- package/dist/components/RecordHistory/hooks/useFetchRecordHistory.js +5 -2
- package/dist/components/RecordHistory/hooks/useFetchRecordHistory.js.map +1 -1
- package/dist/components/RecordHistory/utils/extendedAttribute.d.ts +11 -0
- package/dist/components/RecordHistory/utils/extendedAttribute.js +40 -0
- package/dist/components/RecordHistory/utils/extendedAttribute.js.map +1 -0
- package/dist/locales/en/shared.json +2 -1
- package/dist/locales/fr/shared.json +2 -1
- package/package.json +3 -3
|
@@ -18,6 +18,8 @@ const formatStandardInitialValue = (standardValue, attribute) => {
|
|
|
18
18
|
case AttributeFormat.rich_text:
|
|
19
19
|
case AttributeFormat.boolean:
|
|
20
20
|
return standardValue.raw_payload;
|
|
21
|
+
case AttributeFormat.extended:
|
|
22
|
+
return JSON.stringify(standardValue.raw_payload);
|
|
21
23
|
case AttributeFormat.numeric:
|
|
22
24
|
return Number(standardValue.raw_payload);
|
|
23
25
|
case AttributeFormat.date:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antdUtils.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordContent/antdUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CAAC,SAAkB,EAAgC,EAAE,CAC3E,SAA6B,CAAC,IAAI,KAAK,SAAS,IAAK,SAA6B,CAAC,EAAE,KAAK,SAAS,CAAC;AAEzG,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAE9E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAE5E,MAAM,iBAAiB,GAAG,MAAM,CAAC,EAAE,CAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC;AAElG,MAAM,kCAAkC,GAAG,CACvC,KAA8B,EAC9B,SAAqC,EACI,EAAE,CAC3C,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,WAAW;IAC5C,CAAC,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,aAAa,IAAI,SAAS,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC;AAE5F,MAAM,mCAAmC,GAAG,CACxC,MAAi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,eAAe;qBACV,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;qBACvD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,KAA6C,CAAC;IAEpE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,0BAA0B,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAEzE,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {\n type IRecordForm,\n type RecordFormElementAttribute,\n type RecordFormElementsValue,\n type RecordFormElementsValueLinkValue,\n type RecordFormElementsValueStandardValue,\n} from '_ui/hooks/useGetRecordForm';\nimport {AttributeFormat, AttributeType} from '_ui/_gqlTypes';\nimport {type IDateRangeValue} from '@leav/utils';\nimport {type Store} from 'antd/lib/form/interface';\nimport dayjs from 'dayjs';\n\nconst hasDateRangeValues = (dateRange: unknown): dateRange is IDateRangeValue =>\n (dateRange as IDateRangeValue).from !== undefined && (dateRange as IDateRangeValue).to !== undefined;\n\nconst getCalculatedValue = values => values.find(value => value.isCalculated);\n\nconst getInheritedValue = values => values.find(value => value.isInherited);\n\nconst getUserInputValue = values =>\n values.find(value => !value.isInherited && !value.isCalculated && value.raw_payload !== null);\n\nconst isRecordFormElementsValueLinkValue = (\n value: RecordFormElementsValue,\n attribute: RecordFormElementAttribute,\n): value is RecordFormElementsValueLinkValue =>\n attribute.type === AttributeType.simple_link ||\n (attribute.type === AttributeType.advanced_link && attribute.multiple_values === false);\n\nconst isRecordFormElementsValueLinkValues = (\n values: RecordFormElementsValue[],\n attribute: RecordFormElementAttribute,\n): values is RecordFormElementsValueLinkValue[] =>\n attribute.type === AttributeType.advanced_link && attribute.multiple_values === true;\n\nconst isRecordFormElementsMultipleValues = (attribute: RecordFormElementAttribute) =>\n attribute.type === AttributeType.advanced && attribute.multiple_values === true;\n\nconst formatStandardInitialValue = (\n standardValue: RecordFormElementsValueStandardValue,\n attribute: RecordFormElementAttribute,\n) => {\n if (!standardValue?.raw_payload) {\n return getEmptyInitialValue(attribute);\n }\n\n switch (attribute.format) {\n case AttributeFormat.color:\n case AttributeFormat.text:\n case AttributeFormat.rich_text:\n case AttributeFormat.boolean:\n return standardValue.raw_payload;\n case AttributeFormat.numeric:\n return Number(standardValue.raw_payload);\n case AttributeFormat.date:\n return dayjs.unix(Number(standardValue.raw_payload));\n case AttributeFormat.date_range:\n if (hasDateRangeValues(standardValue.raw_payload)) {\n return [\n dayjs.unix(Number(standardValue.raw_payload.from)),\n dayjs.unix(Number(standardValue.raw_payload.to)),\n ];\n } else if (typeof standardValue.raw_payload === 'string') {\n const convertedFieldValue = JSON.parse(standardValue.raw_payload) as any;\n return [dayjs.unix(Number(convertedFieldValue.from)), dayjs.unix(Number(convertedFieldValue.to))];\n }\n }\n};\n\nexport const EMPTY_INITIAL_VALUE_STRING = '';\nexport const EMPTY_INITIAL_VALUE_UNDEFINED = undefined;\n\nexport const getEmptyInitialValue = (attribute: RecordFormElementAttribute) => {\n if ([AttributeFormat.date_range, AttributeFormat.color].includes(attribute.format)) {\n return EMPTY_INITIAL_VALUE_UNDEFINED;\n }\n return EMPTY_INITIAL_VALUE_STRING;\n};\n\nexport const getAntdDisplayedValue = (\n values: RecordFormElementsValueStandardValue[],\n attribute: RecordFormElementAttribute,\n) =>\n formatStandardInitialValue(\n getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null,\n attribute,\n );\n\nexport const getAntdFormInitialValues = (recordForm: IRecordForm) =>\n recordForm.elements.reduce<Store>((acc, {attribute, values}) => {\n if (!attribute) {\n return acc;\n }\n\n const value = getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null;\n\n if (isRecordFormElementsValueLinkValue(value, attribute)) {\n acc[attribute.id] = value?.linkValue?.id;\n return acc;\n }\n\n if (isRecordFormElementsValueLinkValues(values, attribute)) {\n acc[attribute.id] = values.map(val => val?.linkValue?.id ?? undefined);\n return acc;\n }\n\n if (isRecordFormElementsMultipleValues(attribute)) {\n const userInputValues = values.filter(val => val.id_value);\n const calculatedValues = values.filter(val => val.isCalculated);\n const inheritedValues = values.filter(val => val.isInherited);\n\n const effectiveValues =\n userInputValues.length > 0\n ? userInputValues\n : calculatedValues.length > 0\n ? calculatedValues\n : inheritedValues.length > 0\n ? inheritedValues\n : [];\n\n acc[attribute.id] =\n effectiveValues.length === 0\n ? [getEmptyInitialValue(attribute)]\n : effectiveValues\n .sort((a, b) => Number(a.id_value) - Number(b.id_value))\n .map(val => formatStandardInitialValue(val, attribute));\n return acc;\n }\n\n const standardValue = value as RecordFormElementsValueStandardValue;\n\n acc[attribute.id] = formatStandardInitialValue(standardValue, attribute);\n\n return acc;\n }, {});\n"]}
|
|
1
|
+
{"version":3,"file":"antdUtils.js","sourceRoot":"","sources":["../../../../src/components/RecordEdition/EditRecordContent/antdUtils.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAG7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,kBAAkB,GAAG,CAAC,SAAkB,EAAgC,EAAE,CAC3E,SAA6B,CAAC,IAAI,KAAK,SAAS,IAAK,SAA6B,CAAC,EAAE,KAAK,SAAS,CAAC;AAEzG,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAE9E,MAAM,iBAA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AE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC3D,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChE,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAE9D,MAAM,eAAe,GACjB,eAAe,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC;gBAC3B,CAAC,CAAC,gBAAgB;gBAClB,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBAC1B,CAAC,CAAC,eAAe;oBACjB,CAAC,CAAC,EAAE,CAAC;QAEjB,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACb,eAAe,CAAC,MAAM,KAAK,CAAC;gBACxB,CAAC,CAAC,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;gBACnC,CAAC,CAAC,eAAe;qBACV,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;qBACvD,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,KAA6C,CAAC;IAEpE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,0BAA0B,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAEzE,OAAO,GAAG,CAAC;AACf,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {\n type IRecordForm,\n type RecordFormElementAttribute,\n type RecordFormElementsValue,\n type RecordFormElementsValueLinkValue,\n type RecordFormElementsValueStandardValue,\n} from '_ui/hooks/useGetRecordForm';\nimport {AttributeFormat, AttributeType} from '_ui/_gqlTypes';\nimport {type IDateRangeValue} from '@leav/utils';\nimport {type Store} from 'antd/lib/form/interface';\nimport dayjs from 'dayjs';\n\nconst hasDateRangeValues = (dateRange: unknown): dateRange is IDateRangeValue =>\n (dateRange as IDateRangeValue).from !== undefined && (dateRange as IDateRangeValue).to !== undefined;\n\nconst getCalculatedValue = values => values.find(value => value.isCalculated);\n\nconst getInheritedValue = values => values.find(value => value.isInherited);\n\nconst getUserInputValue = values =>\n values.find(value => !value.isInherited && !value.isCalculated && value.raw_payload !== null);\n\nconst isRecordFormElementsValueLinkValue = (\n value: RecordFormElementsValue,\n attribute: RecordFormElementAttribute,\n): value is RecordFormElementsValueLinkValue =>\n attribute.type === AttributeType.simple_link ||\n (attribute.type === AttributeType.advanced_link && attribute.multiple_values === false);\n\nconst isRecordFormElementsValueLinkValues = (\n values: RecordFormElementsValue[],\n attribute: RecordFormElementAttribute,\n): values is RecordFormElementsValueLinkValue[] =>\n attribute.type === AttributeType.advanced_link && attribute.multiple_values === true;\n\nconst isRecordFormElementsMultipleValues = (attribute: RecordFormElementAttribute) =>\n attribute.type === AttributeType.advanced && attribute.multiple_values === true;\n\nconst formatStandardInitialValue = (\n standardValue: RecordFormElementsValueStandardValue,\n attribute: RecordFormElementAttribute,\n) => {\n if (!standardValue?.raw_payload) {\n return getEmptyInitialValue(attribute);\n }\n\n switch (attribute.format) {\n case AttributeFormat.color:\n case AttributeFormat.text:\n case AttributeFormat.rich_text:\n case AttributeFormat.boolean:\n return standardValue.raw_payload;\n case AttributeFormat.extended:\n return JSON.stringify(standardValue.raw_payload);\n case AttributeFormat.numeric:\n return Number(standardValue.raw_payload);\n case AttributeFormat.date:\n return dayjs.unix(Number(standardValue.raw_payload));\n case AttributeFormat.date_range:\n if (hasDateRangeValues(standardValue.raw_payload)) {\n return [\n dayjs.unix(Number(standardValue.raw_payload.from)),\n dayjs.unix(Number(standardValue.raw_payload.to)),\n ];\n } else if (typeof standardValue.raw_payload === 'string') {\n const convertedFieldValue = JSON.parse(standardValue.raw_payload) as any;\n return [dayjs.unix(Number(convertedFieldValue.from)), dayjs.unix(Number(convertedFieldValue.to))];\n }\n }\n};\n\nexport const EMPTY_INITIAL_VALUE_STRING = '';\nexport const EMPTY_INITIAL_VALUE_UNDEFINED = undefined;\n\nexport const getEmptyInitialValue = (attribute: RecordFormElementAttribute) => {\n if ([AttributeFormat.date_range, AttributeFormat.color].includes(attribute.format)) {\n return EMPTY_INITIAL_VALUE_UNDEFINED;\n }\n return EMPTY_INITIAL_VALUE_STRING;\n};\n\nexport const getAntdDisplayedValue = (\n values: RecordFormElementsValueStandardValue[],\n attribute: RecordFormElementAttribute,\n) =>\n formatStandardInitialValue(\n getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null,\n attribute,\n );\n\nexport const getAntdFormInitialValues = (recordForm: IRecordForm) =>\n recordForm.elements.reduce<Store>((acc, {attribute, values}) => {\n if (!attribute) {\n return acc;\n }\n\n const value = getUserInputValue(values) ?? getInheritedValue(values) ?? getCalculatedValue(values) ?? null;\n\n if (isRecordFormElementsValueLinkValue(value, attribute)) {\n acc[attribute.id] = value?.linkValue?.id;\n return acc;\n }\n\n if (isRecordFormElementsValueLinkValues(values, attribute)) {\n acc[attribute.id] = values.map(val => val?.linkValue?.id ?? undefined);\n return acc;\n }\n\n if (isRecordFormElementsMultipleValues(attribute)) {\n const userInputValues = values.filter(val => val.id_value);\n const calculatedValues = values.filter(val => val.isCalculated);\n const inheritedValues = values.filter(val => val.isInherited);\n\n const effectiveValues =\n userInputValues.length > 0\n ? userInputValues\n : calculatedValues.length > 0\n ? calculatedValues\n : inheritedValues.length > 0\n ? inheritedValues\n : [];\n\n acc[attribute.id] =\n effectiveValues.length === 0\n ? [getEmptyInitialValue(attribute)]\n : effectiveValues\n .sort((a, b) => Number(a.id_value) - Number(b.id_value))\n .map(val => formatStandardInitialValue(val, attribute));\n return acc;\n }\n\n const standardValue = value as RecordFormElementsValueStandardValue;\n\n acc[attribute.id] = formatStandardInitialValue(standardValue, attribute);\n\n return acc;\n }, {});\n"]}
|
|
@@ -65,6 +65,6 @@ export const DSRichTextWrapper = ({ value, presentationValue, isLastValueOfMulti
|
|
|
65
65
|
setHasChanged(true);
|
|
66
66
|
onChange(inputValue);
|
|
67
67
|
};
|
|
68
|
-
return (_jsx(KitRichText, { id: attribute.id, autoFocus: isFocused, helper: isErrors ? String(errors[0]) : undefined, status: isErrors ? 'error' : undefined, value: valueToDisplay, readonly: readonly, onChange: _handleOnChange, onFocus: _handleFocus, onBlur: _handleOnBlur, placeholder: t('record_edition.placeholder.enter_a_text'), maxLength: attribute.character_limit ?? undefined, showCount: true }));
|
|
68
|
+
return (_jsx(KitRichText, { id: attribute.id, style: { width: '100%', height: '100%' }, autoFocus: isFocused, helper: isErrors ? String(errors[0]) : undefined, status: isErrors ? 'error' : undefined, value: valueToDisplay, readonly: readonly, onChange: _handleOnChange, onFocus: _handleFocus, onBlur: _handleOnBlur, placeholder: t('record_edition.placeholder.enter_a_text'), maxLength: attribute.character_limit ?? undefined, showCount: true }));
|
|
69
69
|
};
|
|
70
70
|
//# sourceMappingURL=DSRichTextWrapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DSRichTextWrapper.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAC,WAAW,EAA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AAiB,IAAI,eAAe,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACrG,kCAAkC,EAAE,CAAC;YACrC,OAAO;QACX,CAAC;QAED,QAAQ,CAAC,aAAa,CAAC,CAAC;QACxB,MAAM,YAAY,CAAC,aAAa,EAAE,SAAS,CAAC,EAAE,CAAC,CAAC;QAChD,YAAY,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,UAAU,CAAC,EAAE;QACjC,aAAa,CAAC,IAAI,CAAC,CAAC;QACpB,QAAQ,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,OAAO,CACH,KAAC,WAAW,IACR,EAAE,EAAE,SAAS,CAAC,EAAE,EAChB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACtC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,CAAC,CAAC,yCAAyC,CAAC,EACzD,SAAS,EAAE,SAAS,CAAC,eAAe,IAAI,SAAS,EACjD,SAAS,SACX,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useState} from 'react';\nimport {Form} from 'antd';\nimport {KitRichText} from 'aristid-ds';\nimport {type IStandFieldValueContentProps} from './_types';\nimport {type KitRichTextProps} from 'aristid-ds/dist/Kit/DataEntry/RichText/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {EMPTY_INITIAL_VALUE_STRING} from '../../../antdUtils';\n\nconst LEADING_EMPTY_P_TAG = /^<p>(\\s| )*<\\/p>/;\nconst TRAILING_EMPTY_P_TAG = /(<p>(\\s| )*<\\/p>)+$/;\n\nconst cleanRichTextValue = (value: string) => {\n if (!value) {\n return null;\n }\n const cleanedValue = value.replace(LEADING_EMPTY_P_TAG, '').replace(TRAILING_EMPTY_P_TAG, '').trim();\n\n return cleanedValue === '' ? null : cleanedValue;\n};\n\nexport const DSRichTextWrapper: FunctionComponent<IStandFieldValueContentProps<KitRichTextProps>> = ({\n value,\n presentationValue,\n isLastValueOfMultivalues,\n removeLastValueOfMultivalues,\n onChange,\n attribute,\n readonly,\n handleSubmit,\n calculatedFlags,\n inheritedFlags,\n}) => {\n if (!onChange) {\n throw Error('DSRichTextWrapper should be used inside a antd Form.Item');\n }\n\n const isNewValueOfMultivalues = isLastValueOfMultivalues && value === EMPTY_INITIAL_VALUE_STRING;\n const focusedDefaultValue = attribute.multiple_values ? isNewValueOfMultivalues : false;\n\n const [hasChanged, setHasChanged] = useState(false);\n const [isFocused, setIsFocused] = useState(focusedDefaultValue);\n const {errors} = Form.Item.useStatus();\n const {t} = useSharedTranslation();\n\n const isErrors = errors.length > 0;\n const valueToDisplay = isFocused || isErrors || !presentationValue ? value : presentationValue;\n\n // TODO: Remove inheritedValues[0] and calculatedValues[0] when we will have a proper way to override multiple values. For now, those attributes are set in readonly mode.\n const _resetToInheritedOrCalculatedValue = async () => {\n setHasChanged(false);\n if (inheritedFlags.isInheritedValues) {\n onChange(inheritedFlags.inheritedValues[0].raw_payload);\n } else if (calculatedFlags.isCalculatedValues) {\n onChange(calculatedFlags.calculatedValues[0].raw_payload);\n }\n await handleSubmit(null, attribute.id);\n };\n\n const _handleFocus = () => {\n setIsFocused(true);\n };\n\n const _handleOnBlur = async (inputValue: string) => {\n setHasChanged(false);\n const valueToSubmit = cleanRichTextValue(inputValue);\n if (!hasChanged) {\n onChange(valueToSubmit);\n setIsFocused(false);\n\n if (isNewValueOfMultivalues) {\n removeLastValueOfMultivalues();\n }\n return;\n }\n\n if (valueToSubmit === null && (inheritedFlags.isInheritedValues || calculatedFlags.isCalculatedValues)) {\n _resetToInheritedOrCalculatedValue();\n return;\n }\n\n onChange(valueToSubmit);\n await handleSubmit(valueToSubmit, attribute.id);\n setIsFocused(false);\n };\n\n const _handleOnChange = inputValue => {\n setHasChanged(true);\n onChange(inputValue);\n };\n\n return (\n <KitRichText\n id={attribute.id}\n autoFocus={isFocused}\n helper={isErrors ? String(errors[0]) : undefined}\n status={isErrors ? 'error' : undefined}\n value={valueToDisplay}\n readonly={readonly}\n onChange={_handleOnChange}\n onFocus={_handleFocus}\n onBlur={_handleOnBlur}\n placeholder={t('record_edition.placeholder.enter_a_text')}\n maxLength={attribute.character_limit ?? undefined}\n showCount\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"DSRichTextWrapper.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/DSRichTextWrapper.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AAGvC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,0BAA0B,EAAC,MAAM,oBAAoB,CAAC;AAE9D,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AACpD,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAExD,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,EAAE;IACzC,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,mBAA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CAAC;IAEF,OAAO,CACH,KAAC,WAAW,IACR,EAAE,EAAE,SAAS,CAAC,EAAE,EAChB,KAAK,EAAE,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAC,EACtC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAChD,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EACtC,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,CAAC,CAAC,yCAAyC,CAAC,EACzD,SAAS,EAAE,SAAS,CAAC,eAAe,IAAI,SAAS,EACjD,SAAS,SACX,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useState} from 'react';\nimport {Form} from 'antd';\nimport {KitRichText} from 'aristid-ds';\nimport {type IStandFieldValueContentProps} from './_types';\nimport {type KitRichTextProps} from 'aristid-ds/dist/Kit/DataEntry/RichText/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {EMPTY_INITIAL_VALUE_STRING} from '../../../antdUtils';\n\nconst LEADING_EMPTY_P_TAG = /^<p>(\\s| )*<\\/p>/;\nconst TRAILING_EMPTY_P_TAG = /(<p>(\\s| )*<\\/p>)+$/;\n\nconst cleanRichTextValue = (value: string) => {\n if (!value) {\n return null;\n }\n const cleanedValue = value.replace(LEADING_EMPTY_P_TAG, '').replace(TRAILING_EMPTY_P_TAG, '').trim();\n\n return cleanedValue === '' ? null : cleanedValue;\n};\n\nexport const DSRichTextWrapper: FunctionComponent<IStandFieldValueContentProps<KitRichTextProps>> = ({\n value,\n presentationValue,\n isLastValueOfMultivalues,\n removeLastValueOfMultivalues,\n onChange,\n attribute,\n readonly,\n handleSubmit,\n calculatedFlags,\n inheritedFlags,\n}) => {\n if (!onChange) {\n throw Error('DSRichTextWrapper should be used inside a antd Form.Item');\n }\n\n const isNewValueOfMultivalues = isLastValueOfMultivalues && value === EMPTY_INITIAL_VALUE_STRING;\n const focusedDefaultValue = attribute.multiple_values ? isNewValueOfMultivalues : false;\n\n const [hasChanged, setHasChanged] = useState(false);\n const [isFocused, setIsFocused] = useState(focusedDefaultValue);\n const {errors} = Form.Item.useStatus();\n const {t} = useSharedTranslation();\n\n const isErrors = errors.length > 0;\n const valueToDisplay = isFocused || isErrors || !presentationValue ? value : presentationValue;\n\n // TODO: Remove inheritedValues[0] and calculatedValues[0] when we will have a proper way to override multiple values. For now, those attributes are set in readonly mode.\n const _resetToInheritedOrCalculatedValue = async () => {\n setHasChanged(false);\n if (inheritedFlags.isInheritedValues) {\n onChange(inheritedFlags.inheritedValues[0].raw_payload);\n } else if (calculatedFlags.isCalculatedValues) {\n onChange(calculatedFlags.calculatedValues[0].raw_payload);\n }\n await handleSubmit(null, attribute.id);\n };\n\n const _handleFocus = () => {\n setIsFocused(true);\n };\n\n const _handleOnBlur = async (inputValue: string) => {\n setHasChanged(false);\n const valueToSubmit = cleanRichTextValue(inputValue);\n if (!hasChanged) {\n onChange(valueToSubmit);\n setIsFocused(false);\n\n if (isNewValueOfMultivalues) {\n removeLastValueOfMultivalues();\n }\n return;\n }\n\n if (valueToSubmit === null && (inheritedFlags.isInheritedValues || calculatedFlags.isCalculatedValues)) {\n _resetToInheritedOrCalculatedValue();\n return;\n }\n\n onChange(valueToSubmit);\n await handleSubmit(valueToSubmit, attribute.id);\n setIsFocused(false);\n };\n\n const _handleOnChange = inputValue => {\n setHasChanged(true);\n onChange(inputValue);\n };\n\n return (\n <KitRichText\n id={attribute.id}\n style={{width: '100%', height: '100%'}}\n autoFocus={isFocused}\n helper={isErrors ? String(errors[0]) : undefined}\n status={isErrors ? 'error' : undefined}\n value={valueToDisplay}\n readonly={readonly}\n onChange={_handleOnChange}\n onFocus={_handleFocus}\n onBlur={_handleOnBlur}\n placeholder={t('record_edition.placeholder.enter_a_text')}\n maxLength={attribute.character_limit ?? undefined}\n showCount\n />\n );\n};\n"]}
|
|
@@ -21,6 +21,7 @@ function StandardFieldValue({ presentationValue, handleSubmit, attribute, label,
|
|
|
21
21
|
AttributeFormat.boolean,
|
|
22
22
|
AttributeFormat.rich_text,
|
|
23
23
|
AttributeFormat.color,
|
|
24
|
+
AttributeFormat.extended,
|
|
24
25
|
];
|
|
25
26
|
const commonProps = {
|
|
26
27
|
handleSubmit,
|
|
@@ -40,6 +41,7 @@ function StandardFieldValue({ presentationValue, handleSubmit, attribute, label,
|
|
|
40
41
|
else {
|
|
41
42
|
switch (attribute.format) {
|
|
42
43
|
case AttributeFormat.text:
|
|
44
|
+
case AttributeFormat.extended:
|
|
43
45
|
valueContent = _jsx(DSInputWrapper, { ...commonProps });
|
|
44
46
|
break;
|
|
45
47
|
case AttributeFormat.date:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StandardFieldValue.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,IAAI,EAAyB,MAAM,MAAM,CAAC;AAGlD,OAAO,EAAC,eAAe,EAAoD,MAAM,eAAe,CAAC;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAgB5D,SAAS,kBAAkB,CAAC,EACxB,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,KAAK,EACL,QAAQ,EACR,eAAe,EACf,cAAc,EACd,SAAS,EACT,4BAA4B,EAC5B,wBAAwB,GAAG,KAAK,GACT;IACvB,MAAM,mBAAmB,GAAG,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,MAAM,CAAC;IAE7D,MAAM,sBAAsB,GAAG;QAC3B,eAAe,CAAC,IAAI;QACpB,eAAe,CAAC,UAAU;QAC1B,eAAe,CAAC,OAAO;QACvB,eAAe,CAAC,SAAS;QACzB,eAAe,CAAC,IAAI;QACpB,eAAe,CAAC,OAAO;QACvB,eAAe,CAAC,SAAS;QACzB,eAAe,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"StandardFieldValue.js","sourceRoot":"","sources":["../../../../../../../src/components/RecordEdition/EditRecordContent/uiElements/StandardField/StandardFieldValue/StandardFieldValue.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAC,IAAI,EAAyB,MAAM,MAAM,CAAC;AAGlD,OAAO,EAAC,eAAe,EAAoD,MAAM,eAAe,CAAC;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAC,uBAAuB,EAAC,MAAM,2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ACxD,MAAM;YACV,KAAK,eAAe,CAAC,UAAU;gBAC3B,YAAY,GAAG,KAAC,oBAAoB,OAAK,WAAW,GAAI,CAAC;gBACzD,MAAM;YACV,KAAK,eAAe,CAAC,OAAO;gBACxB,YAAY,GAAG,KAAC,oBAAoB,OAAK,WAAW,GAAI,CAAC;gBACzD,MAAM;YACV,KAAK,eAAe,CAAC,SAAS;gBAC1B,YAAY,GAAG,KAAC,uBAAuB,OAAK,WAAW,GAAI,CAAC;gBAC5D,MAAM;YACV,KAAK,eAAe,CAAC,OAAO;gBACxB,YAAY,GAAG,KAAC,gBAAgB,OAAK,WAAW,GAAI,CAAC;gBACrD,MAAM;YACV,KAAK,eAAe,CAAC,SAAS;gBAC1B,YAAY,GAAG,KAAC,iBAAiB,OAAK,WAAW,GAAI,CAAC;gBACtD,MAAM;YACV,KAAK,eAAe,CAAC,KAAK;gBACtB,YAAY,GAAG,KAAC,oBAAoB,OAAK,WAAW,GAAI,CAAC;QACjE,CAAC;IACL,CAAC;IAED,OAAO,CACH,sBAAsB,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CACjD,KAAC,IAAI,CAAC,IAAI,IAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAM,SAAS,EAAE,OAAO,kBAChD,YAAY,GACL,CACf,CACJ,CAAC;AACN,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type AnyPrimitive} from '@leav/utils';\nimport {Form, type FormListFieldData} from 'antd';\nimport {type ReactNode} from 'react';\nimport {type ISubmitMultipleResult} from '_ui/components/RecordEdition/EditRecordContent/_types';\nimport {AttributeFormat, type RecordFormAttributeStandardAttributeFragment} from '_ui/_gqlTypes';\nimport {DSListSelect} from './ValuesList/DSListSelect';\nimport {DSInputWrapper} from './DSInputWrapper';\nimport {DSDatePickerWrapper} from './DSDatePickerWrapper';\nimport {DSRangePickerWrapper} from './DSRangePickerWrapper';\nimport {DSInputNumberWrapper} from './DSInputNumberWrapper';\nimport {DSInputEncryptedWrapper} from './DSInputEncryptedWrapper';\nimport {DSBooleanWrapper} from './DSBooleanWrapper';\nimport {DSRichTextWrapper} from './DSRichTextWrapper';\nimport {DSColorPickerWrapper} from './DSColorPickerWrapper';\nimport {type CalculatedFlags, type InheritedFlags} from '../../shared/calculatedInheritedFlags';\n\ninterface IStandardFieldValueProps {\n presentationValue: string;\n handleSubmit: (value: AnyPrimitive | null) => Promise<void | ISubmitMultipleResult>;\n attribute: RecordFormAttributeStandardAttributeFragment;\n label: string;\n readonly: boolean;\n calculatedFlags: CalculatedFlags;\n inheritedFlags: InheritedFlags;\n listField?: FormListFieldData;\n removeLastValueOfMultivalues?: () => void;\n isLastValueOfMultivalues?: boolean;\n}\n\nfunction StandardFieldValue({\n presentationValue,\n handleSubmit,\n attribute,\n label,\n readonly,\n calculatedFlags,\n inheritedFlags,\n listField,\n removeLastValueOfMultivalues,\n isLastValueOfMultivalues = false,\n}: IStandardFieldValueProps): JSX.Element {\n const isValuesListEnabled = !!attribute?.values_list?.enable;\n\n const attributeFormatsWithDS = [\n AttributeFormat.text,\n AttributeFormat.date_range,\n AttributeFormat.numeric,\n AttributeFormat.encrypted,\n AttributeFormat.date,\n AttributeFormat.boolean,\n AttributeFormat.rich_text,\n AttributeFormat.color,\n AttributeFormat.extended,\n ];\n\n const commonProps = {\n handleSubmit,\n attribute,\n presentationValue,\n isLastValueOfMultivalues,\n removeLastValueOfMultivalues,\n readonly,\n label,\n calculatedFlags,\n inheritedFlags,\n };\n\n let valueContent: ReactNode;\n if (isValuesListEnabled) {\n valueContent = <DSListSelect {...commonProps} />;\n } else {\n switch (attribute.format) {\n case AttributeFormat.text:\n case AttributeFormat.extended:\n valueContent = <DSInputWrapper {...commonProps} />;\n break;\n case AttributeFormat.date:\n valueContent = <DSDatePickerWrapper {...commonProps} />;\n break;\n case AttributeFormat.date_range:\n valueContent = <DSRangePickerWrapper {...commonProps} />;\n break;\n case AttributeFormat.numeric:\n valueContent = <DSInputNumberWrapper {...commonProps} />;\n break;\n case AttributeFormat.encrypted:\n valueContent = <DSInputEncryptedWrapper {...commonProps} />;\n break;\n case AttributeFormat.boolean:\n valueContent = <DSBooleanWrapper {...commonProps} />;\n break;\n case AttributeFormat.rich_text:\n valueContent = <DSRichTextWrapper {...commonProps} />;\n break;\n case AttributeFormat.color:\n valueContent = <DSColorPickerWrapper {...commonProps} />;\n }\n }\n\n return (\n attributeFormatsWithDS.includes(attribute.format) && (\n <Form.Item name={attribute.id} {...listField} noStyle>\n {valueContent}\n </Form.Item>\n )\n );\n}\n\nexport default StandardFieldValue;\n"]}
|
|
@@ -9,6 +9,7 @@ import { useSharedTranslation } from '../../hooks/useSharedTranslation';
|
|
|
9
9
|
import { KitButton, KitSpace, KitTypography } from 'aristid-ds';
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
11
|
import styled from 'styled-components';
|
|
12
|
+
import { getExtendedAttributeDiffs, getExtendedAttributeLabels, } from '../../components/RecordHistory/utils/extendedAttribute';
|
|
12
13
|
const StyledLinkButton = styled(KitButton) `
|
|
13
14
|
&[role='link'] {
|
|
14
15
|
display: inline-flex;
|
|
@@ -40,20 +41,27 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
40
41
|
};
|
|
41
42
|
const getAttributeLabel = () => localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');
|
|
42
43
|
const formatValue = (logData) => {
|
|
43
|
-
if (attribute?.format === AttributeFormat.rich_text) {
|
|
44
|
+
if (attribute?.format === AttributeFormat.rich_text || attribute?.format === AttributeFormat.extended) {
|
|
44
45
|
return (_jsx(KitTypography.AdvancedParagraph, { size: "fontSize5", ellipsis: { rows: 4, expandable: true }, children: logData.asString }));
|
|
45
46
|
}
|
|
46
47
|
return _jsx(KitTypography.Text, { size: "fontSize5", children: logData.asString });
|
|
47
48
|
};
|
|
48
49
|
const formatValueChange = () => {
|
|
49
50
|
const noValue = _jsx(KitTypography.Text, { size: "fontSize5", children: t('record_history.no_value') });
|
|
51
|
+
if (attribute?.format === AttributeFormat.extended) {
|
|
52
|
+
const diffs = getExtendedAttributeDiffs(hasValue(before) ? JSON.parse(before.asString) : undefined, hasValue(after) ? JSON.parse(after.asString) : undefined);
|
|
53
|
+
return diffs.map(diff => (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [getExtendedAttributeLabels(diff.path, attribute
|
|
54
|
+
.embedded_fields, lang, t('record_history.unknown_attribute'))
|
|
55
|
+
.reverse()
|
|
56
|
+
.map((key, i, arr) => (_jsxs("span", { children: [_jsx("strong", { children: key }), i < arr.length - 1 && ` ${t('record_history.of')}`] }, key))), ":", diff.before !== null ? formatValue({ asString: diff.before }) : noValue, _jsx(KitTypography.Text, { size: "fontSize5", children: "\u2192" }), diff.after !== null ? formatValue({ asString: diff.after }) : noValue] })));
|
|
57
|
+
}
|
|
50
58
|
if (attribute?.multiple_values) {
|
|
51
59
|
const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;
|
|
52
60
|
if (uniqValue != null) {
|
|
53
61
|
return (_jsx(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: formatValue(uniqValue) }));
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
|
-
return (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [hasBefore ? formatValue(before) : noValue, _jsx(KitTypography.Text, { size: "fontSize5", children: "
|
|
64
|
+
return (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [hasBefore ? formatValue(before) : noValue, _jsx(KitTypography.Text, { size: "fontSize5", children: "\u2192" }), hasAfter ? formatValue(after) : noValue] }));
|
|
57
65
|
};
|
|
58
66
|
switch (action) {
|
|
59
67
|
case LogAction.VALUE_SAVE:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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CACH,MAAC,QAAQ,IAAa,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,UAAU,aACjD,MAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,aAC/B,aAAa,EAAE,OAAG,eAAe,EAAE,OAAE,2BAAS,iBAAiB,EAAE,GAAU,IAC3D,EACrB,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAAE,aAAa,EAAE,GAAsB,EAC1E,iBAAiB,EAAE,KALT,KAAK,CAMT,CACd,CAAC;IACV,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {localizedTranslation} from '@leav/utils';\nimport {AttributeFormat, LogAction} from '_ui/_gqlTypes';\nimport {useLang} from '_ui/hooks';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport dayjs from 'dayjs';\nimport {type FunctionComponent} from 'react';\nimport {type LogEntry, type LogEntryAttribute, type LogEntryData, type LogEntryValue} from './_types';\nimport styled from 'styled-components';\n\ninterface IRecordHistoryLogEntryProps {\n index: number;\n logEntry: LogEntry;\n}\n\nconst StyledLinkButton = styled(KitButton)`\n &[role='link'] {\n display: inline-flex;\n }\n`;\n\nexport const RecordHistoryLogEntry: FunctionComponent<IRecordHistoryLogEntryProps> = ({index, logEntry}) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n const {action, time, user, topic, before, after} = logEntry as LogEntryValue;\n const attribute: LogEntryAttribute | undefined = topic?.attribute;\n\n const hasValue = (value: LogEntryData) => value != null && 'asString' in value && value.asString != null;\n const hasBefore = hasValue(before);\n const hasAfter = hasValue(after);\n\n const getUserString = () => {\n const email = user?.properties[0]?.values[0]?.payload;\n return email ? (\n <StyledLinkButton type=\"link\" href={`mailto:${email}`}>\n {email}\n </StyledLinkButton>\n ) : (\n user?.id || t('record_history.unknown_user')\n );\n };\n const getDateString = () => dayjs.unix(time).format('DD/MM/YYYY HH:mm:ss'); // Maybe use https://day.js.org/docs/en/display/format#localized-formats if needed\n const getActionString = () => {\n if (attribute?.multiple_values) {\n if (!hasBefore && hasAfter) {\n return t('record_history.action.value_add');\n }\n if (hasBefore && !hasAfter) {\n return t('record_history.action.value_delete');\n }\n }\n return t('record_history.action.value_modify');\n };\n\n const getAttributeLabel = () =>\n localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');\n\n const formatValue = (logData: LogEntryData) => {\n if (attribute?.format === AttributeFormat.rich_text) {\n return (\n <KitTypography.AdvancedParagraph size=\"fontSize5\" ellipsis={{rows: 4, expandable: true}}>\n {logData.asString}\n </KitTypography.AdvancedParagraph>\n );\n }\n return <KitTypography.Text size=\"fontSize5\">{logData.asString}</KitTypography.Text>;\n };\n\n const formatValueChange = () => {\n const noValue = <KitTypography.Text size=\"fontSize5\">{t('record_history.no_value')}</KitTypography.Text>;\n\n if (attribute?.multiple_values) {\n const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;\n if (uniqValue != null) {\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {formatValue(uniqValue)}\n </KitSpace>\n );\n }\n }\n\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {hasBefore ? formatValue(before) : noValue}\n <KitTypography.Text size=\"fontSize5\"> → </KitTypography.Text>\n {hasAfter ? formatValue(after) : noValue}\n </KitSpace>\n );\n };\n\n switch (action) {\n case LogAction.VALUE_SAVE:\n case LogAction.VALUE_DELETE:\n return (\n <KitSpace key={index} size=\"xxs\" direction=\"vertical\">\n <KitTypography.Text size=\"fontSize5\">\n {getUserString()} {getActionString()} <strong>{getAttributeLabel()}</strong>\n </KitTypography.Text>\n <KitTypography.Text size=\"fontSize5\">{getDateString()}</KitTypography.Text>\n {formatValueChange()}\n </KitSpace>\n );\n }\n};\n\nexport default RecordHistoryLogEntry;\n"]}
|
|
1
|
+
{"version":3,"file":"RecordHistoryLogEntry.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryLogEntry.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,eAAe,EAAE,SAAS,EAA0D,MAAM,eAAe,CAAC;AAClH,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,OAAO,EACH,yBAAyB,EACzB,0BAA0B,GAC7B,MAAM,sDAAsD,CAAC;AAO9D,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;;;CAIzC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAmD,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE;IACvG,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,IAAI,EAAC,GAAG,OAAO,EAAE,CAAC;IACzB,MAAM,EAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAC,GAAG,QAAyB,CAAC;IAC7E,MAAM,SAAS,GAAkC,KAAK,EAAE,SAAS,CAAC;IAElE,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,UAAU,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;IACzG,MAAM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,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,IACjC,CACd,CAAC;IACN,CAAC,CAAC;IAEF,QAAQ,MAAM,EAAE,CAAC;QACb,KAAK,SAAS,CAAC,UAAU,CAAC;QAC1B,KAAK,SAAS,CAAC,YAAY;YACvB,OAAO,CACH,MAAC,QAAQ,IAAa,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,UAAU,aACjD,MAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,aAC/B,aAAa,EAAE,OAAG,eAAe,EAAE,OAAE,2BAAS,iBAAiB,EAAE,GAAU,IAC3D,EACrB,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,YAAE,aAAa,EAAE,GAAsB,EAC1E,iBAAiB,EAAE,KALT,KAAK,CAMT,CACd,CAAC;IACV,CAAC;AACL,CAAC,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {localizedTranslation} from '@leav/utils';\nimport {AttributeFormat, LogAction, type RecordHistoryLogAttributeStandardAttributeFragment} from '_ui/_gqlTypes';\nimport {useLang} from '_ui/hooks';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport dayjs from 'dayjs';\nimport {type FunctionComponent} from 'react';\nimport {type LogEntry, type LogEntryAttribute, type LogEntryData, type LogEntryValue} from './_types';\nimport styled from 'styled-components';\nimport {type IEmbeddedField} from '_ui/components/RecordHistory/_queries/recordHistoryQuery';\nimport {\n getExtendedAttributeDiffs,\n getExtendedAttributeLabels,\n} from '_ui/components/RecordHistory/utils/extendedAttribute';\n\ninterface IRecordHistoryLogEntryProps {\n index: number;\n logEntry: LogEntry;\n}\n\nconst StyledLinkButton = styled(KitButton)`\n &[role='link'] {\n display: inline-flex;\n }\n`;\n\nexport const RecordHistoryLogEntry: FunctionComponent<IRecordHistoryLogEntryProps> = ({index, logEntry}) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n const {action, time, user, topic, before, after} = logEntry as LogEntryValue;\n const attribute: LogEntryAttribute | undefined = topic?.attribute;\n\n const hasValue = (value: LogEntryData) => value != null && 'asString' in value && value.asString != null;\n const hasBefore = hasValue(before);\n const hasAfter = hasValue(after);\n\n const getUserString = () => {\n const email = user?.properties[0]?.values[0]?.payload;\n return email ? (\n <StyledLinkButton type=\"link\" href={`mailto:${email}`}>\n {email}\n </StyledLinkButton>\n ) : (\n user?.id || t('record_history.unknown_user')\n );\n };\n const getDateString = () => dayjs.unix(time).format('DD/MM/YYYY HH:mm:ss'); // Maybe use https://day.js.org/docs/en/display/format#localized-formats if needed\n const getActionString = () => {\n if (attribute?.multiple_values) {\n if (!hasBefore && hasAfter) {\n return t('record_history.action.value_add');\n }\n if (hasBefore && !hasAfter) {\n return t('record_history.action.value_delete');\n }\n }\n return t('record_history.action.value_modify');\n };\n\n const getAttributeLabel = () =>\n localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');\n\n const formatValue = (logData: LogEntryData) => {\n if (attribute?.format === AttributeFormat.rich_text || attribute?.format === AttributeFormat.extended) {\n return (\n <KitTypography.AdvancedParagraph size=\"fontSize5\" ellipsis={{rows: 4, expandable: true}}>\n {logData.asString}\n </KitTypography.AdvancedParagraph>\n );\n }\n return <KitTypography.Text size=\"fontSize5\">{logData.asString}</KitTypography.Text>;\n };\n\n const formatValueChange = () => {\n const noValue = <KitTypography.Text size=\"fontSize5\">{t('record_history.no_value')}</KitTypography.Text>;\n\n if (attribute?.format === AttributeFormat.extended) {\n const diffs = getExtendedAttributeDiffs(\n hasValue(before) ? JSON.parse(before.asString) : undefined,\n hasValue(after) ? JSON.parse(after.asString) : undefined,\n );\n\n return diffs.map(diff => (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {getExtendedAttributeLabels(\n diff.path,\n (attribute as RecordHistoryLogAttributeStandardAttributeFragment)\n .embedded_fields as IEmbeddedField[],\n lang,\n t('record_history.unknown_attribute'),\n )\n .reverse()\n .map((key, i, arr) => (\n <span key={key}>\n <strong>{key}</strong>\n {i < arr.length - 1 && ` ${t('record_history.of')}`}\n </span>\n ))}\n :{diff.before !== null ? formatValue({asString: diff.before}) : noValue}\n <KitTypography.Text size=\"fontSize5\">→</KitTypography.Text>\n {diff.after !== null ? formatValue({asString: diff.after}) : noValue}\n </KitSpace>\n ));\n }\n\n if (attribute?.multiple_values) {\n const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;\n\n if (uniqValue != null) {\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {formatValue(uniqValue)}\n </KitSpace>\n );\n }\n }\n\n return (\n <KitSpace size=\"xxs\" direction=\"horizontal\" wrap>\n {hasBefore ? formatValue(before) : noValue}\n <KitTypography.Text size=\"fontSize5\">→</KitTypography.Text>\n {hasAfter ? formatValue(after) : noValue}\n </KitSpace>\n );\n };\n\n switch (action) {\n case LogAction.VALUE_SAVE:\n case LogAction.VALUE_DELETE:\n return (\n <KitSpace key={index} size=\"xxs\" direction=\"vertical\">\n <KitTypography.Text size=\"fontSize5\">\n {getUserString()} {getActionString()} <strong>{getAttributeLabel()}</strong>\n </KitTypography.Text>\n <KitTypography.Text size=\"fontSize5\">{getDateString()}</KitTypography.Text>\n {formatValueChange()}\n </KitSpace>\n );\n }\n};\n\nexport default RecordHistoryLogEntry;\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface IEmbeddedField {
|
|
2
|
+
id: string;
|
|
3
|
+
label: Record<string, string>;
|
|
4
|
+
embedded_fields?: IEmbeddedField[];
|
|
5
|
+
}
|
|
6
|
+
export declare const recordHistoryLogAttributeFragment: (depthEmbeddedFields: number) => string;
|
|
7
|
+
export declare const getRecordHistoryQuery: (depthAttributeEmbeddedFields?: number) => import("graphql").DocumentNode;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
|
+
// This file is released under LGPL V3
|
|
3
|
+
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
+
import { gqlUnchecked } from '../../../_utils';
|
|
5
|
+
import { getEmbeddedFields } from '../../../_queries/attributes/getAttributeWithEmbeddedFields';
|
|
6
|
+
export const recordHistoryLogAttributeFragment = (depthEmbeddedFields) => `
|
|
7
|
+
attribute {
|
|
8
|
+
id
|
|
9
|
+
label
|
|
10
|
+
type
|
|
11
|
+
format
|
|
12
|
+
multiple_values
|
|
13
|
+
... on StandardAttribute {
|
|
14
|
+
${getEmbeddedFields(depthEmbeddedFields)}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
const RecordHistoryLogEntryFragment = (depthAttributeEmbeddedFields) => `
|
|
19
|
+
logs {
|
|
20
|
+
action
|
|
21
|
+
time
|
|
22
|
+
topic {
|
|
23
|
+
${recordHistoryLogAttributeFragment(depthAttributeEmbeddedFields)}
|
|
24
|
+
}
|
|
25
|
+
user {
|
|
26
|
+
id
|
|
27
|
+
whoAmI { # Don't know why, but frontend need that to load record !
|
|
28
|
+
id
|
|
29
|
+
library {
|
|
30
|
+
id
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
properties(attributeIds: ["email"]) {
|
|
34
|
+
attributeId
|
|
35
|
+
values {
|
|
36
|
+
... on Value {
|
|
37
|
+
payload
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
before {
|
|
43
|
+
asString
|
|
44
|
+
}
|
|
45
|
+
after {
|
|
46
|
+
asString
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
export const getRecordHistoryQuery = (depthAttributeEmbeddedFields = 0) => gqlUnchecked `
|
|
51
|
+
query getRecordHistory($record: LogTopicRecordFilterInput!, $attributeId: String, $actions: [LogAction!], $pagination: Pagination) {
|
|
52
|
+
logs(filters: {
|
|
53
|
+
topic: {
|
|
54
|
+
record: $record,
|
|
55
|
+
attribute: $attributeId
|
|
56
|
+
},
|
|
57
|
+
actions: $actions,
|
|
58
|
+
}, pagination: $pagination) {
|
|
59
|
+
total
|
|
60
|
+
${RecordHistoryLogEntryFragment(depthAttributeEmbeddedFields)}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
//# sourceMappingURL=recordHistoryQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordHistoryQuery.js","sourceRoot":"","sources":["../../../../src/components/RecordHistory/_queries/recordHistoryQuery.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,iBAAiB,EAAC,MAAM,wDAAwD,CAAC;AAQzF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,mBAA2B,EAAE,EAAE,CAAC;;;;;;;;cAQpE,iBAAiB,CAAC,mBAAmB,CAAC;;;CAGnD,CAAC;AAEF,MAAM,6BAA6B,GAAG,CAAC,4BAAoC,EAAE,EAAE,CAAC;;;;;cAKlE,iCAAiC,CAAC,4BAA4B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B5E,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,+BAAuC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAA;;;;;;;;;;cAUjF,6BAA6B,CAAC,4BAA4B,CAAC;;;CAGxE,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {gqlUnchecked} from '_ui/_utils';\nimport {getEmbeddedFields} from '_ui/_queries/attributes/getAttributeWithEmbeddedFields';\n\nexport interface IEmbeddedField {\n id: string;\n label: Record<string, string>;\n embedded_fields?: IEmbeddedField[];\n}\n\nexport const recordHistoryLogAttributeFragment = (depthEmbeddedFields: number) => `\n attribute {\n id\n label\n type\n format\n multiple_values\n ... on StandardAttribute {\n ${getEmbeddedFields(depthEmbeddedFields)}\n }\n }\n`;\n\nconst RecordHistoryLogEntryFragment = (depthAttributeEmbeddedFields: number) => `\n logs {\n action\n time\n topic {\n ${recordHistoryLogAttributeFragment(depthAttributeEmbeddedFields)}\n }\n user {\n id\n whoAmI { # Don't know why, but frontend need that to load record !\n id\n library {\n id\n }\n }\n properties(attributeIds: [\"email\"]) {\n attributeId\n values {\n ... on Value {\n payload\n }\n }\n }\n }\n before {\n asString\n }\n after {\n asString\n }\n }\n`;\n\nexport const getRecordHistoryQuery = (depthAttributeEmbeddedFields: number = 0) => gqlUnchecked`\n query getRecordHistory($record: LogTopicRecordFilterInput!, $attributeId: String, $actions: [LogAction!], $pagination: Pagination) {\n logs(filters: {\n topic: {\n record: $record,\n attribute: $attributeId\n },\n actions: $actions,\n }, pagination: $pagination) {\n total\n ${RecordHistoryLogEntryFragment(depthAttributeEmbeddedFields)}\n }\n }\n`;\n"]}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
2
2
|
// This file is released under LGPL V3
|
|
3
3
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
4
|
-
import { LogAction
|
|
4
|
+
import { LogAction } from '../../../_gqlTypes';
|
|
5
5
|
import { useCallback, useEffect, useState } from 'react';
|
|
6
|
+
import { useQuery } from '@apollo/client';
|
|
7
|
+
import { getRecordHistoryQuery } from '../../../components/RecordHistory/_queries/recordHistoryQuery';
|
|
6
8
|
export const RECORD_HISTORY_LOGS_PAGE = 50;
|
|
7
9
|
export const RECORD_HISTORY_LOGS_FIRST_PAGE = 1;
|
|
10
|
+
const DEPTH_EMBEDDED_FIELDS = 100;
|
|
8
11
|
const eventsToFetch = [LogAction.VALUE_SAVE, LogAction.VALUE_DELETE];
|
|
9
12
|
export const useFetchRecordHistory = ({ record, attributeId, }) => {
|
|
10
13
|
const [logs, setLogs] = useState([]);
|
|
11
14
|
const [total, setTotal] = useState(0);
|
|
12
15
|
const [hasMore, setHasMore] = useState(false);
|
|
13
|
-
const { loading, error, data: history, refetch, } =
|
|
16
|
+
const { loading, error, data: history, refetch, } = useQuery(getRecordHistoryQuery(DEPTH_EMBEDDED_FIELDS), {
|
|
14
17
|
fetchPolicy: 'network-only',
|
|
15
18
|
variables: {
|
|
16
19
|
record: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFetchRecordHistory.js","sourceRoot":"","sources":["../../../../src/components/RecordHistory/hooks/useFetchRecordHistory.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"useFetchRecordHistory.js","sourceRoot":"","sources":["../../../../src/components/RecordHistory/hooks/useFetchRecordHistory.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAExC,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0DAA0D,CAAC;AAgB/F,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAChD,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,MAAM,aAAa,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,YAAY,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B,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAC;SACrE,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;YACtB,OAAO;QACX,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,CAAC;QACjB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnB,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IAC1C,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvB,OAAO;QACH,OAAO;QACP,OAAO,EAAE,CAAC,CAAC,KAAK;QAChB,IAAI;QACJ,KAAK;QACL,OAAO;QACP,SAAS;KACZ,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {LogAction} from '_ui/_gqlTypes';\nimport {type LogEntry} from '../_types';\nimport {useCallback, useEffect, useState} from 'react';\nimport {useQuery} from '@apollo/client';\nimport {getRecordHistoryQuery} from '_ui/components/RecordHistory/_queries/recordHistoryQuery';\n\nexport interface IUseFetchRecordHistoryHook {\n loading: boolean;\n inError: boolean;\n logs: LogEntry[];\n total: number;\n hasMore: boolean;\n fetchMore: () => void;\n}\n\nexport interface IUseFetchRecordHistoryProps {\n record: {id: string; libraryId: string};\n attributeId?: string;\n}\n\nexport const RECORD_HISTORY_LOGS_PAGE = 50;\nexport const RECORD_HISTORY_LOGS_FIRST_PAGE = 1;\nconst DEPTH_EMBEDDED_FIELDS = 100;\n\nconst eventsToFetch = [LogAction.VALUE_SAVE, LogAction.VALUE_DELETE];\n\nexport const useFetchRecordHistory = ({\n record,\n attributeId,\n}: IUseFetchRecordHistoryProps): IUseFetchRecordHistoryHook => {\n const [logs, setLogs] = useState<LogEntry[]>([]);\n const [total, setTotal] = useState<number>(0);\n const [hasMore, setHasMore] = useState<boolean>(false);\n\n const {\n loading,\n error,\n data: history,\n refetch,\n } = useQuery(getRecordHistoryQuery(DEPTH_EMBEDDED_FIELDS), {\n fetchPolicy: 'network-only',\n variables: {\n record: {\n id: record.id,\n libraryId: record.libraryId,\n },\n attributeId,\n actions: eventsToFetch,\n pagination: {limit: RECORD_HISTORY_LOGS_FIRST_PAGE, offset: 0},\n },\n });\n\n useEffect(() => {\n // Reset if record or attribute change\n setLogs([]);\n setTotal(0);\n setHasMore(false);\n }, [record.id, record.libraryId, attributeId]);\n\n const fetchMore = useCallback(() => {\n refetch({\n record: {\n id: record.id,\n libraryId: record.libraryId,\n },\n attributeId,\n actions: eventsToFetch,\n pagination: {limit: RECORD_HISTORY_LOGS_PAGE, offset: logs.length},\n });\n }, [logs.length, refetch, record.id, record.libraryId, attributeId]);\n\n useEffect(() => {\n if (loading || !history) {\n return;\n }\n const newLogs = [...logs, ...history.logs.logs];\n const newTotal = history.logs.total || 0;\n setLogs(newLogs);\n setTotal(newTotal);\n setHasMore(newLogs.length < newTotal);\n }, [history, loading]);\n\n return {\n loading,\n inError: !!error,\n logs,\n total,\n hasMore,\n fetchMore,\n };\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IEmbeddedField } from '../../../components/RecordHistory/_queries/recordHistoryQuery';
|
|
2
|
+
export declare const getExtendedAttributeDiffs: (extendedValueBefore: unknown | undefined, extendedValueAfter: unknown | undefined, path?: string[], diffs?: Array<{
|
|
3
|
+
path: string;
|
|
4
|
+
before: string | null;
|
|
5
|
+
after: string | null;
|
|
6
|
+
}>) => Array<{
|
|
7
|
+
path: string;
|
|
8
|
+
before: string | null;
|
|
9
|
+
after: string | null;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const getExtendedAttributeLabels: (path: string, embeddedFields: IEmbeddedField[], lang: string[], unknownAttributeLabel: string) => string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { localizedTranslation } from '@leav/utils';
|
|
2
|
+
// This function compares two extended attribute values and returns the differences
|
|
3
|
+
export const getExtendedAttributeDiffs = (extendedValueBefore, extendedValueAfter, path = [], diffs = []) => {
|
|
4
|
+
if ((typeof extendedValueBefore !== 'object' || extendedValueBefore === null) &&
|
|
5
|
+
(typeof extendedValueAfter !== 'object' || extendedValueAfter === null)) {
|
|
6
|
+
if (extendedValueBefore !== extendedValueAfter) {
|
|
7
|
+
diffs.push({
|
|
8
|
+
path: path.join('.'),
|
|
9
|
+
before: extendedValueBefore === null || extendedValueBefore === undefined
|
|
10
|
+
? null
|
|
11
|
+
: String(extendedValueBefore),
|
|
12
|
+
after: extendedValueAfter === null || extendedValueAfter === undefined ? null : String(extendedValueAfter),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return diffs;
|
|
16
|
+
}
|
|
17
|
+
const keys = new Set([...Object.keys(extendedValueBefore || {}), ...Object.keys(extendedValueAfter || {})]);
|
|
18
|
+
for (const key of keys) {
|
|
19
|
+
getExtendedAttributeDiffs(extendedValueBefore?.[key], extendedValueAfter?.[key], [...path, key], diffs);
|
|
20
|
+
}
|
|
21
|
+
return diffs;
|
|
22
|
+
};
|
|
23
|
+
// This function retrieves the labels for each part of the dot-separated path
|
|
24
|
+
export const getExtendedAttributeLabels = (path, // dot separated path
|
|
25
|
+
embeddedFields, // root embedded fields
|
|
26
|
+
lang, unknownAttributeLabel) => {
|
|
27
|
+
let nestedEmbeddedFields = [...embeddedFields];
|
|
28
|
+
let current = null;
|
|
29
|
+
const labels = [];
|
|
30
|
+
for (const id of path.split('.')) {
|
|
31
|
+
current = nestedEmbeddedFields.find(attr => attr.id === id);
|
|
32
|
+
if (!current) {
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
labels.push(localizedTranslation(current?.label, lang) || current?.id || unknownAttributeLabel);
|
|
36
|
+
nestedEmbeddedFields = current.embedded_fields ?? [];
|
|
37
|
+
}
|
|
38
|
+
return labels;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=extendedAttribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extendedAttribute.js","sourceRoot":"","sources":["../../../../src/components/RecordHistory/utils/extendedAttribute.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AAEjD,mFAAmF;AACnF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACrC,mBAAwC,EACxC,kBAAuC,EACvC,OAAiB,EAAE,EACnB,QAA4E,EAAE,EACZ,EAAE;IACpE,IACI,CAAC,OAAO,mBAAmB,KAAK,QAAQ,IAAI,mBAAmB,KAAK,IAAI,CAAC;QACzE,CAAC,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,IAAI,CAAC,EACzE,CAAC;QACC,IAAI,mBAAmB,KAAK,kBAAkB,EAAE,CAAC;YAC7C,KAAK,CAAC,IAAI,CAAC;gBACP,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;gBACpB,MAAM,EACF,mBAAmB,KAAK,IAAI,IAAI,mBAAmB,KAAK,SAAS;oBAC7D,CAAC,CAAC,IAAI;oBACN,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;gBACrC,KAAK,EACD,kBAAkB,KAAK,IAAI,IAAI,kBAAkB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC;aAC1G,CAAC,CAAC;QACP,CAA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ClB,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type IEmbeddedField} from '_ui/components/RecordHistory/_queries/recordHistoryQuery';\nimport {localizedTranslation} from '@leav/utils';\n\n// This function compares two extended attribute values and returns the differences\nexport const getExtendedAttributeDiffs = (\n extendedValueBefore: unknown | undefined,\n extendedValueAfter: unknown | undefined,\n path: string[] = [],\n diffs: Array<{path: string; before: string | null; after: string | null}> = [],\n): Array<{path: string; before: string | null; after: string | null}> => {\n if (\n (typeof extendedValueBefore !== 'object' || extendedValueBefore === null) &&\n (typeof extendedValueAfter !== 'object' || extendedValueAfter === null)\n ) {\n if (extendedValueBefore !== extendedValueAfter) {\n diffs.push({\n path: path.join('.'),\n before:\n extendedValueBefore === null || extendedValueBefore === undefined\n ? null\n : String(extendedValueBefore),\n after:\n extendedValueAfter === null || extendedValueAfter === undefined ? null : String(extendedValueAfter),\n });\n }\n\n return diffs;\n }\n\n const keys = new Set([...Object.keys(extendedValueBefore || {}), ...Object.keys(extendedValueAfter || {})]);\n for (const key of keys) {\n getExtendedAttributeDiffs(extendedValueBefore?.[key], extendedValueAfter?.[key], [...path, key], diffs);\n }\n\n return diffs;\n};\n\n// This function retrieves the labels for each part of the dot-separated path\nexport const getExtendedAttributeLabels = (\n path: string, // dot separated path\n embeddedFields: IEmbeddedField[], // root embedded fields\n lang: string[],\n unknownAttributeLabel: string,\n): string[] => {\n let nestedEmbeddedFields = [...embeddedFields];\n let current: IEmbeddedField = null;\n const labels: string[] = [];\n\n for (const id of path.split('.')) {\n current = nestedEmbeddedFields.find(attr => attr.id === id);\n if (!current) {\n break;\n }\n labels.push(localizedTranslation(current?.label, lang) || current?.id || unknownAttributeLabel);\n nestedEmbeddedFields = current.embedded_fields ?? [];\n }\n\n return labels;\n};\n"]}
|
|
@@ -542,7 +542,8 @@
|
|
|
542
542
|
"unknown_attribute": "unknown attribute",
|
|
543
543
|
"unknown_user": "unknown user",
|
|
544
544
|
"show_history": "See full history ({{total}} entries)",
|
|
545
|
-
"hide_history": "Hide history ({{total}} entries)"
|
|
545
|
+
"hide_history": "Hide history ({{total}} entries)",
|
|
546
|
+
"of": "of"
|
|
546
547
|
},
|
|
547
548
|
"view": {
|
|
548
549
|
"views": "Views",
|
|
@@ -542,7 +542,8 @@
|
|
|
542
542
|
"unknown_attribute": "Attribut inconnu",
|
|
543
543
|
"unknown_user": "Utilisateur inconnu",
|
|
544
544
|
"show_history": "Voir tout l'historique ({{total}} événements)",
|
|
545
|
-
"hide_history": "Masquer l'historique ({{total}} événements)"
|
|
545
|
+
"hide_history": "Masquer l'historique ({{total}} événements)",
|
|
546
|
+
"of": "de"
|
|
546
547
|
},
|
|
547
548
|
"view": {
|
|
548
549
|
"views": "Vues",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leav/ui",
|
|
3
|
-
"version": "1.7.0-
|
|
3
|
+
"version": "1.7.0-bba65313",
|
|
4
4
|
"description": "Shared React components and hooks",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "yarn build",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/react": "18.2.14",
|
|
45
45
|
"@types/react-dom": "18.2.6",
|
|
46
46
|
"@types/react-table": "7.7.20",
|
|
47
|
-
"aristid-ds": "14.0.0-
|
|
47
|
+
"aristid-ds": "14.0.0-1708442",
|
|
48
48
|
"babel-jest": "29.7.0",
|
|
49
49
|
"graphql": "16.12.0",
|
|
50
50
|
"i18next": "22.5.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@apollo/client": ">=3.8.1",
|
|
65
|
-
"aristid-ds": "^14.0.0-
|
|
65
|
+
"aristid-ds": "^14.0.0-1708442",
|
|
66
66
|
"i18next": ">=22.5.1",
|
|
67
67
|
"react": "^18.2.0",
|
|
68
68
|
"react-dom": "^18.2.0",
|