Skip to content

Commit 060eb98

Browse files
committed
Fixed issue with filtering out quick add items in the section item picker
The quick add items were added to the returned json from the server and the official flag was not set on them so they were filtered out. This fix adds the official flag to those appended items.
1 parent 92e8578 commit 060eb98

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

app/assets/javascripts/lara-typescript.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125704,7 +125704,8 @@ var getLaraAuthoringAPI = function (authoringArgs) {
125704125704
type: "MwInteractive",
125705125705
useCount: 0,
125706125706
dateAdded: 0,
125707-
isQuickAddItem: true
125707+
isQuickAddItem: true,
125708+
official: true
125708125709
});
125709125710
result.allEmbeddables.push({
125710125711
id: "Embeddable::Xhtml",
@@ -125713,7 +125714,8 @@ var getLaraAuthoringAPI = function (authoringArgs) {
125713125714
type: "Embeddable::Xhtml",
125714125715
useCount: 0,
125715125716
dateAdded: 0,
125716-
isQuickAddItem: true
125717+
isQuickAddItem: true,
125718+
official: true
125717125719
});
125718125720
var plugins = json.plugins;
125719125721

@@ -130287,8 +130289,6 @@ var SectionItemButton = function (_a) {
130287130289
};
130288130290

130289130291
var SectionItemPicker = function (props) {
130290-
var _a;
130291-
130292130292
var api = (0, use_api_provider_1.usePageAPI)();
130293130293
var allItems = (0, react_1.useMemo)(function () {
130294130294
if (!api.getAllEmbeddables.data) {
@@ -130306,28 +130306,28 @@ var SectionItemPicker = function (props) {
130306130306
allEmbeddables: allEmbeddables
130307130307
};
130308130308
}, [api.getAllEmbeddables.data, api.isAdmin]);
130309-
var quickAddItems = (_a = api.getAllEmbeddables.data) === null || _a === void 0 ? void 0 : _a.allEmbeddables.filter(function (e) {
130309+
var quickAddItems = allItems === null || allItems === void 0 ? void 0 : allItems.allEmbeddables.filter(function (e) {
130310130310
return e.isQuickAddItem;
130311130311
});
130312130312
var onClose = props.onClose,
130313130313
onAdd = props.onAdd;
130314130314
var modalIsVisible = true;
130315130315

130316-
var _b = (0, react_1.useState)(null),
130317-
currentSelectedItem = _b[0],
130318-
setCurrentSelectedItem = _b[1];
130316+
var _a = (0, react_1.useState)(null),
130317+
currentSelectedItem = _a[0],
130318+
setCurrentSelectedItem = _a[1];
130319130319

130320-
var _c = (0, react_1.useState)((allItems === null || allItems === void 0 ? void 0 : allItems.allEmbeddables) || []),
130321-
allItemsList = _c[0],
130322-
setAllItemsList = _c[1];
130320+
var _b = (0, react_1.useState)((allItems === null || allItems === void 0 ? void 0 : allItems.allEmbeddables) || []),
130321+
allItemsList = _b[0],
130322+
setAllItemsList = _b[1];
130323130323

130324-
var _d = (0, react_1.useState)(false),
130325-
isSearching = _d[0],
130326-
setIsSearching = _d[1];
130324+
var _c = (0, react_1.useState)(false),
130325+
isSearching = _c[0],
130326+
setIsSearching = _c[1];
130327130327

130328-
var _e = (0, react_1.useState)(modalIsVisible),
130329-
modalVisibility = _e[0],
130330-
setModalVisibility = _e[1];
130328+
var _d = (0, react_1.useState)(modalIsVisible),
130329+
modalVisibility = _d[0],
130330+
setModalVisibility = _d[1];
130331130331

130332130332
var itemSelected = currentSelectedItem !== null; // Escape key deselects the current item:
130333130333

lara-typescript/src/section-authoring/api/lara-api-provider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,8 @@ export const getLaraAuthoringAPI =
261261
type: "MwInteractive",
262262
useCount: 0,
263263
dateAdded: 0,
264-
isQuickAddItem: true
264+
isQuickAddItem: true,
265+
official: true,
265266
});
266267
result.allEmbeddables.push({
267268
id: "Embeddable::Xhtml",
@@ -270,7 +271,8 @@ export const getLaraAuthoringAPI =
270271
type: "Embeddable::Xhtml",
271272
useCount: 0,
272273
dateAdded: 0,
273-
isQuickAddItem: true
274+
isQuickAddItem: true,
275+
official: true,
274276
});
275277
const plugins = (json.plugins as IPluginType[]);
276278
for (const plugin of plugins) {

lara-typescript/src/section-authoring/components/section-item-picker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const SectionItemPicker: React.FC<IProps> = (props) => {
3737
});
3838
return {allEmbeddables};
3939
}, [api.getAllEmbeddables.data, api.isAdmin]);
40-
const quickAddItems = api.getAllEmbeddables.data?.allEmbeddables.filter(e => e.isQuickAddItem);
40+
const quickAddItems = allItems?.allEmbeddables.filter(e => e.isQuickAddItem);
4141
const { onClose, onAdd } = props;
4242
const modalIsVisible = true;
4343
const [currentSelectedItem, setCurrentSelectedItem]

0 commit comments

Comments
 (0)