@instructure/quiz-core 22.10.1 → 22.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/banks/api/banks.js +18 -97
- package/es/banks/components/SharingModal/index.js +6 -3
- package/es/banks/components/SharingModal/presenter.js +207 -131
- package/es/building/api/items.js +120 -24
- package/es/building/api/quizEntries.js +78 -15
- package/es/building/components/resources/quizEntry/QuizEntryShow/presenter.js +11 -2
- package/es/common/actions/sharedBanks.js +13 -1
- package/es/common/actions/sharingModal.js +7 -0
- package/es/common/components/resources/quiz/AddContent/Body/index.js +1 -1
- package/es/common/components/resources/quiz/AddContent/Body/presenter.js +129 -141
- package/es/common/components/resources/quiz/AddContent/Popover/presenter.js +126 -119
- package/es/common/components/shared/InteractionTypes/index.js +1 -4
- package/es/common/components/shared/InteractionTypes/presenter.js +1 -3
- package/es/common/middleware/sharedBanksMiddleware.js +243 -0
- package/es/common/records/Item.js +2 -1
- package/es/common/records/QuizEntry.js +7 -0
- package/es/common/reducers/sharingModal.js +17 -0
- package/es/common/util/useRemoteComponent.js +127 -0
- package/es/configureStore.js +4 -1
- package/es/index.js +3 -2
- package/lib/banks/api/banks.js +17 -96
- package/lib/banks/components/SharingModal/index.js +5 -2
- package/lib/banks/components/SharingModal/presenter.js +205 -129
- package/lib/building/api/items.js +120 -23
- package/lib/building/api/quizEntries.js +78 -14
- package/lib/building/components/resources/quizEntry/QuizEntryShow/presenter.js +10 -1
- package/lib/common/actions/sharedBanks.js +13 -1
- package/lib/common/actions/sharingModal.js +13 -0
- package/lib/common/components/resources/quiz/AddContent/Body/index.js +1 -1
- package/lib/common/components/resources/quiz/AddContent/Body/presenter.js +132 -141
- package/lib/common/components/resources/quiz/AddContent/Popover/presenter.js +127 -119
- package/lib/common/components/shared/InteractionTypes/index.js +1 -4
- package/lib/common/components/shared/InteractionTypes/presenter.js +1 -3
- package/lib/common/middleware/sharedBanksMiddleware.js +250 -0
- package/lib/common/records/Item.js +2 -1
- package/lib/common/records/QuizEntry.js +7 -0
- package/lib/common/reducers/sharingModal.js +23 -0
- package/lib/common/util/useRemoteComponent.js +134 -0
- package/lib/configureStore.js +4 -1
- package/lib/index.js +22 -0
- package/package.json +8 -8
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = exports.SharingModalPresenter = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -19,6 +18,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
19
18
|
var _immutable = require("immutable");
|
|
20
19
|
var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
|
|
21
20
|
var _partial = _interopRequireDefault(require("lodash/partial"));
|
|
21
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
22
22
|
var _quizCommon = require("@instructure/quiz-common");
|
|
23
23
|
var _uiHeading = require("@instructure/ui-heading");
|
|
24
24
|
var _uiButtons = require("@instructure/ui-buttons");
|
|
@@ -35,12 +35,11 @@ var _Spinner = _interopRequireDefault(require("../../../common/components/shared
|
|
|
35
35
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
36
36
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
37
37
|
var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
|
|
38
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
38
39
|
var _dec, _class, _SharingModalPresenter;
|
|
39
40
|
/** @jsx jsx */
|
|
40
41
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
41
42
|
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; }
|
|
42
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
44
43
|
function _callSuper(_this, derived, args) {
|
|
45
44
|
function isNativeReflectConstruct() {
|
|
46
45
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
@@ -57,27 +56,29 @@ function _callSuper(_this, derived, args) {
|
|
|
57
56
|
}
|
|
58
57
|
var noop = function noop() {};
|
|
59
58
|
var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCommon.withStyleOverrides)(_styles["default"], _theme["default"]), _dec(_class = (_SharingModalPresenter = /*#__PURE__*/function (_Component) {
|
|
60
|
-
|
|
59
|
+
// =============
|
|
60
|
+
// LIFECYCLE
|
|
61
|
+
// =============
|
|
62
|
+
|
|
63
|
+
function SharingModalPresenter(props) {
|
|
61
64
|
var _this2;
|
|
62
65
|
(0, _classCallCheck2["default"])(this, SharingModalPresenter);
|
|
63
|
-
|
|
64
|
-
args[_key] = arguments[_key];
|
|
65
|
-
}
|
|
66
|
-
_this2 = _callSuper(this, SharingModalPresenter, [].concat(args));
|
|
66
|
+
_this2 = _callSuper(this, SharingModalPresenter, [props]);
|
|
67
67
|
(0, _defineProperty2["default"])(_this2, "state", {
|
|
68
68
|
accountPermission: null,
|
|
69
69
|
shares: (0, _immutable.List)(),
|
|
70
70
|
newEntities: (0, _immutable.List)(),
|
|
71
71
|
searchSelection: [],
|
|
72
72
|
searchPermission: _quizCommon.READ_ONLY,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
selectedTabIndex: 0,
|
|
74
|
+
value: '',
|
|
75
|
+
startingPoint: 0,
|
|
76
|
+
numOfResults: 0,
|
|
77
|
+
searchValue: '',
|
|
78
|
+
displayEntities: []
|
|
75
79
|
});
|
|
76
80
|
(0, _defineProperty2["default"])(_this2, "shareListRef", null);
|
|
77
81
|
(0, _defineProperty2["default"])(_this2, "shareButtonRef", null);
|
|
78
|
-
// =============
|
|
79
|
-
// LIFECYCLE
|
|
80
|
-
// =============
|
|
81
82
|
(0, _defineProperty2["default"])(_this2, "checkForSharedBanks", function () {
|
|
82
83
|
var size = _this2.props.sharedBanks.size;
|
|
83
84
|
if (size >= 0 && size !== _this2.props.bank.sharedCount || size === 0) {
|
|
@@ -88,13 +89,70 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
});
|
|
92
|
+
(0, _defineProperty2["default"])(_this2, "normalizeText", function (text) {
|
|
93
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase();
|
|
94
|
+
});
|
|
91
95
|
// =============
|
|
92
96
|
// HELPERS
|
|
93
97
|
// =============
|
|
98
|
+
(0, _defineProperty2["default"])(_this2, "createFilteredList", function () {
|
|
99
|
+
var entities = _this2.state.shares;
|
|
100
|
+
var users = entities.filter(function (s) {
|
|
101
|
+
return s.get('entityType') === _quizCommon.SHARED_WITH_USER;
|
|
102
|
+
});
|
|
103
|
+
var courses = entities.filter(function (s) {
|
|
104
|
+
return s.get('entityType') === _quizCommon.SHARED_WITH_COURSE;
|
|
105
|
+
});
|
|
106
|
+
var accounts = entities.filter(function (s) {
|
|
107
|
+
return s.get('entityType') === _quizCommon.SHARED_WITH_ACCOUNT;
|
|
108
|
+
});
|
|
109
|
+
switch (_this2.state.selectedTabIndex) {
|
|
110
|
+
case 0:
|
|
111
|
+
{
|
|
112
|
+
var displayedUsers = users.filter(function (item) {
|
|
113
|
+
return _this2.normalizeText(item.get('title')).includes(_this2.normalizeText(_this2.state.searchValue));
|
|
114
|
+
});
|
|
115
|
+
_this2.setState({
|
|
116
|
+
numOfResults: displayedUsers.size,
|
|
117
|
+
displayEntities: displayedUsers.slice(0, _this2.state.startingPoint + _this2.props.limit)
|
|
118
|
+
});
|
|
119
|
+
_this2.debouncedStopLoading();
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case 1:
|
|
123
|
+
{
|
|
124
|
+
var displayedCourses = courses.filter(function (item) {
|
|
125
|
+
return _this2.normalizeText(item.get('title')).includes(_this2.normalizeText(_this2.state.searchValue));
|
|
126
|
+
});
|
|
127
|
+
_this2.setState({
|
|
128
|
+
numOfResults: displayedCourses.size,
|
|
129
|
+
displayEntities: displayedCourses.slice(0, _this2.state.startingPoint + _this2.props.limit)
|
|
130
|
+
});
|
|
131
|
+
_this2.debouncedStopLoading();
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case 2:
|
|
135
|
+
{
|
|
136
|
+
var displayedAccounts = accounts.filter(function (item) {
|
|
137
|
+
return _this2.normalizeText(item.get('title')).includes(_this2.normalizeText(_this2.state.searchValue));
|
|
138
|
+
});
|
|
139
|
+
_this2.setState({
|
|
140
|
+
numOfResults: displayedAccounts.size,
|
|
141
|
+
displayEntities: displayedAccounts.slice(0, _this2.state.startingPoint + _this2.props.limit)
|
|
142
|
+
});
|
|
143
|
+
_this2.debouncedStopLoading();
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
94
148
|
(0, _defineProperty2["default"])(_this2, "handleTabChange", function (event, _ref) {
|
|
95
149
|
var index = _ref.index;
|
|
96
150
|
_this2.setState({
|
|
97
|
-
selectedTabIndex: index
|
|
151
|
+
selectedTabIndex: index,
|
|
152
|
+
startingPoint: 0,
|
|
153
|
+
value: ''
|
|
154
|
+
}, function () {
|
|
155
|
+
_this2.checkForSharedBanks();
|
|
98
156
|
});
|
|
99
157
|
});
|
|
100
158
|
(0, _defineProperty2["default"])(_this2, "modalDismissCleanup", function () {
|
|
@@ -108,30 +166,6 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
108
166
|
// removes the creator's temporary sharedBank record
|
|
109
167
|
_this2.props.removeSharedBank('-1');
|
|
110
168
|
});
|
|
111
|
-
(0, _defineProperty2["default"])(_this2, "numEntitiesToRemove", function () {
|
|
112
|
-
var permissions = Object.values(_this2.state.entitiesWithChangedPermission);
|
|
113
|
-
return permissions.reduce(function (count, val) {
|
|
114
|
-
return val === _quizCommon.REMOVED_ACCESS ? count + 1 : count;
|
|
115
|
-
}, 0);
|
|
116
|
-
});
|
|
117
|
-
(0, _defineProperty2["default"])(_this2, "newEntitiesToSubmit", function () {
|
|
118
|
-
var newEntities = _this2.state.newEntities.filter(function (entity) {
|
|
119
|
-
return _this2.state.entitiesWithChangedPermission[entity.get('id')] !== _quizCommon.REMOVED_ACCESS;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// special case if the creator tries to change their own permissions before
|
|
123
|
-
// first share, since they don't have a SharedBank record to update
|
|
124
|
-
var newCreatorPerm = _this2.state.entitiesWithChangedPermission['-1'];
|
|
125
|
-
if (newCreatorPerm && newCreatorPerm !== _quizCommon.CAN_EDIT) {
|
|
126
|
-
var creatorSharedBank = _this2.props.sharedBanks.find(function (sharedBank) {
|
|
127
|
-
return sharedBank.get('id') == '-1';
|
|
128
|
-
});
|
|
129
|
-
newEntities = newEntities.push((0, _immutable.Map)(_objectSpread(_objectSpread({}, creatorSharedBank.toJS()), {}, {
|
|
130
|
-
permission: newCreatorPerm
|
|
131
|
-
})));
|
|
132
|
-
}
|
|
133
|
-
return newEntities;
|
|
134
|
-
});
|
|
135
169
|
(0, _defineProperty2["default"])(_this2, "isSharedWithAccount", function () {
|
|
136
170
|
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this2.state;
|
|
137
171
|
return [_quizCommon.READ_ONLY, _quizCommon.CAN_EDIT].includes(state.accountPermission);
|
|
@@ -143,50 +177,11 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
143
177
|
_this2.props.updateSharedCount(null);
|
|
144
178
|
_this2.modalDismissCleanup();
|
|
145
179
|
});
|
|
146
|
-
(0, _defineProperty2["default"])(_this2, "handleSubmit", function () {
|
|
147
|
-
// calls the sharedBank api with the new entities you shared the current bank with
|
|
148
|
-
var promises = [];
|
|
149
|
-
if (_this2.state.accountPermission !== _this2.props.bank.accountPermission) {
|
|
150
|
-
var updatedBank = _this2.props.bank.set('accountPermission', _this2.state.accountPermission);
|
|
151
|
-
promises.push(_this2.props.updateBank(updatedBank));
|
|
152
|
-
}
|
|
153
|
-
_this2.newEntitiesToSubmit().forEach(function (entity) {
|
|
154
|
-
_this2.props.onShare(entity.toJS());
|
|
155
|
-
promises.push(_this2.props.shareBank(_this2.sharedBankForEntity(entity), _this2.props.getUserInfo));
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// call the update api if any shared bank permission was updated
|
|
159
|
-
Object.entries(_this2.state.entitiesWithChangedPermission).forEach(function (_ref2) {
|
|
160
|
-
var _ref3 = (0, _slicedToArray2["default"])(_ref2, 2),
|
|
161
|
-
sharedBankId = _ref3[0],
|
|
162
|
-
permission = _ref3[1];
|
|
163
|
-
var sharedBank = _this2.props.sharedBanks.find(function (sharedBank) {
|
|
164
|
-
return sharedBank.get('id') === sharedBankId;
|
|
165
|
-
});
|
|
166
|
-
if (sharedBank && sharedBank.get('permission') !== permission && sharedBankId != '-1') {
|
|
167
|
-
promises.push(_this2.props.updateSharedBankPermission(_this2.props.bank.id, sharedBankId, permission));
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// waits till all the calls to the shareBank and updateSharedBank apis have completed
|
|
172
|
-
Promise.all(promises).then(function (values) {
|
|
173
|
-
// calls getBank for the current bank to update the sharedCount
|
|
174
|
-
_this2.props.getBank(_this2.props.bank.id);
|
|
175
|
-
});
|
|
176
|
-
_this2.setState({
|
|
177
|
-
newEntities: (0, _immutable.List)()
|
|
178
|
-
});
|
|
179
|
-
_this2.modalDismissCleanup(!!_this2.numEntitiesToRemove());
|
|
180
|
-
});
|
|
181
180
|
(0, _defineProperty2["default"])(_this2, "handleSearchSelectionChange", function (searchSelection) {
|
|
182
181
|
_this2.setState({
|
|
183
182
|
searchSelection: searchSelection
|
|
184
183
|
});
|
|
185
184
|
});
|
|
186
|
-
(0, _defineProperty2["default"])(_this2, "updateEntitiesCount", function () {
|
|
187
|
-
// state.shares is a list containing everyone in the list,
|
|
188
|
-
_this2.props.updateSharedCount(_this2.state.shares.size - _this2.numEntitiesToRemove());
|
|
189
|
-
});
|
|
190
185
|
(0, _defineProperty2["default"])(_this2, "originalPermissionForEntity", function (entity) {
|
|
191
186
|
var originalEntity = _this2.props.sharedBanks.find(function (sb) {
|
|
192
187
|
return sb.get('id') == entity.get('id');
|
|
@@ -196,15 +191,15 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
196
191
|
(0, _defineProperty2["default"])(_this2, "handleEntityRemove", function (entity, undoRemove) {
|
|
197
192
|
_this2.confirmPermissionChange(entity, _quizCommon.REMOVED_ACCESS);
|
|
198
193
|
});
|
|
199
|
-
(0, _defineProperty2["default"])(_this2, "handleSearchPermissionChange", function (e,
|
|
200
|
-
var value =
|
|
194
|
+
(0, _defineProperty2["default"])(_this2, "handleSearchPermissionChange", function (e, _ref2) {
|
|
195
|
+
var value = _ref2.value;
|
|
201
196
|
_this2.setState({
|
|
202
197
|
searchPermission: value
|
|
203
198
|
});
|
|
204
199
|
});
|
|
205
200
|
(0, _defineProperty2["default"])(_this2, "handleSearchFilter", function (searchResults) {
|
|
206
201
|
return searchResults.filter(function (result) {
|
|
207
|
-
return !_this2.
|
|
202
|
+
return !_this2.props.sharedBanks.some(function (entity) {
|
|
208
203
|
return entity.get('entityId') === result.uuid;
|
|
209
204
|
}) && (result.uuid !== _this2.props.bank.creator || _this2.props.bank.sharedCount > 0);
|
|
210
205
|
});
|
|
@@ -230,7 +225,7 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
230
225
|
});
|
|
231
226
|
});
|
|
232
227
|
(0, _defineProperty2["default"])(_this2, "updatePermission", /*#__PURE__*/function () {
|
|
233
|
-
var
|
|
228
|
+
var _ref3 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(entity, permission) {
|
|
234
229
|
var _this2$props, updateSharedBankPermission, getBank, bank;
|
|
235
230
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
236
231
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -247,7 +242,7 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
247
242
|
}, _callee);
|
|
248
243
|
}));
|
|
249
244
|
return function (_x, _x2) {
|
|
250
|
-
return
|
|
245
|
+
return _ref3.apply(this, arguments);
|
|
251
246
|
};
|
|
252
247
|
}());
|
|
253
248
|
(0, _defineProperty2["default"])(_this2, "translatedPermissionLevel", function (permission) {
|
|
@@ -278,18 +273,24 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
278
273
|
};
|
|
279
274
|
});
|
|
280
275
|
});
|
|
281
|
-
(0, _defineProperty2["default"])(_this2, "handleAccountPermissionChange", function (e,
|
|
282
|
-
var value =
|
|
276
|
+
(0, _defineProperty2["default"])(_this2, "handleAccountPermissionChange", function (e, _ref4) {
|
|
277
|
+
var value = _ref4.value;
|
|
283
278
|
return _this2.setState({
|
|
284
279
|
accountPermission: value
|
|
285
280
|
});
|
|
286
281
|
});
|
|
287
|
-
(0, _defineProperty2["default"])(_this2, "handleShareListRef", function (node) {
|
|
288
|
-
_this2.shareListRef = node;
|
|
289
|
-
});
|
|
290
282
|
(0, _defineProperty2["default"])(_this2, "handleShareButtonRef", function (node) {
|
|
291
283
|
_this2.shareButtonRef = node;
|
|
292
284
|
});
|
|
285
|
+
(0, _defineProperty2["default"])(_this2, "handleChange", function (e, value) {
|
|
286
|
+
_this2.setState({
|
|
287
|
+
value: value
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
(0, _defineProperty2["default"])(_this2, "handleClear", function (e) {
|
|
291
|
+
e.stopPropagation();
|
|
292
|
+
_this2.handleChange(e, '');
|
|
293
|
+
});
|
|
293
294
|
(0, _defineProperty2["default"])(_this2, "renderSearchSection", function (searchType) {
|
|
294
295
|
if (_this2.props.bank.canEdit()) {
|
|
295
296
|
return (0, _emotion.jsx)(_react["default"].Fragment, null, (0, _emotion.jsx)(_uiGrid.Grid, {
|
|
@@ -328,15 +329,105 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
328
329
|
}));
|
|
329
330
|
}
|
|
330
331
|
});
|
|
331
|
-
(0, _defineProperty2["default"])(_this2, "renderShareList", function (
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
(0, _defineProperty2["default"])(_this2, "renderShareList", function () {
|
|
333
|
+
if (_this2.props.loading) {
|
|
334
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
335
|
+
height: "12em",
|
|
336
|
+
as: "div"
|
|
337
|
+
}, (0, _emotion.jsx)(_uiView.View, {
|
|
338
|
+
position: "absolute",
|
|
339
|
+
as: "div",
|
|
340
|
+
insetBlockEnd: "0"
|
|
341
|
+
}, (0, _emotion.jsx)(_Spinner["default"], {
|
|
342
|
+
renderTitle: "Loading...",
|
|
343
|
+
size: "small",
|
|
344
|
+
fontSize: "medium"
|
|
345
|
+
})));
|
|
346
|
+
}
|
|
347
|
+
if (_this2.state.displayEntities.size > 0) {
|
|
348
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
349
|
+
height: "12em",
|
|
350
|
+
overflowY: "auto",
|
|
351
|
+
overflowX: "hidden",
|
|
352
|
+
as: "div",
|
|
353
|
+
padding: "xx-small xx-small none"
|
|
354
|
+
}, (0, _emotion.jsx)(_ShareList["default"], {
|
|
355
|
+
canEdit: _this2.props.bank.canEdit(),
|
|
356
|
+
entities: _this2.state.displayEntities,
|
|
357
|
+
onPermissionChange: _this2.handleEntityPermissionChange,
|
|
358
|
+
onEntityRemove: _this2.handleEntityRemove,
|
|
359
|
+
sharedBanks: _this2.props.sharedBanks
|
|
360
|
+
}), (0, _emotion.jsx)("div", null, _this2.renderShowMoreButton()));
|
|
361
|
+
}
|
|
362
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
363
|
+
height: "12em",
|
|
364
|
+
as: "div"
|
|
365
|
+
}, (0, _formatMessage["default"])('No results found'));
|
|
366
|
+
});
|
|
367
|
+
(0, _defineProperty2["default"])(_this2, "showMoreResult", function () {
|
|
368
|
+
_this2.setState({
|
|
369
|
+
startingPoint: _this2.state.startingPoint + _this2.props.limit
|
|
338
370
|
});
|
|
339
371
|
});
|
|
372
|
+
(0, _defineProperty2["default"])(_this2, "renderShowMoreButton", function () {
|
|
373
|
+
var shouldShowButton = _this2.state.startingPoint + _this2.props.limit < _this2.state.numOfResults;
|
|
374
|
+
if (!shouldShowButton) {
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
378
|
+
css: {
|
|
379
|
+
display: shouldShowButton
|
|
380
|
+
},
|
|
381
|
+
background: "primary",
|
|
382
|
+
padding: "small none",
|
|
383
|
+
as: "div"
|
|
384
|
+
}, (0, _emotion.jsx)(_uiButtons.CondensedButton, {
|
|
385
|
+
onClick: function onClick(e) {
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
e.stopPropagation();
|
|
388
|
+
_this2.showMoreResult();
|
|
389
|
+
}
|
|
390
|
+
}, (0, _formatMessage["default"])('Show more')));
|
|
391
|
+
});
|
|
392
|
+
(0, _defineProperty2["default"])(_this2, "renderClearButton", function () {
|
|
393
|
+
if (!_this2.state.value.length || _this2.state.readOnly || _this2.state.disabled) return null;
|
|
394
|
+
return (0, _emotion.jsx)(_uiButtons.IconButton, {
|
|
395
|
+
type: "button",
|
|
396
|
+
size: "small",
|
|
397
|
+
withBackground: false,
|
|
398
|
+
withBorder: false,
|
|
399
|
+
screenReaderLabel: "Clear search",
|
|
400
|
+
disabled: _this2.state.disabled || _this2.state.readOnly,
|
|
401
|
+
onClick: _this2.handleClear
|
|
402
|
+
}, (0, _emotion.jsx)(_uiIcons.IconTroubleLine, null));
|
|
403
|
+
});
|
|
404
|
+
(0, _defineProperty2["default"])(_this2, "renderSharedSearch", function () {
|
|
405
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
406
|
+
margin: "none large none medium"
|
|
407
|
+
}, (0, _emotion.jsx)(_quizCommon.TextInput, {
|
|
408
|
+
size: 'medium',
|
|
409
|
+
placeholder: (0, _formatMessage["default"])('Search...'),
|
|
410
|
+
value: _this2.state.value,
|
|
411
|
+
onChange: _this2.handleChange,
|
|
412
|
+
interaction: 'enabled',
|
|
413
|
+
inputRef: function inputRef(el) {
|
|
414
|
+
return _this2.inputRef = el;
|
|
415
|
+
},
|
|
416
|
+
renderBeforeInput: (0, _emotion.jsx)(_uiIcons.IconSearchLine, {
|
|
417
|
+
inline: false
|
|
418
|
+
}),
|
|
419
|
+
renderAfterInput: _this2.renderClearButton(),
|
|
420
|
+
shouldNotWrap: true
|
|
421
|
+
}));
|
|
422
|
+
});
|
|
423
|
+
_this2.debouncedSearch = (0, _debounce["default"])(function () {
|
|
424
|
+
_this2.setState({
|
|
425
|
+
searchValue: _this2.state.value
|
|
426
|
+
});
|
|
427
|
+
}, 300);
|
|
428
|
+
_this2.debouncedStopLoading = (0, _debounce["default"])(function () {
|
|
429
|
+
if (_this2.props.loading != false) _this2.props.changeSharedBankLoading(false);
|
|
430
|
+
}, 300);
|
|
340
431
|
return _this2;
|
|
341
432
|
}
|
|
342
433
|
(0, _inherits2["default"])(SharingModalPresenter, _Component);
|
|
@@ -363,6 +454,16 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
363
454
|
var updatedBank = this.props.bank.set('accountPermission', this.state.accountPermission);
|
|
364
455
|
this.props.updateBank(updatedBank, false);
|
|
365
456
|
}
|
|
457
|
+
if (prevState.value !== this.state.value) {
|
|
458
|
+
if (this.props.loading == false) this.props.changeSharedBankLoading(true);
|
|
459
|
+
this.setState({
|
|
460
|
+
startingPoint: 0
|
|
461
|
+
});
|
|
462
|
+
this.debouncedSearch();
|
|
463
|
+
}
|
|
464
|
+
if (prevState.searchValue !== this.state.searchValue || prevState.startingPoint !== this.state.startingPoint || prevState.selectedTabIndex !== this.state.selectedTabIndex || prevState.shares.size !== this.state.shares.size) {
|
|
465
|
+
this.createFilteredList();
|
|
466
|
+
}
|
|
366
467
|
}
|
|
367
468
|
}, {
|
|
368
469
|
key: "sharedBankForEntity",
|
|
@@ -410,7 +511,7 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
410
511
|
as: "div",
|
|
411
512
|
weight: "bold",
|
|
412
513
|
lineHeight: "double"
|
|
413
|
-
}, (0, _formatMessage["default"])('Currently shared with')), this.renderShareList(
|
|
514
|
+
}, (0, _formatMessage["default"])('Currently shared with')), this.renderSharedSearch(), this.renderShareList()), (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
|
|
414
515
|
renderTitle: (0, _formatMessage["default"])('Courses ({ coursesCount })', {
|
|
415
516
|
coursesCount: existingCourses.size
|
|
416
517
|
}),
|
|
@@ -420,7 +521,7 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
420
521
|
as: "div",
|
|
421
522
|
weight: "bold",
|
|
422
523
|
lineHeight: "double"
|
|
423
|
-
}, (0, _formatMessage["default"])('Currently shared with')), this.renderShareList(
|
|
524
|
+
}, (0, _formatMessage["default"])('Currently shared with')), this.renderSharedSearch(), this.renderShareList()), ((currentUser === null || currentUser === void 0 ? void 0 : currentUser.bank_admin) || (currentUser === null || currentUser === void 0 ? void 0 : currentUser.can_share_banks_with_subaccounts)) && (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
|
|
424
525
|
renderTitle: (0, _formatMessage["default"])('Accounts ({ accountsCount })', {
|
|
425
526
|
accountsCount: existingAccounts.size
|
|
426
527
|
}),
|
|
@@ -430,37 +531,7 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
430
531
|
as: "div",
|
|
431
532
|
weight: "bold",
|
|
432
533
|
lineHeight: "double"
|
|
433
|
-
}, (0, _formatMessage["default"])('Currently shared with')), this.renderShareList(
|
|
434
|
-
}
|
|
435
|
-
}, {
|
|
436
|
-
key: "renderOriginalDesignEntities",
|
|
437
|
-
value: function renderOriginalDesignEntities(existingPeople, existingCourses) {
|
|
438
|
-
return (0, _emotion.jsx)("div", {
|
|
439
|
-
className: "fs-mask"
|
|
440
|
-
}, (0, _emotion.jsx)(_uiText.Text, {
|
|
441
|
-
as: "div",
|
|
442
|
-
weight: "bold"
|
|
443
|
-
}, (0, _formatMessage["default"])('Currently shared with')), (0, _emotion.jsx)(_uiView.View, {
|
|
444
|
-
as: "div",
|
|
445
|
-
"data-automation": "sdk-shared-bank-user-list"
|
|
446
|
-
}, !this.state.newEntities.isEmpty() && (0, _emotion.jsx)(_uiView.View, {
|
|
447
|
-
as: "div",
|
|
448
|
-
margin: "0 0 medium 0"
|
|
449
|
-
}, this.renderShareList(this.state.newEntities)), (0, _emotion.jsx)(_uiTabs.Tabs, {
|
|
450
|
-
onRequestTabChange: this.handleTabChange
|
|
451
|
-
}, (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
|
|
452
|
-
renderTitle: (0, _formatMessage["default"])('People ({ peopleCount })', {
|
|
453
|
-
peopleCount: existingPeople.size
|
|
454
|
-
}),
|
|
455
|
-
isSelected: this.state.selectedTabIndex === 0,
|
|
456
|
-
padding: "large small small small"
|
|
457
|
-
}, this.renderShareList(existingPeople)), !existingCourses.isEmpty() && (0, _emotion.jsx)(_uiTabs.Tabs.Panel, {
|
|
458
|
-
renderTitle: (0, _formatMessage["default"])('Courses ({ coursesCount })', {
|
|
459
|
-
coursesCount: existingCourses.size
|
|
460
|
-
}),
|
|
461
|
-
isSelected: this.state.selectedTabIndex === 1,
|
|
462
|
-
padding: "large small small small"
|
|
463
|
-
}, this.renderShareList(existingCourses)))));
|
|
534
|
+
}, (0, _formatMessage["default"])('Currently shared with')), this.renderSharedSearch(), this.renderShareList())));
|
|
464
535
|
}
|
|
465
536
|
}, {
|
|
466
537
|
key: "renderEntitiesSection",
|
|
@@ -543,7 +614,10 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
543
614
|
updateSharedBankPermission: _propTypes["default"].func.isRequired,
|
|
544
615
|
updateSharedCount: _propTypes["default"].func,
|
|
545
616
|
withConfirm: _propTypes["default"].func.isRequired,
|
|
546
|
-
styles: _propTypes["default"].object
|
|
617
|
+
styles: _propTypes["default"].object,
|
|
618
|
+
limit: _propTypes["default"].number,
|
|
619
|
+
loading: _propTypes["default"].bool,
|
|
620
|
+
changeSharedBankLoading: _propTypes["default"].func.isRequired
|
|
547
621
|
}), (0, _defineProperty2["default"])(_SharingModalPresenter, "defaultProps", {
|
|
548
622
|
bank: null,
|
|
549
623
|
currentUser: null,
|
|
@@ -553,6 +627,8 @@ var SharingModalPresenter = exports.SharingModalPresenter = (_dec = (0, _quizCom
|
|
|
553
627
|
onDismiss: noop,
|
|
554
628
|
onShare: function onShare() {},
|
|
555
629
|
sharedBanks: (0, _immutable.List)(),
|
|
556
|
-
updateSharedCount: Function.prototype
|
|
630
|
+
updateSharedCount: Function.prototype,
|
|
631
|
+
limit: 10,
|
|
632
|
+
loading: false
|
|
557
633
|
}), _SharingModalPresenter)) || _class);
|
|
558
634
|
var _default = exports["default"] = SharingModalPresenter;
|