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
1237acfa
You need to sign in or sign up before continuing.
Commit
1237acfa
authored
Sep 07, 2018
by
Георгий Попов
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Задача 12799] Добавил ссылку редактирования статьи на карточку опечатки
Для этого, используя fetch api, выполнил запрос на реализованный контроллер.
parent
3b834f25
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
index.jsx
cp/javascript/src/components/Typo/index.jsx
+30
-0
style.css
cp/javascript/src/components/Typo/style.css
+8
-0
style.css
cp/javascript/src/style.css
+9
-0
No files found.
cp/javascript/src/components/Typo/index.jsx
View file @
1237acfa
...
@@ -4,6 +4,7 @@ import EditableText from "../EditableText";
...
@@ -4,6 +4,7 @@ import EditableText from "../EditableText";
import
'./style.css'
import
'./style.css'
import
'whatwg-fetch'
export
default
class
Typo
extends
Component
{
export
default
class
Typo
extends
Component
{
...
@@ -25,6 +26,33 @@ export default class Typo extends Component {
...
@@ -25,6 +26,33 @@ export default class Typo extends Component {
}
}
/**
/**
* Запрашивает с сервера ссылку на редактирование статьи и устанавливает element.href равным
* полученной ссылке.
*
* Метод setEditLink вызывается по событию onMouseOver карточки для того, чтобы
* избежать большого числа запросов серверу. Если карточек много, то будет выполнено
* довольно много запросов. OnMouseOver позволяет снизить кол-во запросов и нагрузку
* на адаптер.
*/
setEditLink
=
async
(
element
)
=>
{
let
queryString
=
`?typoId=
${
this
.
typo
.
id
}
`
;
let
result
=
await
fetch
(
`
${
window
.
baseUrl
}
/users/typos/getEditUrl
${
queryString
}
`
,
{
method
:
"GET"
,
credentials
:
'include'
});
console
.
log
(
result
);
let
resultJson
=
await
result
.
json
();
const
editUrl
=
resultJson
.
editUrl
;
// Задаем ссылку
element
.
href
=
editUrl
;
return
false
;
}
/**
* Управляет отображением всплывающей подсказки для
* Управляет отображением всплывающей подсказки для
* кнопки принятия исправления.
* кнопки принятия исправления.
*/
*/
...
@@ -139,6 +167,8 @@ export default class Typo extends Component {
...
@@ -139,6 +167,8 @@ export default class Typo extends Component {
<
CardFooter
>
<
CardFooter
>
<
p
>
Комментарий: "
{
typo
.
comment
}
"
</
p
>
<
p
>
Комментарий: "
{
typo
.
comment
}
"
</
p
>
Добавлена
<
small
>
{
typo
.
date
}
</
small
>
Добавлена
<
small
>
{
typo
.
date
}
</
small
>
<
a
id=
"typo-edit"
className=
"link"
target=
{
"_blank"
}
onMouseOver=
{
(
e
)
=>
this
.
setEditLink
(
e
.
target
)
}
>
Редактировать статью
</
a
>
</
CardFooter
>
</
CardFooter
>
</
Card
>
</
Card
>
);
);
...
...
cp/javascript/src/components/Typo/style.css
View file @
1237acfa
...
@@ -36,3 +36,10 @@
...
@@ -36,3 +36,10 @@
cursor
:
pointer
;
cursor
:
pointer
;
text-decoration
:
underline
;
text-decoration
:
underline
;
}
}
#typo-edit
{
position
:
absolute
;
right
:
10px
;
bottom
:
10px
;
font-size
:
80%
;
}
\ No newline at end of file
cp/javascript/src/style.css
View file @
1237acfa
...
@@ -25,3 +25,11 @@
...
@@ -25,3 +25,11 @@
@-moz-keyframes
spin
{
100
%
{
-moz-transform
:
rotate
(
360deg
);
}
}
@-moz-keyframes
spin
{
100
%
{
-moz-transform
:
rotate
(
360deg
);
}
}
@-webkit-keyframes
spin
{
100
%
{
-webkit-transform
:
rotate
(
360deg
);
}
}
@-webkit-keyframes
spin
{
100
%
{
-webkit-transform
:
rotate
(
360deg
);
}
}
@keyframes
spin
{
100
%
{
-webkit-transform
:
rotate
(
360deg
);
transform
:
rotate
(
360deg
);
}
}
@keyframes
spin
{
100
%
{
-webkit-transform
:
rotate
(
360deg
);
transform
:
rotate
(
360deg
);
}
}
.link
{
cursor
:
pointer
;
}
.link
:hover
{
text-decoration
:
underline
!important
;
}
\ 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