Skip to content

Commit

Permalink
Merge pull request #3443 from mirumee/use-autocomplete-country
Browse files Browse the repository at this point in the history
Use autocomplete fields in country choice
  • Loading branch information
maarcingebala committed Dec 17, 2018
2 parents 7b87a29 + f607cfa commit 82f9257
Show file tree
Hide file tree
Showing 25 changed files with 398 additions and 325 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ All notable, unreleased changes to this project will be documented in this file.
- Add alt text to `Product` `thumbnail` and `background_image` of `Collection` and `Category` - #3429 by @fowczarek
- Improve several payment validations - #3418 by @jxltom
- Fix decimal value argument in GraphQL = #3457 by @fowczarek
- Add query batching - #3443 by @dominik-zeglen
- Use autocomplete fields in country selection - #3443 by @dominik-zeglen
- Add alt text to categories and collections - #3461 by @dominik-zeglen
- Use first and last name of a customer or staff member in UI - #3247 by @Bonifacy1, @dominik-zeglen
- Bump `urllib3` and `elasticsearch` to latest versions - #3460 by @maarcingebala
Expand Down
138 changes: 96 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
"apollo-cache-inmemory": "^1.3.11",
"apollo-client": "^2.4.7",
"apollo-client-preset": "^1.0.6",
"apollo-link": "^1.2.5",
"apollo-link-batch-http": "^1.2.5",
"apollo-link-context": "^1.0.10",
"apollo-link-error": "^1.1.2",
"apollo-link-http": "^1.5.7",
"apollo-upload-client": "^9.1.0",
"bootstrap": "4.1.2",
"classnames": "^2.2.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ export class SearchProductsProvider extends React.Component<
render() {
const { children } = this.props;
return (
<TypedSearchProductsQuery
variables={{ query: this.state.query }}
skip={!this.state.query}
>
<TypedSearchProductsQuery variables={{ query: this.state.query }}>
{searchOpts => children(this.search, searchOpts)}
</TypedSearchProductsQuery>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { AddressTypeInput } from "../../customers/types";
import i18n from "../../i18n";
import { maybe } from "../../misc";
import FormSpacer from "../FormSpacer";
import SingleSelectField from "../SingleSelectField";
import SingleAutocompleteSelectField from "../SingleAutocompleteSelectField";

const styles = (theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -149,10 +149,10 @@ const AddressEdit = withStyles(styles, { name: "AddressEdit" })(
<FormSpacer />
<div className={classes.root}>
<div>
<SingleSelectField
<SingleAutocompleteSelectField
disabled={disabled}
error={!!errors.country}
hint={errors.country}
helperText={errors.country}
label={i18n.t("Country")}
name="country"
onChange={onChange}
Expand Down
4 changes: 4 additions & 0 deletions saleor/static/dashboard-next/components/Debounce.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export class Debounce<T> extends React.Component<DebounceProps<T>> {
this.timer = setTimeout(() => debounceFn(...args), time || 200);
};

componentWillUnmount() {
clearTimeout(this.timer);
}

render() {
return this.props.children(this.handleDebounce);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export const MultiAutocompleteSelectField = withStyles(styles, {
inputValue,
selectedItem,
toggleMenu,
closeMenu,
openMenu,
highlightedIndex
}) => {
return (
Expand All @@ -133,6 +135,9 @@ export const MultiAutocompleteSelectField = withStyles(styles, {
placeholder
}),
endAdornment: <ArrowDropdownIcon onClick={toggleMenu} />,
id: undefined,
onBlur: closeMenu,
onFocus: openMenu,
startAdornment: selectedItem.map(item => (
<Chip
key={item.value}
Expand Down
14 changes: 5 additions & 9 deletions saleor/static/dashboard-next/components/Shop/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ export const shopContext = React.createContext<ShopContext>(undefined);

export const ShopProvider: React.StatelessComponent<{}> = ({ children }) => (
<TypedShopInfoQuery>
{({ data }) =>
data && data.shop !== undefined ? (
<shopContext.Provider value={data.shop}>
{children}
</shopContext.Provider>
) : (
children
)
}
{({ data }) => (
<shopContext.Provider value={data ? data.shop : undefined}>
{children}
</shopContext.Provider>
)}
</TypedShopInfoQuery>
);
export const Shop = shopContext.Consumer;
Expand Down

0 comments on commit 82f9257

Please sign in to comment.