Commit d1fc5463 authored by Pierre Marchand's avatar Pierre Marchand

[client/project] reload timeline on successful save

parent 3d1b8722
......@@ -83,4 +83,4 @@ export const _uiTimeline =
export const uiTimeline =
() => none;
\ No newline at end of file
......@@ -3,7 +3,7 @@ import { DIV, SPAN, NODISPLAY, H2 } from 'sdi/components/elements';
import tr, { formatDate, fromRecord } from 'sdi/locale';
import { getUserIdAstNumber, getLang } from 'sdi/app';
import { UnitWidget, getPanelOption } from 'angled-core/profile';
import { Unit, typeNameToName } from 'angled-core/ui';
import { Unit, typeNameToName, InformationUnitName } from 'angled-core/ui';
import {
getUnitbyNameFromCurrentProject,
getModalStatus,
......@@ -18,7 +18,9 @@ import { nameToString } from 'sdi/components/button/names';
import {
setModalStatus,
addTagToUnit,
removeTagFromUnit
removeTagFromUnit,
setEditProjectHidden,
selectUnit
} from 'angled-project/src/events/project';
import { renderMultiSelect } from 'sdi/components/input';
import { setoidIdentified } from 'sdi/util';
......@@ -249,7 +251,21 @@ const uiPubInfos = (unitData: Unit | Unit[]) =>
const makeArray = <T>(a: T | T[]) => (Array.isArray(a) ? a : [a]);
const renderMeta = (data: Unit | Unit[]) =>
const editButton = (
name: InformationUnitName,
) => divTooltipLeft(
tr.angled('updateData'),
{},
makeIcon('edit', 3, 'pencil')(() => {
selectUnit(name);
setEditProjectHidden(false);
})
);
const renderMeta = (
widget: UnitWidget,
data: Unit | Unit[],
) =>
withDisplayType(
'writer',
DIV(
......@@ -258,12 +274,15 @@ const renderMeta = (data: Unit | Unit[]) =>
DIV(
{ className: 'widget__tools' },
isUserAuthor(data) ? audienceModalTrigger(data) : NODISPLAY(),
tagModalTrigger(data)
tagModalTrigger(data),
editButton(widget.name),
)
)
);
export const uiHeader = (widget: UnitWidget) =>
export const uiHeader = (
widget: UnitWidget,
) =>
getUnitbyNameFromCurrentProject(widget.name).fold(
DIV({ className: 'widget__header' }, uiName(widget)),
data =>
......@@ -271,7 +290,7 @@ export const uiHeader = (widget: UnitWidget) =>
{ className: 'widget__header' },
DIV(
{ className: 'widget__header--top' },
renderMeta(data),
renderMeta(widget, data),
uiName(widget, ...makeArray(data))
)
)
......
......@@ -246,7 +246,7 @@ const upload =
const postUnitsInProject = (
units: UnitDataPost,
audiences: number[],
success: () => void,
success: (pid: number) => void,
error: (err: unknown) => void,
) =>
getCurrentProjectId()
......@@ -254,7 +254,7 @@ const postUnitsInProject = (
postUnits(pid, { units, meta: { audiences } })
.then(addProject)
.then(() => {
success();
success(pid);
clearProjectForm(pid);
})
.catch(error)
......@@ -275,7 +275,10 @@ export const pushStaged =
() => {
setLayout('Saving');
assign('component/project/saving/error', null);
const onSuccess = () => setLayout('Form');
const onSuccess = (pid: number) => {
loadTimeline(pid).then(loadCurrentProjectAtTime);
setLayout('Form');
};
const onError = (err: unknown) => {
logger(`SaveError`, err);
assign('component/project/saving/error', `${err}`);
......@@ -417,6 +420,7 @@ export const selectUnit =
export const clearTimeLine = () => {
assign('component/project/timeline', remoteNone);
assign('component/project/timeline-unit', remoteNone);
assign('component/project/timeline/project', remoteNone);
assign('component/project/timeline/window', null);
assign('component/project/timeline/current-id', null);
};
......
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