Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
retypos-server
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
retypos-server
Commits
db904c01
Commit
db904c01
authored
Apr 11, 2018
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Задача 12794] Доделал отображение карточек, добавил метод для получения…
[Задача 12794] Доделал отображение карточек, добавил метод для получения опечаток в модель и контроллер
parent
d1909774
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
17 deletions
+57
-17
Typos.php
cp/application/controllers/users/Typos.php
+11
-0
Typo.php
cp/application/models/Typo.php
+14
-0
Application.jsx
cp/javascript/src/components/Application.jsx
+1
-1
SiteList.jsx
cp/javascript/src/components/SiteList.jsx
+1
-1
index.jsx
cp/javascript/src/components/Typo/index.jsx
+19
-7
TypoList.jsx
cp/javascript/src/components/TypoList.jsx
+11
-8
No files found.
cp/application/controllers/users/Typos.php
View file @
db904c01
...
@@ -100,6 +100,17 @@ class Typos extends CI_Controller {
...
@@ -100,6 +100,17 @@ class Typos extends CI_Controller {
echo
json_encode
(
$this
->
typo
->
getMessagesList
(
$data
));
echo
json_encode
(
$this
->
typo
->
getMessagesList
(
$data
));
}
}
function
getSiteTypos
(
$siteId
=
null
)
{
if
(
is_null
(
$siteId
))
{
return
$this
->
output
->
set_status_header
(
400
)
->
set_output
(
"Missing siteId parameter!"
);
}
return
$this
->
output
->
set_content_type
(
"application/json"
)
->
set_status_header
(
200
)
->
set_output
(
json_encode
(
$this
->
typo
->
getSiteTypos
(
$siteId
)));
}
/*Управление сайтами*/
/*Управление сайтами*/
function
panel_sites
()
{
function
panel_sites
()
{
$id_site
=
$this
->
input
->
get
(
"id"
);
$id_site
=
$this
->
input
->
get
(
"id"
);
...
...
cp/application/models/Typo.php
View file @
db904c01
...
@@ -181,6 +181,20 @@ class Typo extends CI_Model {
...
@@ -181,6 +181,20 @@ class Typo extends CI_Model {
return
$this
->
db
->
get
()
->
result
();
return
$this
->
db
->
get
()
->
result
();
}
}
/**
* Получает список опечаток текущего пользователя для данного
* сайта. Возвращает список.
*
* @param $siteId
*/
function
getSiteTypos
(
$siteId
)
{
$this
->
db
->
select
(
"id, text as originalText, context, comment as correctedText, date, status as isCorrected"
);
$this
->
db
->
from
(
"messages"
);
$this
->
db
->
where
(
"site_id"
,
$siteId
);
return
$this
->
db
->
get
()
->
result
();
}
/* Получаем список сообщений об опечатках */
/* Получаем список сообщений об опечатках */
function
getMessagesList
(
$data
)
{
function
getMessagesList
(
$data
)
{
...
...
cp/javascript/src/components/Application.jsx
View file @
db904c01
import
React
from
'react'
;
import
React
from
'react'
;
import
Typo
from
'./Typo'
import
Typo
from
'./Typo
/index
'
export
default
class
Application
extends
Component
{
export
default
class
Application
extends
Component
{
render
()
{
render
()
{
...
...
cp/javascript/src/components/SiteList.jsx
View file @
db904c01
...
@@ -33,7 +33,7 @@ export default class SiteList extends React.Component {
...
@@ -33,7 +33,7 @@ export default class SiteList extends React.Component {
loadSiteTypos
(
siteId
,
done
)
{
loadSiteTypos
(
siteId
,
done
)
{
$
.
ajax
({
$
.
ajax
({
url
:
window
.
baseUrl
+
"/users/typos/getSiteTypos?siteId="
+
this
.
sites
[
siteId
]
,
url
:
`
${
window
.
baseUrl
}
/users/typos/getSiteTypos/
${
this
.
sites
[
siteId
].
id
}
`
,
}).
done
((
typos
)
=>
{
}).
done
((
typos
)
=>
{
this
.
typos
=
typos
;
this
.
typos
=
typos
;
...
...
cp/javascript/src/components/Typo.jsx
→
cp/javascript/src/components/Typo
/index
.jsx
View file @
db904c01
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
{
Card
,
CardBody
,
CardText
}
from
'reactstrap'
import
{
Card
,
CardHeader
,
CardTitle
,
CardFooter
,
CardBody
,
CardText
}
from
'reactstrap'
import
'./style.css'
export
default
class
Typo
extends
Component
{
export
default
class
Typo
extends
Component
{
...
@@ -11,22 +13,32 @@ export default class Typo extends Component {
...
@@ -11,22 +13,32 @@ export default class Typo extends Component {
const
{
typo
}
=
this
.
props
;
const
{
typo
}
=
this
.
props
;
const
display
=
this
.
state
.
show
?
"d-block"
:
"d-none"
;
const
display
=
this
.
state
.
show
?
"d-block"
:
"d-none"
;
const
textColor
=
"text-white"
;
const
backgroundColor
=
"bg-primary"
;
const
className
=
`TypoCard text-center
${
display
}
${
backgroundColor
}
${
textColor
}
`
;
return
(
return
(
<
Card
className=
{
display
}
>
<
Card
className=
{
className
}
>
<
CardHeader
>
<
CardHeader
>
Опечатка #
{
typo
.
id
}
Опечатка #
{
typo
.
id
}
</
CardHeader
>
</
CardHeader
>
<
CardBody
>
<
CardBody
>
<
CardTitle
><
del
>
{
typo
.
original
}
</
del
>
-
>
{
typo
.
corrected
}
</
CardTitle
>
<
CardTitle
><
del
>
{
typo
.
original
Text
}
</
del
>
-
>
{
typo
.
correctedText
}
</
CardTitle
>
<
CardText
>
{
typo
.
context
}
</
CardText
>
<
CardText
>
{
typo
.
context
}
</
CardText
>
<
a
href=
"#"
className=
"btn btn-primary"
>
Исправить
</
a
>
<
div
className=
"card-buttons"
>
<
a
href=
"#"
className=
"btn btn-danger"
>
Отклонить
</
a
>
<
div
className=
"buttons-wrapper"
>
<
button
className=
"accept-button btn btn-success"
>
Исправить
</
button
>
<
CardFooter
>
{
typo
.
comment
}
</
CardFooter
>
<
button
className=
"decline-button btn btn-danger"
>
Отклонить
</
button
>
</
div
>
</
div
>
</
CardBody
>
</
CardBody
>
<
CardFooter
>
<
p
>
Тут должен отображаться комментарий
</
p
>
Добавлена
<
small
>
{
typo
.
date
}
</
small
>
</
CardFooter
>
</
Card
>
</
Card
>
);
);
}
}
...
...
cp/javascript/src/components/TypoList.jsx
View file @
db904c01
import
React
,
{
Component
}
from
'react'
;
import
React
,
{
Component
}
from
'react'
;
import
Typo
from
"./Typo"
;
import
Typo
from
"./Typo
/index
"
;
export
default
class
TypoList
extends
Component
{
export
default
class
TypoList
extends
Component
{
typos
=
this
.
props
.
typos
;
state
=
{
state
=
{
currentTypo
:
0
currentTypo
:
0
};
};
render
()
{
render
()
{
const
typoCards
=
this
.
typos
.
map
((
typo
,
index
)
=>
const
{
typos
}
=
this
.
props
;
<
Typo
typo=
{
this
.
typos
[
this
.
state
.
currentTypo
]
}
const
typoCards
=
typos
.
map
((
typo
,
index
)
=>
<
Typo
key=
{
typo
.
id
}
typo=
{
typos
[
this
.
state
.
currentTypo
]
}
show=
{
this
.
state
.
currentTypo
===
index
}
/>
show=
{
this
.
state
.
currentTypo
===
index
}
/>
);
);
return
<
div
>
return
(
{
typoCards
}
<
div
>
</
div
>
{
typoCards
}
</
div
>
)
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment