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
7aafcc34
Commit
7aafcc34
authored
Sep 18, 2018
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Задача 12799] Общие исправления. Изменение компонента хранилища состояния опечаток
parent
f0577812
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
31 deletions
+35
-31
Typo.php
cp/application/models/Typo.php
+0
-0
SiteList.jsx
cp/javascript/src/components/SiteList.jsx
+15
-6
index.jsx
cp/javascript/src/components/Typo/index.jsx
+1
-8
index.jsx
cp/javascript/src/components/TypoList/index.jsx
+19
-17
No files found.
cp/application/models/Typo.php
View file @
7aafcc34
cp/javascript/src/components/SiteList.jsx
View file @
7aafcc34
...
...
@@ -11,14 +11,15 @@ export default class SiteList extends React.Component {
super
(
props
);
this
.
sites
=
this
.
props
.
sites
;
console
.
log
(
"Render SiteList"
);
this
.
state
=
{
activeTab
:
0
,
error
:
false
,
refreshing
:
true
refreshing
:
true
,
typos
:
[]
};
this
.
typos
=
[];
// Настройка прогресс бара
TopBarProgress
.
config
({
barColors
:
{
...
...
@@ -59,7 +60,9 @@ export default class SiteList extends React.Component {
$
.
ajax
({
url
:
`
${
window
.
baseUrl
}
/users/typos/getSiteTypos/
${
this
.
sites
[
siteId
].
id
}
`
,
}).
done
((
typos
)
=>
{
this
.
typos
=
typos
;
this
.
setState
({
typos
:
typos
});
if
(
done
)
{
done
();
...
...
@@ -74,6 +77,12 @@ export default class SiteList extends React.Component {
});
}
removeTypoFromList
=
(
typoId
)
=>
{
this
.
setState
({
typos
:
this
.
state
.
typos
.
filter
((
typo
)
=>
{
typo
.
id
!==
typoId
})
});
}
render
()
{
const
tabItems
=
this
.
sites
.
map
((
site
,
index
)
=>
<
NavItem
key=
{
index
}
>
...
...
@@ -83,7 +92,7 @@ export default class SiteList extends React.Component {
<
Badge
id=
{
site
.
id
+
"-typos-count"
}
className=
{
"typos-count"
}
hidden=
{
this
.
state
.
activeTab
!==
index
}
>
{
this
.
typos
.
length
}
{
this
.
state
.
typos
.
length
}
</
Badge
>
</
NavLink
>
{
this
.
state
.
activeTab
===
index
&&
...
...
@@ -113,7 +122,7 @@ export default class SiteList extends React.Component {
if
(
this
.
state
.
activeTab
===
index
)
{
return
(
<
TabPane
key=
{
index
}
tabId=
{
index
}
>
<
TypoList
siteId=
{
site
.
id
}
typos=
{
this
.
typos
}
/>
<
TypoList
siteId=
{
site
.
id
}
typos=
{
this
.
state
.
typos
}
removeTypoCallback=
{
this
.
removeTypoFromList
}
/>
</
TabPane
>
);
}
else
{
// Если не активная вкладка - то не рендерим содержимое
...
...
cp/javascript/src/components/Typo/index.jsx
View file @
7aafcc34
...
...
@@ -112,20 +112,13 @@ export default class Typo extends Component {
render
()
{
const
typo
=
this
.
typo
;
const
{
show
}
=
this
.
props
;
const
display
=
show
?
"d-block"
:
"d-none
"
;
const
display
=
"d-block
"
;
const
textColor
=
"text-white"
;
const
backgroundColor
=
"bg-primary"
;
const
className
=
`TypoCard text-center
${
display
}
${
backgroundColor
}
${
textColor
}
`
;
if
(
show
)
{
console
.
log
(
"Render typo #"
+
typo
.
id
);
}
else
{
return
null
;
}
if
(
!
this
.
state
.
textHighlighted
)
{
this
.
_highlightTypoInContext
();
this
.
state
.
textHighlighted
=
true
;
...
...
cp/javascript/src/components/TypoList/index.jsx
View file @
7aafcc34
...
...
@@ -13,12 +13,19 @@ import './style.css'
const
alertify
=
require
(
"alertify.js"
);
export
default
class
TypoList
extends
Component
{
state
=
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
loading
:
false
,
siteId
:
0
,
resolvedTypos
:
[]
siteId
:
this
.
props
.
siteId
,
};
this
.
removeTypo
=
this
.
props
.
removeTypoCallback
.
bind
(
this
);
console
.
log
(
"Construct(TypoList):"
,
this
);
}
/**
* Одобряет исправление опечатки
* и вносит соответствующее исправление в текст.
...
...
@@ -37,8 +44,7 @@ export default class TypoList extends Component {
alertify
.
success
(
`<p>Опечатка
${
typoId
}
была подтверждена.</p>
<p>Исправления применены к тексту, содержащему опечатку.</p>`
);
this
.
state
.
resolvedTypos
.
push
(
typoId
);
this
.
_decrementSiteTyposCount
();
this
.
removeTypo
(
typoId
);
}
else
{
alertify
.
error
(
response
.
message
);
}
...
...
@@ -66,9 +72,7 @@ export default class TypoList extends Component {
this
.
_setTypoStatus
(
0
,
typoId
,
this
.
state
.
siteId
)
.
done
(()
=>
{
alertify
.
success
(
`Опечатка
${
typoId
}
была отклонена`
);
this
.
state
.
resolvedTypos
.
push
(
typoId
);
this
.
_decrementSiteTyposCount
();
this
.
removeTypo
(
typoId
);
})
.
fail
(()
=>
{
alertify
.
error
(
"Ошибка исправления опечатки, попробуйте позже"
);
...
...
@@ -121,20 +125,18 @@ export default class TypoList extends Component {
}
render
()
{
console
.
log
(
"Render typolist for site "
+
this
.
state
.
siteId
);
const
{
typos
}
=
this
.
props
;
this
.
state
.
siteId
=
this
.
props
.
siteId
;
this
.
updateSiteTyposCount
();
cons
ole
.
log
(
"Render typolist for site "
+
this
.
state
.
siteId
)
;
cons
t
typos
=
this
.
props
.
typos
;
if
(
typos
.
length
===
0
||
this
.
state
.
resolvedTypos
.
length
>=
typos
.
length
)
{
if
(
typos
.
length
===
0
)
{
return
TypoList
.
_displayEmptyMessage
();
}
const
typoCards
=
typos
.
map
((
typo
,
index
)
=>
<
Typo
key=
{
typo
.
id
}
typo=
{
typo
}
show=
{
!
this
.
state
.
resolvedTypos
.
includes
(
typo
.
id
)
}
acceptCallback=
{
this
.
acceptCorrection
.
bind
(
this
,
typo
.
id
)
}
declineCallback=
{
this
.
declineCorrection
.
bind
(
this
,
typo
.
id
)
}
/>
);
...
...
@@ -153,8 +155,7 @@ export default class TypoList extends Component {
* Уменьшает счетчик опечаток сайта
* @private
*/
_decrementSiteTyposCount
()
{
const
value
=
parseInt
(
$
(
`#
${
this
.
state
.
siteId
}
-typos-count`
).
text
());
$
(
`#
${
this
.
state
.
siteId
}
-typos-count`
).
text
(
value
-
1
);
updateSiteTyposCount
()
{
$
(
`#
${
this
.
state
.
siteId
}
-typos-count`
).
text
(
this
.
props
.
typos
.
length
);
}
}
\ 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