@leav/ui 1.7.0 → 1.8.0-26bc59b6
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/__mocks__/common/library.d.ts +1 -0
- package/dist/_gqlTypes/index.d.ts +156 -61
- package/dist/_gqlTypes/index.js +87 -53
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_queries/attributes/getAttributeWithEmbeddedFields.d.ts +1 -1
- package/dist/_queries/libraries/libraryDetailsFragment.js +1 -0
- package/dist/_queries/libraries/libraryDetailsFragment.js.map +1 -1
- package/dist/components/AttributePicker/AttributesList/AttributesList.js +3 -7
- package/dist/components/AttributePicker/AttributesList/AttributesList.js.map +1 -1
- package/dist/components/EditLibraryModal/EditLibrary/EditLibraryAttributes/AttributesList/AttributesList.js +3 -7
- package/dist/components/EditLibraryModal/EditLibrary/EditLibraryAttributes/AttributesList/AttributesList.js.map +1 -1
- package/dist/components/Explorer/TableCell.js +9 -16
- package/dist/components/Explorer/TableCell.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.js +2 -2
- package/dist/components/Explorer/manage-view-settings/configure-display/view-type/SelectViewType.js.map +1 -1
- package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js +2 -2
- package/dist/components/Explorer/manage-view-settings/open-view-settings/useOpenViewSettings.js.map +1 -1
- package/dist/components/Filters/context/useGetTreeFilters.d.ts +8 -6
- package/dist/components/Filters/context/useGetTreeFilters.js +41 -18
- package/dist/components/Filters/context/useGetTreeFilters.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js +1 -1
- package/dist/components/Filters/filter-items/EmptyValueCheckbox.js.map +1 -1
- package/dist/components/Filters/filter-items/SelectAllCheckbox.d.ts +8 -0
- package/dist/components/Filters/filter-items/SelectAllCheckbox.js +22 -0
- package/dist/components/Filters/filter-items/SelectAllCheckbox.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterDropdownContent.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +2 -2
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/{TreeAttributeDropDown.d.ts → tree/TreeAttributeDropDown.d.ts} +1 -1
- package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js +130 -0
- package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.d.ts +20 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js +72 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useGetTreeData.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.d.ts +7 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js +36 -0
- package/dist/components/Filters/filter-items/filter-type/tree/useTreesSearch.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.d.ts +2 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js +14 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/buildFlattenTreeMap.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.d.ts +2 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js +15 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/filterTreeByPermission.js.map +1 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.d.ts +5 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.js +17 -0
- package/dist/components/Filters/filter-items/filter-type/tree/utils/getSelectAllState.js.map +1 -0
- package/dist/components/LibraryItemsList/hooks/useSearchReducer/useSearchReducer.d.ts +1 -1
- package/dist/components/Notifications/hooks/useNotificationSubscription.js +2 -2
- package/dist/components/Notifications/hooks/useNotificationSubscription.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/LinkField/tag/link-record/useLinkRecord.js +4 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/tag/link-record/useLinkRecord.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 +13 -0
- package/dist/components/RecordHistory/utils/extendedAttribute.js +40 -0
- package/dist/components/RecordHistory/utils/extendedAttribute.js.map +1 -0
- package/dist/components/SelectTreeNode/TreeNodeTitle.js +2 -2
- package/dist/components/SelectTreeNode/TreeNodeTitle.js.map +1 -1
- package/dist/locales/en/shared.json +6 -2
- package/dist/locales/fr/shared.json +6 -2
- package/dist/types/records.d.ts +1 -0
- package/dist/types/records.js.map +1 -1
- package/package.json +7 -7
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js +0 -71
- package/dist/components/Filters/filter-items/filter-type/TreeAttributeDropDown.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
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,EAAC,MAAM,eAAe,CAAC;AACzD,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;AAOvC,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,KAA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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} 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;IAC7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AAS,EAAC,YAAY,EAAC,IAAI,mBAC3C,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAC1C,KAAC,aAAa,CAAC,IAAI,IAAC,IAAI,EAAC,WAAW,uBAAuB,EAC1D,QAAQ,CAAC,CAAC,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,CA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AAE;QAC/B,OAAO,CAAC;YACJ,MAAM,EAAE;gBACJ,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,SAAS,EAAE,MAAM,CAAC,SAAS;aAC9B;YACD,WAAW;YACX,OAAO,EAAE,aAAa;YACtB,UAAU,EAAE,EAAC,KAAK,EAAE,wBAAwB,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,13 @@
|
|
|
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, // dot separated path
|
|
12
|
+
embeddedFields: IEmbeddedField[], // root embedded fields
|
|
13
|
+
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,KAA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MAAM;QACV,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,EAAE,IAAI,qBAAqB,CAAC,CAAC;QAChG,oBAAoB,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;IACzD,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,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"]}
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// This file is released under LGPL V3
|
|
4
4
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
5
5
|
import { useState } from 'react';
|
|
6
|
-
import { KitButton, KitTag, KitTypography } from 'aristid-ds';
|
|
6
|
+
import { KitButton, KitIdCard, KitTag, KitTypography } from 'aristid-ds';
|
|
7
7
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
8
|
import { faCheck } from '@fortawesome/free-solid-svg-icons';
|
|
9
9
|
import { useSharedTranslation } from '../../hooks/useSharedTranslation';
|
|
@@ -43,7 +43,7 @@ const SelectedChildrenCount = ({ node, selectedNodes, loadRecursively }) => {
|
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
const selectedChildrenCount = countSelectedNodes(node, selectedNodes);
|
|
46
|
-
return selectedChildrenCount > 0 ? _jsx(KitTag, {
|
|
46
|
+
return selectedChildrenCount > 0 ? (_jsx(KitTag, { children: _jsx(KitIdCard, { description: selectedChildrenCount }) })) : null;
|
|
47
47
|
};
|
|
48
48
|
const countSelectedNodes = (node, selectedNodes) => node.children?.reduce((count, child) => {
|
|
49
49
|
if (selectedNodes.includes(child.id) && !child.isShowMore) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeNodeTitle.js","sourceRoot":"","sources":["../../../src/components/SelectTreeNode/TreeNodeTitle.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAyB,MAAM,OAAO,CAAC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AmB,EAAE,CAAC,GACjF,CACf,EACA,CAAC,SAAS,IAAI,UAAU,IAAI,CACzB,KAAC,eAAe,IACZ,IAAI,EAAE,OAAO,EACb,KAAK,EACD,UAAU,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,oCAAoC,GAElG,CACL,IACiB,IACX,CAClB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAItB,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,eAAe,EAAC,EAAE,EAAE;IAC5C,8CAA8C;IAC9C,IAAI,CAAC,eAAe,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,qBAAqB,GAAG,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAEtE,OAAO,qBAAqB,GAAG,CAAC,CAAC,CAAC,CAAC,CAC/B,KAAC,MAAM,cACH,KAAC,SAAS,IAAC,WAAW,EAAE,qBAAqB,GAAI,GAC5C,CACZ,CAAC,CAAC,CAAC,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,IAAqB,EAAE,aAAuB,EAAU,EAAE,CAClF,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACnC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;QACxD,KAAK,IAAI,CAAC,CAAC;IACf,CAAC;IACD,KAAK,IAAI,kBAAkB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC;AACjB,CAAC,EAAE,CAAC,CAAC,IAAI,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 {useState, type FunctionComponent} from 'react';\nimport {type ITreeMapElement} from './_types';\nimport {KitButton, KitIdCard, KitTag, KitTypography} from 'aristid-ds';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faCheck} from '@fortawesome/free-solid-svg-icons';\nimport {type ITreeNodeWithRecord} from '_ui/types';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport styled from 'styled-components';\n\nconst TreeNodeLine = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n`;\nconst TreeNodeLineSection = styled.div`\n display: flex;\n align-items: center;\n gap: calc(var(--general-spacing-xs) * 1px);\n`;\ninterface ITreeNodeTitleProps {\n checkable: boolean;\n disabledNodes: string[];\n loadRecursively: boolean;\n node: ITreeMapElement;\n onSelect: (node: ITreeNodeWithRecord, selected: boolean) => void;\n selectedNodes: string[];\n showSelectChildrenButton: boolean;\n}\n\nexport const TreeNodeTitle: FunctionComponent<ITreeNodeTitleProps> = ({\n checkable,\n disabledNodes,\n loadRecursively,\n node,\n onSelect,\n selectedNodes,\n showSelectChildrenButton,\n}) => {\n const {t} = useSharedTranslation();\n\n const [hover, setHover] = useState(false);\n\n const isSelected = selectedNodes.includes(node.id) && !node.isShowMore;\n const isDisabled = disabledNodes.includes(node.id);\n\n const buttonInSelectMode = node.children\n .filter(child => !child.isShowMore && !disabledNodes.includes(child.id))\n .every(child => !selectedNodes.includes(child.id));\n\n const handleChildrenSelection = (event: React.MouseEvent) => {\n event.stopPropagation();\n node.children.forEach(child => {\n if (node.disabled || child.isShowMore) {\n return;\n }\n onSelect(child, buttonInSelectMode);\n });\n };\n\n return (\n <TreeNodeLine onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}>\n <TreeNodeLineSection>\n <KitTypography.Text size=\"fontSize5\" disabled={isDisabled}>\n {node.title}\n </KitTypography.Text>\n <SelectedChildrenCount node={node} selectedNodes={selectedNodes} loadRecursively={loadRecursively} />\n </TreeNodeLineSection>\n <TreeNodeLineSection>\n {showSelectChildrenButton && node.children.length > 0 && hover && (\n <KitButton size=\"s\" onClick={e => handleChildrenSelection(e)}>\n {t(`tree-node-selection.${buttonInSelectMode ? 'select_children' : 'unselect_children'}`)}\n </KitButton>\n )}\n {!checkable && isSelected && (\n <FontAwesomeIcon\n icon={faCheck}\n color={\n isDisabled ? 'var(--general-utilities-text-disabled)' : 'var(--general-utilities-text-blue)'\n }\n />\n )}\n </TreeNodeLineSection>\n </TreeNodeLine>\n );\n};\n\nconst SelectedChildrenCount: FunctionComponent<{\n node: ITreeMapElement;\n selectedNodes: string[];\n loadRecursively: boolean;\n}> = ({node, selectedNodes, loadRecursively}) => {\n // it can work only if all children are loaded\n if (!loadRecursively) {\n return null;\n }\n\n const selectedChildrenCount = countSelectedNodes(node, selectedNodes);\n\n return selectedChildrenCount > 0 ? (\n <KitTag>\n <KitIdCard description={selectedChildrenCount} />\n </KitTag>\n ) : null;\n};\n\nconst countSelectedNodes = (node: ITreeMapElement, selectedNodes: string[]): number =>\n node.children?.reduce((count, child) => {\n if (selectedNodes.includes(child.id) && !child.isShowMore) {\n count += 1;\n }\n count += countSelectedNodes(child, selectedNodes);\n return count;\n }, 0) ?? 0;\n"]}
|
|
@@ -310,7 +310,10 @@
|
|
|
310
310
|
"activate": "Activate",
|
|
311
311
|
"add": "Add",
|
|
312
312
|
"add-condition": "Add condition",
|
|
313
|
-
"empty-value": "Undefined"
|
|
313
|
+
"empty-value": "Undefined",
|
|
314
|
+
"visible-by-default": "Value(s) visible by default",
|
|
315
|
+
"hidden-by-default": "Value(s) hidden by default",
|
|
316
|
+
"select-all": "Select All"
|
|
314
317
|
},
|
|
315
318
|
"filter-item": {
|
|
316
319
|
"no-operator": "If"
|
|
@@ -542,7 +545,8 @@
|
|
|
542
545
|
"unknown_attribute": "unknown attribute",
|
|
543
546
|
"unknown_user": "unknown user",
|
|
544
547
|
"show_history": "See full history ({{total}} entries)",
|
|
545
|
-
"hide_history": "Hide history ({{total}} entries)"
|
|
548
|
+
"hide_history": "Hide history ({{total}} entries)",
|
|
549
|
+
"of": "of"
|
|
546
550
|
},
|
|
547
551
|
"view": {
|
|
548
552
|
"views": "Views",
|
|
@@ -310,7 +310,10 @@
|
|
|
310
310
|
"activate": "Activer",
|
|
311
311
|
"add": "Ajouter",
|
|
312
312
|
"add-condition": "Ajouter une condition",
|
|
313
|
-
"empty-value": "Non défini"
|
|
313
|
+
"empty-value": "Non défini",
|
|
314
|
+
"visible-by-default": "Valeurs affichée(s) par défaut",
|
|
315
|
+
"hidden-by-default": "Valeurs masquée(s) par défaut",
|
|
316
|
+
"select-all": "Tout sélectionner"
|
|
314
317
|
},
|
|
315
318
|
"filter-item": {
|
|
316
319
|
"no-operator": "Si"
|
|
@@ -542,7 +545,8 @@
|
|
|
542
545
|
"unknown_attribute": "Attribut inconnu",
|
|
543
546
|
"unknown_user": "Utilisateur inconnu",
|
|
544
547
|
"show_history": "Voir tout l'historique ({{total}} événements)",
|
|
545
|
-
"hide_history": "Masquer l'historique ({{total}} événements)"
|
|
548
|
+
"hide_history": "Masquer l'historique ({{total}} événements)",
|
|
549
|
+
"of": "de"
|
|
546
550
|
},
|
|
547
551
|
"view": {
|
|
548
552
|
"views": "Vues",
|
package/dist/types/records.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"","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 IPreviewScalar} from '@leav/utils';\nimport {type SystemTranslation} from './scalars';\n\nexport interface IRecordIdentityLibrary {\n id: string;\n label?: SystemTranslation | null;\n}\n\nexport interface IRecordIdentityPreview {\n tiny: string | null;\n small: string | null;\n medium: string | null;\n big: string | null;\n huge: string | null;\n}\n\nexport interface IRecordIdentityWhoAmI {\n id: string;\n label?: string | null;\n subLabel?: string | null;\n color?: string | null;\n library: IRecordIdentityLibrary;\n preview?: IPreviewScalar | null;\n}\n\nexport interface IRecordIdentity {\n id: string;\n whoAmI: IRecordIdentityWhoAmI;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/types/records.ts"],"names":[],"mappings":"","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 IPreviewScalar} from '@leav/utils';\nimport {type SystemTranslation} from './scalars';\n\nexport interface IRecordIdentityLibrary {\n id: string;\n label?: SystemTranslation | null;\n}\n\nexport interface IRecordIdentityPreview {\n tiny: string | null;\n small: string | null;\n medium: string | null;\n big: string | null;\n huge: string | null;\n}\n\nexport interface IRecordIdentityWhoAmI {\n id: string;\n label?: string | null;\n subLabel?: string | null;\n color?: string | null;\n library: IRecordIdentityLibrary;\n preview?: IPreviewScalar | null;\n parentContext?: IRecordIdentityWhoAmI[] | null;\n}\n\nexport interface IRecordIdentity {\n id: string;\n whoAmI: IRecordIdentityWhoAmI;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leav/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0-26bc59b6",
|
|
4
4
|
"description": "Shared React components and hooks",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "yarn build",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"repository": "https://github.com/leav-solutions/leav-engine",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@apollo/client": "3.8.1",
|
|
28
|
-
"@babel/preset-env": "7.
|
|
28
|
+
"@babel/preset-env": "7.29.0",
|
|
29
29
|
"@babel/preset-react": "7.28.5",
|
|
30
30
|
"@graphql-codegen/add": "5.0.3",
|
|
31
31
|
"@graphql-codegen/cli": "6.1.1",
|
|
@@ -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",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"react-router-dom": "6.22.0",
|
|
58
58
|
"ts-jest": "29.4.6",
|
|
59
59
|
"tsc-alias": "1.8.16",
|
|
60
|
-
"typescript": "5.
|
|
60
|
+
"typescript": "5.9.3",
|
|
61
61
|
"vite": "7.3.1"
|
|
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",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"react-router-dom": "^6.22.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@ant-design/icons": "5.
|
|
73
|
+
"@ant-design/icons": "5.6.1",
|
|
74
74
|
"@ckeditor/ckeditor5-build-inline": "39.0.2",
|
|
75
75
|
"@ckeditor/ckeditor5-react": "6.1.0",
|
|
76
76
|
"@dnd-kit/core": "6.1.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@fortawesome/free-regular-svg-icons": "7.0.1",
|
|
81
81
|
"@fortawesome/free-solid-svg-icons": "7.0.1",
|
|
82
82
|
"@fortawesome/react-fontawesome": "3.0.2",
|
|
83
|
-
"@leav/utils": "1.
|
|
83
|
+
"@leav/utils": "1.8.0",
|
|
84
84
|
"@uidotdev/usehooks": "2.4.1",
|
|
85
85
|
"dayjs": "^1.11.13",
|
|
86
86
|
"dompurify": "3.2.4",
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { RecordFilterCondition } from '../../../../_gqlTypes';
|
|
3
|
-
import { SelectTreeNode } from '../../../../components/SelectTreeNode';
|
|
4
|
-
import styled from 'styled-components';
|
|
5
|
-
import { EmptyValueCheckbox } from '../EmptyValueCheckbox';
|
|
6
|
-
const DivStyled = styled.div `
|
|
7
|
-
max-height: 30rem;
|
|
8
|
-
overflow: auto;
|
|
9
|
-
`;
|
|
10
|
-
export const TreeAttributeDropDown = ({ filter, onFilterChange, }) => {
|
|
11
|
-
const selectedNodesIds = (filter.nodes ?? []).map(node => node.nodeId);
|
|
12
|
-
const _handleOnCheckEmptyValue = (selected) => {
|
|
13
|
-
onFilterChange({
|
|
14
|
-
...filter,
|
|
15
|
-
withEmptyValues: selected,
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
const _handleOnSelect = (node, selected) => {
|
|
19
|
-
let newSelectedIds;
|
|
20
|
-
if (selected) {
|
|
21
|
-
newSelectedIds = [...selectedNodesIds, node.id];
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.id);
|
|
25
|
-
}
|
|
26
|
-
onFilterChange({
|
|
27
|
-
...filter,
|
|
28
|
-
nodes: newSelectedIds.map(id => ({ nodeId: id, libraryId: node.record.whoAmI.library.id })),
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const _getRecursiveChildrenRecord = (nodes) => {
|
|
32
|
-
const records = [];
|
|
33
|
-
const collectRecordIdsRecursively = (nodeList) => {
|
|
34
|
-
for (const node of nodeList) {
|
|
35
|
-
if (node.id === filter.attribute.linkedTree?.id) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (node.record) {
|
|
39
|
-
records.push(node.record);
|
|
40
|
-
}
|
|
41
|
-
if (node.children && node.children.length > 0) {
|
|
42
|
-
collectRecordIdsRecursively(node.children);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
collectRecordIdsRecursively(nodes);
|
|
47
|
-
// Delete duplicates
|
|
48
|
-
return Array.from(new Set(records));
|
|
49
|
-
};
|
|
50
|
-
const _getRecursiveFieldsFromLibraries = (nodes) => nodes
|
|
51
|
-
.filter(node => !!node.record?.whoAmI?.library?.id)
|
|
52
|
-
.map(node => `${filter.attribute.id}.${node.record?.whoAmI?.library?.id}.id`);
|
|
53
|
-
const _handleOnCheck = (selection) => {
|
|
54
|
-
const newSelectedNodes = selection.filter(node => !node?.disabled);
|
|
55
|
-
const records = _getRecursiveChildrenRecord(selection);
|
|
56
|
-
const fields = _getRecursiveFieldsFromLibraries(selection);
|
|
57
|
-
onFilterChange({
|
|
58
|
-
...filter,
|
|
59
|
-
nodes: newSelectedNodes.map(node => ({
|
|
60
|
-
nodeId: node.id,
|
|
61
|
-
libraryId: node.record?.whoAmI.library.id ?? records[0]?.whoAmI.library.id ?? '',
|
|
62
|
-
})),
|
|
63
|
-
value: records.map(record => record.id),
|
|
64
|
-
formattedValue: records.map(record => record.whoAmI.label).filter(Boolean),
|
|
65
|
-
condition: RecordFilterCondition.EQUAL,
|
|
66
|
-
field: fields,
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
return (_jsxs(DivStyled, { children: [_jsx(EmptyValueCheckbox, { onSelect: _handleOnCheckEmptyValue, filter: filter }), _jsx(SelectTreeNode, { treeId: filter.attribute.linkedTree?.id ?? '', selectedNodes: selectedNodesIds, onSelect: _handleOnSelect, onCheck: _handleOnCheck, multiple: true, canSelectRoot: true, checkStrictly: false, checkable: true, loadRecursively: true, noPagination: true })] }));
|
|
70
|
-
};
|
|
71
|
-
//# sourceMappingURL=TreeAttributeDropDown.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TreeAttributeDropDown.js","sourceRoot":"","sources":["../../../../../src/components/Filters/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C;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} from 'react';\nimport {type IRecordIdentity, type ITreeNodeWithRecord} from '_ui/types';\nimport {RecordFilterCondition} from '_ui/_gqlTypes';\nimport {type IFilterChildrenTreeDropDownProps} from './_types';\nimport {SelectTreeNode} from '_ui/components/SelectTreeNode';\nimport styled from 'styled-components';\nimport {EmptyValueCheckbox} from '../EmptyValueCheckbox';\n\nconst DivStyled = styled.div`\n max-height: 30rem;\n overflow: auto;\n`;\n\nexport const TreeAttributeDropDown: FunctionComponent<IFilterChildrenTreeDropDownProps> = ({\n filter,\n onFilterChange,\n}) => {\n const selectedNodesIds = (filter.nodes ?? []).map(node => node.nodeId);\n\n const _handleOnCheckEmptyValue = (selected: boolean) => {\n onFilterChange({\n ...filter,\n withEmptyValues: selected,\n });\n };\n\n const _handleOnSelect = (node: ITreeNodeWithRecord, selected: boolean) => {\n let newSelectedIds: string[];\n if (selected) {\n newSelectedIds = [...selectedNodesIds, node.id];\n } else {\n newSelectedIds = selectedNodesIds.filter(selectedValue => selectedValue !== node.id);\n }\n onFilterChange({\n ...filter,\n nodes: newSelectedIds.map(id => ({nodeId: id, libraryId: node.record.whoAmI.library.id})),\n });\n };\n\n const _getRecursiveChildrenRecord = (nodes: ITreeNodeWithRecord[]): IRecordIdentity[] => {\n const records: IRecordIdentity[] = [];\n const collectRecordIdsRecursively = (nodeList: ITreeNodeWithRecord[]) => {\n for (const node of nodeList) {\n if (node.id === filter.attribute.linkedTree?.id) {\n continue;\n }\n if (node.record) {\n records.push(node.record);\n }\n if (node.children && node.children.length > 0) {\n collectRecordIdsRecursively(node.children);\n }\n }\n };\n collectRecordIdsRecursively(nodes);\n // Delete duplicates\n return Array.from(new Set(records));\n };\n const _getRecursiveFieldsFromLibraries = (nodes: ITreeNodeWithRecord[]): string[] =>\n nodes\n .filter(node => !!node.record?.whoAmI?.library?.id)\n .map(node => `${filter.attribute.id}.${node.record?.whoAmI?.library?.id}.id`);\n\n const _handleOnCheck = (selection: ITreeNodeWithRecord[]) => {\n const newSelectedNodes = selection.filter(node => !node?.disabled);\n\n const records = _getRecursiveChildrenRecord(selection);\n const fields = _getRecursiveFieldsFromLibraries(selection);\n\n onFilterChange({\n ...filter,\n nodes: newSelectedNodes.map(node => ({\n nodeId: node.id,\n libraryId: node.record?.whoAmI.library.id ?? records[0]?.whoAmI.library.id ?? '',\n })),\n value: records.map(record => record.id),\n formattedValue: records.map(record => record.whoAmI.label).filter(Boolean),\n condition: RecordFilterCondition.EQUAL,\n field: fields,\n });\n };\n\n return (\n <DivStyled>\n <EmptyValueCheckbox onSelect={_handleOnCheckEmptyValue} filter={filter} />\n <SelectTreeNode\n treeId={filter.attribute.linkedTree?.id ?? ''}\n selectedNodes={selectedNodesIds}\n onSelect={_handleOnSelect}\n onCheck={_handleOnCheck}\n multiple\n canSelectRoot={true}\n checkStrictly={false}\n checkable\n loadRecursively={true}\n noPagination={true}\n />\n </DivStyled>\n );\n};\n"]}
|