Skip to content

Commit

Permalink
Merge pull request #72 from NicoLaval/master
Browse files Browse the repository at this point in the history
Fix multiple issues
  • Loading branch information
NicoLaval authored Aug 28, 2019
2 parents 56af64b + a12001d commit adef87a
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 965 deletions.
File renamed without changes.
5 changes: 1 addition & 4 deletions app/src/js/i18n/build-dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,4 @@ export const getMessageForSecondLang = message => {

export default createDictionary(getLang());

export const bauhausLibraryDictionary = createDictionary(
getLang(),
bauhausLibrary
);
export const bauhausLibraryDictionary = createDictionary(getLang(), dictionary);
1 change: 1 addition & 0 deletions packages/bauhaus-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"useTabs": true
},
"dependencies": {
"lodash": "^4.17.15",
"react-loading": "^2.0.3",
"react-select": "^3.0.4"
}
Expand Down
25 changes: 12 additions & 13 deletions packages/bauhaus-library/src/panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import PropTypes from 'prop-types';
import Flag from '../flag';
import './panel.scss';

function Panel({ title, children, context = 'concepts', flag }) {
const flagComponent = flag ? ` ( ${<Flag flag={flag} />} )` : '';
return (
<div className={`panel panel-${context}`}>
<div className="panel-heading">
<h3 className="panel-title">
{title}
{flagComponent}
</h3>
</div>
<div className="panel-body">{children}</div>
const Panel = ({ title, children, context = 'concepts', flag }) => (
<div className={`panel panel-${context}`}>
<div className="panel-heading">
<h3 className="panel-title">
{title}
{flag && ` ( `}
{flag && <Flag flag={flag} />}
{flag && ` )`}
</h3>
</div>
);
}
<div className="panel-body">{children}</div>
</div>
);

Panel.propTypes = {
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
Expand Down
8 changes: 4 additions & 4 deletions packages/bauhaus-library/src/search-rmes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import I18NContext from '../i18n-provider';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import Pagination from '../pagination';
import { filterKeyDeburr, nbResults } from 'js/utils/array-utils';
import { filterKeyDeburr, nbResults } from '../utils/array-utils';

function SearchRmes({
items = [],
Expand All @@ -17,7 +17,7 @@ function SearchRmes({
label,
}) {
const [search, handleSearch] = useState('');
const D = useContext(I18NContext).backToTop || label;
const D = useContext(I18NContext);

const filter = filterKeyDeburr(
Object.keys(items[0] || {}).filter(k => k !== 'id')
Expand All @@ -42,7 +42,7 @@ function SearchRmes({
value={search}
onChange={e => handleSearch(e.target.value)}
type="text"
placeholder={D.searchLabelPlaceholder}
placeholder={D.searchLabelPlaceholder || placeholder}
className="form-control"
aria-label={D.search}
/>
Expand All @@ -64,7 +64,7 @@ function SearchRmes({
</div>
)}
<div className="row">
<p aria-live="assertive">{nbResults(hits)}</p>
<p aria-live="assertive">{nbResults(hits, D)}</p>
</div>
<Pagination itemEls={hitEls} itemsPerPage="10" context={context} />
</div>
Expand Down
20 changes: 20 additions & 0 deletions packages/bauhaus-library/src/utils/array-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import _ from 'lodash';

export const filterKeyDeburr = keys => rawStr => {
const str = _.deburr(rawStr).toLocaleLowerCase();
return item => {
let isIn = false;
for (var i = 0; i < keys.length; i++) {
if (_.deburr((item[keys[i]] || '').toLocaleLowerCase()).includes(str)) {
isIn = true;
break;
}
}
return isIn;
};
};

export const nbResults = (array, dictionnary) => {
const { result, results } = dictionnary;
return `${array.length} ${array.length > 1 ? results : result}`;
};
16 changes: 16 additions & 0 deletions packages/bauhaus-library/src/utils/array-utils.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as A from './array-utils';

const D = { result: 'result', results: 'results' };

describe('array utils', () => {
describe('nbResults', () => {
it('should return string ends with any letter', () => {
expect(A.nbResults([], D)).toMatch(/[A-Za-z]{1}$/);
expect(A.nbResults(['A'], D)).toMatch(/[A-Za-z]{1}$/);
});

it("should return string ends with 's'", () => {
expect(A.nbResults(['a', 'b'], D).endsWith('s')).toBeTruthy();
});
});
});
38 changes: 0 additions & 38 deletions src/js/actions/classifications/correspondences/association.spec.js

This file was deleted.

This file was deleted.

36 changes: 0 additions & 36 deletions src/js/components/operations/families/edition/validation.spec.js

This file was deleted.

56 changes: 0 additions & 56 deletions src/js/components/operations/operations/edition/validation.spec.js

This file was deleted.

56 changes: 0 additions & 56 deletions src/js/components/operations/series/edition/validation.spec.js

This file was deleted.

Loading

0 comments on commit adef87a

Please sign in to comment.