Merge branch 'develop' into dist/ubuntu/bionic/develop
This commit is contained in:
commit
42f7ba3473
|
@ -45,7 +45,7 @@ export const App: FunctionComponent<AppProps> = () => {
|
|||
<Route path="/unauthorized" exact component={UnauthorizedPage} />
|
||||
<PrivateRoute path="/profile" exact component={ProfilePage} />
|
||||
<PrivateRoute path="/workgroups/:id" exact component={WorkgroupPage} />
|
||||
<PrivateRoute path="/decisions/:id" exact component={DecisionSupportFilePage} />
|
||||
<PrivateRoute path="/decisions/:id" component={DecisionSupportFilePage} />
|
||||
<PrivateRoute path="/dashboard" exact component={DashboardPage} />
|
||||
<PrivateRoute path="/logout" exact component={LogoutPage} />
|
||||
<Route component={() => <Redirect to="/" />} />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import { DecisionSupportFile, DecisionSupportFileStatus } from '../../types/decision';
|
||||
import { ItemPanel, TabDefinition, Item } from './ItemPanel';
|
||||
import { ItemPanel, TabDefinition, Item } from '../ItemPanel';
|
||||
import { useUserProfile } from '../../gql/queries/profile';
|
||||
import { inWorkgroup } from '../../types/workgroup';
|
||||
import { useDecisionSupportFiles } from '../../gql/queries/dsf';
|
||||
|
|
|
@ -2,7 +2,7 @@ import React, { } from 'react';
|
|||
import { Workgroup, inWorkgroup } from '../../types/workgroup';
|
||||
import { useWorkgroups } from '../../gql/queries/workgroups';
|
||||
import { useUserProfile } from '../../gql/queries/profile';
|
||||
import { ItemPanel, Item } from './ItemPanel';
|
||||
import { ItemPanel, Item } from '../ItemPanel';
|
||||
|
||||
export function WorkgroupsPanel() {
|
||||
const { workgroups } = useWorkgroups();
|
||||
|
|
|
@ -4,7 +4,7 @@ import { useWorkgroups } from "../gql/queries/workgroups";
|
|||
import { useDecisionSupportFiles } from "../gql/queries/dsf";
|
||||
|
||||
export interface DecisioSupportFileLinkProps {
|
||||
decisionSupportFileId: number
|
||||
decisionSupportFileId: number|string
|
||||
}
|
||||
|
||||
export const DecisionSupportFileLink: FunctionComponent<DecisioSupportFileLinkProps> = ({ decisionSupportFileId }) => {
|
||||
|
|
|
@ -49,7 +49,6 @@ export const ClarificationSection: FunctionComponent<ClarificationSectionProps>
|
|||
|
||||
return (
|
||||
<section>
|
||||
<div className="box">
|
||||
<div className="field">
|
||||
<label className="label is-medium">Intitulé du dossier</label>
|
||||
<div className="control">
|
||||
|
@ -136,7 +135,6 @@ export const ClarificationSection: FunctionComponent<ClarificationSectionProps>
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
|
@ -32,7 +32,6 @@ export const DecisionReportSection: FunctionComponent<DecisionReportSectionProps
|
|||
|
||||
return (
|
||||
<section>
|
||||
<div className="box">
|
||||
<div className="field">
|
||||
<label className="label is-medium">Compte rendu du vote</label>
|
||||
<div className="control">
|
||||
|
@ -45,7 +44,6 @@ export const DecisionReportSection: FunctionComponent<DecisionReportSectionProps
|
|||
</div>
|
||||
<p className="help is-info"><i className="fa fa-info-circle"></i> Penser à indiquer le résultat du vote et les éléments de contexte liés à la prise de décision.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
|
@ -11,6 +11,7 @@ import { OptionsSection } from './OptionsSection';
|
|||
import { useIsAuthorized } from '../../gql/queries/authorization';
|
||||
import { TimelinePanel } from './TimelinePanel';
|
||||
import { DecisionReportSection } from './DecisionReportSection';
|
||||
import { RoutedTabs } from '../RoutedTabs';
|
||||
|
||||
export interface DecisionSupportFilePageProps {
|
||||
|
||||
|
@ -30,10 +31,8 @@ export const DecisionSupportFilePage: FunctionComponent<DecisionSupportFilePageP
|
|||
const [ state, setState ] = useState({
|
||||
dsf: newDecisionSupportFile(),
|
||||
saved: true,
|
||||
selectedTabIndex: 0,
|
||||
});
|
||||
|
||||
|
||||
const { isAuthorized } = useIsAuthorized({
|
||||
variables: {
|
||||
action: 'update',
|
||||
|
@ -48,9 +47,26 @@ export const DecisionSupportFilePage: FunctionComponent<DecisionSupportFilePageP
|
|||
setState(state => ({ ...state, dsf: { ...state.dsf, ...dsf }}))
|
||||
}, [ decisionSupportFiles ]);
|
||||
|
||||
const selectTab = (tabIndex: number) => {
|
||||
setState(state => ({ ...state, selectedTabIndex: tabIndex }));
|
||||
};
|
||||
const tabs = [
|
||||
{
|
||||
name: "Clarifier la proposition",
|
||||
icon: "fas fa-pen",
|
||||
route: '/info',
|
||||
render: () => (<ClarificationSection readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} />)
|
||||
},
|
||||
{
|
||||
name: "Explorer les options",
|
||||
icon: "fas fa-search",
|
||||
route: '/options',
|
||||
render: () => (<OptionsSection readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} />)
|
||||
},
|
||||
{
|
||||
name: "Prendre la décision",
|
||||
icon: "fas fa-person-booth",
|
||||
route: '/vote',
|
||||
render: () => (<DecisionReportSection readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} />)
|
||||
}
|
||||
];
|
||||
|
||||
const updateDSF = (dsf: DecisionSupportFile) => {
|
||||
setState(state => {
|
||||
|
@ -130,46 +146,9 @@ export const DecisionSupportFilePage: FunctionComponent<DecisionSupportFilePageP
|
|||
</section>
|
||||
<div className="columns mt-3">
|
||||
<div className="column is-8">
|
||||
<div className="tabs is-medium is-toggle">
|
||||
<ul>
|
||||
<li className={`has-background-white ${state.selectedTabIndex === 0 ? 'is-active': ''}`}
|
||||
onClick={selectTab.bind(null, 0)}>
|
||||
<a>
|
||||
<span className="icon is-small"><i className="fas fa-pen" aria-hidden="true"></i></span>
|
||||
<span>Clarifier la proposition</span>
|
||||
</a>
|
||||
</li>
|
||||
<li className={`has-background-white ${state.selectedTabIndex === 1 ? 'is-active': ''}`}
|
||||
onClick={selectTab.bind(null, 1)}>
|
||||
<a>
|
||||
<span className="icon is-small"><i className="fas fa-search" aria-hidden="true"></i></span>
|
||||
<span>Explorer les options</span>
|
||||
</a>
|
||||
</li>
|
||||
<li className={`has-background-white ${state.selectedTabIndex === 2 ? 'is-active': ''}`}
|
||||
onClick={selectTab.bind(null, 2)}>
|
||||
<a>
|
||||
<span className="icon is-small"><i className="fas fa-person-booth" aria-hidden="true"></i></span>
|
||||
<span>Prendre la décision</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div className="box">
|
||||
<RoutedTabs baseRoute={`/decisions/${id}`} tabs={tabs} />
|
||||
</div>
|
||||
{
|
||||
state.selectedTabIndex === 0 ?
|
||||
<ClarificationSection readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} /> :
|
||||
null
|
||||
}
|
||||
{
|
||||
state.selectedTabIndex === 1 ?
|
||||
<OptionsSection readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} /> :
|
||||
null
|
||||
}
|
||||
{
|
||||
state.selectedTabIndex === 2 ?
|
||||
<DecisionReportSection readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} /> :
|
||||
null
|
||||
}
|
||||
</div>
|
||||
<div className="column is-4">
|
||||
<MetadataPanel readOnly={!isAuthorized} dsf={state.dsf} updateDSF={updateDSF} />
|
||||
|
|
|
@ -75,8 +75,7 @@ export const OptionsSection: FunctionComponent<OptionsSectionProps> = ({ dsf, up
|
|||
|
||||
return (
|
||||
<section>
|
||||
<h4 id="options-section" className="is-size-4 title is-spaced"><a href="#options-section">Explorer les options</a></h4>
|
||||
<div className="box">
|
||||
<h4 id="options-section" className="is-size-4 title is-spaced">Explorer les options</h4>
|
||||
<div className="table-container">
|
||||
<table className={`table is-bordered is-striped is-hoverable is-fullwidth`}>
|
||||
<thead>
|
||||
|
@ -154,7 +153,6 @@ export const OptionsSection: FunctionComponent<OptionsSectionProps> = ({ dsf, up
|
|||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
import React, { FunctionComponent, useState, useEffect } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { WithLoader } from "../WithLoader";
|
||||
import { WithLoader } from "./WithLoader";
|
||||
|
||||
export interface Item {
|
||||
id: string
|
|
@ -0,0 +1,79 @@
|
|||
import React, { FunctionComponent, ReactNode, useEffect, useState } from 'react';
|
||||
import { useHistory, useLocation, useRouteMatch } from 'react-router';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export interface Tab {
|
||||
route: string
|
||||
name: string
|
||||
icon ?: string
|
||||
render: (tab: Tab) => ReactNode
|
||||
}
|
||||
|
||||
export interface RoutedTabsProps {
|
||||
tabs: Tab[]
|
||||
baseRoute?: string
|
||||
defaultTabIndex?: number
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const RoutedTabs: FunctionComponent<RoutedTabsProps> = ({ tabs, baseRoute, defaultTabIndex }) => {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
|
||||
const tabRoute = (route: string): string => {
|
||||
return `${baseRoute}${route}`;
|
||||
};
|
||||
|
||||
const [ selectedTabIndex, setSelectedTabIndex ] = useState(defaultTabIndex || 0);
|
||||
const expectedTab = tabs[selectedTabIndex];
|
||||
const expectedTabRoute = tabRoute(expectedTab.route);
|
||||
|
||||
let matchExpectedTabRoute = useRouteMatch(expectedTabRoute);
|
||||
|
||||
useEffect(() => {
|
||||
if (matchExpectedTabRoute) return;
|
||||
|
||||
const newTabIndex = tabs.findIndex(t => location.pathname === tabRoute(t.route));
|
||||
|
||||
if (newTabIndex !== -1) {
|
||||
selectTab(newTabIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
history.push(expectedTabRoute);
|
||||
}, [matchExpectedTabRoute]);
|
||||
|
||||
const selectTab = (tabIndex: number) => {
|
||||
setSelectedTabIndex(tabIndex);
|
||||
const newTab = tabs[tabIndex];
|
||||
history.push(tabRoute(newTab.route));
|
||||
};
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="tabs is-medium is-boxed">
|
||||
<ul>
|
||||
{
|
||||
tabs.map((t: Tab, i: number) => {
|
||||
return (
|
||||
<li key={`tab-${i}`} className={`has-background-white ${selectedTabIndex === i ? 'is-active': ''}`}
|
||||
onClick={selectTab.bind(null, i)}>
|
||||
<a>
|
||||
{
|
||||
t.icon ?
|
||||
<span className="icon is-small"><i className={t.icon} aria-hidden="true"></i></span> :
|
||||
null
|
||||
}
|
||||
<span>{t.name}</span>
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
})
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
{ expectedTab.render(expectedTab) }
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import React, { FunctionComponent } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useDecisionSupportFiles } from '../../gql/queries/dsf';
|
||||
import { DecisionSupportFile } from '../../types/decision';
|
||||
import { User } from '../../types/user';
|
||||
import { DecisionSupportFileLink } from '../DecisionSupportFileLink';
|
||||
import { WorkgroupLink } from '../WorkgroupLink';
|
||||
|
||||
export interface DecisionSupportFilePanelProps {
|
||||
workgroupId: string
|
||||
}
|
||||
|
||||
export const DecisionSupportFilePanel: FunctionComponent<DecisionSupportFilePanelProps> = ({ workgroupId }) => {
|
||||
const { decisionSupportFiles } = useDecisionSupportFiles({
|
||||
variables: {
|
||||
filter: {
|
||||
workgroups: [workgroupId],
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<nav className="panel">
|
||||
<p className="panel-heading">
|
||||
Dossiers d'aide à la décision
|
||||
</p>
|
||||
{
|
||||
decisionSupportFiles.map((dsf: DecisionSupportFile) => {
|
||||
return (
|
||||
<Link to={`/decisions/${dsf.id}`} key={`dsf-${dsf.id}`} className="panel-block">
|
||||
<span className="panel-icon">
|
||||
<i className="fas fa-file" aria-hidden="true"></i>
|
||||
</span>
|
||||
<span>{dsf.title}</span>
|
||||
</Link>
|
||||
);
|
||||
})
|
||||
}
|
||||
{
|
||||
decisionSupportFiles.length === 0 ?
|
||||
<a className="panel-block has-text-centered is-block">
|
||||
<p className="is-italic">Aucun dossier pour l'instant.</p>
|
||||
</a> :
|
||||
null
|
||||
}
|
||||
</nav>
|
||||
);
|
||||
}
|
|
@ -1,18 +1,18 @@
|
|||
import React, { useEffect, useState, Fragment } from 'react';
|
||||
import { Page } from '../Page';
|
||||
import { WithLoader } from '../WithLoader';
|
||||
import { useParams } from 'react-router';
|
||||
import { useWorkgroupsQuery, useWorkgroups } from '../../gql/queries/workgroups';
|
||||
import { useUserProfileQuery, useUserProfile } from '../../gql/queries/profile';
|
||||
import { useWorkgroups } from '../../gql/queries/workgroups';
|
||||
import { useUserProfile } from '../../gql/queries/profile';
|
||||
import { MembersPanel } from './MembersPanel';
|
||||
import { User } from '../../types/user';
|
||||
import { InfoPanel } from './InfoPanel';
|
||||
import { Workgroup } from '../../types/workgroup';
|
||||
import { useJoinWorkgroupMutation, useLeaveWorkgroupMutation, useCloseWorkgroupMutation } from '../../gql/mutations/workgroups';
|
||||
import { TimelinePanel } from './TimelinePanel';
|
||||
import { DecisionSupportFilePanel } from './DecisionSupportFilePanel';
|
||||
|
||||
export function WorkgroupPage() {
|
||||
const { id } = useParams();
|
||||
const { id } = useParams<any>();
|
||||
const { workgroups } = useWorkgroups({
|
||||
variables:{
|
||||
filter: {
|
||||
|
@ -140,6 +140,7 @@ export function WorkgroupPage() {
|
|||
</div>
|
||||
<div className="column is-4">
|
||||
<MembersPanel users={state.workgroup.members as User[]} />
|
||||
<DecisionSupportFilePanel workgroupId={state.workgroup.id} />
|
||||
</div>
|
||||
<div className="column is-4">
|
||||
<TimelinePanel workgroup={state.workgroup} />
|
||||
|
|
|
@ -46,6 +46,7 @@ type DecisionSupportFile {
|
|||
|
||||
input DecisionSupportFileFilter {
|
||||
ids: [ID]
|
||||
workgroups: [ID]
|
||||
}
|
||||
|
||||
input AuthorizationObject {
|
||||
|
|
|
@ -108,6 +108,10 @@ func (r *DSFRepository) Search(ctx context.Context, filter *DecisionSupportFileF
|
|||
if filter.Ids != nil {
|
||||
query = query.Where("id in (?)", filter.Ids)
|
||||
}
|
||||
|
||||
if filter.Workgroups != nil {
|
||||
query = query.Where("workgroup_id in (?)", filter.Workgroups)
|
||||
}
|
||||
}
|
||||
|
||||
dsfs := make([]*DecisionSupportFile, 0)
|
||||
|
|
Loading…
Reference in New Issue