Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to add an option to a metadata template multi select field #230

Merged
merged 2 commits into from
Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Next Release

**New Features and Enhancements**

- Add ability to add an option to a metadata template multi select field ([#230](https://github.com/box/boxcli/pull/230))

## 2.8.0 (2020-12-03)

**Warning:**
Expand Down
14 changes: 14 additions & 0 deletions src/commands/metadata-templates/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const FLAG_HANDLERS = Object.freeze({
switch (currentOp.op) {
case 'addEnumOption':
case 'editEnumOption':
case 'addMultiSelectOption':
currentOp.data.key = value.input;
break;
case 'reorderEnumOptions':
Expand Down Expand Up @@ -228,6 +229,15 @@ const FLAG_HANDLERS = Object.freeze({
},
};
},
'add-multi-select-option': (value, currentOp, ops) => {
ops.push(currentOp);

return {
op: 'addMultiSelectOption',
fieldKey: value.input,
data: {},
};
},
});

/**
Expand Down Expand Up @@ -301,6 +311,10 @@ MetadataTemplatesUpdateCommand.flags = {
description: 'Add a multi-select field with the provided display name',
multiple: true,
}),
'add-multi-select-option': flags.string({
description: 'Add an option to a specified multiselect field; must be followed by one or more --option flags',
PJSimon marked this conversation as resolved.
Show resolved Hide resolved
multiple: true,
}),
'field-key': flags.string({
description: 'Set the key of a field',
multiple: true,
Expand Down
9 changes: 9 additions & 0 deletions test/commands/metadata-templates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,13 @@ describe('Metadata Templates', () => {
]
}
},
{
op: 'addMultiSelectOption',
fieldKey: 'foo',
data: {
key: 'bas',
},
},
{
op: 'addField',
data: {
Expand Down Expand Up @@ -488,6 +495,8 @@ describe('Metadata Templates', () => {
'--option=bar',
'--option=baz',
'--no-hidden',
'--add-multi-select-option=foo',
'--option=bas',
PJSimon marked this conversation as resolved.
Show resolved Hide resolved
'--number=Count',
'--date=Date',
'--json',
Expand Down