Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development'
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaPolit committed May 16, 2017
2 parents 57bbe03 + 5e38436 commit abb3dcc
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 68 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ PR check list:
- [ ] Server test
- [ ] End-to-end test
- [ ] Pass code linter to client and server
- [ ] Database views added ?
- [ ] Update READ.me ?

QA check list:
Expand Down
7 changes: 7 additions & 0 deletions app/react/App/scss/modules/_entity.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@
text-overflow: ellipsis;
}
}

.create-reference {
z-index: 6;
@media(max-width: 1023px) {
top: 0;
}
}
5 changes: 1 addition & 4 deletions app/react/App/scss/modules/_search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
z-index: 6;
top: 0;
@media(min-width: 1024px) {
z-index: 4;
top: $header-height;
&.is-hidden {
right: 0;
}
}
}

.metadata-sidepanel {
z-index: 6;
}

.search-box {
position: relative;
display: block;
Expand Down
7 changes: 1 addition & 6 deletions app/react/Entities/containers/EntityForm.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {filterBaseProperties} from 'app/Entities/utils/filterBaseProperties';
import {saveEntity} from 'app/Entities/actions/actions';
import {actions, MetadataForm} from 'app/Metadata';

function onSubmit(data) {
return saveEntity(filterBaseProperties(data));
}

function mapStateToProps(state) {
return {
model: 'entityView.entityForm',
Expand All @@ -20,7 +15,7 @@ function mapStateToProps(state) {
}

export function mapDispatchToProps(dispatch) {
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit}, dispatch);
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit: saveEntity}, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(MetadataForm);
17 changes: 0 additions & 17 deletions app/react/Entities/containers/specs/EntityForm.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
import * as entityActions from '../../actions/actions';
import entitiesUtils from '../../utils/filterBaseProperties';

import {mapDispatchToProps} from '../EntityForm';

describe('Viewer EntityForm', () => {
describe('mapDispatchToProps', () => {
beforeEach(() => {
spyOn(entityActions, 'saveEntity');
spyOn(entitiesUtils, 'filterBaseProperties').and.callFake(data => 'filtered ' + data);
});

it('should only send document base data on submit', () => {
expect(entityActions.saveEntity).not.toHaveBeenCalled();
mapDispatchToProps(() => {}).onSubmit('data');
expect(entityActions.saveEntity).toHaveBeenCalledWith('filtered data');
});
});
});
7 changes: 1 addition & 6 deletions app/react/Library/containers/DocumentForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {wrapDispatch} from 'app/Multireducer';

import {filterBaseProperties} from 'app/Entities/utils/filterBaseProperties';
import {saveDocument} from 'app/Library/actions/libraryActions';
import {actions, MetadataForm} from 'app/Metadata';

function onSubmit(data) {
return saveDocument(filterBaseProperties(data));
}

function mapStateToProps(state, props) {
const templates = state.templates;
const thesauris = state.thesauris;
Expand All @@ -23,7 +18,7 @@ function mapStateToProps(state, props) {
}

function mapDispatchToProps(dispatch, props) {
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit}, wrapDispatch(dispatch, props.storeKey));
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit: saveDocument}, wrapDispatch(dispatch, props.storeKey));
}

export default connect(mapStateToProps, mapDispatchToProps)(MetadataForm);
7 changes: 1 addition & 6 deletions app/react/Library/containers/EntityForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {wrapDispatch} from 'app/Multireducer';

import {filterBaseProperties} from 'app/Entities/utils/filterBaseProperties';
import {saveEntity} from 'app/Library/actions/libraryActions';
import {actions, MetadataForm} from 'app/Metadata';

function onSubmit(data) {
return saveEntity(filterBaseProperties(data));
}

function mapStateToProps(state, props) {
const templates = state.templates;
const thesauris = state.thesauris;
Expand All @@ -23,7 +18,7 @@ function mapStateToProps(state, props) {
}

function mapDispatchToProps(dispatch, props) {
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit}, wrapDispatch(dispatch, props.storeKey));
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit: saveEntity}, wrapDispatch(dispatch, props.storeKey));
}

export default connect(mapStateToProps, mapDispatchToProps)(MetadataForm);
3 changes: 2 additions & 1 deletion app/react/Metadata/components/MetadataForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Select as SimpleSelect} from 'app/Forms';
import MetadataFormFields from './MetadataFormFields';
import {FormGroup, IconSelector} from 'app/ReactReduxForms';
import {createSelector} from 'reselect';
import {filterBaseProperties} from 'app/Entities/utils/filterBaseProperties';
import t from 'app/I18N/t';

const selectTemplateOptions = createSelector(
Expand All @@ -28,7 +29,7 @@ const selectTemplateOptions = createSelector(
export class MetadataForm extends Component {

onSubmit(metadata) {
this.props.onSubmit(metadata, this.props.model);
this.props.onSubmit(filterBaseProperties(metadata), this.props.model);
}

render() {
Expand Down
5 changes: 4 additions & 1 deletion app/react/Metadata/components/specs/MetadataForm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import MetadataFormFields from '../MetadataFormFields';
import {Form, Field} from 'react-redux-form';
import {FormGroup, Select as SimpleSelect} from 'app/Forms';
import {IconSelector} from 'app/ReactReduxForms';
import entitiesUtils from 'app/Entities/utils/filterBaseProperties';


describe('MetadataForm', () => {
Expand Down Expand Up @@ -94,9 +95,11 @@ describe('MetadataForm', () => {

describe('submit', () => {
it('should call onSubmit with the values', () => {
spyOn(entitiesUtils, 'filterBaseProperties').and.returnValue('filteredProperties');
render();
component.find(Form).simulate('submit', 'values');
expect(props.onSubmit).toHaveBeenCalledWith('values', 'metadata');
expect(entitiesUtils.filterBaseProperties).toHaveBeenCalledWith('values');
expect(props.onSubmit).toHaveBeenCalledWith('filteredProperties', 'metadata');
});
});

Expand Down
6 changes: 4 additions & 2 deletions app/react/Templates/components/FilterSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ export class FilterSuggestions extends Component {
}

getThesauriName(thesauriId) {
return this.props.thesauris.toJS().find((thesauri) => {
let _thesauri = this.props.thesauris.toJS().find((thesauri) => {
return thesauri._id === thesauriId;
}).name;
}) || {};

return _thesauri.name;
}

filterSuggestions(label, type, content, hasThesauri) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,13 @@ describe('FilterSuggestions', () => {
.toBe('Best SCI FI Authors');
});
});

describe('when content does not match with a thesauri (happening when opening property and the dictionary has been deleted)', () => {
it('should not show anything', () => {
renderComponent('authors', 'select', 'non existent thesauri');
let suggestion = component.find('tbody > tr').at(1);
expect(suggestion.text().trim())
.toBe('Template 2 Select Best SCI FI Authors');
});
});
});
7 changes: 1 addition & 6 deletions app/react/Viewer/containers/DocumentForm.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {actions, MetadataForm} from 'app/Metadata';
import {filterBaseProperties} from 'app/Entities/utils/filterBaseProperties';
import {saveDocument} from '../actions/documentActions';

function onSubmit(data) {
return saveDocument(filterBaseProperties(data));
}

function mapStateToProps({documentViewer, templates, thesauris}) {
return {
model: 'documentViewer.sidepanel.metadata',
Expand All @@ -19,7 +14,7 @@ function mapStateToProps({documentViewer, templates, thesauris}) {
}

export function mapDispatchToProps(dispatch) {
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit}, dispatch);
return bindActionCreators({changeTemplate: actions.changeTemplate, onSubmit: saveDocument}, dispatch);
}

export default connect(mapStateToProps, mapDispatchToProps)(MetadataForm);
17 changes: 0 additions & 17 deletions app/react/Viewer/containers/specs/DocumentForm.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
import * as documentActions from '../../actions/documentActions';
import entitiesUtils from 'app/Entities/utils/filterBaseProperties';

import {mapDispatchToProps} from '../DocumentForm';

describe('Viewer DocumentForm', () => {
describe('mapDispatchToProps', () => {
beforeEach(() => {
spyOn(documentActions, 'saveDocument');
spyOn(entitiesUtils, 'filterBaseProperties').and.callFake(data => 'filtered ' + data);
});

it('should only send document base data on submit', () => {
expect(documentActions.saveDocument).not.toHaveBeenCalled();
mapDispatchToProps(() => {}).onSubmit('data');
expect(documentActions.saveDocument).toHaveBeenCalledWith('filtered data');
});
});
});
3 changes: 2 additions & 1 deletion nightmare/paths/multiEdit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ describe('multi edit path', () => {

describe('editing different types', () => {
it('should render a form with comon properties', (done) => {
nightmare.click(selectors.libraryView.libraryFirstDocument)
nightmare
.click(selectors.libraryView.libraryFirstDocument)
.shiftClick(selectors.libraryView.libraryThirdDocument)
.click(selectors.libraryView.libraryMultiEditEditButton)
.wait(selectors.libraryView.libraryMultiEditFormOption)
Expand Down

0 comments on commit abb3dcc

Please sign in to comment.