mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-10 15:14:33 +08:00
fixes current timezone setup for activities
This commit is contained in:
parent
86ac07c69f
commit
249d3d7698
4 changed files with 20 additions and 19 deletions
|
@ -2,6 +2,7 @@ module ClientApi
|
|||
class ActivitiesController < ApplicationController
|
||||
|
||||
def index
|
||||
@timezone = current_user.time_zone
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render template: '/client_api/activities/index',
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// @flow
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import Moment from "react-moment";
|
||||
import type {Node} from 'react';
|
||||
import styled from "styled-components";
|
||||
import { FormattedDate } from "react-intl";
|
||||
|
||||
import {
|
||||
WHITE_COLOR,
|
||||
|
@ -10,7 +11,7 @@ import {
|
|||
} from "../../../config/constants/colors";
|
||||
|
||||
const StyledLi = styled.li`
|
||||
border-radius: .25em;
|
||||
border-radius: 0.25em;
|
||||
margin-bottom: 1em;
|
||||
background-color: ${WHITE_COLOR};
|
||||
border: 1px solid ${COLOR_CONCRETE};
|
||||
|
@ -19,8 +20,8 @@ const TimeSpan = styled.span`
|
|||
min-width: 150px;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
border-top-left-radius: .25em;
|
||||
border-bottom-left-radius: .25em;
|
||||
border-top-left-radius: 0.25em;
|
||||
border-bottom-left-radius: 0.25em;
|
||||
border: 3px solid ${BORDER_GRAY_COLOR};
|
||||
background-color: ${BORDER_GRAY_COLOR};
|
||||
padding-left: 10px;
|
||||
|
@ -32,23 +33,21 @@ const TextSpan = styled.span`
|
|||
display: table-cell;
|
||||
padding: 3px 10px;
|
||||
text-align: justify;
|
||||
`
|
||||
`;
|
||||
|
||||
const ActivityElement = ({ activity }) =>
|
||||
const ActivityElement = ({ activity }: Activity ): Node => (
|
||||
<StyledLi>
|
||||
<TimeSpan>
|
||||
<Moment format="HH.mm">
|
||||
{activity.created_at}
|
||||
</Moment>
|
||||
<FormattedDate
|
||||
value={new Date(activity.created_at)}
|
||||
hour="2-digit"
|
||||
minute="2-digit"
|
||||
timeZone={activity.timezone}
|
||||
hour12={false}
|
||||
/>
|
||||
</TimeSpan>
|
||||
<TextSpan dangerouslySetInnerHTML={{ __html: activity.message }} />
|
||||
</StyledLi>;
|
||||
|
||||
ActivityElement.propTypes = {
|
||||
activity: PropTypes.shape({
|
||||
message: PropTypes.string.isRequired,
|
||||
created_at: PropTypes.string.isRequired
|
||||
}).isRequired
|
||||
};
|
||||
</StyledLi>
|
||||
);
|
||||
|
||||
export default ActivityElement;
|
||||
|
|
|
@ -4,5 +4,6 @@ json.global_activities do
|
|||
json.id activity.id
|
||||
json.message activity.message
|
||||
json.created_at activity.created_at
|
||||
json.timezone @timezone
|
||||
end
|
||||
end
|
||||
|
|
|
@ -96,4 +96,4 @@
|
|||
"webpack-manifest-plugin": "^1.1.2",
|
||||
"webpack-merge": "^4.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue