mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-05-10 07:14:37 +02:00
#261 - Update tags and categories
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user