Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Make small Createable/Multiselect UI refactor #684

Merged
merged 1 commit into from Jul 17, 2019

Conversation

kellyi
Copy link
Contributor

@kellyi kellyi commented Jul 17, 2019

Overview

I had some very tiny epiphanies about simpler ways to do the multiselect/creatable dropdowns for product types & production types, so I'm making this PR to update the code before we forget about it.

  • drop partition/concat/map code to set up selected creatable
    multiselect options: it's effectively useless because the createables
    don't care whether the selected values are within the list of choices
    sent from the API
  • adjust conditional setup for Creatable/Select components
  • update product_types and production_types propTypes

Connects #652

Testing Instructions

  • serve this branch and verify that the claimed details form works the same as it does on develop

Checklist

  • fixup! commits have been squashed
  • CI passes after rebase
  • CHANGELOG.md updated with summary of features or fixes, following Keep a Changelog guidelines

- drop partition/concat/map code to set up selected creatable
multiselect options: it's effectively useless because the createables
don't care whether the selected values are within the list of choices
sent from the API
- adjust conditional setup for Creatable/Select components
- update product_types and production_types propTypes
@kellyi kellyi force-pushed the ki/small-product-types-refactor branch from 439e70e to 4a56cdb Compare July 17, 2019 02:35
map(optionsInExistingSet, mapStringToOption),
map(newlyCreatedOptionsPrime, mapStringToOption),
);
return map(value, s => ({ value: s, label: s }));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deleted bit was code I wrote that in retrospect was basically useless: the point of the Createable is that any option is valid, so there's no need to intersect with the existing choices. Since we know the structure of the choices, we can just map all the values to be that.

})();

const SelectComponent = isCreatable ? Creatable : Select;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these two components get an identical set of props, we can cut some lines below by conditionally choosing the component here.

Copy link
Contributor

@jwalgran jwalgran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup. Works as before. Thanks.

@jwalgran jwalgran assigned kellyi and unassigned jwalgran Jul 17, 2019
@kellyi kellyi merged commit 0eaca70 into develop Jul 17, 2019
@kellyi kellyi deleted the ki/small-product-types-refactor branch July 17, 2019 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants