diff --git a/Admin/Install/Search.php b/Admin/Install/Search.php new file mode 100644 index 0000000..8998e2b --- /dev/null +++ b/Admin/Install/Search.php @@ -0,0 +1,43 @@ + __DIR__ . '/SearchCommands.php']); + } +} diff --git a/Admin/Install/SearchCommands.php b/Admin/Install/SearchCommands.php new file mode 100644 index 0000000..a57aea0 --- /dev/null +++ b/Admin/Install/SearchCommands.php @@ -0,0 +1,32 @@ + [ + [ + 'dest' => '\Modules\Kanban\Controller\SearchController:searchGeneral', + 'verb' => RouteVerb::ANY, + 'permission' => [ + 'module' => SearchController::NAME, + 'type' => PermissionType::READ, + 'state' => PermissionCategory::BOARD, + ], + ], + ], +]; diff --git a/Controller/ApiController.php b/Controller/ApiController.php index d19f042..be57740 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -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, diff --git a/Controller/SearchController.php b/Controller/SearchController.php new file mode 100644 index 0000000..841ba9b --- /dev/null +++ b/Controller/SearchController.php @@ -0,0 +1,77 @@ +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); + } +} diff --git a/Models/Elastic/KanbanCard.json b/Models/Elastic/KanbanCard.json new file mode 100644 index 0000000..3aa7e63 --- /dev/null +++ b/Models/Elastic/KanbanCard.json @@ -0,0 +1,7 @@ +{ + "id": "{id}", + "title": "{title}", + "content": "{content}", + "language": "{language}", + "tags": ["{tags}"] +} \ No newline at end of file diff --git a/Models/Elastic/KanbanCardComment.json b/Models/Elastic/KanbanCardComment.json new file mode 100644 index 0000000..9371180 --- /dev/null +++ b/Models/Elastic/KanbanCardComment.json @@ -0,0 +1,4 @@ +{ + "id": "{id}", + "content": "{content}" +} \ No newline at end of file diff --git a/Models/KanbanCard.php b/Models/KanbanCard.php index 36ee38d..ec45d2c 100755 --- a/Models/KanbanCard.php +++ b/Models/KanbanCard.php @@ -62,7 +62,7 @@ class KanbanCard implements \JsonSerializable public int $type = CardType::TEXT; /** - * Color schme. + * Color scheme. * * @var string * @since 1.0.0 diff --git a/info.json b/info.json index ff30ff5..4f19249 100755 --- a/info.json +++ b/info.json @@ -24,7 +24,9 @@ }, "providing": { "Navigation": "*", - "Media": "*" + "Media": "*", + "Kanban": "*", + "Search": "*" }, "load": [ {