Skip to content

Commit

Permalink
fix: add featured content to initiatives edit (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivzhang authored Sep 12, 2023
1 parent d28b56f commit a3f0361
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getTagItems } from "../../core/schemas/internal/getTagItems";
import { getCategoryItems } from "../../core/schemas/internal/getCategoryItems";
import { getLocationExtent } from "../../core/schemas/internal/getLocationExtent";
import { getLocationOptions } from "../../core/schemas/internal/getLocationOptions";
import { getFeaturedContentCatalogs } from "../../core/schemas/internal/getFeaturedContentCatalogs";

/**
* @private
Expand Down Expand Up @@ -142,6 +143,45 @@ export const buildUiSchema = async (
},
],
},
{
type: "Section",
labelKey: `${i18nScope}.sections.featuredContent.label`,
options: {
helperText: {
labelKey: `${i18nScope}.sections.featuredContent.helperText`,
},
},
elements: [
{
scope: "/properties/view/properties/featuredContentIds",
type: "Control",
options: {
control: "hub-field-input-gallery-picker",
targetEntity: "item",
catalogs: getFeaturedContentCatalogs(context.currentUser),
facets: [
{
label: `{{${i18nScope}.fields.featuredContent.facets.type:translate}`,
key: "type",
display: "multi-select",
field: "type",
options: [],
operation: "OR",
aggLimit: 100,
},
{
label: `{{${i18nScope}.fields.featuredContent.facets.sharing:translate}`,
key: "access",
display: "multi-select",
field: "access",
options: [],
operation: "OR",
},
],
},
},
],
},
],
};
};
9 changes: 8 additions & 1 deletion packages/common/src/initiatives/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const DEFAULT_INITIATIVE: Partial<IHubInitiative> = {
permissions: [],
schemaVersion: 2,
features: InitiativeDefaultFeatures,
view: {
featuredContentIds: [],
},
};

/**
Expand All @@ -33,5 +36,9 @@ export const DEFAULT_INITIATIVE_MODEL: IModel = {
schemaVersion: 2,
},
},
data: {},
data: {
view: {
featuredContentIds: [],
},
},
} as unknown as IModel;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as getLocationExtentModule from "../../../src/core/schemas/internal/get
import * as getLocationOptionsModule from "../../../src/core/schemas/internal/getLocationOptions";
import * as getTagItemsModule from "../../../src/core/schemas/internal/getTagItems";
import * as getCategoryItemsModule from "../../../src/core/schemas/internal/getCategoryItems";
import * as getFeaturedContentCatalogsModule from "../../../src/core/schemas/internal/getFeaturedContentCatalogs";

describe("buildUiSchema: initiative edit", () => {
it("returns the full initiative edit uiSchema", async () => {
Expand All @@ -19,6 +20,10 @@ describe("buildUiSchema: initiative edit", () => {
spyOn(getTagItemsModule, "getTagItems").and.returnValue(
Promise.resolve([])
);
spyOn(
getFeaturedContentCatalogsModule,
"getFeaturedContentCatalogs"
).and.returnValue({});

const uiSchema = await buildUiSchema(
"some.scope",
Expand Down Expand Up @@ -136,6 +141,47 @@ describe("buildUiSchema: initiative edit", () => {
},
],
},
{
type: "Section",
labelKey: "some.scope.sections.featuredContent.label",
options: {
helperText: {
labelKey: "some.scope.sections.featuredContent.helperText",
},
},
elements: [
{
scope: "/properties/view/properties/featuredContentIds",
type: "Control",
options: {
control: "hub-field-input-gallery-picker",
targetEntity: "item",
catalogs: {},
facets: [
{
label:
"{{some.scope.fields.featuredContent.facets.type:translate}",
key: "type",
display: "multi-select",
field: "type",
options: [],
operation: "OR",
aggLimit: 100,
},
{
label:
"{{some.scope.fields.featuredContent.facets.sharing:translate}",
key: "access",
display: "multi-select",
field: "access",
options: [],
operation: "OR",
},
],
},
},
],
},
],
});
});
Expand Down

0 comments on commit a3f0361

Please sign in to comment.