[Задача 12794] Добавил возможность перейти к статье, содержащей ошибку

parent e5852bad
......@@ -186,12 +186,13 @@ class Typo extends CI_Model {
* сайта. Возвращает список.
*
* @param $siteId
* @return array Список опечаток
*/
function getSiteTypos($siteId) {
$this->db->select("id, text as originalText, context, comment as correctedText, date, status as isCorrected");
$this->db->select("id, link, text as originalText, context, comment as correctedText, date, status as isCorrected");
$this->db->from("messages");
$this->db->where("site_id", $siteId);
$this->db->where("status", 0);
return $this->db->get()->result();
}
......@@ -353,6 +354,16 @@ class Typo extends CI_Model {
curl_close($curl);
}
/**
* Устанавливает статус опечатки как исправлено,
* но при этом не вносит изменений в текст статьи.
*
* @param $typoId Идентификатор опечатки
*/
function declineTypo($typoId) {
}
}
/**/
\ No newline at end of file
......@@ -10,7 +10,7 @@ export default class Typo extends Component {
};
render() {
const {typo} = this.props;
const {typo, acceptCallback, declineCallback} = this.props;
const display = this.state.show ? "d-block" : "d-none";
const textColor = "text-white";
......@@ -22,6 +22,9 @@ export default class Typo extends Component {
<Card className={className}>
<CardHeader>
Опечатка #{typo.id}
<span id="typo-id">
<a href={typo.link} target="_blank">Ссылка на текст</a>
</span>
</CardHeader>
<CardBody>
......@@ -30,8 +33,8 @@ export default class Typo extends Component {
<div className="card-buttons">
<div className="buttons-wrapper">
<button className="accept-button btn btn-warning">Исправить</button>
<button className="decline-button btn btn-danger">Отклонить</button>
<button className="accept-button btn btn-warning" onClick={acceptCallback}>Исправить</button>
<button className="decline-button btn btn-danger" onClick={declineCallback}>Отклонить</button>
</div>
</div>
</CardBody>
......
......@@ -17,4 +17,14 @@
bottom: 0;
width: 100%;
margin-bottom: 20px;
}
.TypoCard a {
color: white;
}
.TypoCard #typo-id {
position: absolute;
right: 10px;
top: 12px;
}
\ No newline at end of file
......@@ -6,13 +6,39 @@ export default class TypoList extends Component {
currentTypo: 0
};
/**
* Одобряет предложеное исправление опечатки
* и вносит соответствующее исправление в текст.
*
* @param typoId Идентификатор опечатки
*/
acceptCorrection(typoId) {
alert("Accept");
this.state.currentTypo++;
this.forceUpdate();
}
/**
* Отклоняет исправление опечатки.
* Опечатка не исправляется автоматически.
*
* @param typoId Идентификатор опечатки.
*/
declineCorrection(typoId) {
alert("Decline");
this.state.currentTypo++;
this.forceUpdate();
}
render() {
const {typos} = this.props;
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}
acceptCallback={this.acceptCorrection.bind(this, typo.id)}
declineCallback={this.declineCorrection.bind(this, typo.id)}/>
);
return (
......
......@@ -49,6 +49,10 @@ body {
margin-bottom: 5px !important;
}
.header .nav-item {
border-bottom: none !important;
}
li.nav-item {
cursor: pointer;
border-bottom: 1px solid transparent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment