diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index dde0b78..33dc475 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -51,7 +51,7 @@ return [ ], ], ], - '^.*/qa/question.*$' => [ + '^.*/qa/question(\?.*|$)$' => [ [ 'dest' => '\Modules\QA\Controller\BackendController:viewQADoc', 'verb' => RouteVerb::GET, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 3e32e38..12adc63 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -361,16 +361,18 @@ final class ApiController extends Controller ->where('isAccepted', true) ->execute(); - if ($oldNewAccepted->id !== $oldAccepted->id) { + if ($oldAccepted->id !== 0 && + $oldNewAccepted->id !== $oldAccepted->id + ) { $oldUnaccepted = clone $oldAccepted; $oldUnaccepted->isAccepted = !$oldUnaccepted->isAccepted; $this->updateModel($request->header->account, $oldAccepted, $oldUnaccepted, QAAnswerMapper::class, 'answer', $request->getOrigin()); } - $new = $this->updateAnsweredStatusFromRequest($request); + $newAccepted = $this->updateAnsweredStatusFromRequest($request, $newAccepted); $this->updateModel($request->header->account, $oldNewAccepted, $newAccepted, QAAnswerMapper::class, 'answer', $request->getOrigin()); - $this->createStandardUpdateResponse($request, $response, $new); + $this->createStandardUpdateResponse($request, $response, $newAccepted); } /** @@ -401,10 +403,8 @@ final class ApiController extends Controller * * @since 1.0.0 */ - public function updateAnsweredStatusFromRequest(RequestAbstract $request) : QAAnswer + public function updateAnsweredStatusFromRequest(RequestAbstract $request, QAAnswer $answer) : QAAnswer { - /** @var \Modules\QA\Models\QAAnswer $answer */ - $answer = QAAnswerMapper::get()->where('id', (int) $request->getData('id'))->execute(); $answer->isAccepted = !$answer->isAccepted; return $answer; diff --git a/Controller/BackendController.php b/Controller/BackendController.php index be1e90d..9029c8a 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -15,8 +15,11 @@ declare(strict_types=1); namespace Modules\QA\Controller; use Model\SettingMapper; +use Modules\Admin\Models\AccountMapper; +use Modules\Profile\Models\ProfileMapper; use Modules\QA\Models\QAAppMapper; use Modules\QA\Models\QAHelperMapper; +use Modules\QA\Models\QAQuestion; use Modules\QA\Models\QAQuestionMapper; use phpOMS\Asset\AssetType; use phpOMS\Contract\RenderableInterface; @@ -156,8 +159,22 @@ final class BackendController extends Controller $view->setTemplate('/Modules/QA/Theme/Backend/qa-question-create'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1006001001, $request, $response); - /** @var \Modules\QA\Models\QAQuestion $question */ - $question = QAQuestionMapper::get()->where('id', (int) $request->getData('id'))->execute(); + $question = new QAQuestion(); + + $question->createdBy = ProfileMapper::get() + ->with('account') + ->with('image') + ->where('account', $request->header->account) + ->execute(); + + if ($question->createdBy->account->id === 0) { + $question->createdBy->account = AccountMapper::get() + ->where('id', $request->header->account) + ->execute(); + } + + $scores = QAHelperMapper::getAccountScore($question->getAccounts()); + $view->data['scores'] = $scores; $view->data['question'] = $question; return $view; diff --git a/Theme/Backend/Lang/de.lang.php b/Theme/Backend/Lang/de.lang.php index f2b91b4..fc76b3c 100755 --- a/Theme/Backend/Lang/de.lang.php +++ b/Theme/Backend/Lang/de.lang.php @@ -14,8 +14,14 @@ declare(strict_types=1); return ['QA' => [ 'All' => 'Alle', + 'Answer' => 'Antwort', + 'Question' => 'Frage', + 'Vote' => 'Bewerten', + 'Score' => 'Bewertung', + 'Accept' => 'Akzeptieren', 'Badges' => 'Abzeichen', 'List' => 'Liste', + 'Title' => 'Titel', 'Name' => 'Name', 'QA' => 'Q&A', ]]; diff --git a/Theme/Backend/Lang/en.lang.php b/Theme/Backend/Lang/en.lang.php index 3c91f99..c78a33f 100755 --- a/Theme/Backend/Lang/en.lang.php +++ b/Theme/Backend/Lang/en.lang.php @@ -14,8 +14,14 @@ declare(strict_types=1); return ['QA' => [ 'All' => 'All', + 'Answer' => 'Answer', + 'Question' => 'Question', + 'Vote' => 'Vote', + 'Score' => 'Score', + 'Accept' => 'Accept', 'Badges' => 'Badges', 'List' => 'List', + 'Title' => 'Title', 'Name' => 'Name', 'QA' => 'QA', ]]; diff --git a/Theme/Backend/qa-question-create.tpl.php b/Theme/Backend/qa-question-create.tpl.php index e69de29..8aeb471 100755 --- a/Theme/Backend/qa-question-create.tpl.php +++ b/Theme/Backend/qa-question-create.tpl.php @@ -0,0 +1,78 @@ +data['question']; + +/** @var \Modules\QA\Models\QAAnswer[] $answers */ +$answers = $question->getAnswersByScore(); + +/** @var array $scores */ +$scores = $this->data['scores']; + +echo $this->data['nav']->render(); +?> + +
+
+
+
+
+
getHtml('Question'); ?>
+
+
+ + +
+ +
+ + +
+
+
+
+ getTags(); + foreach ($tags as $tag) : + if ($tag->id === 0) { continue; } + ?> + icon) ? '' : ''; ?>printHtml($tag->getL11n()); ?> + +
+ + getMedia(); foreach ($files as $file) : ?> + name; ?> + + + + + +
+
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/qa-question.tpl.php b/Theme/Backend/qa-question.tpl.php index efab113..e04c8cd 100755 --- a/Theme/Backend/qa-question.tpl.php +++ b/Theme/Backend/qa-question.tpl.php @@ -32,28 +32,34 @@ echo $this->data['nav']->render();
+ request->header->account !== $question->createdBy->account->id) : ?> expand_less + getVoteScore(); ?> - Score + getHtml('Score'); ?> + request->header->account !== $question->createdBy->account->id) : ?> expand_more +
getAnswerCount(); ?> @@ -64,7 +70,11 @@ echo $this->data['nav']->render();
printHtml($question->name); ?>
-
question; ?>
+ id === 0) : ?> + + +
question; ?>
+
expand_less + getVoteScore(); ?> Score + request->header->account !== $answer->createdBy->account->id) : ?> expand_more +
+ request->header->account === $question->createdBy->account->id) : ?> + check + request->header->account === $question->createdBy->account->id) : ?> + printHtml($answer->isAccepted ? 'Accepted' : 'Accept'); ?>
diff --git a/Theme/Backend/styles.css b/Theme/Backend/styles.css index d6bfebc..e2e6d1c 100755 --- a/Theme/Backend/styles.css +++ b/Theme/Backend/styles.css @@ -19,13 +19,14 @@ display: flex; flex-direction: column; } - .qa-question-view .portlet-body { - height: 100%; - } + +.qa textarea { + height: 100px; +} .qa .qa-accept { - font-size: 2rem; - font-weight: 200; + font-size: 3rem; + font-weight: 800; color: #ccc; cursor: pointer; } .qa .accepted .qa-accept { @@ -33,8 +34,8 @@ .qa .accepted .portlet { border-top: 3px solid #81e27d; } .qa .qa-vote { - font-size: 2rem; - font-weight: 200; + font-size: 3rem; + font-weight: 800; color: #ccc; cursor: pointer; } .qa .qa-vote.voted { @@ -57,7 +58,7 @@ .qa .counter-area .text { font-size: .8rem; } .qa .score.closed { - background: #f00; } + background: #ee5649; } .qa .score.open { background: #f8ffa8; } .qa .score.done { diff --git a/Theme/Backend/styles.scss b/Theme/Backend/styles.scss index af980d7..28f0b0b 100755 --- a/Theme/Backend/styles.scss +++ b/Theme/Backend/styles.scss @@ -30,8 +30,8 @@ flex-direction: column; } - .portlet-body { - height: 100%; + textarea { + height: 100px; } .counter-container+.counter-container { @@ -41,8 +41,8 @@ .qa { .qa-accept { - font-size: 2rem; - font-weight: 200; + font-size: 3rem; + font-weight: 800; color: #ccc; cursor: pointer; } @@ -58,10 +58,10 @@ } .qa-vote { - font-size: 2rem; - font-weight: 200; + font-size: 3rem; color: #ccc; cursor: pointer; + font-weight: 800; &.voted { color: #81e27d; @@ -95,7 +95,7 @@ .score { &.closed { - background: #f00; + background: #ee5649; } &.open {