@leav/ui 1.10.0 → 1.11.0
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 +14 -1
- package/dist/_gqlTypes/index.js +39 -15
- package/dist/_gqlTypes/index.js.map +1 -1
- package/dist/_utils/index.d.ts +0 -1
- package/dist/_utils/index.js +0 -3
- package/dist/_utils/index.js.map +1 -1
- package/dist/components/Explorer/_queries/useExplorerCountData.js +3 -4
- package/dist/components/Explorer/_queries/useExplorerCountData.js.map +1 -1
- package/dist/components/Filters/filter-items/CommonFilterItem.js +8 -6
- package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js +6 -1
- package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +11 -19
- package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
- package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js +27 -18
- package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js.map +1 -1
- package/dist/components/Notifications/InitNotificationsSubscription.d.ts +4 -2
- package/dist/components/Notifications/InitNotificationsSubscription.js.map +1 -1
- package/dist/components/RecordEdition/EditRecord/EditRecord.d.ts +1 -0
- package/dist/components/RecordEdition/EditRecord/EditRecord.js +2 -26
- package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordButtons/SidebarButton.js +2 -2
- package/dist/components/RecordEdition/EditRecordButtons/SidebarButton.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/_types.d.ts +1 -19
- package/dist/components/RecordEdition/EditRecordContent/_types.js +0 -5
- package/dist/components/RecordEdition/EditRecordContent/_types.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.d.ts +0 -3
- package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
- package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.d.ts +1 -2
- package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js +7 -9
- package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +2 -33
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js +11 -0
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js.map +1 -1
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.d.ts +1 -0
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js +4 -20
- package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistory.d.ts +1 -0
- package/dist/components/RecordHistory/RecordHistory.js +3 -3
- package/dist/components/RecordHistory/RecordHistory.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistoryGoUpButton.d.ts +1 -0
- package/dist/components/RecordHistory/RecordHistoryGoUpButton.js +3 -3
- package/dist/components/RecordHistory/RecordHistoryGoUpButton.js.map +1 -1
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js +7 -5
- package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
- package/dist/components/RecordHistory/_queries/recordHistoryQuery.js +38 -14
- package/dist/components/RecordHistory/_queries/recordHistoryQuery.js.map +1 -1
- package/dist/components/RecordHistory/_types.d.ts +2 -2
- package/dist/components/RecordHistory/_types.js.map +1 -1
- package/dist/hooks/useRedirectToLogin/useRedirectToLogin.d.ts +2 -1
- package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js +32 -4
- package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js.map +1 -1
- package/dist/locales/en/shared.json +3 -31
- package/dist/locales/fr/shared.json +3 -31
- package/package.json +5 -5
- package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.d.ts +0 -3
- package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.js +0 -2
- package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.d.ts +0 -1
- package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.js +0 -5
- package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.d.ts +0 -1
- package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.js +0 -5
- package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.d.ts +0 -7
- package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.js +0 -20
- package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.d.ts +0 -11
- package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js +0 -35
- package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.d.ts +0 -52
- package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.js +0 -144
- package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.d.ts +0 -9
- package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.js +0 -19
- package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.d.ts +0 -5
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.js +0 -21
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.d.ts +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.js +0 -14
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.d.ts +0 -9
- package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.js +0 -28
- package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.d.ts +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.js +0 -25
- package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.d.ts +0 -7
- package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.js +0 -33
- package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.js +0 -13
- package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.d.ts +0 -10
- package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.js +0 -24
- package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.d.ts +0 -13
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js +0 -41
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.d.ts +0 -8
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.js +0 -34
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.js.map +0 -1
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.d.ts +0 -2
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.js +0 -6
- package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.js.map +0 -1
|
@@ -3,19 +3,20 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
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 { useGetRecordValuesQuery } from '../../../../hooks/useGetRecordValuesQuery/useGetRecordValuesQuery';
|
|
6
|
-
import { KitAlert, KitButton, KitEmpty, KitSkeleton,
|
|
6
|
+
import { KitAlert, KitButton, KitDivider, KitEmpty, KitSkeleton, KitTypography } from 'aristid-ds';
|
|
7
7
|
import { RecordInformations } from './RecordInformations/RecordInformations';
|
|
8
8
|
import { useSharedTranslation } from '../../../../hooks/useSharedTranslation';
|
|
9
9
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
10
10
|
import { faRotateRight } from '@fortawesome/free-solid-svg-icons';
|
|
11
11
|
import { RecordHistory } from '../../../RecordHistory/RecordHistory';
|
|
12
12
|
import styled from 'styled-components';
|
|
13
|
+
import RecordHistoryGoUpButton from '../../../../components/RecordHistory/RecordHistoryGoUpButton';
|
|
13
14
|
const StyledDivContentWrapper = styled.div `
|
|
14
15
|
display: flex;
|
|
15
16
|
flex-direction: column;
|
|
16
17
|
height: 100%;
|
|
17
18
|
`;
|
|
18
|
-
export const RecordSummary = ({ record }) => {
|
|
19
|
+
export const RecordSummary = ({ record, scrollAll }) => {
|
|
19
20
|
const { t } = useSharedTranslation();
|
|
20
21
|
const { loading, error, data, refetch } = useGetRecordValuesQuery(record?.library?.id, ['created_at', 'created_by', 'modified_at', 'modified_by'], [record?.id]);
|
|
21
22
|
if (loading) {
|
|
@@ -24,24 +25,7 @@ export const RecordSummary = ({ record }) => {
|
|
|
24
25
|
if (error) {
|
|
25
26
|
return (_jsxs(_Fragment, { children: [_jsx(KitAlert, { type: "error", message: t('record_summary.error.title'), description: t('record_summary.error.description'), details: error.message, customContent: record?.id && (_jsx(KitButton, { onClick: () => refetch([record?.id]), type: "action", icon: _jsx(FontAwesomeIcon, { icon: faRotateRight }), danger: true, children: t('record_summary.error.refresh') })) }), _jsx(KitEmpty, { image: KitEmpty.ASSET_TASKS_ERROR })] }));
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
-
return (_jsx(StyledDivContentWrapper, { children: _jsx(KitTabs, { items: [
|
|
29
|
-
{
|
|
30
|
-
key: 'informations',
|
|
31
|
-
label: t('record_summary.informations'),
|
|
32
|
-
tabContent: _jsx(RecordInformations, { record: record, recordData: recordData }),
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
key: 'chat',
|
|
36
|
-
label: t('record_summary.chat'),
|
|
37
|
-
disabled: true,
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
key: 'history',
|
|
41
|
-
label: t('record_summary.history'),
|
|
42
|
-
tabContent: _jsx(RecordHistory, { record: record }),
|
|
43
|
-
},
|
|
44
|
-
] }) }));
|
|
28
|
+
return (_jsx(StyledDivContentWrapper, { children: _jsxs(RecordHistoryGoUpButton, { disabled: !scrollAll, children: [_jsx(KitTypography.Text, { weight: "bold", children: t('record_summary.informations') }), _jsx(RecordInformations, { record: record, recordData: data?.[record?.id] }), _jsx(KitDivider, {}), _jsx(KitTypography.Text, { weight: "bold", children: t('record_summary.history') }), record && _jsx(RecordHistory, { record: record, noScroll: scrollAll })] }) }));
|
|
45
29
|
};
|
|
46
30
|
export default RecordSummary;
|
|
47
31
|
//# sourceMappingURL=RecordSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordSummary.js","sourceRoot":"","sources":["../../../../../src/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,uBAAuB,EAAC,MAAM,mEAAmE,CAAC;AAE1G,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAY,WAAW,
|
|
1
|
+
{"version":3,"file":"RecordSummary.js","sourceRoot":"","sources":["../../../../../src/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,uBAAuB,EAAC,MAAM,mEAAmE,CAAC;AAE1G,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAY,WAAW,EAAW,aAAa,EAAC,MAAM,YAAY,CAAC;AACpH,OAAO,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAC,aAAa,EAAC,MAAM,sCAAsC,CAAC;AACnE,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,uBAAuB,MAAM,sDAAsD,CAAC;AAO3F,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAIzC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA2C,CAAC,EAAC,MAAM,EAAE,SAAS,EAAC,EAAE,EAAE;IACzF,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,EAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAC,GAAG,uBAAuB,CAC3D,MAAM,EAAE,OAAO,EAAE,EAAE,EACnB,CAAC,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,CAAC,EAC1D,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,EAAE,SAAS,GAAI,IAC3C,GACJ,CAC7B,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,aAAa,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 {useGetRecordValuesQuery} from '../../../../hooks/useGetRecordValuesQuery/useGetRecordValuesQuery';\nimport {type IRecordIdentityWhoAmI} from '../../../../types/records';\nimport {KitAlert, KitButton, KitDivider, KitEmpty, KitError, KitSkeleton, KitTabs, KitTypography} from 'aristid-ds';\nimport {RecordInformations} from './RecordInformations/RecordInformations';\nimport {type FunctionComponent} from 'react';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faRotateRight} from '@fortawesome/free-solid-svg-icons';\nimport {RecordHistory} from '../../../RecordHistory/RecordHistory';\nimport styled from 'styled-components';\nimport RecordHistoryGoUpButton from '_ui/components/RecordHistory/RecordHistoryGoUpButton';\n\ninterface IRecordSummaryProps {\n record: IRecordIdentityWhoAmI | null;\n scrollAll?: boolean;\n}\n\nconst StyledDivContentWrapper = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n`;\n\nexport const RecordSummary: FunctionComponent<IRecordSummaryProps> = ({record, scrollAll}) => {\n const {t} = useSharedTranslation();\n const {loading, error, data, refetch} = useGetRecordValuesQuery(\n record?.library?.id,\n ['created_at', 'created_by', 'modified_at', 'modified_by'],\n [record?.id],\n );\n\n if (loading) {\n return (\n <span data-testid=\"record-summary-skeleton\">\n <KitSkeleton.KitItemCardSkeleton />\n </span>\n );\n }\n\n if (error) {\n return (\n <>\n <KitAlert\n type=\"error\"\n message={t('record_summary.error.title')}\n description={t('record_summary.error.description')}\n details={error.message}\n customContent={\n record?.id && (\n <KitButton\n onClick={() => refetch([record?.id])}\n type=\"action\"\n icon={<FontAwesomeIcon icon={faRotateRight} />}\n danger\n >\n {t('record_summary.error.refresh')}\n </KitButton>\n )\n }\n />\n <KitEmpty image={KitEmpty.ASSET_TASKS_ERROR} />\n </>\n );\n }\n\n return (\n <StyledDivContentWrapper>\n <RecordHistoryGoUpButton disabled={!scrollAll}>\n <KitTypography.Text weight=\"bold\">{t('record_summary.informations')}</KitTypography.Text>\n <RecordInformations record={record} recordData={data?.[record?.id]} />\n <KitDivider />\n <KitTypography.Text weight=\"bold\">{t('record_summary.history')}</KitTypography.Text>\n {record && <RecordHistory record={record} noScroll={scrollAll} />}\n </RecordHistoryGoUpButton>\n </StyledDivContentWrapper>\n );\n};\n\nexport default RecordSummary;\n"]}
|
|
@@ -3,6 +3,7 @@ import { type FunctionComponent } from 'react';
|
|
|
3
3
|
interface IRecordHistoryProps {
|
|
4
4
|
record: IRecordIdentityWhoAmI;
|
|
5
5
|
attributeId?: string;
|
|
6
|
+
noScroll?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare const RecordHistory: FunctionComponent<IRecordHistoryProps>;
|
|
8
9
|
export default RecordHistory;
|
|
@@ -15,7 +15,7 @@ import { RecordHistoryLogEntry } from './RecordHistoryLogEntry';
|
|
|
15
15
|
const StyledDivContentWrapper = styled.div `
|
|
16
16
|
margin-top: calc(var(--general-spacing-xs) * 1px);
|
|
17
17
|
flex: 1 1 0;
|
|
18
|
-
overflow-y: auto;
|
|
18
|
+
overflow-y: ${props => (props.$scrollable ? 'auto' : 'unset')};
|
|
19
19
|
`;
|
|
20
20
|
// TODO: This component should be moved to /apps/app-studio/src/modules/information-and-history/record-history/ when he will no longer be used by RecordSummary and ValuesSummary (those components will be removed in the future)
|
|
21
21
|
// Also when component will be moved
|
|
@@ -23,7 +23,7 @@ const StyledDivContentWrapper = styled.div `
|
|
|
23
23
|
// - remove usage of styled-components
|
|
24
24
|
// - instead of a record we could receive a recordId and a libraryId directly
|
|
25
25
|
// - remove styling of StyledDivContentWrapper that will no longer be necessary
|
|
26
|
-
export const RecordHistory = ({ record, attributeId }) => {
|
|
26
|
+
export const RecordHistory = ({ record, attributeId, noScroll }) => {
|
|
27
27
|
const { t } = useSharedTranslation();
|
|
28
28
|
const [showAllHistory, setShowAllHistory] = useState(false);
|
|
29
29
|
const { loading, inError, logs, total, hasMore, fetchMore } = useFetchRecordHistory({
|
|
@@ -44,7 +44,7 @@ export const RecordHistory = ({ record, attributeId }) => {
|
|
|
44
44
|
if (logs.length === 0) {
|
|
45
45
|
return (_jsx(StyledDivContentWrapper, { children: _jsx(KitTypography.Text, { children: t('record_history.empty_history') }) }));
|
|
46
46
|
}
|
|
47
|
-
return (_jsx(StyledDivContentWrapper, { children: _jsx(RecordHistoryGoUpButton, { children: _jsxs(KitSpace, { size: "s", direction: "vertical", children: [showAllHistory && (_jsxs(_Fragment, { children: [logs.map((logEntry, index) => (_jsx(RecordHistoryLogEntry, { index: index, logEntry: logEntry }, index))), _jsx(ShowMore, { hasMore: hasMore, fetchMore: fetchMore })] })), !showAllHistory && _jsx(RecordHistoryLogEntry, { index: 0, logEntry: logs[0] }, 0), total > 1 && (_jsx(KitButton, { type: "secondary", size: "s", onClick: () => setShowAllHistory(!showAllHistory), children: showAllHistory
|
|
47
|
+
return (_jsx(StyledDivContentWrapper, { "$scrollable": !noScroll, children: _jsx(RecordHistoryGoUpButton, { disabled: noScroll, children: _jsxs(KitSpace, { size: "s", direction: "vertical", children: [showAllHistory && (_jsxs(_Fragment, { children: [logs.map((logEntry, index) => (_jsx(RecordHistoryLogEntry, { index: index, logEntry: logEntry }, index))), _jsx(ShowMore, { hasMore: hasMore, fetchMore: fetchMore })] })), !showAllHistory && _jsx(RecordHistoryLogEntry, { index: 0, logEntry: logs[0] }, 0), total > 1 && (_jsx(KitButton, { type: "secondary", size: "s", onClick: () => setShowAllHistory(!showAllHistory), children: showAllHistory
|
|
48
48
|
? t('record_history.hide_history', { total })
|
|
49
49
|
: t('record_history.show_history', { total }) }))] }) }) }));
|
|
50
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordHistory.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistory.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"RecordHistory.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistory.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAEpE,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AACrC,OAAO,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAC,uB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AC,8BAA8B,CAAC,GAAsB,GACtD,CAC7B,CAAC;IACN,CAAC;IAED,OAAO,CACH,KAAC,uBAAuB,mBAAc,CAAC,QAAQ,YAC3C,KAAC,uBAAuB,IAAC,QAAQ,EAAE,QAAQ,YACvC,MAAC,QAAQ,IAAC,IAAI,EAAC,GAAG,EAAC,SAAS,EAAC,UAAU,aAClC,cAAc,IAAI,CACf,8BACK,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,CAC3B,KAAC,qBAAqB,IAAa,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,IAAvC,KAAK,CAAsC,CAC1E,CAAC,EACF,KAAC,QAAQ,IAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAI,IACrD,CACN,EACA,CAAC,cAAc,IAAI,KAAC,qBAAqB,IAAS,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,IAA9B,CAAC,CAAiC,EACjF,KAAK,GAAG,CAAC,IAAI,CACV,KAAC,SAAS,IAAC,IAAI,EAAC,WAAW,EAAC,IAAI,EAAC,GAAG,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC,cAAc,CAAC,YACjF,cAAc;4BACX,CAAC,CAAC,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAC,CAAC;4BAC3C,CAAC,CAAC,CAAC,CAAC,6BAA6B,EAAE,EAAC,KAAK,EAAC,CAAC,GACvC,CACf,IACM,GACW,GACJ,CAC7B,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,aAAa,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {KitButton, KitSpace, KitTypography} from 'aristid-ds';\nimport {type FunctionComponent, useState} from 'react';\nimport styled from 'styled-components';\nimport {ErrorDisplay} from '../ErrorDisplay';\nimport {Loading} from '../Loading';\nimport {ShowMore} from '../ShowMore';\nimport {useFetchRecordHistory} from './hooks/useFetchRecordHistory';\nimport {RecordHistoryGoUpButton} from './RecordHistoryGoUpButton';\nimport {RecordHistoryLogEntry} from './RecordHistoryLogEntry';\n\ninterface IRecordHistoryProps {\n record: IRecordIdentityWhoAmI;\n attributeId?: string;\n noScroll?: boolean;\n}\n\nconst StyledDivContentWrapper = styled.div<{\n $scrollable?: boolean;\n}>`\n margin-top: calc(var(--general-spacing-xs) * 1px);\n flex: 1 1 0;\n overflow-y: ${props => (props.$scrollable ? 'auto' : 'unset')};\n`;\n\n// TODO: This component should be moved to /apps/app-studio/src/modules/information-and-history/record-history/ when he will no longer be used by RecordSummary and ValuesSummary (those components will be removed in the future)\n// Also when component will be moved\n// - put together translations with information_and_history\n// - remove usage of styled-components\n// - instead of a record we could receive a recordId and a libraryId directly\n// - remove styling of StyledDivContentWrapper that will no longer be necessary\nexport const RecordHistory: FunctionComponent<IRecordHistoryProps> = ({record, attributeId, noScroll}) => {\n const {t} = useSharedTranslation();\n const [showAllHistory, setShowAllHistory] = useState<boolean>(false);\n const {loading, inError, logs, total, hasMore, fetchMore} = useFetchRecordHistory({\n record: {\n id: record.id,\n libraryId: record.library.id,\n },\n attributeId,\n });\n\n if (loading && logs.length === 0) {\n // TODO: Add a better loading state\n return <Loading />;\n }\n\n if (inError) {\n //TODO: Add a better error state\n return <ErrorDisplay message={t('record_history.error_fetching')} />;\n }\n\n if (logs.length === 0) {\n return (\n <StyledDivContentWrapper>\n <KitTypography.Text>{t('record_history.empty_history')}</KitTypography.Text>\n </StyledDivContentWrapper>\n );\n }\n\n return (\n <StyledDivContentWrapper $scrollable={!noScroll}>\n <RecordHistoryGoUpButton disabled={noScroll}>\n <KitSpace size=\"s\" direction=\"vertical\">\n {showAllHistory && (\n <>\n {logs.map((logEntry, index) => (\n <RecordHistoryLogEntry key={index} index={index} logEntry={logEntry} />\n ))}\n <ShowMore hasMore={hasMore} fetchMore={fetchMore} />\n </>\n )}\n {!showAllHistory && <RecordHistoryLogEntry key={0} index={0} logEntry={logs[0]} />}\n {total > 1 && (\n <KitButton type=\"secondary\" size=\"s\" onClick={() => setShowAllHistory(!showAllHistory)}>\n {showAllHistory\n ? t('record_history.hide_history', {total})\n : t('record_history.show_history', {total})}\n </KitButton>\n )}\n </KitSpace>\n </RecordHistoryGoUpButton>\n </StyledDivContentWrapper>\n );\n};\n\nexport default RecordHistory;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06
|
|
3
3
|
// This file is released under LGPL V3
|
|
4
4
|
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
@@ -14,14 +14,14 @@ const StyledKitButtonGoUp = styled(KitButton) `
|
|
|
14
14
|
bottom: calc(var(--general-spacing-m) * 1px);
|
|
15
15
|
z-index: 10;
|
|
16
16
|
`;
|
|
17
|
-
export const RecordHistoryGoUpButton = ({ children }) => {
|
|
17
|
+
export const RecordHistoryGoUpButton = ({ disabled, children }) => {
|
|
18
18
|
// cannot use detectScrollTopRef because it is not a ref to div but to a customRef to a callback
|
|
19
19
|
const scrollTopRef = useRef(null);
|
|
20
20
|
// Detect if the top of the list is visible or not
|
|
21
21
|
// to show or hide the "go up" button
|
|
22
22
|
const [detectScrollTopRef, detectScrollTopEntry] = useIntersectionObserver({ threshold: 0 });
|
|
23
23
|
const showGoUpButton = !detectScrollTopEntry?.isIntersecting;
|
|
24
|
-
return (_jsxs("div", { ref: scrollTopRef, children: [_jsx("div", { ref: detectScrollTopRef }), children, showGoUpButton && (_jsx(StyledKitButtonGoUp, { type: "segmented", size: "m", icon: _jsx(FontAwesomeIcon, { icon: faAngleUp }), onClick: () => {
|
|
24
|
+
return disabled ? (_jsx(_Fragment, { children: children })) : (_jsxs("div", { ref: scrollTopRef, children: [_jsx("div", { ref: detectScrollTopRef }), children, showGoUpButton && (_jsx(StyledKitButtonGoUp, { type: "segmented", size: "m", icon: _jsx(FontAwesomeIcon, { icon: faAngleUp }), onClick: () => {
|
|
25
25
|
scrollTopRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
26
26
|
} }))] }));
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordHistoryGoUpButton.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryGoUpButton.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAiB,MAAM,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,mBAAmB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;;;;CAK5C,CAAC;
|
|
1
|
+
{"version":3,"file":"RecordHistoryGoUpButton.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/RecordHistoryGoUpButton.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAiB,MAAM,EAAC,MAAM,OAAO,CAAC;AAC7C,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,mBAAmB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;;;;;CAK5C,CAAC;AAOF,MAAM,CAAC,MAAM,uBAAuB,GAA4C,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAC,EAAE,EAAE;IACrG,gGAAgG;IAChG,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAElD,kDAAkD;IAClD,qCAAqC;IACrC,MAAM,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,GAAG,uBAAuB,CAAiB,EAAC,SAAS,EAAE,CAAC,EAAC,CAAC,CAAC;IAC3G,MAAM,cAAc,GAAG,CAAC,oBAAoB,EAAE,cAAc,CAAC;IAE7D,OAAO,QAAQ,CAAC,CAAC,CAAC,CACd,4BAAG,QAAQ,GAAI,CAClB,CAAC,CAAC,CAAC,CACA,eAAK,GAAG,EAAE,YAAY,aAClB,cAAK,GAAG,EAAE,kBAAkB,GAAI,EAC/B,QAAQ,EACR,cAAc,IAAI,CACf,KAAC,mBAAmB,IAChB,IAAI,EAAC,WAAW,EAChB,IAAI,EAAC,GAAG,EACR,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,SAAS,GAAI,EAC1C,OAAO,EAAE,GAAG,EAAE;oBACV,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC,CAAC;gBAC/D,CAAC,GACH,CACL,IACC,CACT,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,uBAAuB,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 {faAngleUp} from '@fortawesome/free-solid-svg-icons';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {useIntersectionObserver} from '@uidotdev/usehooks';\nimport {KitButton} from 'aristid-ds';\nimport {type ReactNode, useRef} from 'react';\nimport styled from 'styled-components';\n\nconst StyledKitButtonGoUp = styled(KitButton)`\n position: absolute;\n right: calc(var(--general-spacing-m) * 1px);\n bottom: calc(var(--general-spacing-m) * 1px);\n z-index: 10;\n`;\n\ninterface IRecordHistoryGoUpButtonProps {\n children: ReactNode;\n disabled?: boolean;\n}\n\nexport const RecordHistoryGoUpButton: React.FC<IRecordHistoryGoUpButtonProps> = ({disabled, children}) => {\n // cannot use detectScrollTopRef because it is not a ref to div but to a customRef to a callback\n const scrollTopRef = useRef<HTMLDivElement>(null);\n\n // Detect if the top of the list is visible or not\n // to show or hide the \"go up\" button\n const [detectScrollTopRef, detectScrollTopEntry] = useIntersectionObserver<HTMLDivElement>({threshold: 0});\n const showGoUpButton = !detectScrollTopEntry?.isIntersecting;\n\n return disabled ? (\n <>{children}</>\n ) : (\n <div ref={scrollTopRef}>\n <div ref={detectScrollTopRef} />\n {children}\n {showGoUpButton && (\n <StyledKitButtonGoUp\n type=\"segmented\"\n size=\"m\"\n icon={<FontAwesomeIcon icon={faAngleUp} />}\n onClick={() => {\n scrollTopRef.current?.scrollIntoView({behavior: 'smooth'});\n }}\n />\n )}\n </div>\n );\n};\n\nexport default RecordHistoryGoUpButton;\n"]}
|
|
@@ -23,13 +23,14 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
23
23
|
const hasValue = (value) => value != null && 'asString' in value && value.asString != null;
|
|
24
24
|
const hasBefore = hasValue(before);
|
|
25
25
|
const hasAfter = hasValue(after);
|
|
26
|
+
const isKnownAttribute = (attr) => attr != null && 'multiple_values' in attr;
|
|
26
27
|
const getUserString = () => {
|
|
27
|
-
const email = user
|
|
28
|
+
const email = user && 'properties' in user ? user.properties[0]?.values[0]?.payload : null;
|
|
28
29
|
return email ? (_jsx(StyledLinkButton, { type: "link", href: `mailto:${email}`, children: email })) : (user?.id || t('record_history.unknown_user'));
|
|
29
30
|
};
|
|
30
31
|
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
|
|
31
32
|
const getActionString = () => {
|
|
32
|
-
if (attribute
|
|
33
|
+
if (isKnownAttribute(attribute) && attribute.multiple_values) {
|
|
33
34
|
if (!hasBefore && hasAfter) {
|
|
34
35
|
return t('record_history.action.value_add');
|
|
35
36
|
}
|
|
@@ -41,21 +42,22 @@ export const RecordHistoryLogEntry = ({ index, logEntry }) => {
|
|
|
41
42
|
};
|
|
42
43
|
const getAttributeLabel = () => localizedTranslation(attribute?.label, lang) || attribute?.id || t('record_history.unknown_attribute');
|
|
43
44
|
const formatValue = (logData) => {
|
|
44
|
-
if (attribute
|
|
45
|
+
if (isKnownAttribute(attribute) &&
|
|
46
|
+
(attribute.format === AttributeFormat.rich_text || attribute.format === AttributeFormat.extended)) {
|
|
45
47
|
return (_jsx(KitTypography.AdvancedParagraph, { size: "fontSize5", ellipsis: { rows: 4, expandable: true }, children: logData.asString }));
|
|
46
48
|
}
|
|
47
49
|
return _jsx(KitTypography.Text, { size: "fontSize5", children: logData.asString });
|
|
48
50
|
};
|
|
49
51
|
const formatValueChange = () => {
|
|
50
52
|
const noValue = _jsx(KitTypography.Text, { size: "fontSize5", children: t('record_history.no_value') });
|
|
51
|
-
if (attribute
|
|
53
|
+
if (isKnownAttribute(attribute) && attribute.format === AttributeFormat.extended) {
|
|
52
54
|
const diffs = getExtendedAttributeDiffs(hasValue(before) ? JSON.parse(before.asString) : undefined, hasValue(after) ? JSON.parse(after.asString) : undefined);
|
|
53
55
|
return diffs.map(diff => (_jsxs(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: [getExtendedAttributeLabels(diff.path, attribute
|
|
54
56
|
.embedded_fields, lang, t('record_history.unknown_attribute'))
|
|
55
57
|
.reverse()
|
|
56
58
|
.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
59
|
}
|
|
58
|
-
if (attribute
|
|
60
|
+
if (isKnownAttribute(attribute) && attribute.multiple_values) {
|
|
59
61
|
const uniqValue = !hasBefore && hasAfter ? after : hasBefore && !hasAfter ? before : null;
|
|
60
62
|
if (uniqValue != null) {
|
|
61
63
|
return (_jsx(KitSpace, { size: "xxs", direction: "horizontal", wrap: true, children: formatValue(uniqValue) }));
|
|
@@ -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,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,EA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,CACH,KAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,YAAY,EAAC,IAAI,kBAC3C,WAAW,CAAC,SAAS,CAAC,GAChB,CACd,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,CACH,MAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,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"]}
|
|
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,K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gBACpB,OAAO,CACH,KAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,EAAC,YAAY,EAAC,IAAI,kBAC3C,WAAW,CAAC,SAAS,CAAC,GAChB,CACd,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,CACH,MAAC,QAAQ,IAAC,IAAI,EAAC,KAAK,EAAC,SAAS,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 const isKnownAttribute = (attr: typeof attribute): attr is Extract<typeof attribute, {multiple_values: boolean}> =>\n attr != null && 'multiple_values' in attr;\n\n const getUserString = () => {\n const email = user && 'properties' in user ? user.properties[0]?.values[0]?.payload : null;\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 (isKnownAttribute(attribute) && 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 (\n isKnownAttribute(attribute) &&\n (attribute.format === AttributeFormat.rich_text || attribute.format === AttributeFormat.extended)\n ) {\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 (isKnownAttribute(attribute) && 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 (isKnownAttribute(attribute) && 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"]}
|
|
@@ -5,14 +5,32 @@ import { gqlUnchecked } from '../../../_utils';
|
|
|
5
5
|
import { getEmbeddedFields } from '../../../_queries/attributes/getAttributeWithEmbeddedFields';
|
|
6
6
|
export const recordHistoryLogAttributeFragment = (depthEmbeddedFields) => `
|
|
7
7
|
attribute {
|
|
8
|
-
id
|
|
9
|
-
label
|
|
10
|
-
type
|
|
11
|
-
format
|
|
12
|
-
multiple_values
|
|
13
8
|
... on StandardAttribute {
|
|
9
|
+
id
|
|
10
|
+
label
|
|
11
|
+
type
|
|
12
|
+
format
|
|
13
|
+
multiple_values
|
|
14
14
|
${getEmbeddedFields(depthEmbeddedFields)}
|
|
15
15
|
}
|
|
16
|
+
... on LinkAttribute {
|
|
17
|
+
id
|
|
18
|
+
label
|
|
19
|
+
type
|
|
20
|
+
format
|
|
21
|
+
multiple_values
|
|
22
|
+
}
|
|
23
|
+
... on TreeAttribute {
|
|
24
|
+
id
|
|
25
|
+
label
|
|
26
|
+
type
|
|
27
|
+
format
|
|
28
|
+
multiple_values
|
|
29
|
+
}
|
|
30
|
+
... on LogUnknownEntity {
|
|
31
|
+
id
|
|
32
|
+
label
|
|
33
|
+
}
|
|
16
34
|
}
|
|
17
35
|
`;
|
|
18
36
|
const RecordHistoryLogEntryFragment = (depthAttributeEmbeddedFields) => `
|
|
@@ -23,21 +41,27 @@ const RecordHistoryLogEntryFragment = (depthAttributeEmbeddedFields) => `
|
|
|
23
41
|
${recordHistoryLogAttributeFragment(depthAttributeEmbeddedFields)}
|
|
24
42
|
}
|
|
25
43
|
user {
|
|
26
|
-
|
|
27
|
-
whoAmI { # Don't know why, but frontend need that to load record !
|
|
44
|
+
... on Record {
|
|
28
45
|
id
|
|
29
|
-
|
|
46
|
+
whoAmI { # Don't know why, but frontend need that to load record !
|
|
30
47
|
id
|
|
48
|
+
library {
|
|
49
|
+
id
|
|
50
|
+
}
|
|
31
51
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
52
|
+
properties(attributeIds: ["email"]) {
|
|
53
|
+
attributeId
|
|
54
|
+
values {
|
|
55
|
+
... on Value {
|
|
56
|
+
payload
|
|
57
|
+
}
|
|
38
58
|
}
|
|
39
59
|
}
|
|
40
60
|
}
|
|
61
|
+
... on LogUnknownEntity {
|
|
62
|
+
id
|
|
63
|
+
label
|
|
64
|
+
}
|
|
41
65
|
}
|
|
42
66
|
before {
|
|
43
67
|
asString
|
|
@@ -1 +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
|
|
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;;;;;;;;;;;;;;;;;;;;;CAqBnD,CAAC;AAEF,MAAM,6BAA6B,GAAG,CAAC,4BAAoC,EAAE,EAAE,CAAC;;;;;cAKlE,iCAAiC,CAAC,4BAA4B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC5E,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 ... on StandardAttribute {\n id\n label\n type\n format\n multiple_values\n ${getEmbeddedFields(depthEmbeddedFields)}\n }\n ... on LinkAttribute {\n id\n label\n type\n format\n multiple_values\n }\n ... on TreeAttribute {\n id\n label\n type\n format\n multiple_values\n }\n ... on LogUnknownEntity {\n id\n label\n }\n }\n`;\n\nconst RecordHistoryLogEntryFragment = (depthAttributeEmbeddedFields: number) => `\n logs {\n action\n time\n topic {\n ${recordHistoryLogAttributeFragment(depthAttributeEmbeddedFields)}\n }\n user {\n ... on Record {\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 ... on LogUnknownEntity {\n id\n label\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,8 +1,8 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RecordHistoryLogEntryFragment } from '../../_gqlTypes';
|
|
2
2
|
export type LogEntry = RecordHistoryLogEntryFragment;
|
|
3
3
|
export type LogEntryValue = Extract<LogEntry, {
|
|
4
4
|
before?: any;
|
|
5
5
|
after?: any;
|
|
6
6
|
}>;
|
|
7
|
-
export type LogEntryAttribute =
|
|
7
|
+
export type LogEntryAttribute = NonNullable<NonNullable<LogEntryValue['topic']>['attribute']>;
|
|
8
8
|
export type LogEntryData = LogEntryValue['before'] | LogEntryValue['after'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/_types.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
|
|
1
|
+
{"version":3,"file":"_types.js","sourceRoot":"","sources":["../../../src/components/RecordHistory/_types.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 RecordHistoryLogEntryFragment} from '_ui/_gqlTypes';\n\nexport type LogEntry = RecordHistoryLogEntryFragment;\nexport type LogEntryValue = Extract<LogEntry, {before?: any; after?: any}>;\nexport type LogEntryAttribute = NonNullable<NonNullable<LogEntryValue['topic']>['attribute']>;\nexport type LogEntryData = LogEntryValue['before'] | LogEntryValue['after'];\n"]}
|
|
@@ -2,13 +2,41 @@
|
|
|
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
4
|
import { isDevEnv } from '../../_utils/isDevEnv';
|
|
5
|
+
import { GLOBAL_BASE_URL } from '../../constants';
|
|
5
6
|
export default function useRedirectToLogin() {
|
|
7
|
+
const redirectToLogin = () => {
|
|
8
|
+
if (isDevEnv()) {
|
|
9
|
+
return window.location.replace(`${window.location.origin}${GLOBAL_BASE_URL}/app/login/?dest=${encodeURIComponent(window.location.toString())}`);
|
|
10
|
+
}
|
|
11
|
+
return window.location.reload();
|
|
12
|
+
};
|
|
13
|
+
// Avoid multiple simultaneous auth checks by sharing the same promise
|
|
14
|
+
let authCheckPromise = null;
|
|
6
15
|
return {
|
|
7
|
-
redirectToLogin
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
redirectToLogin,
|
|
17
|
+
checkAuthOrRedirectToLogin: async () => {
|
|
18
|
+
if (!authCheckPromise) {
|
|
19
|
+
authCheckPromise = (async () => {
|
|
20
|
+
try {
|
|
21
|
+
const res = await fetch(`${GLOBAL_BASE_URL}/auth/login-checker`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
});
|
|
24
|
+
if (!res.ok) {
|
|
25
|
+
throw new Error(res.statusText, { cause: res });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.error('An error occurred while checking authentication, redirecting to login...', {
|
|
30
|
+
error: e,
|
|
31
|
+
});
|
|
32
|
+
redirectToLogin();
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
authCheckPromise = null;
|
|
36
|
+
}
|
|
37
|
+
})();
|
|
10
38
|
}
|
|
11
|
-
return
|
|
39
|
+
return authCheckPromise;
|
|
12
40
|
},
|
|
13
41
|
};
|
|
14
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRedirectToLogin.js","sourceRoot":"","sources":["../../../src/hooks/useRedirectToLogin/useRedirectToLogin.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useRedirectToLogin.js","sourceRoot":"","sources":["../../../src/hooks/useRedirectToLogin/useRedirectToLogin.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAE9C,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACtC,MAAM,eAAe,GAAG,GAAG,EAAE;QACzB,IAAI,QAAQ,EAAE,EAAE,CAAC;YACb,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAC1B,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,eAAe,oBAAoB,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAClH,CAAC;QACN,CAAC;QACD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC,CAAC;IAEF,sEAAsE;IACtE,IAAI,gBAAgB,GAAyB,IAAI,CAAC;IAElD,OAAO;QACH,eAAe;QACf,0BAA0B,EAAE,KAAK,IAAI,EAAE;YACnC,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACpB,gBAAgB,GAAG,CAAC,KAAK,IAAI,EAAE;oBAC3B,IAAI,CAAC;wBACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,eAAe,qBAAqB,EAAE;4BAC7D,MAAM,EAAE,MAAM;yBACjB,CAAC,CAAC;wBACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;4BACV,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC,CAAC;wBAClD,CAAC;oBACL,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACT,OAAO,CAAC,KAAK,CAAC,0EAA0E,EAAE;4BACtF,KAAK,EAAE,CAAC;yBACX,CAAC,CAAC;wBACH,eAAe,EAAE,CAAC;oBACtB,CAAC;4BAAS,CAAC;wBACP,gBAAgB,GAAG,IAAI,CAAC;oBAC5B,CAAC;gBACL,CAAC,CAAC,EAAE,CAAC;YACT,CAAC;YACD,OAAO,gBAAgB,CAAC;QAC5B,CAAC;KACJ,CAAC;AACN,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 {isDevEnv} from '_ui/_utils/isDevEnv';\nimport {GLOBAL_BASE_URL} from '_ui/constants';\n\nexport default function useRedirectToLogin() {\n const redirectToLogin = () => {\n if (isDevEnv()) {\n return window.location.replace(\n `${window.location.origin}${GLOBAL_BASE_URL}/app/login/?dest=${encodeURIComponent(window.location.toString())}`,\n );\n }\n return window.location.reload();\n };\n\n // Avoid multiple simultaneous auth checks by sharing the same promise\n let authCheckPromise: Promise<void> | null = null;\n\n return {\n redirectToLogin,\n checkAuthOrRedirectToLogin: async () => {\n if (!authCheckPromise) {\n authCheckPromise = (async () => {\n try {\n const res = await fetch(`${GLOBAL_BASE_URL}/auth/login-checker`, {\n method: 'POST',\n });\n if (!res.ok) {\n throw new Error(res.statusText, {cause: res});\n }\n } catch (e) {\n console.error('An error occurred while checking authentication, redirecting to login...', {\n error: e,\n });\n redirectToLogin();\n } finally {\n authCheckPromise = null;\n }\n })();\n }\n return authCheckPromise;\n },\n };\n}\n"]}
|
|
@@ -411,42 +411,21 @@
|
|
|
411
411
|
},
|
|
412
412
|
"record_edition": {
|
|
413
413
|
"no_form_error": "No form available",
|
|
414
|
-
"invalid_format": "Invalid format",
|
|
415
414
|
"missing_attribute": "Missing attribute",
|
|
416
415
|
"modified_at": "Modified at",
|
|
417
416
|
"created_at": "Created at",
|
|
418
|
-
"link_created_at": "Linked at",
|
|
419
417
|
"add_value": "Add value",
|
|
420
|
-
"add_value_link": "Add link",
|
|
421
418
|
"delete_value": "Delete value",
|
|
422
|
-
"delete_value_confirm": "Do you really want to delete this value?",
|
|
423
419
|
"whoAmI": "Information",
|
|
424
420
|
"no_value": "No value",
|
|
425
|
-
"value_details": "Value details",
|
|
426
|
-
"link_details": "Link details",
|
|
427
|
-
"by": "by",
|
|
428
|
-
"no_matching_value": "No matching value",
|
|
429
|
-
"copy_value": "Copy",
|
|
430
421
|
"select": "Select",
|
|
431
|
-
"new_value": "New value",
|
|
432
|
-
"advanced_search": "Advanced search",
|
|
433
|
-
"search_elements": "Search elements",
|
|
434
422
|
"values_list": "Values List",
|
|
435
423
|
"new_record": "Create",
|
|
436
|
-
"value_details_section": "Value",
|
|
437
|
-
"link_value_details_section": "Linked record",
|
|
438
|
-
"attribute_details_section": "More details...",
|
|
439
|
-
"path_section": "Path",
|
|
440
|
-
"start_typing_message": "Start typing to search elements",
|
|
441
|
-
"metadata_section": "Value properties",
|
|
442
|
-
"metadata_section_link": "Link properties",
|
|
443
|
-
"value_length": "{{length}} characters",
|
|
444
424
|
"delete_all": "Delete all",
|
|
445
425
|
"delete_all_values": "Delete all values",
|
|
446
426
|
"delete_all_values_confirm": "Do you really want to delete all values?",
|
|
447
427
|
"delete_link": "Delete link",
|
|
448
428
|
"delete_link_description": "Do you really want to delete the link?",
|
|
449
|
-
"value_details_tooltip": "More details",
|
|
450
429
|
"attribute": {
|
|
451
430
|
"id": "Identifier",
|
|
452
431
|
"info_title": "Attribute info",
|
|
@@ -467,8 +446,6 @@
|
|
|
467
446
|
"format_rich_text": "Rich Text"
|
|
468
447
|
},
|
|
469
448
|
"date_range_value": "From {{from}} to {{to}}",
|
|
470
|
-
"external_update_warning": "This record has been updated by {{modifiers}}",
|
|
471
|
-
"field_external_update": "This field has been updated",
|
|
472
449
|
"create": "Create",
|
|
473
450
|
"create_and_edit": "Create and edit",
|
|
474
451
|
"cancel_confirm_modal_title": "Confirm cancellation?",
|
|
@@ -477,9 +454,6 @@
|
|
|
477
454
|
"inherited_value": "Inherited value",
|
|
478
455
|
"calculated_value": "Calculated value",
|
|
479
456
|
"overrided_value": "Overrided value",
|
|
480
|
-
"date_range_from_to": "from {{- from}} to {{- to}}",
|
|
481
|
-
"link_search_result_count": "Results ({{count}}/{{total}})",
|
|
482
|
-
"suggestions_count": "Suggestions ({{count}})",
|
|
483
457
|
"search_not_found": "No match",
|
|
484
458
|
"press_enter_to": "Press enter to ",
|
|
485
459
|
"select_this_value": "Select this value",
|
|
@@ -498,8 +472,8 @@
|
|
|
498
472
|
"select_an_option": "Select an option"
|
|
499
473
|
},
|
|
500
474
|
"replace-by-existing-item": "Replace by an existing item",
|
|
501
|
-
"open_sidebar": "
|
|
502
|
-
"close_sidebar": "
|
|
475
|
+
"open_sidebar": "Show informations",
|
|
476
|
+
"close_sidebar": "Hide informations"
|
|
503
477
|
},
|
|
504
478
|
"record_summary": {
|
|
505
479
|
"preview_title": "Click here to visualize preview.",
|
|
@@ -510,15 +484,13 @@
|
|
|
510
484
|
"created_at_value": "{{date}} by {{user}}",
|
|
511
485
|
"modified_at": "Modified on",
|
|
512
486
|
"modified_at_value": "{{date}} by {{user}}",
|
|
513
|
-
"new_record": "New record",
|
|
514
487
|
"id_entity": "Entity identifier",
|
|
515
488
|
"creation": "Creation",
|
|
516
489
|
"last_modification": "Last modification",
|
|
517
490
|
"date_by_user": "{{date}} by {{user}}",
|
|
518
|
-
"open_preview_modal": "Open preview modal",
|
|
519
491
|
"informations": "Informations",
|
|
520
|
-
"chat": "Chat",
|
|
521
492
|
"history": "History",
|
|
493
|
+
"entity": "{{entity}}",
|
|
522
494
|
"entity_overview": "{{entity}} overview",
|
|
523
495
|
"attribute": "Attribute",
|
|
524
496
|
"attribute_format": "Attribute format",
|