Commit c8eb36a5 authored by Florent Chehab's avatar Florent Chehab

Generic module connected

parent 7255c33d
Pipeline #27202 passed with stages
in 2 minutes and 38 seconds
......@@ -85,7 +85,6 @@ class GenericModule extends MyComponent {
};
myRender() {
console.log(renderFirstRow)
const { classes } = this.props;
return (
<div>
......@@ -106,7 +105,6 @@ class GenericModule extends MyComponent {
GenericModule.defaultProps = {
title: null,
usefulLinks: [],
};
GenericModule.propTypes = {
......
......@@ -19,6 +19,7 @@ import GenericModule from './GenericModule';
import MyComponent from '../../MyComponent';
import dateToStr from '../../../utils/dateToStr';
import {
universitiesSemestersDatesElFetchData,
......@@ -43,13 +44,7 @@ const styles = theme => ({
function convertDate(date) {
if (date) {
const d = new Date(date);
let dd = d.getDate();
let mm = d.getMonth() + 1;
dd = dd < 10 ? '0' + dd : dd;
mm = mm < 10 ? '0' + mm : mm;
const yyyy = d.getFullYear();
return dd + '/' + mm + '/' + yyyy;
return dateToStr(date);
} else {
return "Non connue."
}
......@@ -63,11 +58,11 @@ class UniversitySemestersDates extends MyComponent {
const semestersDates = this.getFetchedData('universitiesSemestersDatesEl');
let { autumn_begin, autumn_end, spring_begin, spring_end, comment } = semestersDates;
console.log("semestersDates", semestersDates);
autumn_begin = convertDate(autumn_begin);
autumn_end = convertDate(autumn_end);
spring_begin = convertDate(spring_begin);
spring_end = convertDate(spring_end);
return (
<GenericModule title={"Date des semestres"} modelData={semestersDates}>
<div className={classes.root}>
......
......@@ -30,7 +30,7 @@ export default function renderFirstRow() {
const userData = this.getFetchedData('userDataEl');
const serverModerationStatus = this.getFetchedData('serverModerationStatus');
const { editTooltip, editClass } = getEditTooltipAndClass(readOnly, modelData, userData.owner_level, serverModerationStatus.activated, serverModerationStatus.moderator_level);
console.log("render title", renderTitle)
return (
<Grid container spacing={8}>
<Grid item xs style={{ paddingBottom: theme.spacing.unit }}>
......
......@@ -2,14 +2,18 @@ import React from 'react';
import NotificationImportantIcon from '@material-ui/icons/NotificationImportant';
import Typography from '@material-ui/core/Typography';
export default function renderTitle() {
const { title, classes, importanceLevel } = this.props;
const { title, classes, modelData } = this.props;
const { importanceLevel } = modelData;
if (title) {
if (importanceLevel) {
if (importanceLevel && importanceLevel != '-') {
let c = classNames(classes.titleIcon);
if (importanceLevel == "IMPORTANT") {
if (importanceLevel == "++") {
c = classNames(classes.titleIcon, classes.red)
} else if (importanceLevel == "important") {
} else if (importanceLevel == "+") {
c = classNames(classes.titleIcon, classes.orange)
}
return (
......
import React from 'react';
import Typography from '@material-ui/core/Typography';
import dateTimeToStr from '../../../../utils/dateTimeToStr';
export default function renderUpdateInfo() {
const { modelData } = this.props;
const { updated_by, updated_on } = modelData;
const readOnly = modelData.model_config.read_only;
if (!updated_by) {
if (readOnly) {
return (
<Typography variant='caption'>Date de mise à jour et auteur(e) non connu(e).</Typography>
<Typography variant='caption'>Ils s'agit de donner automatiquement récupérer et non modifiables.</Typography>
)
} else {
return (
<Typography variant='caption'>Mis à jour par <em>{updated_by}</em> le {updated_on}</Typography>
)
if (updated_on) {
const { date, time } = dateTimeToStr(updated_on);
<Typography variant='caption'>Mis à jour par <em>{updated_by}</em> le {date} à {time}</Typography>
} else {
return (
<Typography variant='caption'>Mis à jour par <em>{updated_by}</em> à une date inconnue.</Typography>
)
}
}
}
\ No newline at end of file
......@@ -5,7 +5,9 @@ import Avatar from '@material-ui/core/Avatar';
import LinkIcon from '@material-ui/icons/Link';
export default function renderUsefulLinks() {
const { classes, usefulLinks, theme } = this.props;
const { classes, theme, modelData } = this.props;
const usefulLinks = modelData.useful_links;
const nbItems = usefulLinks.length;
if (nbItems == 0) {
return (<div></div>)
......
const reg = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/;
export default function dateTimeToStr(dateTime){
const res = reg.exec(dateTime);
let yyyy = res[1],
mm = res[2],
dd = res[3],
hh = res[4],
min = res[5],
sec = res[6];
return {
date: dd + '/' + mm + '/' + yyyy,
time: hh + 'h' + min,
fullTime: hh + 'h' + min + 's' + sec
}
}
\ No newline at end of file
const reg = /(\d{4})-(\d{2})-(\d{2})/;
export default function dateToStr(dateTime) {
const res = reg.exec(dateTime);
let yyyy = res[1],
mm = res[2],
dd = res[3];
return dd + '/' + mm + '/' + yyyy;
}
\ No newline at end of file
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