Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Conversation

@francoischalifour
Copy link
Contributor

Changes

  • mainAttribute has been replaced by attributesToDisplayand now accepts multiple attributes
  • Introduce new flag --attributes-to-display
  • Introduce a checkbox menu for the attributes to display
  • The Angular template is now compatible with attributesToDisplay (it was not adapting the hits template depending on mainAttribute)
  • Update all the hits template
  • Fix Android template (wrong namespace)
  • Revert c578859 which was breaking the React InstantSearch Native template

Preview

Preview

Using as an argument:

npx create-instantsearch-app my-app --attributes-to-display "name, description"

Closes #151.

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

looks good!

const attributesToDisplay = (optionsFromArguments.attributesToDisplay || '')
.split(',')
.filter(Boolean)
.map(x => x.trim());
Copy link
Contributor

Choose a reason for hiding this comment

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

technically an attribute could end/start in spaces no? Probably not a real issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's say you run the command:

npx create-instantsearch-app my-app \
  --attributes-to-display "name,description, location"

You will get the following attributes: ['name', 'description', ' location']. It will then inject this into your template:

_highlightResult. location.value // → breaks because of the space

If you trim the values, you'd get: ['name', 'description', 'location']. This is the reason why we need this check.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, knew why there could be valid padding, was just wondering if an attribute could start/end with spaces 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't see any reasons why. Do you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Now we know that we may have a bug here. Since it's rather an edge case, we can move forward.

cell.textLabel?.highlightedTextColor = .blue
cell.textLabel?.highlightedBackgroundColor = .yellow
cell.textLabel?.highlightedText = SearchResults.highlightResult(hit: hit, path: "name")?.value
cell.textLabel?.highlightedText = SearchResults.highlightResult(hit: hit, path: "{{attributesToDisplay.[0]}}")?.value
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to handle multiple attributes UI-wise in Swift.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make that an issue and ask some help from the mobile team #178

"react": "16.4.1",
"react-instantsearch-native": "{{libraryVersion}}",
"react-native": "0.56.0"
"react-native": "0.55.4"
Copy link
Contributor Author

@francoischalifour francoischalifour Jul 28, 2018

Choose a reason for hiding this comment

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

React Native 0.56.0 was not compatible with the template because of the Expo SDK v27.

@francoischalifour francoischalifour force-pushed the feat/attributes-to-display branch from e3b9322 to d0ffc8d Compare July 30, 2018 14:08
@francoischalifour francoischalifour force-pushed the feat/attributes-to-display branch from d0ffc8d to f4a1518 Compare July 30, 2018 15:00
@francoischalifour
Copy link
Contributor Author

Note

After releasing this new feature, update the new InstantSearch documentation on the Algolia website:

 npx create-instantsearch-app ais-ecommerce-demo-app \
   --template "React InstantSearch" \
   --app-id B1G2GM9NG0 \
   --api-key aadef574be1f9252bb48d4ea09b5cfe5 \
   --index-name demo_ecommerce \
-  --main-attribute name
+  --attributes-to-display name

@bobylito bobylito merged commit 0b93202 into master Aug 8, 2018
@bobylito bobylito deleted the feat/attributes-to-display branch August 8, 2018 08:35
aymeric-giraudet pushed a commit to algolia/instantsearch that referenced this pull request Dec 14, 2022
…antsearch-app#153)

* feat(cli): Accept multiple attributes to display

BREAKING CHANGE: The option `mainAttribute` has been renamed `attributesToDisplay` and now accepts multiple attributes.

Closes algolia/create-instantsearch-app#151

* docs(readme): Document `attributesToDisplay`

* test(e2e): Update tests with `attributesToDisplay`

* build(release): Update release-template script with `attributesToDisplay`

* feat(templates): Update templates with `attributesToDisplay`

* test(snapshots): Update template snapshots

* fix(template): Remove unused CSS imports
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide multiple fields for the main attribute?

4 participants