Skip to content

Commit

Permalink
Merge pull request #52 from EmmanuelDemey/master
Browse files Browse the repository at this point in the history
zenika
  • Loading branch information
Evargalo authored Jul 4, 2019
2 parents 14226e9 + 4ca1c8e commit a0a7188
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 134 deletions.
9 changes: 9 additions & 0 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,12 @@ footer {
outline: none;
transition: border 0.24s ease-in-out;
}

.action-toolbar {
display: flex;
flex-direction: row;

.empty-center {
flex-grow: 1;
}
}
5 changes: 4 additions & 1 deletion src/js/components/auth/no-auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ const mapDispatchToProps = {
checkAuth,
};

export default connect(null, mapDispatchToProps)(LoginNoAuth);
export default connect(
null,
mapDispatchToProps
)(LoginNoAuth);
36 changes: 33 additions & 3 deletions src/js/components/operations/document/edition/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { validate } from 'js/components/operations/document/edition/validation';
import { LINK, DOCUMENT } from '../utils';
import Dropzone from 'react-dropzone';
import Loading from 'js/components/shared/loading';
import DatePickerRmes from 'js/components/shared/date-picker-rmes';

const defaultDocument = {
labelLg1: '',
Expand All @@ -26,15 +27,17 @@ class OperationsDocumentationEdition extends Component {
langs: PropTypes.object.isRequired,
saveDocument: PropTypes.func.isRequired,
type: PropTypes.oneOf([LINK, DOCUMENT]),
operationsAsyncTask: PropTypes.bool,
};

constructor(props) {
super(props);
this.state = this.setInitialState(props);
}

componentWillReceiveProps(nextProps) {
this.setState(this.setInitialState(nextProps));
componentWillReceiveProps(ownProps) {
if (this.props.document.url !== ownProps.document.url)
this.setState(this.setInitialState(ownProps));
}

setInitialState = props => {
Expand All @@ -54,6 +57,7 @@ class OperationsDocumentationEdition extends Component {
files,
});
};

removeFile = () => {
this.setState({
serverSideError: '',
Expand Down Expand Up @@ -94,11 +98,20 @@ class OperationsDocumentationEdition extends Component {
type,
} = this.props;

if (this.props.operationsAsyncTask)
return <Loading textType="saving" context="operations" />;

const { document, files, serverSideError } = this.state;
const isEditing = !!document.id;

const errors = validate(document, type, files);
const globalError = errors.errorMessage || serverSideError;

let updatedDate;
if (document.updatedDate) {
const [year, month, day] = document.updatedDate.split('-');
updatedDate = `${year}-${month}-${day}T23:00:00.000Z`;
}
return (
<div className="container editor-container">
{isEditing && (
Expand Down Expand Up @@ -228,7 +241,24 @@ class OperationsDocumentationEdition extends Component {
</div>
</div>
)}

{type === DOCUMENT && (
<div className="row">
<div className="col-md-12 form-group">
<label>
<NoteFlag text={D.titleUpdatedDate} lang={lg1} />
<span className="boldRed">*</span>
</label>
<DatePickerRmes
value={updatedDate}
onChange={date => {
const value = date.split('T')[0];
this.onChange({ target: { value, id: 'updatedDate' } });
}}
placement="top"
/>
</div>
</div>
)}
{type === DOCUMENT && files.length === 0 && (
<div className="row">
<div className="col-md-12 form-group">
Expand Down
2 changes: 0 additions & 2 deletions src/js/components/operations/document/edition/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class OperationsDocumentationEditionContainer extends Component {
render() {
if (!this.props.document)
return <Loading textType="loading" context="operations" />;
if (this.props.operationsAsyncTask)
return <Loading textType="saving" context="operations" />;
return <DocumentationEdition {...this.props} />;
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/js/components/operations/document/visualization/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Note } from 'js/components/shared/note/note';
import D from 'js/i18n';
import PropTypes from 'prop-types';
import React from 'react';
import { isDocument } from '../utils';

/**
* @typedef OperationsDocumentationVisualizationProps
Expand Down Expand Up @@ -38,6 +39,18 @@ function OperationsDocumentationVisualization({
/>
)}
</div>
{isDocument(attr) && (
<div className="row">
<Note
text={new Date(attr.updatedDate).toLocaleDateString()}
title={D.titleUpdatedDate}
lang={lg1}
alone={true}
allowEmpty={true}
context="operations"
/>
</div>
)}
<div className="row">
<Note
text={
Expand Down
36 changes: 20 additions & 16 deletions src/js/components/operations/families/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,34 @@ import PageTitle from 'js/components/shared/page-title';
import SearchRmes from 'js/components/shared/search-rmes/search-rmes';
import D from 'js/i18n';
import { Link } from 'react-router-dom';
import { ADMIN } from 'js/utils/auth/roles';
import Auth from 'js/utils/auth/components/auth';

function FamiliesHome({ families }) {
return (
<React.Fragment>
<div className="container">
<div className="row">
<div className="col-md-3 operations-btn-group-vertical">
<div className="row">
<div className="col-md-8 col-md-offset-2">
<Link
to="/operations/family/create"
col={8}
offset={2}
className="btn btn-operations btn-lg col-md-12"
>
<span
className="glyphicon glyphicon-plus"
aria-hidden="true"
/>
<span> {D.btnNewMale}</span>
</Link>
<Auth roles={[ADMIN]}>
<div className="col-md-3 operations-btn-group-vertical">
<div className="row">
<div className="col-md-8 col-md-offset-2">
<Link
to="/operations/family/create"
col={8}
offset={2}
className="btn btn-operations btn-lg col-md-12"
>
<span
className="glyphicon glyphicon-plus"
aria-hidden="true"
/>
<span> {D.btnNewMale}</span>
</Link>
</div>
</div>
</div>
</div>
</Auth>
<div className="col-md-8 centered pull-right">
<PageTitle
title={D.familiesSearchTitle}
Expand Down
18 changes: 11 additions & 7 deletions src/js/components/operations/families/visualization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import Loading from 'js/components/shared/loading';
import loadFamily from 'js/actions/operations/families/item';
import Button from 'js/components/shared/button';
import { getSecondLang } from 'js/reducers/app';
import { ADMIN, CNIS } from 'js/utils/auth/roles';
import Auth from 'js/utils/auth/components/auth';

const extractId = buildExtract('id');
class FamilyVisualizationContainer extends PureComponent {
Expand Down Expand Up @@ -48,19 +50,21 @@ class FamilyVisualizationContainer extends PureComponent {
<PageSubtitle subTitle={attr.prefLabelLg2} context="operations" />
)}

<div className="row btn-line">
<div className="row btn-line action-toolbar">
<Button
action={goBack(this.props, '/operations/families')}
label={D.btnReturn}
context="operations"
/>

<div className="col-md-8 centered" />
<Button
action={`/operations/family/${attr.id}/modify`}
label={D.btnUpdate}
context="operations"
/>
<div className="empty-center" />
<Auth roles={[ADMIN, CNIS]}>
<Button
action={`/operations/family/${attr.id}/modify`}
label={D.btnUpdate}
context="operations"
/>
</Auth>
</div>
<OperationsFamilyVisualization
secondLang={secondLang}
Expand Down
42 changes: 23 additions & 19 deletions src/js/components/operations/indicators/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import SearchRmes from 'js/components/shared/search-rmes/search-rmes';
import D from 'js/i18n';
import check from 'js/utils/auth';
import { Link } from 'react-router-dom';
import Auth from 'js/utils/auth/components/auth';
import { INDICATOR_CREATOR, ADMIN } from 'js/utils/auth/roles';

function IndicatorsHome({ indicators, permission: { authType, roles } }) {
const authImpl = check(authType);
Expand All @@ -13,26 +15,28 @@ function IndicatorsHome({ indicators, permission: { authType, roles } }) {
<React.Fragment>
<div className="container">
<div className="row">
<div className="col-md-3 operations-btn-group-vertical">
{adminOrContributor && (
<div className="row">
<div className="col-md-8 col-md-offset-2">
<Link
to="/operations/indicator/create"
col={8}
offset={2}
className="btn btn-operations btn-lg col-md-12"
>
<span
className="glyphicon glyphicon-plus"
aria-hidden="true"
/>
<span> {D.btnNewMale}</span>
</Link>
<Auth roles={[ADMIN, INDICATOR_CREATOR]}>
<div className="col-md-3 operations-btn-group-vertical">
{adminOrContributor && (
<div className="row">
<div className="col-md-8 col-md-offset-2">
<Link
to="/operations/indicator/create"
col={8}
offset={2}
className="btn btn-operations btn-lg col-md-12"
>
<span
className="glyphicon glyphicon-plus"
aria-hidden="true"
/>
<span> {D.btnNewMale}</span>
</Link>
</div>
</div>
</div>
)}
</div>
)}
</div>
</Auth>
<div className="col-md-8 centered pull-right">
<PageTitle
title={D.indicatorsSearchTitle}
Expand Down
40 changes: 24 additions & 16 deletions src/js/components/operations/indicators/visualization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import loadIndicator from 'js/actions/operations/indicators/item';
import Button from 'js/components/shared/button';
import { CL_FREQ } from 'js/actions/constants/codeList';
import { getSecondLang } from 'js/reducers/app';
import Auth from 'js/utils/auth/components/auth';
import { INDICATOR_CREATOR, ADMIN, SERIES_CREATOR } from 'js/utils/auth/roles';

const extractId = buildExtract('id');
class IndicatorVisualizationContainer extends Component {
Expand All @@ -37,6 +39,7 @@ class IndicatorVisualizationContainer extends Component {
organisations,
} = this.props;
if (!attr.id) return <Loading textType="loading" context="operations" />;

return (
<div className="container">
<CheckSecondLang
Expand All @@ -49,33 +52,38 @@ class IndicatorVisualizationContainer extends Component {
<PageSubtitle subTitle={attr.prefLabelLg2} context="operations" />
)}

<div className="row btn-line">
<div className="row btn-line action-toolbar">
<Button
action={goBack(this.props, '/operations/indicators')}
label={D.btnReturn}
context="operations"
/>

<div className="col-md-6 centered" />
<div className="empty-center" />
{attr.idSims && (
<Button
action={`/operations/sims/${attr.idSims}`}
label={D.btnSimsVisu}
context="operations"
/>
<>
<Button
action={`/operations/sims/${attr.idSims}`}
label={D.btnSimsVisu}
context="operations"
/>
</>
)}
{!attr.idSims && (
<Auth roles={[ADMIN, SERIES_CREATOR, INDICATOR_CREATOR]}>
<Button
action={`/operations/indicator/${attr.id}/sims/create`}
label={D.btnSimsCreate}
context="operations"
/>
</Auth>
)}
<Auth roles={[ADMIN, INDICATOR_CREATOR]}>
<Button
action={`/operations/indicator/${attr.id}/sims/create`}
label={D.btnSimsCreate}
action={`/operations/indicator/${attr.id}/modify`}
label={D.btnUpdate}
context="operations"
/>
)}
<Button
action={`/operations/indicator/${attr.id}/modify`}
label={D.btnUpdate}
context="operations"
/>
</Auth>
</div>
<OperationsIndicatorVisualization
secondLang={secondLang}
Expand Down
Loading

0 comments on commit a0a7188

Please sign in to comment.