cozy-ui 117.0.0 → 117.2.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 +21 -0
- package/package.json +1 -1
- package/react/ActionsMenu/Actions/addToFavorites.js +66 -0
- package/react/ActionsMenu/Actions/download.js +42 -0
- package/react/ActionsMenu/Actions/index.js +3 -0
- package/react/ActionsMenu/Actions/locales/en.json +12 -0
- package/react/ActionsMenu/Actions/locales/fr.json +12 -0
- package/react/ActionsMenu/Actions/removeFromFavorites.js +66 -0
- package/react/NestedSelect/NestedSelect.jsx +23 -12
- package/react/NestedSelect/NestedSelect.md +1 -8
- package/react/NestedSelect/NestedSelect.spec.jsx +15 -12
- package/react/NestedSelect/styles.styl +1 -1
- package/react/QualificationModal/helpers.js +61 -0
- package/react/QualificationModal/helpers.spec.js +32 -0
- package/react/QualificationModal/index.jsx +14 -37
- package/react/QualificationModal/locales/en.json +2 -1
- package/react/QualificationModal/locales/fr.json +2 -1
- package/transpiled/react/ActionsMenu/Actions/addToFavorites.js +144 -0
- package/transpiled/react/ActionsMenu/Actions/download.js +49 -0
- package/transpiled/react/ActionsMenu/Actions/index.js +3 -0
- package/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales.js +24 -0
- package/transpiled/react/ActionsMenu/Actions/removeFromFavorites.js +144 -0
- package/transpiled/react/NestedSelect/NestedSelect.js +33 -15
- package/transpiled/react/QualificationModal/helpers.js +68 -0
- package/transpiled/react/QualificationModal/index.js +12 -40
- package/transpiled/react/QualificationModal/locales/index.js +4 -2
- package/transpiled/react/stylesheet.css +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
|
|
16
|
+
import React, { forwardRef } from 'react';
|
|
17
|
+
import { splitFilename } from 'cozy-client/dist/models/file';
|
|
18
|
+
import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
|
|
19
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
|
+
import StarOutlineIcon from "cozy-ui/transpiled/react/Icons/StarOutline";
|
|
21
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
22
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
23
|
+
import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
|
|
24
|
+
|
|
25
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
26
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
28
|
+
ref: ref
|
|
29
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
+
icon: icon
|
|
31
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
32
|
+
primary: label
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
Component.displayName = 'addToFavorites';
|
|
36
|
+
return Component;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var addToFavorites = function addToFavorites(_ref) {
|
|
40
|
+
var showAlert = _ref.showAlert;
|
|
41
|
+
|
|
42
|
+
var _getActionsI18n = getActionsI18n(),
|
|
43
|
+
t = _getActionsI18n.t;
|
|
44
|
+
|
|
45
|
+
var icon = StarOutlineIcon;
|
|
46
|
+
var label = t('favorites.add.label');
|
|
47
|
+
return {
|
|
48
|
+
name: 'addToFavorites',
|
|
49
|
+
icon: icon,
|
|
50
|
+
label: label,
|
|
51
|
+
displayCondition: function displayCondition(docs) {
|
|
52
|
+
return docs.length > 0 && docs.every(function (doc) {
|
|
53
|
+
var _doc$cozyMetadata;
|
|
54
|
+
|
|
55
|
+
return !((_doc$cozyMetadata = doc.cozyMetadata) !== null && _doc$cozyMetadata !== void 0 && _doc$cozyMetadata.favorite);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
Component: makeComponent(label, icon),
|
|
59
|
+
action: function () {
|
|
60
|
+
var _action = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(docs, _ref2) {
|
|
61
|
+
var client, _iterator, _step, doc, _splitFilename, filename;
|
|
62
|
+
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
client = _ref2.client;
|
|
68
|
+
_context.prev = 1;
|
|
69
|
+
_iterator = _createForOfIteratorHelper(docs);
|
|
70
|
+
_context.prev = 3;
|
|
71
|
+
|
|
72
|
+
_iterator.s();
|
|
73
|
+
|
|
74
|
+
case 5:
|
|
75
|
+
if ((_step = _iterator.n()).done) {
|
|
76
|
+
_context.next = 11;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
doc = _step.value;
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
return client.save(_objectSpread(_objectSpread({}, doc), {}, {
|
|
83
|
+
cozyMetadata: _objectSpread(_objectSpread({}, doc.cozyMetadata), {}, {
|
|
84
|
+
favorite: true
|
|
85
|
+
})
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
case 9:
|
|
89
|
+
_context.next = 5;
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case 11:
|
|
93
|
+
_context.next = 16;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case 13:
|
|
97
|
+
_context.prev = 13;
|
|
98
|
+
_context.t0 = _context["catch"](3);
|
|
99
|
+
|
|
100
|
+
_iterator.e(_context.t0);
|
|
101
|
+
|
|
102
|
+
case 16:
|
|
103
|
+
_context.prev = 16;
|
|
104
|
+
|
|
105
|
+
_iterator.f();
|
|
106
|
+
|
|
107
|
+
return _context.finish(16);
|
|
108
|
+
|
|
109
|
+
case 19:
|
|
110
|
+
_splitFilename = splitFilename(docs[0]), filename = _splitFilename.filename;
|
|
111
|
+
showAlert({
|
|
112
|
+
message: t('favorites.add.success', {
|
|
113
|
+
filename: filename,
|
|
114
|
+
smart_count: docs.length
|
|
115
|
+
}),
|
|
116
|
+
severity: 'success'
|
|
117
|
+
});
|
|
118
|
+
_context.next = 26;
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 23:
|
|
122
|
+
_context.prev = 23;
|
|
123
|
+
_context.t1 = _context["catch"](1);
|
|
124
|
+
showAlert({
|
|
125
|
+
message: t('favorites.error'),
|
|
126
|
+
severity: 'error'
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
case 26:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context.stop();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, _callee, null, [[1, 23], [3, 13, 16, 19]]);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
function action(_x, _x2) {
|
|
138
|
+
return _action.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return action;
|
|
142
|
+
}()
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { downloadFile } from 'cozy-client/dist/models/file';
|
|
4
|
+
import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
|
|
5
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
6
|
+
import DownloadIcon from "cozy-ui/transpiled/react/Icons/Download";
|
|
7
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
8
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
9
|
+
import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
|
|
10
|
+
|
|
11
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
12
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
14
|
+
ref: ref
|
|
15
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
16
|
+
icon: icon
|
|
17
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
18
|
+
primary: label
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
21
|
+
Component.displayName = 'download';
|
|
22
|
+
return Component;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export var download = function download(_ref) {
|
|
26
|
+
var encryptedUrl = _ref.encryptedUrl;
|
|
27
|
+
|
|
28
|
+
var _getActionsI18n = getActionsI18n(),
|
|
29
|
+
t = _getActionsI18n.t;
|
|
30
|
+
|
|
31
|
+
var icon = DownloadIcon;
|
|
32
|
+
var label = t('download');
|
|
33
|
+
return {
|
|
34
|
+
name: 'download',
|
|
35
|
+
icon: icon,
|
|
36
|
+
label: label,
|
|
37
|
+
Component: makeComponent(label, icon),
|
|
38
|
+
action: function action(docs, _ref2) {
|
|
39
|
+
var client = _ref2.client,
|
|
40
|
+
webviewIntent = _ref2.webviewIntent;
|
|
41
|
+
return downloadFile({
|
|
42
|
+
client: client,
|
|
43
|
+
file: docs[0],
|
|
44
|
+
url: encryptedUrl,
|
|
45
|
+
webviewIntent: webviewIntent
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -5,6 +5,9 @@ export { smsTo } from './smsTo';
|
|
|
5
5
|
export { call } from './call';
|
|
6
6
|
export { emailTo } from './emailTo';
|
|
7
7
|
export { print } from './print';
|
|
8
|
+
export { download } from './download';
|
|
9
|
+
export { addToFavorites } from './addToFavorites';
|
|
10
|
+
export { removeFromFavorites } from './removeFromFavorites';
|
|
8
11
|
export { viewInContacts } from './viewInContacts';
|
|
9
12
|
export { viewInDrive } from './viewInDrive';
|
|
10
13
|
export { copyToClipboard } from './copyToClipboard';
|
|
@@ -5,6 +5,18 @@ var en = {
|
|
|
5
5
|
emailTo: "Send an email",
|
|
6
6
|
smsTo: "Send a message",
|
|
7
7
|
print: "Print",
|
|
8
|
+
download: "Download",
|
|
9
|
+
favorites: {
|
|
10
|
+
add: {
|
|
11
|
+
label: "Add to favorites",
|
|
12
|
+
success: "%{filename} has been added to favorites |||| These items have been added to favorites"
|
|
13
|
+
},
|
|
14
|
+
remove: {
|
|
15
|
+
label: "Remove from favorites",
|
|
16
|
+
success: "%{filename} has been removed from favorites |||| These items have been removed from favorites"
|
|
17
|
+
},
|
|
18
|
+
error: "An error occurred, please try again."
|
|
19
|
+
},
|
|
8
20
|
others: "Others",
|
|
9
21
|
editAttribute: "Edit attribute",
|
|
10
22
|
copyToClipboard: {
|
|
@@ -21,6 +33,18 @@ var fr = {
|
|
|
21
33
|
emailTo: "Envoyer un e-mail",
|
|
22
34
|
smsTo: "Envoyer un message",
|
|
23
35
|
print: "Imprimer",
|
|
36
|
+
download: "T\xE9l\xE9charger",
|
|
37
|
+
favorites: {
|
|
38
|
+
add: {
|
|
39
|
+
label: "Ajouter aux favoris",
|
|
40
|
+
success: "%{filename} a \xE9t\xE9 ajout\xE9 aux favoris |||| Ces \xE9l\xE9ments ont \xE9t\xE9 ajout\xE9s aux favoris"
|
|
41
|
+
},
|
|
42
|
+
remove: {
|
|
43
|
+
label: "Retirer des favoris",
|
|
44
|
+
success: "%{filename} a \xE9t\xE9 retir\xE9 des favoris |||| Ces \xE9l\xE9ments ont \xE9t\xE9 retir\xE9s des favoris"
|
|
45
|
+
},
|
|
46
|
+
error: "Une erreur est survenue, merci de r\xE9essayer."
|
|
47
|
+
},
|
|
24
48
|
others: "Autres",
|
|
25
49
|
editAttribute: "Editer l'attribut",
|
|
26
50
|
copyToClipboard: {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
15
|
+
|
|
16
|
+
import React, { forwardRef } from 'react';
|
|
17
|
+
import { splitFilename } from 'cozy-client/dist/models/file';
|
|
18
|
+
import { getActionsI18n } from "cozy-ui/transpiled/react/ActionsMenu/Actions/locales/withActionsLocales";
|
|
19
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
20
|
+
import StarIcon from "cozy-ui/transpiled/react/Icons/Star";
|
|
21
|
+
import ListItemIcon from "cozy-ui/transpiled/react/ListItemIcon";
|
|
22
|
+
import ListItemText from "cozy-ui/transpiled/react/ListItemText";
|
|
23
|
+
import ActionsMenuItem from "cozy-ui/transpiled/react/ActionsMenu/ActionsMenuItem";
|
|
24
|
+
|
|
25
|
+
var makeComponent = function makeComponent(label, icon) {
|
|
26
|
+
var Component = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
27
|
+
return /*#__PURE__*/React.createElement(ActionsMenuItem, _extends({}, props, {
|
|
28
|
+
ref: ref
|
|
29
|
+
}), /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(Icon, {
|
|
30
|
+
icon: icon
|
|
31
|
+
})), /*#__PURE__*/React.createElement(ListItemText, {
|
|
32
|
+
primary: label
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
Component.displayName = 'removeFromFavorites';
|
|
36
|
+
return Component;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export var removeFromFavorites = function removeFromFavorites(_ref) {
|
|
40
|
+
var showAlert = _ref.showAlert;
|
|
41
|
+
|
|
42
|
+
var _getActionsI18n = getActionsI18n(),
|
|
43
|
+
t = _getActionsI18n.t;
|
|
44
|
+
|
|
45
|
+
var icon = StarIcon;
|
|
46
|
+
var label = t('favorites.remove.label');
|
|
47
|
+
return {
|
|
48
|
+
name: 'removeFromFavorites',
|
|
49
|
+
icon: icon,
|
|
50
|
+
label: label,
|
|
51
|
+
displayCondition: function displayCondition(docs) {
|
|
52
|
+
return docs.length > 0 && docs.every(function (doc) {
|
|
53
|
+
var _doc$cozyMetadata;
|
|
54
|
+
|
|
55
|
+
return (_doc$cozyMetadata = doc.cozyMetadata) === null || _doc$cozyMetadata === void 0 ? void 0 : _doc$cozyMetadata.favorite;
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
Component: makeComponent(label, icon),
|
|
59
|
+
action: function () {
|
|
60
|
+
var _action = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(docs, _ref2) {
|
|
61
|
+
var client, _iterator, _step, doc, _splitFilename, filename;
|
|
62
|
+
|
|
63
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
64
|
+
while (1) {
|
|
65
|
+
switch (_context.prev = _context.next) {
|
|
66
|
+
case 0:
|
|
67
|
+
client = _ref2.client;
|
|
68
|
+
_context.prev = 1;
|
|
69
|
+
_iterator = _createForOfIteratorHelper(docs);
|
|
70
|
+
_context.prev = 3;
|
|
71
|
+
|
|
72
|
+
_iterator.s();
|
|
73
|
+
|
|
74
|
+
case 5:
|
|
75
|
+
if ((_step = _iterator.n()).done) {
|
|
76
|
+
_context.next = 11;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
doc = _step.value;
|
|
81
|
+
_context.next = 9;
|
|
82
|
+
return client.save(_objectSpread(_objectSpread({}, doc), {}, {
|
|
83
|
+
cozyMetadata: _objectSpread(_objectSpread({}, doc.cozyMetadata), {}, {
|
|
84
|
+
favorite: false
|
|
85
|
+
})
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
case 9:
|
|
89
|
+
_context.next = 5;
|
|
90
|
+
break;
|
|
91
|
+
|
|
92
|
+
case 11:
|
|
93
|
+
_context.next = 16;
|
|
94
|
+
break;
|
|
95
|
+
|
|
96
|
+
case 13:
|
|
97
|
+
_context.prev = 13;
|
|
98
|
+
_context.t0 = _context["catch"](3);
|
|
99
|
+
|
|
100
|
+
_iterator.e(_context.t0);
|
|
101
|
+
|
|
102
|
+
case 16:
|
|
103
|
+
_context.prev = 16;
|
|
104
|
+
|
|
105
|
+
_iterator.f();
|
|
106
|
+
|
|
107
|
+
return _context.finish(16);
|
|
108
|
+
|
|
109
|
+
case 19:
|
|
110
|
+
_splitFilename = splitFilename(docs[0]), filename = _splitFilename.filename;
|
|
111
|
+
showAlert({
|
|
112
|
+
message: t('favorites.success.remove', {
|
|
113
|
+
filename: filename,
|
|
114
|
+
smart_count: docs.length
|
|
115
|
+
}),
|
|
116
|
+
severity: 'success'
|
|
117
|
+
});
|
|
118
|
+
_context.next = 26;
|
|
119
|
+
break;
|
|
120
|
+
|
|
121
|
+
case 23:
|
|
122
|
+
_context.prev = 23;
|
|
123
|
+
_context.t1 = _context["catch"](1);
|
|
124
|
+
showAlert({
|
|
125
|
+
message: t('favorites.error'),
|
|
126
|
+
severity: 'error'
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
case 26:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context.stop();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}, _callee, null, [[1, 23], [3, 13, 16, 19]]);
|
|
135
|
+
}));
|
|
136
|
+
|
|
137
|
+
function action(_x, _x2) {
|
|
138
|
+
return _action.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return action;
|
|
142
|
+
}()
|
|
143
|
+
};
|
|
144
|
+
};
|
|
@@ -8,17 +8,18 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
9
|
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
+
import debounce from 'lodash/debounce';
|
|
11
12
|
import omit from 'lodash/omit';
|
|
12
13
|
import PropTypes from 'prop-types';
|
|
13
|
-
import React, { useState, useRef } from 'react';
|
|
14
|
+
import React, { useState, useRef, useMemo } from 'react';
|
|
14
15
|
import ItemRow from "cozy-ui/transpiled/react/NestedSelect/ItemRow";
|
|
15
16
|
import { makeHistory } from "cozy-ui/transpiled/react/NestedSelect/helpers";
|
|
16
17
|
var styles = {
|
|
17
18
|
"Modal__back": "styles__Modal__back___qxUn_",
|
|
18
19
|
"search-container--without-title": "styles__search-container--without-title___3P2fe"
|
|
19
20
|
};
|
|
20
|
-
import Input from "cozy-ui/transpiled/react/Input";
|
|
21
21
|
import List from "cozy-ui/transpiled/react/List";
|
|
22
|
+
import SearchBar from "cozy-ui/transpiled/react/SearchBar";
|
|
22
23
|
import Typography from "cozy-ui/transpiled/react/Typography";
|
|
23
24
|
export { ItemRow };
|
|
24
25
|
/**
|
|
@@ -29,8 +30,6 @@ export { ItemRow };
|
|
|
29
30
|
*/
|
|
30
31
|
|
|
31
32
|
var NestedSelect = function NestedSelect(_ref) {
|
|
32
|
-
var _state$searchValue;
|
|
33
|
-
|
|
34
33
|
var onSelect = _ref.onSelect,
|
|
35
34
|
ContentComponent = _ref.ContentComponent,
|
|
36
35
|
HeaderComponent = _ref.HeaderComponent,
|
|
@@ -47,13 +46,21 @@ var NestedSelect = function NestedSelect(_ref) {
|
|
|
47
46
|
|
|
48
47
|
var _useState = useState({
|
|
49
48
|
history: makeHistory(options, canSelectParent),
|
|
50
|
-
searchValue: ''
|
|
51
|
-
searchResult: []
|
|
49
|
+
searchValue: ''
|
|
52
50
|
}),
|
|
53
51
|
_useState2 = _slicedToArray(_useState, 2),
|
|
54
52
|
state = _useState2[0],
|
|
55
53
|
setState = _useState2[1];
|
|
56
54
|
|
|
55
|
+
var _useState3 = useState(null),
|
|
56
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
57
|
+
searchResult = _useState4[0],
|
|
58
|
+
setSearchResult = _useState4[1];
|
|
59
|
+
|
|
60
|
+
var delayedSetSearchResult = useMemo(function () {
|
|
61
|
+
return debounce(setSearchResult, 250);
|
|
62
|
+
}, [setSearchResult]);
|
|
63
|
+
|
|
57
64
|
var handleBack = function handleBack() {
|
|
58
65
|
var _state$history = _toArray(state.history),
|
|
59
66
|
item = _state$history[0],
|
|
@@ -93,21 +100,31 @@ var NestedSelect = function NestedSelect(_ref) {
|
|
|
93
100
|
|
|
94
101
|
if (onSearch) {
|
|
95
102
|
var searchValue = ev.target.value;
|
|
96
|
-
|
|
103
|
+
|
|
104
|
+
var _searchResult = onSearch(searchValue);
|
|
105
|
+
|
|
97
106
|
setState(function (state) {
|
|
98
107
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
99
|
-
searchValue: searchValue
|
|
100
|
-
searchResult: searchResult
|
|
108
|
+
searchValue: searchValue
|
|
101
109
|
});
|
|
102
110
|
});
|
|
111
|
+
delayedSetSearchResult(_searchResult);
|
|
103
112
|
}
|
|
104
113
|
};
|
|
105
114
|
|
|
115
|
+
var onClear = function onClear() {
|
|
116
|
+
setState(function (state) {
|
|
117
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
118
|
+
searchValue: ''
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
delayedSetSearchResult(null);
|
|
122
|
+
};
|
|
123
|
+
|
|
106
124
|
var current = state.history[0];
|
|
107
125
|
var children = current.children || [];
|
|
108
126
|
var level = state.history.length - 1;
|
|
109
127
|
var parentItem = transformParentItem(omit(current, 'children'));
|
|
110
|
-
var hasSearchResult = ((_state$searchValue = state.searchValue) === null || _state$searchValue === void 0 ? void 0 : _state$searchValue.length) > 0;
|
|
111
128
|
|
|
112
129
|
var isSelectedWithLevel = function isSelectedWithLevel(item) {
|
|
113
130
|
return isSelected(item, level);
|
|
@@ -131,21 +148,22 @@ var NestedSelect = function NestedSelect(_ref) {
|
|
|
131
148
|
className: cx('u-ml-1 u-mb-half', _defineProperty({
|
|
132
149
|
'u-mr-1': currentTitle
|
|
133
150
|
}, styles['search-container--without-title'], !currentTitle))
|
|
134
|
-
}, /*#__PURE__*/React.createElement(
|
|
151
|
+
}, /*#__PURE__*/React.createElement(SearchBar, {
|
|
135
152
|
placeholder: searchOptions.placeholderSearch,
|
|
153
|
+
value: state.searchValue,
|
|
136
154
|
onChange: onChange,
|
|
137
|
-
|
|
138
|
-
})),
|
|
155
|
+
onClear: onClear
|
|
156
|
+
})), searchResult ? searchResult.length === 0 ? /*#__PURE__*/React.createElement(Typography, {
|
|
139
157
|
variant: "body1",
|
|
140
158
|
className: "u-flex u-flex-justify-center u-mb-1 "
|
|
141
|
-
}, searchOptions.noDataLabel) :
|
|
159
|
+
}, searchOptions.noDataLabel) : searchResult.map(function (item, index) {
|
|
142
160
|
return /*#__PURE__*/React.createElement(ItemRow, {
|
|
143
161
|
radioPosition: radioPosition,
|
|
144
162
|
key: item.key || item.title,
|
|
145
163
|
item: item,
|
|
146
164
|
onClick: handleClickItem,
|
|
147
165
|
isSelected: isSelectedWithLevel(item),
|
|
148
|
-
isLast: index ===
|
|
166
|
+
isLast: index === searchResult.length - 1,
|
|
149
167
|
ellipsis: ellipsis,
|
|
150
168
|
noDivider: noDivider
|
|
151
169
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { themesList } from 'cozy-client/dist/models/document/documentTypeData';
|
|
4
|
+
import { isQualificationNote } from 'cozy-client/dist/models/document/documentTypeDataHelpers';
|
|
5
|
+
import { getBoundT } from 'cozy-client/dist/models/document/locales';
|
|
6
|
+
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
7
|
+
import FileTypeNoteIcon from "cozy-ui/transpiled/react/Icons/FileTypeNote";
|
|
8
|
+
import QualificationIconStack from "cozy-ui/transpiled/react/QualificationIconStack";
|
|
9
|
+
export var makeOptions = function makeOptions(lang) {
|
|
10
|
+
var qualifT = getBoundT(lang);
|
|
11
|
+
return {
|
|
12
|
+
children: [{
|
|
13
|
+
id: 'none',
|
|
14
|
+
title: qualifT('Scan.themes.none'),
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(QualificationIconStack, null)
|
|
16
|
+
}].concat(_toConsumableArray(themesList.map(function (theme) {
|
|
17
|
+
return {
|
|
18
|
+
id: theme.id,
|
|
19
|
+
title: qualifT("Scan.themes.".concat(theme.label)),
|
|
20
|
+
icon: /*#__PURE__*/React.createElement(QualificationIconStack, {
|
|
21
|
+
theme: theme.label
|
|
22
|
+
}),
|
|
23
|
+
children: theme.items.map(function (item) {
|
|
24
|
+
return {
|
|
25
|
+
id: item.label,
|
|
26
|
+
item: item,
|
|
27
|
+
title: qualifT("Scan.items.".concat(item.label)),
|
|
28
|
+
icon: isQualificationNote(item) ? /*#__PURE__*/React.createElement(Icon, {
|
|
29
|
+
icon: FileTypeNoteIcon,
|
|
30
|
+
size: 64
|
|
31
|
+
}) : /*#__PURE__*/React.createElement(QualificationIconStack, {
|
|
32
|
+
qualification: item.label
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
})))
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export var searchOptionsFn = function searchOptionsFn(options, value) {
|
|
41
|
+
var deepOptions = options.children.flatMap(function (child) {
|
|
42
|
+
return child.children;
|
|
43
|
+
}).reduce(function (acc, curr) {
|
|
44
|
+
if (!!curr && !acc.some(function (el) {
|
|
45
|
+
return el.id === curr.id;
|
|
46
|
+
})) {
|
|
47
|
+
acc.push(curr);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return acc;
|
|
51
|
+
}, []);
|
|
52
|
+
return deepOptions.filter(function (deepOption) {
|
|
53
|
+
return deepOption.title.toLowerCase().includes(value.toLowerCase());
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export var makeSearchOptions = function makeSearchOptions(_ref) {
|
|
57
|
+
var options = _ref.options,
|
|
58
|
+
title = _ref.title,
|
|
59
|
+
noDataLabel = _ref.noDataLabel,
|
|
60
|
+
t = _ref.t;
|
|
61
|
+
return {
|
|
62
|
+
placeholderSearch: title || t('QualificationModal.title'),
|
|
63
|
+
noDataLabel: noDataLabel || t('QualificationModal.noDataLabel'),
|
|
64
|
+
onSearch: function onSearch(value) {
|
|
65
|
+
return searchOptionsFn(options, value);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -1,57 +1,20 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import React, { useMemo } from 'react';
|
|
6
5
|
import { useClient } from 'cozy-client';
|
|
7
|
-
import { themesList } from 'cozy-client/dist/models/document/documentTypeData';
|
|
8
|
-
import { isQualificationNote } from 'cozy-client/dist/models/document/documentTypeDataHelpers';
|
|
9
|
-
import { getBoundT } from 'cozy-client/dist/models/document/locales';
|
|
10
6
|
import { isSupportedQualification } from 'cozy-client/dist/models/document/qualification';
|
|
7
|
+
import { makeOptions, makeSearchOptions } from "cozy-ui/transpiled/react/QualificationModal/helpers";
|
|
11
8
|
import { locales } from "cozy-ui/transpiled/react/QualificationModal/locales";
|
|
12
|
-
import Icon from "cozy-ui/transpiled/react/Icon";
|
|
13
|
-
import FileTypeNoteIcon from "cozy-ui/transpiled/react/Icons/FileTypeNote";
|
|
14
9
|
import NestedSelectResponsive from "cozy-ui/transpiled/react/NestedSelect/NestedSelectResponsive";
|
|
15
|
-
import QualificationIconStack from "cozy-ui/transpiled/react/QualificationIconStack";
|
|
16
10
|
import { useI18n, useExtendI18n } from "cozy-ui/transpiled/react/providers/I18n";
|
|
17
11
|
|
|
18
|
-
var makeOptions = function makeOptions(lang) {
|
|
19
|
-
var qualifT = getBoundT(lang);
|
|
20
|
-
return {
|
|
21
|
-
children: [{
|
|
22
|
-
id: 'none',
|
|
23
|
-
title: qualifT('Scan.themes.none'),
|
|
24
|
-
icon: /*#__PURE__*/React.createElement(QualificationIconStack, null)
|
|
25
|
-
}].concat(_toConsumableArray(themesList.map(function (theme) {
|
|
26
|
-
return {
|
|
27
|
-
id: theme.id,
|
|
28
|
-
title: qualifT("Scan.themes.".concat(theme.label)),
|
|
29
|
-
icon: /*#__PURE__*/React.createElement(QualificationIconStack, {
|
|
30
|
-
theme: theme.label
|
|
31
|
-
}),
|
|
32
|
-
children: theme.items.map(function (item) {
|
|
33
|
-
return {
|
|
34
|
-
id: item.label,
|
|
35
|
-
item: item,
|
|
36
|
-
title: qualifT("Scan.items.".concat(item.label)),
|
|
37
|
-
icon: isQualificationNote(item) ? /*#__PURE__*/React.createElement(Icon, {
|
|
38
|
-
icon: FileTypeNoteIcon,
|
|
39
|
-
size: 64
|
|
40
|
-
}) : /*#__PURE__*/React.createElement(QualificationIconStack, {
|
|
41
|
-
qualification: item.label
|
|
42
|
-
})
|
|
43
|
-
};
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
|
-
})))
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
12
|
var QualificationModal = function QualificationModal(_ref) {
|
|
51
13
|
var _file$metadata, _file$metadata$qualif;
|
|
52
14
|
|
|
53
15
|
var file = _ref.file,
|
|
54
16
|
title = _ref.title,
|
|
17
|
+
noDataLabel = _ref.noDataLabel,
|
|
55
18
|
onClose = _ref.onClose;
|
|
56
19
|
useExtendI18n(locales);
|
|
57
20
|
var client = useClient();
|
|
@@ -64,6 +27,14 @@ var QualificationModal = function QualificationModal(_ref) {
|
|
|
64
27
|
var options = useMemo(function () {
|
|
65
28
|
return makeOptions(lang);
|
|
66
29
|
}, [lang]);
|
|
30
|
+
var searchOptions = useMemo(function () {
|
|
31
|
+
return makeSearchOptions({
|
|
32
|
+
options: options,
|
|
33
|
+
title: title,
|
|
34
|
+
noDataLabel: noDataLabel,
|
|
35
|
+
t: t
|
|
36
|
+
});
|
|
37
|
+
}, [options, title, noDataLabel, t]);
|
|
67
38
|
|
|
68
39
|
var isSelected = function isSelected(_ref2) {
|
|
69
40
|
var id = _ref2.id,
|
|
@@ -108,11 +79,11 @@ var QualificationModal = function QualificationModal(_ref) {
|
|
|
108
79
|
}();
|
|
109
80
|
|
|
110
81
|
return /*#__PURE__*/React.createElement(NestedSelectResponsive, {
|
|
111
|
-
title: title || t('QualificationModal.title'),
|
|
112
82
|
options: options,
|
|
113
83
|
noDivider: true,
|
|
114
84
|
document: file,
|
|
115
85
|
isSelected: isSelected,
|
|
86
|
+
searchOptions: searchOptions,
|
|
116
87
|
onSelect: handleClick,
|
|
117
88
|
onClose: onClose
|
|
118
89
|
});
|
|
@@ -121,6 +92,7 @@ var QualificationModal = function QualificationModal(_ref) {
|
|
|
121
92
|
QualificationModal.propTypes = {
|
|
122
93
|
file: PropTypes.object,
|
|
123
94
|
title: PropTypes.string,
|
|
95
|
+
noDataLabel: PropTypes.string,
|
|
124
96
|
onClose: PropTypes.func
|
|
125
97
|
};
|
|
126
98
|
export default QualificationModal;
|