Skip to content

Commit

Permalink
Merge 79a2737 into c132ea7
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyDo committed Apr 25, 2019
2 parents c132ea7 + 79a2737 commit d0e1846
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/client/entity-editor/common/linked-entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import FontAwesome from 'react-fontawesome';
import PropTypes from 'prop-types';
import React from 'react';
import {kebabCase as _kebabCase} from 'lodash';
import {genEntityIconHTMLElement} from '../../helpers/entity';


Expand All @@ -46,7 +47,7 @@ class LinkedEntity extends React.Component {
if (type && id) {
url = type === 'Area' ?
`//musicbrainz.org/area/${id}` :
`/${type.toLowerCase()}/${id}`;
`/${_kebabCase(type)}/${id}`;
}
if (url) {
window.open(url, '_blank');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import ReactSelect from 'react-select';
import Relationship from './relationship';
import _ from 'lodash';


function isValidRelationship(relationship: _Relationship) {
const {relationshipType, sourceEntity, targetEntity} = relationship;

Expand Down Expand Up @@ -258,7 +257,7 @@ class RelationshipModal
label={label}
languageOptions={this.props.languageOptions}
name="entity"
type={types.map(_.toLower)}
type={types}
value={this.state.targetEntity}
onChange={this.handleEntityChange}
/>
Expand Down
14 changes: 12 additions & 2 deletions src/server/helpers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ export function autocomplete(orm, query, collection) {
};

if (collection) {
dslQuery.type = _.snakeCase(collection);
if (Array.isArray(collection)) {
dslQuery.type = collection.map(_.snakeCase);
}
else {
dslQuery.type = _.snakeCase(collection);
}
}

return _searchForEntities(orm, dslQuery);
Expand Down Expand Up @@ -410,7 +415,12 @@ export function searchByName(orm, name, collection, size, from) {
};

if (collection) {
dslQuery.type = _.snakeCase(collection);
if (Array.isArray(collection)) {
dslQuery.type = collection.map(_.snakeCase);
}
else {
dslQuery.type = _.snakeCase(collection);
}
}

return _searchForEntities(orm, dslQuery);
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ router.get('/autocomplete', (req, res) => {
const query = req.query.q;
const collection = req.query.collection || null;

const searchPromise = search.autocomplete(orm, query, _snakeCase(collection));
const searchPromise = search.autocomplete(orm, query, collection);

handler.sendPromiseResult(res, searchPromise);
});
Expand Down

0 comments on commit d0e1846

Please sign in to comment.