Commit 3d1b8722 authored by Pierre Marchand's avatar Pierre Marchand

[client/project] disabling unit timeline

parent 32260457
......@@ -73,7 +73,7 @@ const txClass = (
widget: UnitWidget,
) => withDisplayType('writer',
unitNameIsInCurrentTransaction(widget.name) ? 'in-transaction' : ''
).getOrElse('')
).getOrElse('');
const renderUiWidget =
(project: Project, widget: UnitWidget) => {
......
import { DIV } from 'sdi/components/elements';
import { formatDate } from 'sdi/locale';
import tr, { formatDate } from 'sdi/locale';
import { divTooltipTopRight } from 'sdi/components/tooltip';
import { } from '../../../remote/timeline';
import { getUnitHistory, getTimelineUnitDateStart, getTimelineUnitDateEnd, getCurrentTransaction } from '../../../queries/project';
import { Unit } from 'angled-core/ui';
import { getUnitHistory, getTimelineUnitDateStart, getTimelineUnitDateEnd, getCurrentTransaction, getSelectedUnit } from '../../../queries/project';
import { Unit, InformationUnitName } from 'angled-core/ui';
import { some, none } from 'fp-ts/lib/Option';
import { index } from 'fp-ts/lib/Array';
import { unitDisplayName } from 'angled-core/queries/app';
export const setHighlightTimelineItem =
(unit: Unit) =>
......@@ -60,19 +61,26 @@ const renderEventUnit =
),
);
const renderEventUnitMissing = () => [DIV({}, 'Loading Unit History')];
const renderEventUnitMissing = (
name: InformationUnitName,
) => DIV({}, `${tr.core('loadingData')}: ${unitDisplayName(name)}`);
export const uiTimeline =
() => DIV({ className: 'timeline__wrapper' },
DIV({ className: 'timeline__prehistory' }),
DIV({ className: 'timeline' },
...(getUnitHistory().foldL(
renderEventUnitMissing,
units => units.map(renderEventUnit))),
),
// DIV({ className: 'timeline__future' }),
// setTimelineWindowOneWeek(() => setTimelineWindow(7 * 24 * 60 * 60 * 1000), setTimelineWindowButtonActive(7 * 24 * 60 * 60 * 1000)),
// setTimelineWindowOneDay(() => setTimelineWindow(24 * 60 * 60 * 1000), setTimelineWindowButtonActive(24 * 60 * 60 * 1000)),
// resetTimelineWindow(() => setTimelineWindow(null), resetTimelineWindowButtonActive()),
// This timeline doesn't work ATM, disabling - pm
export const _uiTimeline =
() => getSelectedUnit().map(name =>
getUnitHistory()
.fold(
renderEventUnitMissing(name),
units => DIV({ className: 'timeline__wrapper' },
DIV({ className: 'timeline__prehistory' }),
DIV({ className: 'timeline' },
...(units.map(renderEventUnit)),
),
))
);
export const uiTimeline =
() => none;
\ No newline at end of file
......@@ -2,7 +2,13 @@ import { DIV } from 'sdi/components/elements';
import tr, { formatDate } from 'sdi/locale';
import { divTooltipTopRight } from 'sdi/components/tooltip';
import { fromNullable, some, none } from 'fp-ts/lib/Option';
import { getTimeline, getTimelineDateStart, getTimelineDateEnd, getCurrentTimelineId, getTimelineWindow } from '../../queries/project';
import {
getTimeline,
getTimelineDateStart,
getTimelineDateEnd,
getCurrentTimelineId,
getTimelineWindow ,
} from '../../queries/project';
import { setCurrentTimelineId, loadCurrentProjectAtTime, setTimelineWindow, clearTimelineWindow } from '../../events/project';
import { Transaction } from '../../remote';
import { makeLabelAndIcon } from '../buttons';
......
......@@ -37,7 +37,7 @@ import { getCurrentProfile } from '../queries/profile';
import { getCurrentProjectId, getCurrentTimelineTime, getLastStageUnitForName, getRemovedFromMulti, getStagedUnits, findProject } from '../queries/project';
import { fetchNova } from '../remote/nova';
import { deleteTag, postProject, postTag, postUnits } from '../remote/project';
import { fetchProjectAtTime, fetchTimelineUnit, UnitHistory } from '../remote/timeline';
import { fetchProjectAtTime, fetchUnitHistory, UnitHistory } from '../remote/timeline';
import { RemovedUnitIdentifier } from '../shape/project';
import { loadTimeline, setLayout } from './app';
import { navigateForm, navigateFormNaked } from './route';
......@@ -58,7 +58,7 @@ export const addNewProject =
.map(name =>
postProject(getApiUrl('geodata/angled/p/project/'))
.then(p =>
postUnits(getApiUrl(`geodata/angled/p/project/${p.id}/ui/`),
postUnits(p.id,
{
units: { name: { unit: 'UnitName', name } },
meta: { audiences: [] },
......@@ -251,7 +251,7 @@ const postUnitsInProject = (
) =>
getCurrentProjectId()
.map(pid =>
postUnits(getApiUrl(`geodata/angled/p/project/${pid}/ui/`), { units, meta: { audiences } })
postUnits(pid, { units, meta: { audiences } })
.then(addProject)
.then(() => {
success();
......@@ -427,7 +427,7 @@ export const loadUnitHistory =
assign('component/project/timeline-unit', remoteLoading);
getCurrentProjectId()
.map(pid =>
fetchTimelineUnit(pid, name)
fetchUnitHistory(pid, name)
.then((u: UnitHistory) =>
assign('component/project/timeline-unit', remoteSuccess(u)))
.catch(err =>
......
......@@ -2,13 +2,16 @@
import { postIO, postUnrelatedIO, deleteIO } from 'sdi/source';
import { UnitPost, ProjectIO } from 'angled-core/ui';
import { Tagged, TaggedIO } from 'angled-core/ref';
import { getApiUrl } from 'sdi/app';
export const postProject =
(url: string) => postIO(ProjectIO, url, {});
export const postUnits =
(url: string, units: UnitPost) => postUnrelatedIO(ProjectIO, url, units);
(pid: number, units: UnitPost) =>
postUnrelatedIO(ProjectIO,
getApiUrl(`geodata/angled/p/project/${pid}/inform/`), units);
export const postTag =
(url: string, t: Partial<Tagged>) => postIO(TaggedIO, url, t);
......
......@@ -44,10 +44,10 @@ export const fetchProjectAtTime = (
);
export const fetchTimelineUnit = (
export const fetchUnitHistory = (
id: number,
name: InformationUnitName,
) => fetchIO(
UnitHistoryIO,
getApiUrl(`geodata/angled/p/project/${id}/timeline/?ui=${name}`),
getApiUrl(`geodata/angled/p/project/${id}/unit/?name=${name}`),
);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment