This commit is contained in:
Dennis Eichhorn 2024-02-04 20:34:12 +00:00
parent 828989a4e1
commit b44c01d622
8 changed files with 172 additions and 8 deletions

43
Admin/Install/Search.php Normal file
View File

@ -0,0 +1,43 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Kanban\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Kanban\Admin\Install;
use phpOMS\Application\ApplicationAbstract;
/**
* Search class.
*
* @package Modules\Kanban\Admin\Install
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class Search
{
/**
* Install navigation providing
*
* @param ApplicationAbstract $app Application
* @param string $path Module path
*
* @return void
*
* @since 1.0.0
*/
public static function install(ApplicationAbstract $app, string $path) : void
{
\Modules\Search\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/SearchCommands.php']);
}
}

View File

@ -0,0 +1,32 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Kanban
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
use Modules\Kanban\Controller\SearchController;
use Modules\Kanban\Models\PermissionCategory;
use phpOMS\Account\PermissionType;
use phpOMS\Router\RouteVerb;
return [
'^(?!:).+.*?' => [
[
'dest' => '\Modules\Kanban\Controller\SearchController:searchGeneral',
'verb' => RouteVerb::ANY,
'permission' => [
'module' => SearchController::NAME,
'type' => PermissionType::READ,
'state' => PermissionCategory::BOARD,
],
],
],
];

View File

@ -97,7 +97,7 @@ final class ApiController extends Controller
}
if (!empty($uploadedFiles = $request->files)) {
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
$uploaded = $this->app->moduleManager->get('Media', 'Api')->uploadFiles(
[],
[],
$uploadedFiles,
@ -111,10 +111,9 @@ final class ApiController extends Controller
}
}
if (!empty($mediaFiles = $request->getDataJson('media'))) {
foreach ($mediaFiles as $media) {
$card->files[] = new NullMedia($media);
}
$mediaFiles = $request->getDataJson('media');
foreach ($mediaFiles as $media) {
$card->files[] = new NullMedia($media);
}
return $card;
@ -194,7 +193,7 @@ final class ApiController extends Controller
$comment->createdBy = new NullAccount($request->header->account);
if (!empty($uploadedFiles = $request->files)) {
$uploaded = $this->app->moduleManager->get('Media')->uploadFiles(
$uploaded = $this->app->moduleManager->get('Media', 'Api')->uploadFiles(
[],
[],
$uploadedFiles,

View File

@ -0,0 +1,77 @@
<?php
/**
* Jingga
*
* PHP Version 8.1
*
* @package Modules\Kanban
* @copyright Dennis Eichhorn
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
declare(strict_types=1);
namespace Modules\Kanban\Controller;
use Modules\Kanban\Models\KanbanCardMapper;
use phpOMS\DataStorage\Database\Query\OrderType;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\System\MimeType;
/**
* Search class.
*
* @package Modules\Kanban
* @license OMS License 2.0
* @link https://jingga.app
* @since 1.0.0
*/
final class SearchController extends Controller
{
/**
* Api method to search for tags
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param array $data Generic data
*
* @return void
*
* @api
*
* @since 1.0.0
*/
public function searchGeneral(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
{
/** @var \Modules\Kanban\Models\KanbanCard[] $docs */
$docs = KanbanCardMapper::getAll()
->with('tags')
->with('tags/title')
->where('name', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE')
->where('descriptionRaw', '%' . ($request->getDataString('search') ?? '') . '%', 'LIKE', 'OR')
->where('tags/title/language', $response->header->l11n->language)
->sort('createdAt', OrderType::DESC)
->limit(8)
->execute();
$results = [];
foreach ($docs as $doc) {
$results[] = [
'title' => $doc->name,
'summary' => '',
'link' => '{/base}/kanban/card?id=' . $doc->id,
'account' => '',
'createdAt' => $doc->createdAt,
'image' => '',
'tags' => $doc->tags,
'type' => 'list_links',
'module' => 'Kanban',
];
}
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
$response->add($request->uri->__toString(), $results);
}
}

View File

@ -0,0 +1,7 @@
{
"id": "{id}",
"title": "{title}",
"content": "{content}",
"language": "{language}",
"tags": ["{tags}"]
}

View File

@ -0,0 +1,4 @@
{
"id": "{id}",
"content": "{content}"
}

View File

@ -62,7 +62,7 @@ class KanbanCard implements \JsonSerializable
public int $type = CardType::TEXT;
/**
* Color schme.
* Color scheme.
*
* @var string
* @since 1.0.0

View File

@ -24,7 +24,9 @@
},
"providing": {
"Navigation": "*",
"Media": "*"
"Media": "*",
"Kanban": "*",
"Search": "*"
},
"load": [
{