cozy-viewer 6.0.0 → 7.0.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/CHANGELOG.md +26 -0
- package/dist/Panel/ActionMenuWrapper.js +1 -1
- package/dist/Panel/Qualification.js +25 -8
- package/dist/Panel/QualificationListItemContact.js +8 -6
- package/dist/Panel/QualificationListItemDate.js +7 -3
- package/dist/Panel/QualificationListItemInformation.js +24 -3
- package/dist/Panel/QualificationListItemOther.js +7 -3
- package/dist/Panel/QualificationListItemQualification.d.ts +14 -0
- package/dist/Panel/QualificationListItemQualification.js +64 -0
- package/package.json +6 -6
- package/src/Panel/ActionMenuWrapper.jsx +1 -1
- package/src/Panel/Qualification.jsx +39 -14
- package/src/Panel/QualificationListItemContact.jsx +7 -2
- package/src/Panel/QualificationListItemDate.jsx +6 -1
- package/src/Panel/QualificationListItemInformation.jsx +31 -2
- package/src/Panel/QualificationListItemOther.jsx +6 -1
- package/src/Panel/QualificationListItemQualification.jsx +48 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.0.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@6.0.1...cozy-viewer@7.0.0) (2024-12-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **Viewer:** Add icons on qualification items ([b723037](https://github.com/cozy/cozy-libs/commit/b7230373edb395d06640992591fbd0f4320f1555))
|
|
12
|
+
* **Viewer:** Add new qualification item ([4f76701](https://github.com/cozy/cozy-libs/commit/4f767014ad3faf2023fbbcb52915357efee0c41b))
|
|
13
|
+
* **Viewer:** Upgrade cozy-ui ([806f310](https://github.com/cozy/cozy-libs/commit/806f3100af004654e0246d38d9937c4a015f0428))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
* **Viewer:** You must have `cozy-ui >= 113.8.0`
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [6.0.1](https://github.com/cozy/cozy-libs/compare/cozy-viewer@6.0.0...cozy-viewer@6.0.1) (2024-12-04)
|
|
25
|
+
|
|
26
|
+
**Note:** Version bump only for package cozy-viewer
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
6
32
|
# [6.0.0](https://github.com/cozy/cozy-libs/compare/cozy-viewer@5.1.1...cozy-viewer@6.0.0) (2024-12-03)
|
|
7
33
|
|
|
8
34
|
|
|
@@ -148,7 +148,7 @@ ActionMenuWrapper.propTypes = {
|
|
|
148
148
|
file: _propTypes.default.object,
|
|
149
149
|
optionFile: _propTypes.default.shape({
|
|
150
150
|
name: _propTypes.default.string,
|
|
151
|
-
value: _propTypes.default.string
|
|
151
|
+
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])
|
|
152
152
|
})
|
|
153
153
|
};
|
|
154
154
|
var _default = ActionMenuWrapper;
|
|
@@ -15,6 +15,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
|
|
16
16
|
var _paper = require("cozy-client/dist/models/paper");
|
|
17
17
|
|
|
18
|
+
var _Divider = _interopRequireDefault(require("cozy-ui/transpiled/react/Divider"));
|
|
19
|
+
|
|
18
20
|
var _List = _interopRequireDefault(require("cozy-ui/transpiled/react/List"));
|
|
19
21
|
|
|
20
22
|
var _ActionMenuWrapper = _interopRequireDefault(require("./ActionMenuWrapper"));
|
|
@@ -27,6 +29,8 @@ var _QualificationListItemInformation = _interopRequireDefault(require("./Qualif
|
|
|
27
29
|
|
|
28
30
|
var _QualificationListItemOther = _interopRequireDefault(require("./QualificationListItemOther"));
|
|
29
31
|
|
|
32
|
+
var _QualificationListItemQualification = _interopRequireDefault(require("./QualificationListItemQualification"));
|
|
33
|
+
|
|
30
34
|
var _ExpirationAlert = _interopRequireDefault(require("../components/ExpirationAlert"));
|
|
31
35
|
|
|
32
36
|
var _withViewerLocales = require("../hoc/withViewerLocales");
|
|
@@ -93,6 +97,9 @@ var Qualification = function Qualification(_ref) {
|
|
|
93
97
|
var _file$bills, _file$bills$data;
|
|
94
98
|
|
|
95
99
|
var relatedBills = (_file$bills = file.bills) === null || _file$bills === void 0 ? void 0 : (_file$bills$data = _file$bills.data) === null || _file$bills$data === void 0 ? void 0 : _file$bills$data[0];
|
|
100
|
+
var formattedMetadataQualification = (0, _paper.formatMetadataQualification)(metadata).sort(function (a, b) {
|
|
101
|
+
return a.name === 'qualification' ? -1 : b.name === 'qualification' ? 1 : 0;
|
|
102
|
+
}); // move "qualification" metadata in first position
|
|
96
103
|
|
|
97
104
|
if (relatedBills) {
|
|
98
105
|
var formattedBillsMetadata = _paper.KNOWN_BILLS_ATTRIBUTES_NAMES.map(function (attrName) {
|
|
@@ -102,10 +109,10 @@ var Qualification = function Qualification(_ref) {
|
|
|
102
109
|
};
|
|
103
110
|
});
|
|
104
111
|
|
|
105
|
-
return
|
|
112
|
+
return formattedMetadataQualification.concat(formattedBillsMetadata);
|
|
106
113
|
}
|
|
107
114
|
|
|
108
|
-
return
|
|
115
|
+
return formattedMetadataQualification;
|
|
109
116
|
}, [metadata, (_file$bills2 = file.bills) === null || _file$bills2 === void 0 ? void 0 : _file$bills2.data]);
|
|
110
117
|
(0, _react.useEffect)(function () {
|
|
111
118
|
actionBtnRef.current = formattedMetadataQualification.map(function (_, idx) {
|
|
@@ -116,21 +123,31 @@ var Qualification = function Qualification(_ref) {
|
|
|
116
123
|
}, [formattedMetadataQualification]);
|
|
117
124
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (0, _paper.isExpiringSoon)(file) && !isExpirationAlertHidden(file) && /*#__PURE__*/_react.default.createElement(_ExpirationAlert.default, {
|
|
118
125
|
file: file
|
|
119
|
-
}), /*#__PURE__*/_react.default.createElement(
|
|
120
|
-
|
|
121
|
-
|
|
126
|
+
}), /*#__PURE__*/_react.default.createElement(_QualificationListItemQualification.default, {
|
|
127
|
+
file: file,
|
|
128
|
+
ref: actionBtnRef.current[0],
|
|
129
|
+
formattedMetadataQualification: formattedMetadataQualification[0],
|
|
130
|
+
toggleActionsMenu: function toggleActionsMenu(val) {
|
|
131
|
+
return _toggleActionsMenu(0, formattedMetadataQualification[0].name, val);
|
|
132
|
+
}
|
|
133
|
+
}), /*#__PURE__*/_react.default.createElement(_List.default, null, formattedMetadataQualification.map(function (meta, idx) {
|
|
122
134
|
var name = meta.name;
|
|
135
|
+
if (name === 'qualification') return null;
|
|
123
136
|
var metadataQualificationType = (0, _paper.getMetadataQualificationType)(name);
|
|
124
137
|
var QualificationListItemComp = ComponentFromMetadataQualificationType[metadataQualificationType];
|
|
125
|
-
|
|
126
|
-
|
|
138
|
+
var isLastItem = idx === formattedMetadataQualification.length - 1;
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
140
|
+
key: idx
|
|
141
|
+
}, /*#__PURE__*/_react.default.createElement(QualificationListItemComp, {
|
|
127
142
|
file: file,
|
|
128
143
|
ref: actionBtnRef.current[idx],
|
|
129
144
|
formattedMetadataQualification: meta,
|
|
130
145
|
toggleActionsMenu: function toggleActionsMenu(val) {
|
|
131
146
|
return _toggleActionsMenu(idx, name, val);
|
|
132
147
|
}
|
|
133
|
-
})
|
|
148
|
+
}), !isLastItem && /*#__PURE__*/_react.default.createElement(_Divider.default, {
|
|
149
|
+
variant: "inset"
|
|
150
|
+
}));
|
|
134
151
|
}), optionFile.name && /*#__PURE__*/_react.default.createElement(_ActionMenuWrapper.default, {
|
|
135
152
|
onClose: hideActionsMenu,
|
|
136
153
|
file: file,
|
|
@@ -21,8 +21,12 @@ var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconB
|
|
|
21
21
|
|
|
22
22
|
var _Dots = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Dots"));
|
|
23
23
|
|
|
24
|
+
var _People = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/People"));
|
|
25
|
+
|
|
24
26
|
var _ListItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItem"));
|
|
25
27
|
|
|
28
|
+
var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
|
|
29
|
+
|
|
26
30
|
var _ListItemSecondaryAction = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemSecondaryAction"));
|
|
27
31
|
|
|
28
32
|
var _Spinner = _interopRequireDefault(require("cozy-ui/transpiled/react/Spinner"));
|
|
@@ -80,9 +84,7 @@ var QualificationListItemContact = function QualificationListItemContact(_ref) {
|
|
|
80
84
|
isLoadingContacts = _useReferencedContact.isLoadingContacts;
|
|
81
85
|
|
|
82
86
|
if (isLoadingContacts) {
|
|
83
|
-
return /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
84
|
-
className: "u-pl-2 u-pr-3"
|
|
85
|
-
}, /*#__PURE__*/_react.default.createElement(_Spinner.default, {
|
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_Spinner.default, {
|
|
86
88
|
color: "var(--secondaryTextColor)"
|
|
87
89
|
}));
|
|
88
90
|
}
|
|
@@ -96,9 +98,9 @@ var QualificationListItemContact = function QualificationListItemContact(_ref) {
|
|
|
96
98
|
return null;
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
100
|
-
|
|
101
|
-
}, /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
101
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
102
|
+
icon: _People.default
|
|
103
|
+
})), /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
102
104
|
primary: formattedTitle,
|
|
103
105
|
secondary: formattedValue
|
|
104
106
|
}), /*#__PURE__*/_react.default.createElement(_ListItemSecondaryAction.default, null, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
|
|
@@ -17,10 +17,14 @@ var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
|
17
17
|
|
|
18
18
|
var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconButton"));
|
|
19
19
|
|
|
20
|
+
var _Calendar = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Calendar"));
|
|
21
|
+
|
|
20
22
|
var _Dots = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Dots"));
|
|
21
23
|
|
|
22
24
|
var _ListItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItem"));
|
|
23
25
|
|
|
26
|
+
var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
|
|
27
|
+
|
|
24
28
|
var _ListItemSecondaryAction = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemSecondaryAction"));
|
|
25
29
|
|
|
26
30
|
var _Typography = _interopRequireDefault(require("cozy-ui/transpiled/react/Typography"));
|
|
@@ -54,9 +58,9 @@ var QualificationListItemDate = /*#__PURE__*/(0, _react.forwardRef)(function (_r
|
|
|
54
58
|
lang: lang
|
|
55
59
|
});
|
|
56
60
|
var isExpirationDate = name === 'expirationDate';
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
58
|
-
|
|
59
|
-
}, /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
61
|
+
return /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
62
|
+
icon: _Calendar.default
|
|
63
|
+
})), /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
60
64
|
primary: formattedTitle,
|
|
61
65
|
secondary: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
|
|
62
66
|
component: "span",
|
|
@@ -17,10 +17,22 @@ var _Icon = _interopRequireDefault(require("cozy-ui/transpiled/react/Icon"));
|
|
|
17
17
|
|
|
18
18
|
var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconButton"));
|
|
19
19
|
|
|
20
|
+
var _Bell = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Bell"));
|
|
21
|
+
|
|
22
|
+
var _Contract = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Contract"));
|
|
23
|
+
|
|
20
24
|
var _Dots = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Dots"));
|
|
21
25
|
|
|
26
|
+
var _Euro = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Euro"));
|
|
27
|
+
|
|
28
|
+
var _Globe = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Globe"));
|
|
29
|
+
|
|
30
|
+
var _Number = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Number"));
|
|
31
|
+
|
|
22
32
|
var _ListItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItem"));
|
|
23
33
|
|
|
34
|
+
var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
|
|
35
|
+
|
|
24
36
|
var _ListItemSecondaryAction = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemSecondaryAction"));
|
|
25
37
|
|
|
26
38
|
var _MidEllipsis = _interopRequireDefault(require("cozy-ui/transpiled/react/MidEllipsis"));
|
|
@@ -33,6 +45,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
45
|
|
|
34
46
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
47
|
|
|
48
|
+
var KNOWN_INFORMATION_METADATA_ICONS = [_Number.default, _Number.default, _Globe.default, _Euro.default, _Contract.default, _Euro.default, _Euro.default, _Number.default, _Number.default, _Bell.default];
|
|
49
|
+
|
|
50
|
+
var makeInformationMetadataIcon = function makeInformationMetadataIcon(name) {
|
|
51
|
+
return KNOWN_INFORMATION_METADATA_ICONS[_paper.KNOWN_INFORMATION_METADATA_NAMES.findIndex(function (el) {
|
|
52
|
+
return el === name;
|
|
53
|
+
})];
|
|
54
|
+
};
|
|
55
|
+
|
|
36
56
|
var QualificationListItemInformation = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
37
57
|
var formattedMetadataQualification = _ref.formattedMetadataQualification,
|
|
38
58
|
file = _ref.file,
|
|
@@ -53,12 +73,13 @@ var QualificationListItemInformation = /*#__PURE__*/(0, _react.forwardRef)(funct
|
|
|
53
73
|
name: name,
|
|
54
74
|
qualificationLabel: qualificationLabel
|
|
55
75
|
});
|
|
76
|
+
var InformationIcon = makeInformationMetadataIcon(name);
|
|
56
77
|
var titleComponent = formattedTitle === name ? /*#__PURE__*/_react.default.createElement(_MidEllipsis.default, {
|
|
57
78
|
text: name
|
|
58
79
|
}) : formattedTitle;
|
|
59
|
-
return /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
60
|
-
|
|
61
|
-
}, /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
80
|
+
return /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
81
|
+
icon: InformationIcon
|
|
82
|
+
})), /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
62
83
|
primary: titleComponent,
|
|
63
84
|
secondary: formattedValue,
|
|
64
85
|
disabled: !value
|
|
@@ -19,8 +19,12 @@ var _IconButton = _interopRequireDefault(require("cozy-ui/transpiled/react/IconB
|
|
|
19
19
|
|
|
20
20
|
var _Dots = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/Dots"));
|
|
21
21
|
|
|
22
|
+
var _File = _interopRequireDefault(require("cozy-ui/transpiled/react/Icons/File"));
|
|
23
|
+
|
|
22
24
|
var _ListItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItem"));
|
|
23
25
|
|
|
26
|
+
var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
|
|
27
|
+
|
|
24
28
|
var _ListItemSecondaryAction = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemSecondaryAction"));
|
|
25
29
|
|
|
26
30
|
var _MidEllipsis = _interopRequireDefault(require("cozy-ui/transpiled/react/MidEllipsis"));
|
|
@@ -50,9 +54,9 @@ var QualificationListItemOther = /*#__PURE__*/(0, _react.forwardRef)(function (_
|
|
|
50
54
|
lang: lang,
|
|
51
55
|
name: name
|
|
52
56
|
});
|
|
53
|
-
return /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
54
|
-
|
|
55
|
-
}, /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement(_ListItem.default, null, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_Icon.default, {
|
|
58
|
+
icon: _File.default
|
|
59
|
+
})), /*#__PURE__*/_react.default.createElement(_QualificationListItemText.default, {
|
|
56
60
|
primary: formattedTitle,
|
|
57
61
|
secondary: /*#__PURE__*/_react.default.createElement(_MidEllipsis.default, {
|
|
58
62
|
text: formattedValue
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default QualificationListItemQualification;
|
|
2
|
+
declare function QualificationListItemQualification({ formattedMetadataQualification }: {
|
|
3
|
+
formattedMetadataQualification: any;
|
|
4
|
+
}): JSX.Element | null;
|
|
5
|
+
declare namespace QualificationListItemQualification {
|
|
6
|
+
const displayName: string;
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
const formattedMetadataQualification: PropTypes.Requireable<PropTypes.InferProps<{
|
|
9
|
+
name: PropTypes.Requireable<string>;
|
|
10
|
+
value: PropTypes.Requireable<string>;
|
|
11
|
+
}>>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
import PropTypes from "prop-types";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _paper = require("cozy-client/dist/models/paper");
|
|
15
|
+
|
|
16
|
+
var _ListItem = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItem"));
|
|
17
|
+
|
|
18
|
+
var _ListItemIcon = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemIcon"));
|
|
19
|
+
|
|
20
|
+
var _ListItemText = _interopRequireDefault(require("cozy-ui/transpiled/react/ListItemText"));
|
|
21
|
+
|
|
22
|
+
var _MidEllipsis = _interopRequireDefault(require("cozy-ui/transpiled/react/MidEllipsis"));
|
|
23
|
+
|
|
24
|
+
var _QualificationIconStack = _interopRequireDefault(require("cozy-ui/transpiled/react/QualificationIconStack"));
|
|
25
|
+
|
|
26
|
+
var _I18n = require("cozy-ui/transpiled/react/providers/I18n");
|
|
27
|
+
|
|
28
|
+
var QualificationListItemQualification = function QualificationListItemQualification(_ref) {
|
|
29
|
+
var formattedMetadataQualification = _ref.formattedMetadataQualification;
|
|
30
|
+
|
|
31
|
+
var _useI18n = (0, _I18n.useI18n)(),
|
|
32
|
+
lang = _useI18n.lang;
|
|
33
|
+
|
|
34
|
+
var name = formattedMetadataQualification.name,
|
|
35
|
+
value = formattedMetadataQualification.value;
|
|
36
|
+
if (!value) return null;
|
|
37
|
+
var formattedValue = (0, _paper.formatOtherMetadataValue)(value, {
|
|
38
|
+
lang: lang,
|
|
39
|
+
name: name
|
|
40
|
+
});
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_ListItem.default, {
|
|
42
|
+
size: "large",
|
|
43
|
+
divider: true
|
|
44
|
+
}, /*#__PURE__*/_react.default.createElement(_ListItemIcon.default, null, /*#__PURE__*/_react.default.createElement(_QualificationIconStack.default, {
|
|
45
|
+
qualification: value
|
|
46
|
+
})), /*#__PURE__*/_react.default.createElement(_ListItemText.default, {
|
|
47
|
+
primary: /*#__PURE__*/_react.default.createElement(_MidEllipsis.default, {
|
|
48
|
+
text: formattedValue
|
|
49
|
+
}),
|
|
50
|
+
primaryTypographyProps: {
|
|
51
|
+
variant: 'h6'
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
QualificationListItemQualification.displayName = 'QualificationListItemQualification';
|
|
57
|
+
QualificationListItemQualification.propTypes = {
|
|
58
|
+
formattedMetadataQualification: _propTypes.default.shape({
|
|
59
|
+
name: _propTypes.default.string,
|
|
60
|
+
value: _propTypes.default.string
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
var _default = QualificationListItemQualification;
|
|
64
|
+
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-viewer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Cozy-Viewer provides a component to show files in a viewer.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"babel-preset-cozy-app": "^2.8.1",
|
|
28
28
|
"cozy-client": "50.0.0",
|
|
29
29
|
"cozy-device-helper": "2.0.0",
|
|
30
|
-
"cozy-harvest-lib": "^31.0.
|
|
30
|
+
"cozy-harvest-lib": "^31.0.3",
|
|
31
31
|
"cozy-intent": "^2.29.1",
|
|
32
32
|
"cozy-logger": "^1.16.1",
|
|
33
|
-
"cozy-sharing": "^16.
|
|
34
|
-
"cozy-ui": "^113.
|
|
33
|
+
"cozy-sharing": "^16.9.0",
|
|
34
|
+
"cozy-ui": "^113.8.0",
|
|
35
35
|
"enzyme": "3.11.0",
|
|
36
36
|
"enzyme-adapter-react-16": "1.15.6",
|
|
37
37
|
"enzyme-to-json": "3.6.2",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"cozy-intent": ">=2.26.0",
|
|
57
57
|
"cozy-logger": ">=1.9.0",
|
|
58
58
|
"cozy-sharing": ">=16.8.0",
|
|
59
|
-
"cozy-ui": ">=113.
|
|
59
|
+
"cozy-ui": ">=113.8.0",
|
|
60
60
|
"react": ">=16.12.0",
|
|
61
61
|
"react-dom": ">=16.12.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b49bd1f6b71446235b2c5a702a13584765787ce8"
|
|
64
64
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import PropTypes from 'prop-types'
|
|
2
|
-
import React, {
|
|
2
|
+
import React, {
|
|
3
|
+
Fragment,
|
|
4
|
+
useRef,
|
|
5
|
+
useState,
|
|
6
|
+
createRef,
|
|
7
|
+
useMemo,
|
|
8
|
+
useEffect
|
|
9
|
+
} from 'react'
|
|
3
10
|
|
|
4
11
|
import {
|
|
5
12
|
isExpiringSoon,
|
|
@@ -7,6 +14,7 @@ import {
|
|
|
7
14
|
KNOWN_BILLS_ATTRIBUTES_NAMES,
|
|
8
15
|
getMetadataQualificationType
|
|
9
16
|
} from 'cozy-client/dist/models/paper'
|
|
17
|
+
import Divider from 'cozy-ui/transpiled/react/Divider'
|
|
10
18
|
import List from 'cozy-ui/transpiled/react/List'
|
|
11
19
|
|
|
12
20
|
import ActionMenuWrapper from './ActionMenuWrapper'
|
|
@@ -14,6 +22,7 @@ import QualificationListItemContact from './QualificationListItemContact'
|
|
|
14
22
|
import QualificationListItemDate from './QualificationListItemDate'
|
|
15
23
|
import QualificationListItemInformation from './QualificationListItemInformation'
|
|
16
24
|
import QualificationListItemOther from './QualificationListItemOther'
|
|
25
|
+
import QualificationListItemQualification from './QualificationListItemQualification'
|
|
17
26
|
import ExpirationAlert from '../components/ExpirationAlert'
|
|
18
27
|
import { withViewerLocales } from '../hoc/withViewerLocales'
|
|
19
28
|
|
|
@@ -51,18 +60,21 @@ const Qualification = ({ file }) => {
|
|
|
51
60
|
|
|
52
61
|
const formattedMetadataQualification = useMemo(() => {
|
|
53
62
|
const relatedBills = file.bills?.data?.[0]
|
|
63
|
+
const formattedMetadataQualification = formatMetadataQualification(
|
|
64
|
+
metadata
|
|
65
|
+
).sort((a, b) =>
|
|
66
|
+
a.name === 'qualification' ? -1 : b.name === 'qualification' ? 1 : 0
|
|
67
|
+
) // move "qualification" metadata in first position
|
|
54
68
|
|
|
55
69
|
if (relatedBills) {
|
|
56
70
|
const formattedBillsMetadata = KNOWN_BILLS_ATTRIBUTES_NAMES.map(
|
|
57
71
|
attrName => ({ name: attrName, value: relatedBills[attrName] })
|
|
58
72
|
)
|
|
59
73
|
|
|
60
|
-
return
|
|
61
|
-
formattedBillsMetadata
|
|
62
|
-
)
|
|
74
|
+
return formattedMetadataQualification.concat(formattedBillsMetadata)
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
return
|
|
77
|
+
return formattedMetadataQualification
|
|
66
78
|
}, [metadata, file.bills?.data])
|
|
67
79
|
|
|
68
80
|
useEffect(() => {
|
|
@@ -76,24 +88,37 @@ const Qualification = ({ file }) => {
|
|
|
76
88
|
{isExpiringSoon(file) && !isExpirationAlertHidden(file) && (
|
|
77
89
|
<ExpirationAlert file={file} />
|
|
78
90
|
)}
|
|
79
|
-
<
|
|
91
|
+
<QualificationListItemQualification
|
|
92
|
+
file={file}
|
|
93
|
+
ref={actionBtnRef.current[0]}
|
|
94
|
+
formattedMetadataQualification={formattedMetadataQualification[0]}
|
|
95
|
+
toggleActionsMenu={val =>
|
|
96
|
+
toggleActionsMenu(0, formattedMetadataQualification[0].name, val)
|
|
97
|
+
}
|
|
98
|
+
/>
|
|
99
|
+
<List>
|
|
80
100
|
{formattedMetadataQualification.map((meta, idx) => {
|
|
81
101
|
const { name } = meta
|
|
102
|
+
if (name === 'qualification') return null
|
|
103
|
+
|
|
82
104
|
const metadataQualificationType = getMetadataQualificationType(name)
|
|
83
105
|
const QualificationListItemComp =
|
|
84
106
|
ComponentFromMetadataQualificationType[metadataQualificationType]
|
|
85
107
|
|
|
108
|
+
const isLastItem = idx === formattedMetadataQualification.length - 1
|
|
109
|
+
|
|
86
110
|
return (
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
<Fragment key={idx}>
|
|
112
|
+
<QualificationListItemComp
|
|
113
|
+
file={file}
|
|
114
|
+
ref={actionBtnRef.current[idx]}
|
|
115
|
+
formattedMetadataQualification={meta}
|
|
116
|
+
toggleActionsMenu={val => toggleActionsMenu(idx, name, val)}
|
|
117
|
+
/>
|
|
118
|
+
{!isLastItem && <Divider variant="inset" />}
|
|
119
|
+
</Fragment>
|
|
94
120
|
)
|
|
95
121
|
})}
|
|
96
|
-
|
|
97
122
|
{optionFile.name && (
|
|
98
123
|
<ActionMenuWrapper
|
|
99
124
|
onClose={hideActionsMenu}
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
9
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
10
10
|
import Dots from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
11
|
+
import PeopleIcon from 'cozy-ui/transpiled/react/Icons/People'
|
|
11
12
|
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
13
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
12
14
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction'
|
|
13
15
|
import Spinner from 'cozy-ui/transpiled/react/Spinner'
|
|
14
16
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
@@ -36,7 +38,7 @@ const QualificationListItemContact = ({ file }) => {
|
|
|
36
38
|
|
|
37
39
|
if (isLoadingContacts) {
|
|
38
40
|
return (
|
|
39
|
-
<ListItem
|
|
41
|
+
<ListItem>
|
|
40
42
|
<Spinner color="var(--secondaryTextColor)" />
|
|
41
43
|
</ListItem>
|
|
42
44
|
)
|
|
@@ -51,7 +53,10 @@ const QualificationListItemContact = ({ file }) => {
|
|
|
51
53
|
|
|
52
54
|
return (
|
|
53
55
|
<>
|
|
54
|
-
<ListItem
|
|
56
|
+
<ListItem>
|
|
57
|
+
<ListItemIcon>
|
|
58
|
+
<Icon icon={PeopleIcon} />
|
|
59
|
+
</ListItemIcon>
|
|
55
60
|
<QualificationListItemText
|
|
56
61
|
primary={formattedTitle}
|
|
57
62
|
secondary={formattedValue}
|
|
@@ -9,8 +9,10 @@ import {
|
|
|
9
9
|
} from 'cozy-client/dist/models/paper'
|
|
10
10
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
11
11
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
12
|
+
import CalendarIcon from 'cozy-ui/transpiled/react/Icons/Calendar'
|
|
12
13
|
import Dots from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
13
14
|
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
15
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
14
16
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction'
|
|
15
17
|
import Typography from 'cozy-ui/transpiled/react/Typography'
|
|
16
18
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
@@ -30,7 +32,10 @@ const QualificationListItemDate = forwardRef(
|
|
|
30
32
|
const isExpirationDate = name === 'expirationDate'
|
|
31
33
|
|
|
32
34
|
return (
|
|
33
|
-
<ListItem
|
|
35
|
+
<ListItem>
|
|
36
|
+
<ListItemIcon>
|
|
37
|
+
<Icon icon={CalendarIcon} />
|
|
38
|
+
</ListItemIcon>
|
|
34
39
|
<QualificationListItemText
|
|
35
40
|
primary={formattedTitle}
|
|
36
41
|
secondary={
|
|
@@ -3,18 +3,43 @@ import React, { forwardRef } from 'react'
|
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
getTranslatedNameForInformationMetadata,
|
|
6
|
-
formatInformationMetadataValue
|
|
6
|
+
formatInformationMetadataValue,
|
|
7
|
+
KNOWN_INFORMATION_METADATA_NAMES
|
|
7
8
|
} from 'cozy-client/dist/models/paper'
|
|
8
9
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
10
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
11
|
+
import BellIcon from 'cozy-ui/transpiled/react/Icons/Bell'
|
|
12
|
+
import ContractIcon from 'cozy-ui/transpiled/react/Icons/Contract'
|
|
10
13
|
import Dots from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
14
|
+
import EuroIcon from 'cozy-ui/transpiled/react/Icons/Euro'
|
|
15
|
+
import GlobeIcon from 'cozy-ui/transpiled/react/Icons/Globe'
|
|
16
|
+
import NumberIcon from 'cozy-ui/transpiled/react/Icons/Number'
|
|
11
17
|
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
18
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
12
19
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction'
|
|
13
20
|
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
|
|
14
21
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
15
22
|
|
|
16
23
|
import QualificationListItemText from './QualificationListItemText'
|
|
17
24
|
|
|
25
|
+
const KNOWN_INFORMATION_METADATA_ICONS = [
|
|
26
|
+
NumberIcon,
|
|
27
|
+
NumberIcon,
|
|
28
|
+
GlobeIcon,
|
|
29
|
+
EuroIcon,
|
|
30
|
+
ContractIcon,
|
|
31
|
+
EuroIcon,
|
|
32
|
+
EuroIcon,
|
|
33
|
+
NumberIcon,
|
|
34
|
+
NumberIcon,
|
|
35
|
+
BellIcon
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
const makeInformationMetadataIcon = name =>
|
|
39
|
+
KNOWN_INFORMATION_METADATA_ICONS[
|
|
40
|
+
KNOWN_INFORMATION_METADATA_NAMES.findIndex(el => el === name)
|
|
41
|
+
]
|
|
42
|
+
|
|
18
43
|
const QualificationListItemInformation = forwardRef(
|
|
19
44
|
({ formattedMetadataQualification, file, toggleActionsMenu }, ref) => {
|
|
20
45
|
const { lang } = useI18n()
|
|
@@ -30,12 +55,16 @@ const QualificationListItemInformation = forwardRef(
|
|
|
30
55
|
name,
|
|
31
56
|
qualificationLabel
|
|
32
57
|
})
|
|
58
|
+
const InformationIcon = makeInformationMetadataIcon(name)
|
|
33
59
|
|
|
34
60
|
const titleComponent =
|
|
35
61
|
formattedTitle === name ? <MidEllipsis text={name} /> : formattedTitle
|
|
36
62
|
|
|
37
63
|
return (
|
|
38
|
-
<ListItem
|
|
64
|
+
<ListItem>
|
|
65
|
+
<ListItemIcon>
|
|
66
|
+
<Icon icon={InformationIcon} />
|
|
67
|
+
</ListItemIcon>
|
|
39
68
|
<QualificationListItemText
|
|
40
69
|
primary={titleComponent}
|
|
41
70
|
secondary={formattedValue}
|
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
import Icon from 'cozy-ui/transpiled/react/Icon'
|
|
9
9
|
import IconButton from 'cozy-ui/transpiled/react/IconButton'
|
|
10
10
|
import Dots from 'cozy-ui/transpiled/react/Icons/Dots'
|
|
11
|
+
import FileIcon from 'cozy-ui/transpiled/react/Icons/File'
|
|
11
12
|
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
13
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
12
14
|
import ListItemSecondaryAction from 'cozy-ui/transpiled/react/ListItemSecondaryAction'
|
|
13
15
|
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
|
|
14
16
|
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
@@ -31,7 +33,10 @@ const QualificationListItemOther = forwardRef(
|
|
|
31
33
|
})
|
|
32
34
|
|
|
33
35
|
return (
|
|
34
|
-
<ListItem
|
|
36
|
+
<ListItem>
|
|
37
|
+
<ListItemIcon>
|
|
38
|
+
<Icon icon={FileIcon} />
|
|
39
|
+
</ListItemIcon>
|
|
35
40
|
<QualificationListItemText
|
|
36
41
|
primary={formattedTitle}
|
|
37
42
|
secondary={<MidEllipsis text={formattedValue} />}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { formatOtherMetadataValue } from 'cozy-client/dist/models/paper'
|
|
5
|
+
import ListItem from 'cozy-ui/transpiled/react/ListItem'
|
|
6
|
+
import ListItemIcon from 'cozy-ui/transpiled/react/ListItemIcon'
|
|
7
|
+
import ListItemText from 'cozy-ui/transpiled/react/ListItemText'
|
|
8
|
+
import MidEllipsis from 'cozy-ui/transpiled/react/MidEllipsis'
|
|
9
|
+
import QualificationIconStack from 'cozy-ui/transpiled/react/QualificationIconStack'
|
|
10
|
+
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
|
|
11
|
+
|
|
12
|
+
const QualificationListItemQualification = ({
|
|
13
|
+
formattedMetadataQualification
|
|
14
|
+
}) => {
|
|
15
|
+
const { lang } = useI18n()
|
|
16
|
+
const { name, value } = formattedMetadataQualification
|
|
17
|
+
|
|
18
|
+
if (!value) return null
|
|
19
|
+
|
|
20
|
+
const formattedValue = formatOtherMetadataValue(value, {
|
|
21
|
+
lang,
|
|
22
|
+
name
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ListItem size="large" divider>
|
|
27
|
+
<ListItemIcon>
|
|
28
|
+
<QualificationIconStack qualification={value} />
|
|
29
|
+
</ListItemIcon>
|
|
30
|
+
<ListItemText
|
|
31
|
+
primary={<MidEllipsis text={formattedValue} />}
|
|
32
|
+
primaryTypographyProps={{ variant: 'h6' }}
|
|
33
|
+
/>
|
|
34
|
+
</ListItem>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
QualificationListItemQualification.displayName =
|
|
39
|
+
'QualificationListItemQualification'
|
|
40
|
+
|
|
41
|
+
QualificationListItemQualification.propTypes = {
|
|
42
|
+
formattedMetadataQualification: PropTypes.shape({
|
|
43
|
+
name: PropTypes.string,
|
|
44
|
+
value: PropTypes.string
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default QualificationListItemQualification
|