@leav/ui 1.10.0 → 1.11.0-dba96a03

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.
Files changed (144) hide show
  1. package/dist/_gqlTypes/index.d.ts +14 -1
  2. package/dist/_gqlTypes/index.js +39 -15
  3. package/dist/_gqlTypes/index.js.map +1 -1
  4. package/dist/_utils/index.d.ts +0 -1
  5. package/dist/_utils/index.js +0 -3
  6. package/dist/_utils/index.js.map +1 -1
  7. package/dist/components/Explorer/_queries/useExplorerCountData.js +3 -4
  8. package/dist/components/Explorer/_queries/useExplorerCountData.js.map +1 -1
  9. package/dist/components/Filters/filter-items/CommonFilterItem.js +8 -6
  10. package/dist/components/Filters/filter-items/CommonFilterItem.js.map +1 -1
  11. package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js +6 -1
  12. package/dist/components/Filters/filter-items/filter-type/BooleanAttributeDropdown.js.map +1 -1
  13. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js +11 -19
  14. package/dist/components/Filters/filter-items/filter-type/FilterValueListDropDown.js.map +1 -1
  15. package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js +27 -18
  16. package/dist/components/Filters/filter-items/filter-type/TextAttributeDropDown.js.map +1 -1
  17. package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js +11 -0
  18. package/dist/components/Filters/filter-items/filter-type/tree/TreeAttributeDropDown.js.map +1 -1
  19. package/dist/components/Filters/filter-items/filter-type/tree/utils/countSelectedTreeChildren.d.ts +2 -0
  20. package/dist/components/Filters/filter-items/filter-type/tree/utils/countSelectedTreeChildren.js +10 -0
  21. package/dist/components/Filters/filter-items/filter-type/tree/utils/countSelectedTreeChildren.js.map +1 -0
  22. package/dist/components/Notifications/InitNotificationsSubscription.d.ts +4 -2
  23. package/dist/components/Notifications/InitNotificationsSubscription.js.map +1 -1
  24. package/dist/components/RecordEdition/EditRecord/EditRecord.d.ts +1 -0
  25. package/dist/components/RecordEdition/EditRecord/EditRecord.js +2 -26
  26. package/dist/components/RecordEdition/EditRecord/EditRecord.js.map +1 -1
  27. package/dist/components/RecordEdition/EditRecordButtons/SidebarButton.js +2 -2
  28. package/dist/components/RecordEdition/EditRecordButtons/SidebarButton.js.map +1 -1
  29. package/dist/components/RecordEdition/EditRecordContent/_types.d.ts +1 -19
  30. package/dist/components/RecordEdition/EditRecordContent/_types.js +0 -5
  31. package/dist/components/RecordEdition/EditRecordContent/_types.js.map +1 -1
  32. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.d.ts +0 -3
  33. package/dist/components/RecordEdition/EditRecordContent/uiElements/LinkField/explorer/LinkFieldExplorer.js.map +1 -1
  34. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js +1 -1
  35. package/dist/components/RecordEdition/EditRecordModal/EditRecordModal.js.map +1 -1
  36. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.d.ts +1 -2
  37. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js +7 -9
  38. package/dist/components/RecordEdition/EditRecordSidebar/EditRecordSidebar.js.map +1 -1
  39. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js +2 -33
  40. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.js.map +1 -1
  41. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js +11 -0
  42. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.js.map +1 -1
  43. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.d.ts +1 -0
  44. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js +4 -20
  45. package/dist/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordSummary.js.map +1 -1
  46. package/dist/components/RecordHistory/RecordHistory.d.ts +1 -0
  47. package/dist/components/RecordHistory/RecordHistory.js +3 -3
  48. package/dist/components/RecordHistory/RecordHistory.js.map +1 -1
  49. package/dist/components/RecordHistory/RecordHistoryGoUpButton.d.ts +1 -0
  50. package/dist/components/RecordHistory/RecordHistoryGoUpButton.js +3 -3
  51. package/dist/components/RecordHistory/RecordHistoryGoUpButton.js.map +1 -1
  52. package/dist/components/RecordHistory/RecordHistoryLogEntry.js +7 -5
  53. package/dist/components/RecordHistory/RecordHistoryLogEntry.js.map +1 -1
  54. package/dist/components/RecordHistory/_queries/recordHistoryQuery.js +38 -14
  55. package/dist/components/RecordHistory/_queries/recordHistoryQuery.js.map +1 -1
  56. package/dist/components/RecordHistory/_types.d.ts +2 -2
  57. package/dist/components/RecordHistory/_types.js.map +1 -1
  58. package/dist/hooks/useRedirectToLogin/useRedirectToLogin.d.ts +2 -1
  59. package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js +32 -4
  60. package/dist/hooks/useRedirectToLogin/useRedirectToLogin.js.map +1 -1
  61. package/dist/locales/en/shared.json +3 -31
  62. package/dist/locales/fr/shared.json +3 -31
  63. package/package.json +5 -5
  64. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.d.ts +0 -3
  65. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.js +0 -2
  66. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/getActiveFieldValues.js.map +0 -1
  67. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.d.ts +0 -1
  68. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.js +0 -5
  69. package/dist/components/RecordEdition/EditRecordContent/helpers/getActiveFieldValues/index.js.map +0 -1
  70. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.d.ts +0 -1
  71. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.js +0 -5
  72. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/index.js.map +0 -1
  73. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.d.ts +0 -7
  74. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.js +0 -20
  75. package/dist/components/RecordEdition/EditRecordContent/helpers/isCurrentVersion/isCurrentVersion.js.map +0 -1
  76. package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.d.ts +0 -11
  77. package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js +0 -35
  78. package/dist/components/RecordEdition/EditRecordContent/hooks/useTabManagement.js.map +0 -1
  79. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.d.ts +0 -2
  80. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.js +0 -6
  81. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/index.js.map +0 -1
  82. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.d.ts +0 -52
  83. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.js +0 -144
  84. package/dist/components/RecordEdition/EditRecordContent/reducers/linkFieldReducer/linkFieldReducer.js.map +0 -1
  85. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.d.ts +0 -9
  86. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.js +0 -19
  87. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/AddValueBtn.js.map +0 -1
  88. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.d.ts +0 -2
  89. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.js +0 -6
  90. package/dist/components/RecordEdition/EditRecordContent/shared/AddValueBtn/index.js.map +0 -1
  91. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.d.ts +0 -5
  92. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.js +0 -21
  93. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/DeleteAllValuesBtn.js.map +0 -1
  94. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.d.ts +0 -2
  95. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.js +0 -6
  96. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteAllValuesBtn/index.js.map +0 -1
  97. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.d.ts +0 -6
  98. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.js +0 -14
  99. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/DeleteValueBtn.js.map +0 -1
  100. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.d.ts +0 -2
  101. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.js +0 -6
  102. package/dist/components/RecordEdition/EditRecordContent/shared/DeleteValueBtn/index.js.map +0 -1
  103. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.d.ts +0 -9
  104. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.js +0 -28
  105. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/FieldFooter.js.map +0 -1
  106. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.d.ts +0 -2
  107. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.js +0 -6
  108. package/dist/components/RecordEdition/EditRecordContent/shared/FieldFooter/index.js.map +0 -1
  109. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.d.ts +0 -6
  110. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.js +0 -25
  111. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/InheritedFieldLabel.js.map +0 -1
  112. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.d.ts +0 -2
  113. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.js +0 -6
  114. package/dist/components/RecordEdition/EditRecordContent/shared/InheritedFieldLabel/index.js.map +0 -1
  115. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.d.ts +0 -7
  116. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.js +0 -33
  117. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/NoValue.js.map +0 -1
  118. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.d.ts +0 -2
  119. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.js +0 -6
  120. package/dist/components/RecordEdition/EditRecordContent/shared/NoValue/index.js.map +0 -1
  121. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.d.ts +0 -2
  122. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.js +0 -13
  123. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/UpdatedFieldIcon.js.map +0 -1
  124. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.d.ts +0 -2
  125. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.js +0 -6
  126. package/dist/components/RecordEdition/EditRecordContent/shared/UpdatedFieldIcon/index.js.map +0 -1
  127. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.d.ts +0 -10
  128. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.js +0 -24
  129. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/ValueDetailsBtn.js.map +0 -1
  130. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.d.ts +0 -2
  131. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.js +0 -6
  132. package/dist/components/RecordEdition/EditRecordContent/shared/ValueDetailsBtn/index.js.map +0 -1
  133. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.d.ts +0 -13
  134. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js +0 -41
  135. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/ValuesVersionBtn.js.map +0 -1
  136. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.d.ts +0 -2
  137. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.js +0 -6
  138. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionBtn/index.js.map +0 -1
  139. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.d.ts +0 -8
  140. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.js +0 -34
  141. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/ValuesVersionIndicator.js.map +0 -1
  142. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.d.ts +0 -2
  143. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.js +0 -6
  144. package/dist/components/RecordEdition/EditRecordContent/shared/ValuesVersionIndicator/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"RecordInformations.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.tsx"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAyB,QAAQ,EAAC,MAAM,OAAO,CAAC;AAEvD,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;A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MAAM,EAAE,EAAE,EAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EACpB,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,EAAC,MAAM,EAAE,MAAM,EAAC,EAC5B,gBAAgB,EAAE,EAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAC,EAC3F,KAAK,EAAE,EAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAC,EAC9C,IAAI,SACN,EACD,WAAW,KAAK,SAAS,IAAI,CAC1B,KAAC,UAAU,IACP,KAAK,EAAE,CAAC,CAAC,mCAAmC,CAAC,EAC7C,eAAe,EAAE,gCAAgC,YAEjD,KAAC,iBAAiB,kBACF,CAAC,CAAC,mCAAmC,CAAC,EAClD,IAAI,EAAC,UAAU,EACf,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,QAAQ,GAAI,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,GAC9C,GACO,CAChB,IACY,EAChB,sBAAsB,IAAI,CACvB,KAAC,SAAS,IACN,IAAI,EAAE,sBAAsB,EAC5B,MAAM,EAAE,WAAW,EAAE,EAAE,EACvB,SAAS,EAAE,WAAW,EAAE,OAAO,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,uBAAuB,CAAC,KAAK,CAAC,GAC/C,CACL,EACD,KAAC,cAAc,cACX,KAAC,cAAc,IAAC,KAAK,EAAE,kBAAkB,GAAI,GAChC,IACC,CACzB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent, useState} from 'react';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport styled from 'styled-components';\nimport {KitButton, KitTooltip} from 'aristid-ds';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {faExpand} from '@fortawesome/free-solid-svg-icons';\nimport PropertiesList from '../../PropertiesList';\nimport {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {type GetRecordColumnsValuesRecord} from '_ui/_queries/records/getRecordColumnsValues';\nimport {useRecordInformations} from './useRecordInformations';\nimport FileModal from '_ui/components/RecordPreviewWithModal/FileModal';\nimport {EntityPreview} from '_ui/components/EntityPreview';\nimport {TOOLTIP_DEFAULT_DELAY_IN_SECONDS} from '_ui/constants';\n\ninterface IInformationsProps {\n record: IRecordIdentityWhoAmI;\n recordData: GetRecordColumnsValuesRecord;\n}\n\nconst InformationsWrapper = styled.div`\n margin-top: calc(var(--general-spacing-s) * 1px);\n`;\n\nconst PreviewWrapper = styled.div`\n position: relative;\n width: 100%;\n height: 162px;\n background-color: var(--general-colors-primary-50);\n border-radius: calc(var(--general-border-radius-s) * 1px);\n padding: calc(var(--general-spacing-xs) * 1px);\n`;\n\nconst ExpandImageButton = styled(KitButton)`\n position: absolute;\n right: 0;\n top: 0;\n`;\n\nconst ContentWrapper = styled.div`\n margin-top: calc(var(--general-spacing-s) * 1px);\n`;\n\nexport const RecordInformations: FunctionComponent<IInformationsProps> = ({record, recordData}) => {\n const {t} = useSharedTranslation();\n const recordInformations = useRecordInformations(record, recordData);\n const [isFilePreviewModalOpen, setFilePreviewModalOpen] = useState(false);\n\n const previewFile = record?.preview?.file;\n const preview = record?.preview?.medium ? String(record?.preview?.medium) : null;\n\n return (\n <InformationsWrapper>\n <PreviewWrapper>\n <EntityPreview\n label={record?.label ?? record?.id}\n color={record?.color}\n image={preview}\n imageStyle={{border: 'none'}}\n placeholderStyle={{height: '100%', width: 'fit-content', margin: 'auto', borderRadius: '0'}}\n style={{height: '100%', background: 'initial'}}\n tile\n />\n {previewFile !== undefined && (\n <KitTooltip\n title={t('record_summary.open_preview_modal')}\n mouseEnterDelay={TOOLTIP_DEFAULT_DELAY_IN_SECONDS}\n >\n <ExpandImageButton\n aria-label={t('record_summary.open_preview_modal')}\n type=\"tertiary\"\n icon={<FontAwesomeIcon icon={faExpand} />}\n onClick={() => setFilePreviewModalOpen(true)}\n />\n </KitTooltip>\n )}\n </PreviewWrapper>\n {isFilePreviewModalOpen && (\n <FileModal\n open={isFilePreviewModalOpen}\n fileId={previewFile?.id}\n libraryId={previewFile?.library}\n onClose={() => setFilePreviewModalOpen(false)}\n />\n )}\n <ContentWrapper>\n <PropertiesList items={recordInformations} />\n </ContentWrapper>\n </InformationsWrapper>\n );\n};\n"]}
1
+ {"version":3,"file":"RecordInformations.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/RecordInformations.tsx"],"names":[],"mappings":";AAMA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAO9D,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAErC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA0C,CAAC,EAAC,MAAM,EAAE,UAAU,EAAC,EAAE,EAAE;IAC9F,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAErE,OAAO,CACH,KAAC,mBAAmB,cAChB,KAAC,cAAc,IAAC,KAAK,EAAE,kBAAkB,GAAI,GAC3B,CACzB,CAAC;AACN,CAAC,CAAC","sourcesContent":["// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06\n// This file is released under LGPL V3\n// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt\nimport {type FunctionComponent} from 'react';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {type GetRecordColumnsValuesRecord} from '_ui/_queries/records/getRecordColumnsValues';\nimport styled from 'styled-components';\nimport PropertiesList from '../../PropertiesList';\nimport {useRecordInformations} from './useRecordInformations';\n\ninterface IInformationsProps {\n record: IRecordIdentityWhoAmI;\n recordData: GetRecordColumnsValuesRecord;\n}\n\nconst InformationsWrapper = styled.div`\n margin-top: calc(var(--general-spacing-s) * 1px);\n`;\n\nexport const RecordInformations: FunctionComponent<IInformationsProps> = ({record, recordData}) => {\n const recordInformations = useRecordInformations(record, recordData);\n\n return (\n <InformationsWrapper>\n <PropertiesList items={recordInformations} />\n </InformationsWrapper>\n );\n};\n"]}
@@ -2,13 +2,24 @@
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 { useSharedTranslation } from '../../../../../hooks/useSharedTranslation';
5
+ import { localizedTranslation } from '@leav/utils';
6
+ import { useLang } from '../../../../../hooks';
7
+ import { useEditRecordReducer } from '../../../../../components/RecordEdition/editRecordReducer/useEditRecordReducer';
5
8
  export const useRecordInformations = (record, recordData) => {
6
9
  const { t } = useSharedTranslation();
10
+ const { lang } = useLang();
11
+ const { state } = useEditRecordReducer();
7
12
  const recordInformations = [
8
13
  {
9
14
  title: t('record_summary.id_entity'),
10
15
  value: record?.id ?? '-',
11
16
  },
17
+ {
18
+ title: t('record_summary.library'),
19
+ value: t('record_summary.entity', {
20
+ entity: localizedTranslation(state.libraryLabel, lang),
21
+ }),
22
+ },
12
23
  ];
13
24
  if (recordData?.created_at?.[0]) {
14
25
  recordInformations.push({
@@ -1 +1 @@
1
- {"version":3,"file":"useRecordInformations.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAQpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAA6B,EAAE,UAAwC,EAAE,EAAE;IAC7G,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IAEnC,MAAM,kBAAkB,GAAG;QACvB;YACI,KAAK,EAAE,CAAC,CAAC,0BAA0B,CAAC;YACpC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,GAAG;SAC3B;KACJ,CAAC;IAEF,IAAI,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9B,kBAAkB,CAAC,IAAI,CAAC;YACpB,KAAK,EAAE,CAAC,CAAC,yBAAyB,CAAC;YACnC,KAAK,EAAE,CAAC,CAAC,6BAA6B,EAAE;gBACpC,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAAgC,CAAA,CAAC,OAAO;gBACzE,IAAI,EAAG,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,CAA4B,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK;gBACvF,aAAa,EAAE,EAAC,WAAW,EAAE,KAAK,EAAC;aACtC,CAAC;SACL,CAAC,CAAC;IACP,CAAC;IAED,IAAI,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,kBAAkB,CAAC,IAAI,CAAC;YACpB,KAAK,EAAE,CAAC,CAAC,kCAAkC,CAAC;YAC5C,KAAK,EAAE,CAAC,CAAC,6BAA6B,EAAE;gBACpC,IAAI,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,CAAgC,CAAA,CAAC,OAAO;gBAC1E,IAAI,EAAG,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,CAA4B,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK;gBACxF,aAAa,EAAE,EAAC,WAAW,EAAE,KAAK,EAAC;aACtC,CAAC;SACL,CAAC,CAAC;IACP,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC9B,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {\n type GetRecordColumnsValuesRecord,\n type IRecordColumnValueLink,\n type IRecordColumnValueStandard,\n} from '_ui/_queries/records/getRecordColumnsValues';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\n\nexport const useRecordInformations = (record: IRecordIdentityWhoAmI, recordData: GetRecordColumnsValuesRecord) => {\n const {t} = useSharedTranslation();\n\n const recordInformations = [\n {\n title: t('record_summary.id_entity'),\n value: record?.id ?? '-',\n },\n ];\n\n if (recordData?.created_at?.[0]) {\n recordInformations.push({\n title: t('record_summary.creation'),\n value: t('record_summary.date_by_user', {\n date: (recordData?.created_at?.[0] as IRecordColumnValueStandard).payload,\n user: (recordData?.created_by?.[0] as IRecordColumnValueLink)?.linkValue?.whoAmI?.label,\n interpolation: {escapeValue: false},\n }),\n });\n }\n\n if (recordData?.modified_at?.[0]) {\n recordInformations.push({\n title: t('record_summary.last_modification'),\n value: t('record_summary.date_by_user', {\n date: (recordData?.modified_at?.[0] as IRecordColumnValueStandard).payload,\n user: (recordData?.modified_by?.[0] as IRecordColumnValueLink)?.linkValue?.whoAmI?.label,\n interpolation: {escapeValue: false},\n }),\n });\n }\n\n return recordInformations;\n};\n"]}
1
+ {"version":3,"file":"useRecordInformations.js","sourceRoot":"","sources":["../../../../../../src/components/RecordEdition/EditRecordSidebar/RecordSummary/RecordInformations/useRecordInformations.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,sCAAsC;AACtC,sEAAsE;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAOpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,oBAAoB,EAAC,MAAM,qEAAqE,CAAC;AAEzG,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAA6B,EAAE,UAAwC,EAAE,EAAE;IAC7G,MAAM,E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EAAG,UAAU,EAAE,WAAW,EAAE,CAAC,CAAC,CAA4B,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK;gBACxF,aAAa,EAAE,EAAC,WAAW,EAAE,KAAK,EAAC;aACtC,CAAC;SACL,CAAC,CAAC;IACP,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC9B,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 {useSharedTranslation} from '_ui/hooks/useSharedTranslation';\nimport {\n type GetRecordColumnsValuesRecord,\n type IRecordColumnValueLink,\n type IRecordColumnValueStandard,\n} from '_ui/_queries/records/getRecordColumnsValues';\nimport {type IRecordIdentityWhoAmI} from '_ui/types';\nimport {localizedTranslation} from '@leav/utils';\nimport {useLang} from '_ui/hooks';\nimport {useEditRecordReducer} from '_ui/components/RecordEdition/editRecordReducer/useEditRecordReducer';\n\nexport const useRecordInformations = (record: IRecordIdentityWhoAmI, recordData: GetRecordColumnsValuesRecord) => {\n const {t} = useSharedTranslation();\n const {lang} = useLang();\n const {state} = useEditRecordReducer();\n\n const recordInformations = [\n {\n title: t('record_summary.id_entity'),\n value: record?.id ?? '-',\n },\n {\n title: t('record_summary.library'),\n value: t('record_summary.entity', {\n entity: localizedTranslation(state.libraryLabel, lang),\n }),\n },\n ];\n\n if (recordData?.created_at?.[0]) {\n recordInformations.push({\n title: t('record_summary.creation'),\n value: t('record_summary.date_by_user', {\n date: (recordData?.created_at?.[0] as IRecordColumnValueStandard).payload,\n user: (recordData?.created_by?.[0] as IRecordColumnValueLink)?.linkValue?.whoAmI?.label,\n interpolation: {escapeValue: false},\n }),\n });\n }\n\n if (recordData?.modified_at?.[0]) {\n recordInformations.push({\n title: t('record_summary.last_modification'),\n value: t('record_summary.date_by_user', {\n date: (recordData?.modified_at?.[0] as IRecordColumnValueStandard).payload,\n user: (recordData?.modified_by?.[0] as IRecordColumnValueLink)?.linkValue?.whoAmI?.label,\n interpolation: {escapeValue: false},\n }),\n });\n }\n\n return recordInformations;\n};\n"]}
@@ -2,6 +2,7 @@ import { type IRecordIdentityWhoAmI } from '../../../../types/records';
2
2
  import { type FunctionComponent } from 'react';
3
3
  interface IRecordSummaryProps {
4
4
  record: IRecordIdentityWhoAmI | null;
5
+ scrollAll?: boolean;
5
6
  }
6
7
  export declare const RecordSummary: FunctionComponent<IRecordSummaryProps>;
7
8
  export default RecordSummary;
@@ -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, KitTabs } from 'aristid-ds';
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
- const recordData = data?.[record?.id];
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,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AACzF,OA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,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,aAAa,GAAI,EAC9C,MAAM,kBAEL,CAAC,CAAC,8BAA8B,CAAC,GAC1B,CACf,GAEP,EACF,KAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,GAAI,IAChD,CACN,CAAC;IACN,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEtC,OAAO,CACH,KAAC,uBAAuB,cACpB,KAAC,OAAO,IACJ,KAAK,EAAE;gBACH;oBACI,GAAG,EAAE,cAAc;oBACnB,KAAK,EAAE,CAAC,CAAC,6BAA6B,CAAC;oBACvC,UAAU,EAAE,KAAC,kBAAkB,IAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAI;iBAC7E;gBACD;oBACI,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE,CAAC,CAAC,qBAAqB,CAAC;oBAC/B,QAAQ,EAAE,IAAI;iBACjB;gBACD;oBACI,GAAG,EAAE,SAAS;oBACd,KAAK,EAAE,CAAC,CAAC,wBAAwB,CAAC;oBAClC,UAAU,EAAE,KAAC,aAAa,IAAC,MAAM,EAAE,MAAM,GAAI;iBAChD;aACJ,GACH,GACoB,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, KitEmpty, KitError, KitSkeleton, KitTabs} 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';\n\ninterface IRecordSummaryProps {\n record: IRecordIdentityWhoAmI | null;\n}\n\nconst StyledDivContentWrapper = styled.div`\n display: flex;\n flex-direction: column;\n height: 100%;\n`;\n\nexport const RecordSummary: FunctionComponent<IRecordSummaryProps> = ({record}) => {\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 const recordData = data?.[record?.id];\n\n return (\n <StyledDivContentWrapper>\n <KitTabs\n items={[\n {\n key: 'informations',\n label: t('record_summary.informations'),\n tabContent: <RecordInformations record={record} recordData={recordData} />,\n },\n {\n key: 'chat',\n label: t('record_summary.chat'),\n disabled: true,\n },\n {\n key: 'history',\n label: t('record_summary.history'),\n tabContent: <RecordHistory record={record} />,\n },\n ]}\n />\n </StyledDivContentWrapper>\n );\n};\n\nexport default RecordSummary;\n"]}
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,uBAA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O,EAAE,KAAK,CAAC,OAAO,EACtB,aAAa,EACT,MAAM,EAAE,EAAE,IAAI,CACV,KAAC,SAAS,IACN,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EACpC,IAAI,EAAC,QAAQ,EACb,IAAI,EAAE,KAAC,eAAe,IAAC,IAAI,EAAE,aAAa,GAAI,EAC9C,MAAM,kBAEL,CAAC,CAAC,8BAA8B,CAAC,GAC1B,CACf,GAEP,EACF,KAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,GAAI,IAChD,CACN,CAAC;IACN,CAAC;IAED,OAAO,CACH,KAAC,uBAAuB,cACpB,MAAC,uBAAuB,IAAC,QAAQ,EAAE,CAAC,SAAS,aACzC,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,MAAM,YAAE,CAAC,CAAC,6BAA6B,CAAC,GAAsB,EACzF,KAAC,kBAAkB,IAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAI,EACtE,KAAC,UAAU,KAAG,EACd,KAAC,aAAa,CAAC,IAAI,IAAC,MAAM,EAAC,MAAM,YAAE,CAAC,CAAC,wBAAwB,CAAC,GAAsB,EACnF,MAAM,IAAI,KAAC,aAAa,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,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,CAA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AC,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}\n\nconst StyledDivContentWrapper = styled.div`\n margin-top: calc(var(--general-spacing-xs) * 1px);\n flex: 1 1 0;\n overflow-y: auto;\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}) => {\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>\n <RecordHistoryGoUpButton>\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
+ {"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;AAQ9D,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAExC;;;kBAGgB,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;CAChE,CAAC;AAEF,kOAAkO;AAClO,oCAAoC;AACpC,2DAA2D;AAC3D,sCAAsC;AACtC,6EAA6E;AAC7E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,aAAa,GAA2C,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAC,EAAE,EAAE;IACrG,MAAM,EAAC,CAAC,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ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C,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,6 +1,7 @@
1
1
  import { type ReactNode } from 'react';
2
2
  interface IRecordHistoryGoUpButtonProps {
3
3
  children: ReactNode;
4
+ disabled?: boolean;
4
5
  }
5
6
  export declare const RecordHistoryGoUpButton: React.FC<IRecordHistoryGoUpButtonProps>;
6
7
  export default RecordHistoryGoUpButton;
@@ -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,sCAA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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}\n\nexport const RecordHistoryGoUpButton: React.FC<IRecordHistoryGoUpButtonProps> = ({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 (\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"]}
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?.properties[0]?.values[0]?.payload;
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?.multiple_values) {
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?.format === AttributeFormat.rich_text || attribute?.format === AttributeFormat.extended) {
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?.format === AttributeFormat.extended) {
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?.multiple_values) {
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,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,GA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I,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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,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
- id
27
- whoAmI { # Don't know why, but frontend need that to load record !
44
+ ... on Record {
28
45
  id
29
- library {
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
- properties(attributeIds: ["email"]) {
34
- attributeId
35
- values {
36
- ... on Value {
37
- payload
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;;;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
+ {"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 RecordHistoryLogAttributeFragment, type RecordHistoryLogEntryFragment } from '../../_gqlTypes';
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 = RecordHistoryLogAttributeFragment;
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 RecordHistoryLogAttributeFragment, type RecordHistoryLogEntryFragment} from '_ui/_gqlTypes';\n\nexport type LogEntry = RecordHistoryLogEntryFragment;\nexport type LogEntryValue = Extract<LogEntry, {before?: any; after?: any}>;\nexport type LogEntryAttribute = RecordHistoryLogAttributeFragment;\nexport type LogEntryData = LogEntryValue['before'] | LogEntryValue['after'];\n"]}
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"]}
@@ -1,3 +1,4 @@
1
1
  export default function useRedirectToLogin(): {
2
- redirectToLogin: () => Promise<void>;
2
+ redirectToLogin: () => void;
3
+ checkAuthOrRedirectToLogin: () => Promise<void>;
3
4
  };
@@ -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: async () => {
8
- if (isDevEnv()) {
9
- return window.location.replace(`${window.location.origin}/app/login/?dest=${encodeURIComponent(window.location.toString())}`);
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 window.location.reload();
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;AAE7C,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACtC,OAAO;QACH,eAAe,EAAE,KAAK,IAAI,EAAE;YACxB,IAAI,QAAQ,EAAE,EAAE,CAAC;gBACb,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAC1B,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,oBAAoB,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,CAChG,CAAC;YACN,CAAC;YACD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,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';\n\nexport default function useRedirectToLogin() {\n return {\n redirectToLogin: async () => {\n if (isDevEnv()) {\n return window.location.replace(\n `${window.location.origin}/app/login/?dest=${encodeURIComponent(window.location.toString())}`,\n );\n }\n return window.location.reload();\n },\n };\n}\n"]}
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"]}