#261 - Update tags and categories

This commit is contained in:
Elio Struyf
2022-02-19 17:32:32 +01:00
parent eabdf00d3d
commit 65f77baf2b
7 changed files with 78 additions and 8 deletions
@@ -72,7 +72,7 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
let value: any = parent[field.name];
if (field.type === "tags" || field.type === "categories" || field.type === "taxonomy") {
setFieldValue(value);
setFieldValue(value || []);
return;
};
@@ -202,6 +202,7 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
<TagPicker
type={TagType.tags}
label={field.title || field.name}
fieldName={field.name}
icon={<TagIcon />}
crntSelected={fieldValue as string[] || []}
options={settings?.tags || []}
@@ -240,6 +241,7 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
<TagPicker
type={TagType.categories}
label={field.title || field.name}
fieldName={field.name}
icon={<ListUnorderedIcon />}
crntSelected={fieldValue as string[] || []}
options={settings.categories}
@@ -71,12 +71,14 @@ const TagPicker: React.FunctionComponent<ITagPickerProps> = (props: React.PropsW
const sendUpdate = (values: string[]) => {
if (type === TagType.tags) {
MessageHelper.sendMessage(CommandToCode.updateTags, {
fieldName,
values,
parents,
blockData
});
} else if (type === TagType.categories) {
MessageHelper.sendMessage(CommandToCode.updateCategories, {
fieldName,
values,
parents,
blockData