Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KSZK
DevTeam
kszkepzes
old
kszkepzes-frontend
Commits
2609236d
Commit
2609236d
authored
5 years ago
by
Rafael László
Browse files
Options
Downloads
Patches
Plain Diff
migrated news page from master
parent
eb52cc0d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/forms/EditNewsForm.js
+6
-1
6 additions, 1 deletion
src/components/forms/EditNewsForm.js
src/components/pages/News.js
+92
-45
92 additions, 45 deletions
src/components/pages/News.js
with
98 additions
and
46 deletions
src/components/forms/EditNewsForm.js
+
6
−
1
View file @
2609236d
import
React
,
{
Component
}
from
'
react
'
;
import
{
Modal
,
Button
,
Form
,
Input
,
TextArea
,
Icon
}
from
'
semantic-ui-react
'
;
import
{
connect
}
from
'
react-redux
'
;
import
moment
from
'
moment
'
;
import
{
writeNews
,
editNews
,
clearWrite
}
from
'
../../actions/news
'
;
...
...
@@ -13,7 +14,7 @@ class EditNewsForm extends Component {
}
render
()
{
const
{
id
,
title
,
text
}
=
this
.
props
.
selectedNews
;
const
{
id
,
title
,
text
,
author
,
last_update_by
,
created_at
,
updated_at
}
=
this
.
props
.
selectedNews
;
const
updated_by
=
this
.
props
.
user
.
id
;
return
(
<
Modal
...
...
@@ -31,6 +32,10 @@ class EditNewsForm extends Component {
>
<
Modal
.
Header
>
Szerkesztés
:
<
/Modal.Header
>
<
Modal
.
Content
>
<
p
style
=
{{
fontStyle
:
'
italic
'
}}
><
b
>
Közzétéve
:
<
/b> {moment
(
created_at
)
.format
(
'LLLL'
)
} <br /
>
<
b
>
Írta
:
<
/b> {author} <br /
>
<
b
>
Szerkesztve
:
<
/b> {moment
(
updated_at
)
.format
(
'LLLL'
)
} <br /
>
<
b
>
Szerkesztette
:
<
/b> {last_update_by}</
p
>
<
Form
>
<
Form
.
Field
control
=
{
Input
}
...
...
This diff is collapsed.
Click to expand it.
src/components/pages/News.js
+
92
−
45
View file @
2609236d
...
...
@@ -3,8 +3,10 @@ import { Container, Segment, Item, Button, Grid } from 'semantic-ui-react';
import
{
connect
}
from
'
react-redux
'
;
import
moment
from
'
moment
'
;
import
AddNewsForm
from
'
../forms/AddNewsForm
'
;
import
EditNewsForm
from
'
../forms/EditNewsForm
'
;
import
AddNewsForm
from
'
../forms/AddNewsForm
'
import
EditNewsForm
from
'
../forms/EditNewsForm
'
import
ConfirmModal
from
'
../forms/ConfirmModal
'
import
{
getNews
,
deleteNews
,
setSelectedNews
}
from
'
../../actions/news
'
;
...
...
@@ -14,58 +16,103 @@ class News extends Component {
UNSAFE_componentWillMount
()
{
this
.
props
.
getNews
();
}
renderNews
()
{
return
this
.
props
.
news
.
map
(
item
=>
(
<
Item
key
=
{
item
.
id
}
>
<
Item
.
Content
>
<
Container
text
textAlign
=
'
left
'
>
<
Item
.
Header
style
=
{{
fontSize
:
'
2em
'
,
width
:
'
100%
'
}}
>
<
Grid
>
<
Grid
.
Column
width
=
{
12
}
>
<
Grid
.
Column
floated
=
'
left
'
width
=
{
this
.
props
.
user
.
role
===
'
Staff
'
?
12
:
16
}
>
{
item
.
title
}
<
/Grid.Column
>
{
this
.
props
.
user
.
role
===
'
Staff
'
?
<
Grid
.
Column
floated
=
'
right
'
width
=
{
4
}
>
<
EditNewsForm
onClick
=
{()
=>
{
this
.
props
.
setSelectedNews
(
item
)
}}
onClick
=
{()
=>
this
.
props
.
setSelectedNews
(
item
)}
/
>
<
ConfirmModal
text
=
{
`törölni akarod a következő hírt:
${
item
.
title
}
`
}
button
=
{
<
Button
compact
color
=
'
red
'
size
=
'
mini
'
onClick
=
{()
=>
this
.
props
.
deleteNews
(
item
)}
>
Delete
Törlés
<
/Button
>
}
onAccept
=
{()
=>
this
.
props
.
deleteNews
(
item
)}
/
>
<
/Grid.Column
>
:
null
}
<
/Grid
>
<
/Item.Header
>
<
Item
.
Description
className
=
'
news-text
'
style
=
{{
fontSize
:
'
1.33em
'
}}
>
<
Item
.
Meta
style
=
{{
fontSize
:
'
0.75em
'
,
fontStyle
:
'
italic
'
}}
>
Közzétéve
:
{
moment
(
item
.
created_at
).
format
(
'
LLLL
'
)}
<
/Item.Meta
>
<
Item
.
Description
className
=
'
news-text
'
style
=
{{
fontSize
:
'
1em
'
}}
>
{
this
.
renderMultiLine
(
item
.
text
)}
<
/Item.Description
>
<
Item
.
Extra
>
<
Grid
>
<
Grid
.
Row
className
=
'
news-extra
'
>
<
Grid
.
Column
floated
=
'
left
'
width
=
{
10
}
>
<
p
>
Készült
:
{
moment
(
item
.
created_at
).
format
(
'
LLLL
'
)}
<
/p
>
<
p
>
Szerkesztve
:
{
moment
(
item
.
updated_at
).
format
(
'
LLLL
'
)}
<
/p
>
<
/Grid.Column
>
<
Grid
.
Column
floated
=
'
right
'
width
=
{
5
}
>
<
p
>
Írta
:
<
strong
>
{
item
.
author
}
<
/strong></
p
>
{
/* TODO get the edited by name */
}
<
p
>
Szerkesztette
:
{
item
.
last_update_by
}
<
/p
>
<
/Grid.Column
>
<
/Grid.Row
>
<
/Grid
>
<
/Item.Extra
>
<
/Container
>
<
/Item.Content
>
<
/Item
>
));
// renderNews() {
// return this.props.news.map(item => (
// <Item key={item.id}>
// <Item.Content>
// <Item.Header
// style={{ fontSize: '2em', width: '100%' }}
// >
// <Grid>
// <Grid.Column width={12}>
// {item.title}
// </Grid.Column>
// { this.props.user.role === 'Staff' ?
// <Grid.Column floated='right' width={4}>
// <EditNewsForm
// onClick={() => {
// this.props.setSelectedNews(item)
// }}
// />
// <Button
// compact
// color='red'
// size='mini'
// onClick={() => this.props.deleteNews(item)}
// >
// Delete
// </Button>
// </Grid.Column>
// : null }
// </Grid>
// </Item.Header>
// <Item.Description className='news-text' style={{ fontSize: '1.33em' }}>
// {this.renderMultiLine(item.text)}
// </Item.Description>
// <Item.Extra>
// <Grid>
// <Grid.Row className='news-extra'>
// <Grid.Column floated='left' width={10}>
// <p> Készült: {moment(item.created_at).format('LLLL')} </p>
// <p> Szerkesztve: {moment(item.updated_at).format('LLLL')}</p>
// </Grid.Column>
// <Grid.Column floated='right' width={5}>
// <p> Írta: <strong>{item.author}</strong></p>
// {/* TODO get the edited by name */}
// <p> Szerkesztette: {item.last_update_by}</p>
// </Grid.Column>
// </Grid.Row>
// </Grid>
// </Item.Extra>
// </Item.Content>
// </Item>
// ));
}
renderMultiLine
(
text
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment