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

parent e5852bad
...@@ -186,12 +186,13 @@ class Typo extends CI_Model { ...@@ -186,12 +186,13 @@ class Typo extends CI_Model {
* сайта. Возвращает список. * сайта. Возвращает список.
* *
* @param $siteId * @param $siteId
* @return array Список опечаток
*/ */
function getSiteTypos($siteId) { 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->from("messages");
$this->db->where("site_id", $siteId); $this->db->where("site_id", $siteId);
$this->db->where("status", 0);
return $this->db->get()->result(); return $this->db->get()->result();
} }
...@@ -353,6 +354,16 @@ class Typo extends CI_Model { ...@@ -353,6 +354,16 @@ class Typo extends CI_Model {
curl_close($curl); curl_close($curl);
} }
/**
* Устанавливает статус опечатки как исправлено,
* но при этом не вносит изменений в текст статьи.
*
* @param $typoId Идентификатор опечатки
*/
function declineTypo($typoId) {
}
} }
/**/ /**/
\ No newline at end of file
...@@ -10,7 +10,7 @@ export default class Typo extends Component { ...@@ -10,7 +10,7 @@ export default class Typo extends Component {
}; };
render() { render() {
const {typo} = this.props; const {typo, acceptCallback, declineCallback} = 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 textColor = "text-white";
...@@ -22,6 +22,9 @@ export default class Typo extends Component { ...@@ -22,6 +22,9 @@ export default class Typo extends Component {
<Card className={className}> <Card className={className}>
<CardHeader> <CardHeader>
Опечатка #{typo.id} Опечатка #{typo.id}
<span id="typo-id">
<a href={typo.link} target="_blank">Ссылка на текст</a>
</span>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
...@@ -30,8 +33,8 @@ export default class Typo extends Component { ...@@ -30,8 +33,8 @@ export default class Typo extends Component {
<div className="card-buttons"> <div className="card-buttons">
<div className="buttons-wrapper"> <div className="buttons-wrapper">
<button className="accept-button btn btn-warning">Исправить</button> <button className="accept-button btn btn-warning" onClick={acceptCallback}>Исправить</button>
<button className="decline-button btn btn-danger">Отклонить</button> <button className="decline-button btn btn-danger" onClick={declineCallback}>Отклонить</button>
</div> </div>
</div> </div>
</CardBody> </CardBody>
......
...@@ -17,4 +17,14 @@ ...@@ -17,4 +17,14 @@
bottom: 0; bottom: 0;
width: 100%; width: 100%;
margin-bottom: 20px; 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 { ...@@ -6,13 +6,39 @@ export default class TypoList extends Component {
currentTypo: 0 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() { render() {
const {typos} = this.props; const {typos} = this.props;
const typoCards = typos.map((typo, index) => const typoCards = typos.map((typo, index) =>
<Typo key={typo.id} typo={typos[this.state.currentTypo]} <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 ( return (
......
...@@ -49,6 +49,10 @@ body { ...@@ -49,6 +49,10 @@ body {
margin-bottom: 5px !important; margin-bottom: 5px !important;
} }
.header .nav-item {
border-bottom: none !important;
}
li.nav-item { li.nav-item {
cursor: pointer; cursor: pointer;
border-bottom: 1px solid transparent; 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