Skip to content

Commit

Permalink
Merge pull request #41 from EmmanuelDemey/master
Browse files Browse the repository at this point in the history
WIP Zenika
  • Loading branch information
alicela authored May 9, 2019
2 parents fb98aa6 + 3a8274c commit f4c2f53
Show file tree
Hide file tree
Showing 35 changed files with 768 additions and 248 deletions.
6 changes: 3 additions & 3 deletions cypress/integration/operations_list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
expect(lis).to.have.length(1);
});

cy.get('h2.page-title-operations').should('be.visible');
cy.get('h1.page-title-operations').should('be.visible');
cy.get('.list-group').should('be.visible');
cy.get('.pagination').should('be.visible');

cy.get('input').type('FAKE DATA');
cy.get('h4').should(h4 => {
expect(h4.first()).to.contain('0');
cy.get('p').should(p => {
expect(p.first()).to.contain('0');
});
cy.get('.pagination li').should(lis => {
expect(lis).to.have.length(0);
Expand Down
7 changes: 5 additions & 2 deletions cypress/integration/serie.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ describe('Series page', () => {

it('Should go the Series creation page and come back', () => {
cy.server().visit(`/operations/series`);
cy.injectAxe();

cy.get(seriesPage.getNewButton()).should('be.visible');
cy.checkA11y();
cy.get(seriesPage.getNewButton()).click();
cy.url().should('match', /\/operations\/series\/create$/);
cy.get(seriesEditPage.getBackButton())
Expand Down Expand Up @@ -85,7 +88,7 @@ describe('Series page', () => {
cy.url().should('include', '/operations/series/');

cy.get('.btn-line a')
.first()
.eq(1)
.click();

cy.url().should('include', '/modify');
Expand All @@ -110,7 +113,7 @@ describe('Series page', () => {
cy.url().should('include', '/operations/series/');

cy.get('.btn-line a')
.first()
.eq(1)
.click();

cy.url().should('include', '/modify');
Expand Down
4 changes: 3 additions & 1 deletion cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'
import './commands';

// Alternatively you can use CommonJS syntax:
// require('./commands')

import 'cypress-axe';
12 changes: 12 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@
"@storybook/react": "4.1.12",
"@types/cypress": "^1.1.3",
"@types/jest": "^24.0.12",
"axe-core": "^3.2.2",
"babel-loader": "8.0.5",
"concurrently": "3.5.1",
"coveralls": "3.0.0",
"cross-env": "5.0.1",
"cypress": "3.2.0",
"cypress-axe": "^0.4.1",
"enzyme": "3.9.0",
"enzyme-adapter-react-16": "1.9.1",
"eslint-config-prettier": "4.0.0",
Expand Down
42 changes: 23 additions & 19 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap-table/4.0.5/react-bootstrap-table.min.css">


<!--
<head>
<meta charset="utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap-table/4.0.5/react-bootstrap-table.min.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />

<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -18,12 +23,12 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>%REACT_APP_NAME%</title>
</head>
<title>%REACT_APP_NAME%</title>
</head>

<body>
<div id="root"></div>
<!--
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -33,6 +38,5 @@
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>

</html>
</body>
</html>
35 changes: 28 additions & 7 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ a {
text-align: center;
}

.img {
width: 15%;
margin-left: 5%;
margin-right: 5%;
margin-top: 2%;
}

.img-flag {
height: 20px;
width: auto;
Expand All @@ -72,6 +65,28 @@ a {
margin-bottom: 15px;
}

ul.home-page-links {
display: flex;
list-style: none;
flex-direction: row;
li {
flex: 1;

h2 {
width: 90%;
margin: 10px auto 10px auto;
text-align: center;
}
img {
width: 90%;
}
}
}
@media screen and (max-width: 640px) {
ul.home-page-links {
flex-direction: column;
}
}
.page-title-link:hover {
color: $color_concepts_1;
text-decoration: none;
Expand Down Expand Up @@ -179,3 +194,9 @@ link {
display: flex;
flex-direction: column;
}

footer {
p {
font-weight: bold;
}
}
82 changes: 57 additions & 25 deletions src/js/actions/operations/sims/item.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
import api from 'js/remote-api/operations-api';
import * as A from 'js/actions/constants';
import { LOADING } from 'js/constants';
import { getLabelsFromOperation } from 'js/utils/msd';
import { getLabelsFromParent } from 'js/utils/msd';

/**
* @typedef {Object} SimsDocuments
* @property {string} uri
* @property {string} url
* @property {string=} updatedDate
* @property {string} labelLg1
* @property {string} labelLg2
* @property {string=} lang
* @property {string} descriptionLg1
* @property {string} descriptionLg2
* Method used to merge a SIMS with the label of its corresponding
* parent.
*
* @param {*} sims
* @param {*} promise
*/

export const saveSims = (sims, callback) => (dispatch, getState) => {
function getFetchLabelsPromise(sims, promise) {
function mergeLabels(parent, parentType) {
return {
...sims,
...getLabelsFromParent(parent, parentType),
};
}
if (sims.idOperation) {
return api
.getOperation(sims.idOperation)
.then(parent => mergeLabels(parent, 'operation'));
}
if (sims.idSeries) {
return api
.getSerie(sims.idSeries)
.then(parent => mergeLabels(parent, 'series'));
}
if (sims.idIndicator) {
return api
.getIndicator(sims.idIndicator)
.then(parent => mergeLabels(parent, 'indicator'));
}
return promise;
}
/**
* This method is called when we need to save a SIMS.
* If the sims passed as a parameter already have an id,
* we will send a PUR request. If this property is not
* present, a POST request will be send.
*
* @param {Sims} sims
* @param {(string) => void} callback
*/
export const saveSims = (sims, callback) => dispatch => {
let promise = Promise.resolve(sims);

if (!sims.labelLg1 && sims.idOperation) {
promise = api.getOperation(sims.idOperation).then(result => {
return {
...sims,
...getLabelsFromOperation(result),
};
});
if (!sims.labelLg1) {
promise = getFetchLabelsPromise(sims, promise);
}

const method = sims.id ? 'putSims' : 'postSims';
Expand All @@ -51,6 +74,15 @@ export const saveSims = (sims, callback) => (dispatch, getState) => {
});
};

function getParentsWithoutSims(idOperation) {
if (idOperation) {
return api
.getOperation(idOperation)
.then(operation => api.getOperationsWithoutReport(operation.series.id));
}
return Promise.resolve([]);
}

export default id => (dispatch, getState) => {
if (!id || getState().operationsSimsCurrentStatus === LOADING) {
return;
Expand All @@ -61,17 +93,16 @@ export default id => (dispatch, getState) => {
id,
},
});

return api.getSims(id).then(
results => {
api
.getOperation(results.idOperation)
.then(operation => api.getOperationsWithoutReport(operation.series.id))
.then((operationsWithoutSims = []) => {
return getParentsWithoutSims(results.idOperation).then(
(parentsWithoutSims = []) => {
dispatch({
type: A.LOAD_OPERATIONS_SIMS_SUCCESS,
payload: {
...results,
operationsWithoutSims,
parentsWithoutSims,
rubrics: results.rubrics.reduce((acc, rubric) => {
// TO BE DELETED
const documents = [
Expand Down Expand Up @@ -115,7 +146,8 @@ export default id => (dispatch, getState) => {
}, {}),
},
});
});
}
);
},

err => {
Expand Down
Loading

0 comments on commit f4c2f53

Please sign in to comment.