Verified Commit c9a0d157 authored by Florent Chehab's avatar Florent Chehab
Browse files

fixed(front - version): force order and cleaned ordering

parent d9bb08e8
......@@ -90,4 +90,4 @@ class VersionViewSet(BaseModelViewSet):
ct = ContentType.objects.get_for_id(content_type_id)
model = ct.model_class()
obj = model.objects.get(pk=object_pk)
return Version.objects.get_for_object(obj)
return Version.objects.get_for_object(obj).order_by('revision_id')
......@@ -31,12 +31,7 @@ const useStyles = makeStyles(theme => ({
}
}));
function VersionInfo({
rawModelData,
versionNumber,
totalNbVersions,
editFromVersion
}) {
function VersionInfo({ rawModelData, versionNumber, editFromVersion }) {
const classes = useStyles();
let dateInfo = <em>(Information non connue.)</em>;
......@@ -52,7 +47,7 @@ function VersionInfo({
(dans de tels cas, seul la dernière est conservée).
</Typography>
<Typography variant="h6" align="center">
{`Version n°${totalNbVersions - versionNumber} du ${dateInfo}`}
{`Version n°${versionNumber + 1} du ${dateInfo}`}
</Typography>
<Button
variant="outlined"
......@@ -68,7 +63,6 @@ function VersionInfo({
VersionInfo.propTypes = {
rawModelData: PropTypes.object.isRequired,
totalNbVersions: PropTypes.number.isRequired,
versionNumber: PropTypes.number.isRequired,
editFromVersion: PropTypes.func.isRequired
};
......@@ -98,7 +92,9 @@ function History({
api.versions.setParams(buildParams(modelInfo));
}, [modelInfo]);
const [currentVersion, goNextVersion, goPreviousVersion] = useStepper(1);
const [currentVersion, goNextVersion, goPreviousVersion] = useStepper(
versions.length - 1
);
const maxSteps = versions.length;
......@@ -145,7 +141,6 @@ function History({
<VersionInfo
rawModelData={newRawModelData}
versionNumber={currentVersion}
totalNbVersions={versions.length}
editFromVersion={editFromVersion}
/>
<br />
......
Supports Markdown
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