mirror of
https://github.com/Karaka-Management/oms-QA.git
synced 2026-02-03 01:58:40 +00:00
First dashboard draft (test)
This commit is contained in:
parent
5a9bd05643
commit
70a27d4a47
|
|
@ -110,6 +110,7 @@ class Installer extends InstallerAbstract
|
|||
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'qa_answer` (
|
||||
`qa_answer_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`qa_answer_status` int(11) NOT NULL,
|
||||
`qa_answer_accepted` tinyint(1) NOT NULL,
|
||||
`qa_answer_answer` text NOT NULL,
|
||||
`qa_answer_created_by` int(11) NOT NULL,
|
||||
`qa_answer_created_at` datetime NOT NULL,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use phpOMS\Router\RouteVerb;
|
|||
return [
|
||||
'^.*/backend/qa/dashboard.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Knowledgebase\Controller:viewQADashboard',
|
||||
'dest' => '\Modules\QA\Controller:viewQADashboard',
|
||||
'verb' => RouteVerb::GET,
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ use phpOMS\Module\ModuleAbstract;
|
|||
use phpOMS\Module\WebInterface;
|
||||
use phpOMS\Views\View;
|
||||
|
||||
use Modules\QA\Models\QAQuestionMapper;
|
||||
|
||||
/**
|
||||
* Task class.
|
||||
*
|
||||
|
|
@ -77,4 +79,26 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
protected static $dependencies = [
|
||||
];
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return \Serializable
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function viewQADashboard(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||
{
|
||||
$view = new View($this->app, $request, $response);
|
||||
$view->setTemplate('/Modules/QA/Theme/Backend/qa-dashboard');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006001001, $request, $response));
|
||||
|
||||
$list = QAQuestionMapper::getNewest(50);
|
||||
$view->setData('questions', $list);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ class QAAnswer implements \JsonSerializable
|
|||
|
||||
private $question = 0;
|
||||
|
||||
private $isAccepted = false;
|
||||
|
||||
private $createdBy = 0;
|
||||
|
||||
private $createdAt = null;
|
||||
|
|
@ -80,6 +82,17 @@ class QAAnswer implements \JsonSerializable
|
|||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function setAccepted(bool $accepted) /* : void */
|
||||
{
|
||||
$this->isAccepted = $accepted;
|
||||
}
|
||||
|
||||
public function isAccepted() : bool
|
||||
{
|
||||
return $this->isAccepted;
|
||||
}
|
||||
|
||||
public function getCreatedBy() : int
|
||||
{
|
||||
return $this->createdBy;
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class QAAnswerMapper extends DataMapperAbstract
|
|||
'qa_answer_answer' => ['name' => 'qa_answer_answer', 'type' => 'string', 'internal' => 'answer'],
|
||||
'qa_answer_question' => ['name' => 'qa_answer_question', 'type' => 'int', 'internal' => 'question'],
|
||||
'qa_answer_status' => ['name' => 'qa_answer_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'qa_answer_accepted' => ['name' => 'qa_answer_accepted', 'type' => 'int', 'internal' => 'isAccepted'],
|
||||
'qa_answer_created_by' => ['name' => 'qa_answer_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'qa_answer_created_at' => ['name' => 'qa_answer_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -69,6 +69,17 @@ class QAQuestion implements \JsonSerializable
|
|||
$this->language = $language;
|
||||
}
|
||||
|
||||
public function isAnswered() : bool
|
||||
{
|
||||
foreach($this->answers as $answer) {
|
||||
if($answer->isAccepted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
$questions = $this->getData('questions');
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<?php foreach($questions as $question) : ?>
|
||||
<section class="box wf-100">
|
||||
<?= count($question->getAnswers()); ?> <?= $question->getName(); ?>
|
||||
<?php $badges = $question->getBadges(); foreach($badges as $badge) : ?>
|
||||
<?= $badge->getName(); ?>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user