From 7d502358af8274b522b458c1a535ae69a887e2b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Adamczyk?= Date: Mon, 30 Oct 2017 15:08:57 +0100 Subject: [PATCH] EZP-28055: As a v2 Editor I want to search for content items by entering a search keyword EZP-28055: As a v2 Editor I want to search for content items by entering a search keyword EZP-28055: As a v2 Editor I want to search for content items by entering a search keyword EZP-28055: As a v2 Editor I want to search for content items by entering a search keyword EZP-28055: As a v2 Editor I want to search for content items by entering a search keyword EZP-28055: As a v2 Editor I want to search for content items by entering a search keyword --- composer.json | 3 - src/bundle/Controller/SearchController.php | 142 ++++++++++++++++++ src/bundle/Resources/config/routing.yml | 6 + .../Resources/public/css/ezplatform.min.css | 3 +- src/bundle/Resources/public/scss/_icons.scss | 6 + .../Resources/translations/search.en.xliff | 96 ++++++++++++ .../views/admin/search/list.html.twig | 72 +++++++++ .../views/admin/search/search.html.twig | 25 +++ .../views/admin/search/search_form.html.twig | 13 ++ .../admin/search/search_table_row.html.twig | 16 ++ .../views/admin/trash/list.html.twig | 9 +- .../views/content/locationview.html.twig | 9 +- .../views/dashboard/dashboard.html.twig | 8 +- src/bundle/Resources/views/layout.html.twig | 11 +- src/lib/Form/Data/Search/SearchData.php | 107 +++++++++++++ src/lib/Form/Factory/FormFactory.php | 19 +++ src/lib/Form/Type/Search/SearchType.php | 27 ++++ src/lib/Menu/LeftSidebarBuilder.php | 2 +- 18 files changed, 557 insertions(+), 17 deletions(-) create mode 100644 src/bundle/Controller/SearchController.php create mode 100644 src/bundle/Resources/translations/search.en.xliff create mode 100644 src/bundle/Resources/views/admin/search/list.html.twig create mode 100644 src/bundle/Resources/views/admin/search/search.html.twig create mode 100644 src/bundle/Resources/views/admin/search/search_form.html.twig create mode 100644 src/bundle/Resources/views/admin/search/search_table_row.html.twig create mode 100644 src/lib/Form/Data/Search/SearchData.php create mode 100644 src/lib/Form/Type/Search/SearchType.php diff --git a/composer.json b/composer.json index 6c2afc37d9..dbc035038b 100644 --- a/composer.json +++ b/composer.json @@ -22,9 +22,6 @@ "ezsystems/ez-support-tools": "^0.1@dev", "knplabs/knp-menu-bundle": "^2.1" }, - "require-dev": { - "phpunit/phpunit": "^6.4" - }, "extra": { "branch-alias": { "dev-master": "1.0.x-dev" diff --git a/src/bundle/Controller/SearchController.php b/src/bundle/Controller/SearchController.php new file mode 100644 index 0000000000..d3e6ec03b4 --- /dev/null +++ b/src/bundle/Controller/SearchController.php @@ -0,0 +1,142 @@ +searchService = $searchService; + $this->pagerContentToDataMapper = $pagerContentToDataMapper; + $this->router = $router; + $this->formFactory = $formFactory; + $this->submitHandler = $submitHandler; + } + + /** + * Renders the simple search form and search results. + * + * @param Request $request + * + * @return Response + */ + public function searchAction(Request $request): Response + { + $search = $request->query->get('search'); + $limit = $search['limit'] ?? 10; + $page = $search['page'] ?? 1; + $query = $search['query']; + + $form = $this->formFactory->createSearchForm(new SearchData($limit, $page, $query), 'search', [ + 'method' => 'GET', + 'csrf_protection' => false, + ]); + + $form->handleRequest($request); + + if ($form->isSubmitted()) { + $result = $this->submitHandler->handle($form, function (SearchData $data) use ($form) { + $limit = $data->getLimit(); + $page = $data->getPage(); + $queryString = $data->getQuery(); + + $query = new Query(); + $query->filter = new Criterion\LogicalAnd( + [ + new Criterion\Visibility(Criterion\Visibility::VISIBLE), + new Criterion\FullText($queryString), + ] + ); + + $query->limit = $limit; + $query->offset = ($page - 1) * $limit; + $query->sortClauses[] = new SortClause\DateModified(Query::SORT_ASC); + + $pagerfanta = new Pagerfanta( + new ContentSearchAdapter( + $query, + $this->searchService + ) + ); + + $pagerfanta->setMaxPerPage($limit); + $pagerfanta->setCurrentPage($page); + + $urlGenerator = $this->router; + + $routeGenerator = function ($page) use (&$urlGenerator, $data) { + return $urlGenerator->generate('ezplatform.search', [ + 'search' => [ + 'query' => $data->getQuery(), + 'page' => $page, + 'limit' => $data->getLimit(), + ], + ]); + }; + + $pagination = (new TwitterBootstrap4View())->render($pagerfanta, $routeGenerator); + + return $this->render('@EzPlatformAdminUi/admin/search/list.html.twig', [ + 'results' => $this->pagerContentToDataMapper->map($pagerfanta), + 'form' => $form->createView(), + 'pagination' => $pagination, + 'pagerfanta' => $pagerfanta, + ]); + }); + + if ($result instanceof Response) { + return $result; + } + } + + return $this->render('@EzPlatformAdminUi/admin/search/search.html.twig', [ + 'form' => $form->createView(), + ]); + } +} diff --git a/src/bundle/Resources/config/routing.yml b/src/bundle/Resources/config/routing.yml index 6bc96c4849..0091537409 100644 --- a/src/bundle/Resources/config/routing.yml +++ b/src/bundle/Resources/config/routing.yml @@ -320,3 +320,9 @@ ezplatform.location.swap: methods: ['POST'] defaults: _controller: 'EzPlatformAdminUiBundle:Location:swap' + +ezplatform.search: + path: /search + methods: ['GET'] + defaults: + _controller: 'EzPlatformAdminUiBundle:Search:search' diff --git a/src/bundle/Resources/public/css/ezplatform.min.css b/src/bundle/Resources/public/css/ezplatform.min.css index b79322b853..9210e976e9 100644 --- a/src/bundle/Resources/public/css/ezplatform.min.css +++ b/src/bundle/Resources/public/css/ezplatform.min.css @@ -1 +1,2 @@ -html{height:100%;width:100%}body{height:100%}.ez-main-row{min-height:calc(100vh - 60px)}.ez-dashboard .ez-main-row{background-color:#bbb}.ez-side-menu .ez-icon,.ez-context-menu .ez-icon{display:block;margin:0 auto;fill:#fff}.ezimage-field img{display:inline-block;max-width:100%;width:auto;height:auto}button.btn{white-space:normal}.ez-field-edit{margin:1rem 0}.nav-tabs{border-bottom:2px solid #fafafa;background-color:#e5e3e3}.nav-tabs .nav-item{margin-bottom:0}.nav-tabs .nav-link{color:#878787}.nav-tabs .nav-link:hover{background-color:#bbb;border-color:#bbb}.nav-tabs .nav-link.active{background-color:#fafafa;border-color:#fafafa}.ez-dashboard .nav-tabs{border-bottom:2px solid #445A64;background-color:#fff;margin-bottom:1rem}.ez-dashboard .nav-tabs .nav-link.active{background-color:#445A64;border-color:#445A64;color:#fff}.ez-content-view .nav-tabs{border-bottom:2px solid #e5e3e3}.ez-content-view .nav-tabs .nav-item{margin-bottom:-2px}.ez-table-header{display:flex;justify-content:space-between;background-color:#a8c8d5;align-items:center;padding:.5rem 1rem}.ez-table-header h5{margin-bottom:0;font-weight:bold}.ez-table-header .ez-icon{width:1rem;height:1rem;fill:#fff;margin-right:.5rem}.ez-dashboard .table thead{background-color:#62828F;color:#fff}.ez-dashboard .table thead th{border-bottom:none}.ez-content-view .table{margin-bottom:3rem}.ez-header{background-color:#e5e3e3}.ez-header .breadcrumb{margin-bottom:0;padding-left:0}.ez-icon{width:2rem;height:2rem}.btn-icon .ez-icon{width:1.5rem;height:1.5rem;fill:#f15a10}.ez-field-edit--ezauthor .btn-icon .ez-icon{fill:#fff;width:1rem;height:1rem}.ez-main-nav .ez-icon{width:1.5rem;height:1.5rem}.ez-page-title{padding-bottom:1rem}.ez-page-title h2{margin-bottom:0}.ez-page-title h5{padding-left:2.5rem;color:#bbb}.btn-icon{padding:0}.ez-field-edit--ezauthor .btn-icon{border-radius:50%;height:2rem;width:2rem}.ez-fieldgroup .ez-fieldgroup-name{color:#0f6d95;border-bottom:2px solid #0f6d95;padding-bottom:.5rem}.ez-fieldgroup .ez-content-field{padding-left:2rem;margin-bottom:1.5rem}.ez-fieldgroup .ez-content-field .ez-content-field-name{background-color:#e5e3e3;margin-bottom:0;padding:.5rem 1.5rem;border-top-right-radius:5px;border-top-left-radius:5px}.ez-fieldgroup .ez-content-field .ez-content-field-value{background-color:#fff;padding:1rem 1.5rem;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.ez-main-nav{padding:0;background-color:#f3f3f3}.ez-main-nav .nav-tabs{background-color:#f3f3f3;border:none;margin-bottom:0}.ez-main-nav .nav-tabs .nav-link{padding:1rem 2rem;color:#333;display:flex}.ez-main-nav .nav-tabs .nav-link .ez-icon{margin-right:.5rem}.ez-main-nav .nav-tabs .nav-link:hover{background-color:#f3f3f3;border-color:#f3f3f3}.ez-main-nav .nav-tabs .nav-link.active{background-color:#fff;border-color:#fff;color:#333}.ez-main-sub-nav{background-color:#fff;padding:0;padding-left:100px}.ez-main-sub-nav .navbar-nav .nav-link{padding:.8rem 1rem;color:#333}.ez-main-sub-nav .navbar-nav .nav-link.active{border-bottom:2px solid #f15a10;font-weight:bold}.ez-notifications-container{position:fixed;bottom:0;width:100%;line-height:2.1}.ez-notifications-container .alert{margin-bottom:0}.ez-field-edit .ez-field-edit__label.required:after,.ez-field-edit .ez-data-source__label.required:after{content:'*:'}.ez-field-edit.is-invalid .ez-field-edit__label-wrapper{color:#cb2540}.ez-field-edit.is-invalid .ez-field-edit__data{position:relative}.ez-field-edit.is-invalid .ez-field-edit__data:before{content:'!';position:absolute;top:0;left:-20px;width:20px;background:red;color:white;text-align:center;font-size:1.5rem;border-top-left-radius:5px;border-bottom-left-radius:5px}.ez-field-edit--ezauthor .ez-data-source__author{background-color:#e5e3e3;padding:1rem}.ez-field-edit--ezauthor .ez-data-source__label-wrapper .ez-data-source__label{margin-bottom:0}.ez-field-edit--ezauthor .ez-data-source__actions{display:flex;align-items:center;padding-top:1.5rem}.ez-field-edit--ezauthor .ez-data-source__actions button{margin:0 .5rem}.ez-field-edit--ezauthor.is-invalid .ez-data-source__field.is-invalid{color:#cb2540}.ez-field-edit--ezauthor.is-invalid .ez-field-edit__data:before{display:none}.ez-field-edit--ezauthor.is-invalid .ez-data-source__author{position:relative}.ez-field-edit--ezauthor.is-invalid .ez-data-source__author.is-invalid:before{content:'!';position:absolute;top:0;left:-20px;width:20px;background:red;color:white;text-align:center;font-size:1.5rem;border-top-left-radius:5px;border-bottom-left-radius:5px}.ez-field-edit--ezstring .ez-field-edit__data{width:50%}.ez-field-edit--ezemail .ez-field-edit__data{width:50%}.ez-field-edit--ezinteger .ez-field-edit__data{width:5rem}.ez-field-edit--ezfloat .ez-field-edit__data{width:5rem}.ez-field-edit--ezboolean .ez-data-source__label{position:relative;width:2rem;height:2.25rem;background-color:#bbb;margin-left:1.125rem}.ez-field-edit--ezboolean .ez-data-source__label input{display:none}.ez-field-edit--ezboolean .ez-data-source__label .ez-data-source__indicator{width:2rem;height:2rem;display:block;background-color:#fafafa;border-radius:50%;position:absolute;top:2px;left:0;transition:all .3s ease-in-out;transform:translateX(-50%)}.ez-field-edit--ezboolean .ez-data-source__label.is-checked{background-color:#0f6d95}.ez-field-edit--ezboolean .ez-data-source__label.is-checked .ez-data-source__indicator{transform:translateX(50%)}.ez-field-edit--ezboolean .ez-data-source__label.is-checked:before{background-color:#0f6d95}.ez-field-edit--ezboolean .ez-data-source__label.is-checked:after{background-color:#0f6d95}.ez-field-edit--ezboolean .ez-data-source__label:before,.ez-field-edit--ezboolean .ez-data-source__label:after{content:'';height:2.25rem;width:2.25rem;border-radius:50%;position:absolute;top:50%;background-color:#bbb;z-index:-1}.ez-field-edit--ezboolean .ez-data-source__label:before{left:0;transform:translate(-50%, -50%)}.ez-field-edit--ezboolean .ez-data-source__label:after{right:0;transform:translate(50%, -50%)}.ez-field-edit--ezurl .ez-field-edit__data{background-color:#e5e3e3;padding:1rem}.ez-field-edit--ezurl.is-invalid .ez-data-source__field--link{color:#cb2540} +html{height:100%;width:100%}body{height:100%}.ez-main-row{min-height:calc(100vh - 60px)}.ez-dashboard .ez-main-row{background-color:#bbb}.ez-side-menu .ez-icon,.ez-context-menu .ez-icon{display:block;margin:0 auto;fill:#fff}.ezimage-field img{display:inline-block;max-width:100%;width:auto;height:auto}button.btn{white-space:normal}.ez-field-edit{margin:1rem 0}.nav-tabs{border-bottom:2px solid #fafafa;background-color:#e5e3e3}.nav-tabs .nav-item{margin-bottom:0}.nav-tabs .nav-link{color:#878787}.nav-tabs .nav-link:hover{background-color:#bbb;border-color:#bbb}.nav-tabs .nav-link.active{background-color:#fafafa;border-color:#fafafa}.ez-dashboard .nav-tabs{border-bottom:2px solid #445A64;background-color:#fff;margin-bottom:1rem}.ez-dashboard .nav-tabs .nav-link.active{background-color:#445A64;border-color:#445A64;color:#fff}.ez-content-view .nav-tabs{border-bottom:2px solid #e5e3e3}.ez-content-view .nav-tabs .nav-item{margin-bottom:-2px}.ez-table-header{display:flex;justify-content:space-between;background-color:#a8c8d5;align-items:center;padding:.5rem 1rem}.ez-table-header h5{margin-bottom:0;font-weight:bold}.ez-table-header .ez-icon{width:1rem;height:1rem;fill:#fff;margin-right:.5rem}.ez-dashboard .table thead{background-color:#62828F;color:#fff}.ez-dashboard .table thead th{border-bottom:none}.ez-content-view .table{margin-bottom:3rem}.ez-header{background-color:#e5e3e3}.ez-header .breadcrumb{margin-bottom:0;padding-left:0}.ez-icon{width:2rem;height:2rem}.btn-icon .ez-icon{width:1.5rem;height:1.5rem;fill:#f15a10}.ez-field-edit--ezauthor .btn-icon .ez-icon{fill:#fff;width:1rem;height:1rem}.ez-main-nav .ez-icon{width:1.5rem;height:1.5rem}.ez-icon-search-button{fill:#fff;height:1rem;width:1rem}.ez-page-title{padding-bottom:1rem}.ez-page-title h2{margin-bottom:0}.ez-page-title h5{padding-left:2.5rem;color:#bbb}.btn-icon{padding:0}.ez-field-edit--ezauthor .btn-icon{border-radius:50%;height:2rem;width:2rem}.ez-fieldgroup .ez-fieldgroup-name{color:#0f6d95;border-bottom:2px solid #0f6d95;padding-bottom:.5rem}.ez-fieldgroup .ez-content-field{padding-left:2rem;margin-bottom:1.5rem}.ez-fieldgroup .ez-content-field .ez-content-field-name{background-color:#e5e3e3;margin-bottom:0;padding:.5rem 1.5rem;border-top-right-radius:5px;border-top-left-radius:5px}.ez-fieldgroup .ez-content-field .ez-content-field-value{background-color:#fff;padding:1rem 1.5rem;border-bottom-right-radius:5px;border-bottom-left-radius:5px}.ez-main-nav{padding:0;background-color:#f3f3f3}.ez-main-nav .nav-tabs{background-color:#f3f3f3;border:none;margin-bottom:0}.ez-main-nav .nav-tabs .nav-link{padding:1rem 2rem;color:#333;display:flex}.ez-main-nav .nav-tabs .nav-link .ez-icon{margin-right:.5rem}.ez-main-nav .nav-tabs .nav-link:hover{background-color:#f3f3f3;border-color:#f3f3f3}.ez-main-nav .nav-tabs .nav-link.active{background-color:#fff;border-color:#fff;color:#333}.ez-main-sub-nav{background-color:#fff;padding:0;padding-left:100px}.ez-main-sub-nav .navbar-nav .nav-link{padding:.8rem 1rem;color:#333}.ez-main-sub-nav .navbar-nav .nav-link.active{border-bottom:2px solid #f15a10;font-weight:bold}.ez-notifications-container{position:fixed;bottom:0;width:100%;line-height:2.1}.ez-notifications-container .alert{margin-bottom:0}.ez-field-edit .ez-field-edit__label.required:after,.ez-field-edit .ez-data-source__label.required:after{content:'*:'}.ez-field-edit.is-invalid .ez-field-edit__label-wrapper{color:#cb2540}.ez-field-edit.is-invalid .ez-field-edit__data{position:relative}.ez-field-edit.is-invalid .ez-field-edit__data:before{content:'!';position:absolute;top:0;left:-20px;width:20px;background:red;color:white;text-align:center;font-size:1.5rem;border-top-left-radius:5px;border-bottom-left-radius:5px}.ez-field-edit--ezauthor .ez-data-source__author{background-color:#e5e3e3;padding:1rem}.ez-field-edit--ezauthor .ez-data-source__label-wrapper .ez-data-source__label{margin-bottom:0}.ez-field-edit--ezauthor .ez-data-source__actions{display:flex;align-items:center;padding-top:1.5rem}.ez-field-edit--ezauthor .ez-data-source__actions button{margin:0 .5rem}.ez-field-edit--ezauthor.is-invalid .ez-data-source__field.is-invalid{color:#cb2540}.ez-field-edit--ezauthor.is-invalid .ez-field-edit__data:before{display:none}.ez-field-edit--ezauthor.is-invalid .ez-data-source__author{position:relative}.ez-field-edit--ezauthor.is-invalid .ez-data-source__author.is-invalid:before{content:'!';position:absolute;top:0;left:-20px;width:20px;background:red;color:white;text-align:center;font-size:1.5rem;border-top-left-radius:5px;border-bottom-left-radius:5px}.ez-field-edit--ezstring .ez-field-edit__data{width:50%}.ez-field-edit--ezemail .ez-field-edit__data{width:50%}.ez-field-edit--ezinteger .ez-field-edit__data{width:5rem}.ez-field-edit--ezfloat .ez-field-edit__data{width:5rem}.ez-field-edit--ezboolean .ez-data-source__label{position:relative;width:2rem;height:2.25rem;background-color:#bbb;margin-left:1.125rem}.ez-field-edit--ezboolean .ez-data-source__label input{display:none}.ez-field-edit--ezboolean .ez-data-source__label .ez-data-source__indicator{width:2rem;height:2rem;display:block;background-color:#fafafa;border-radius:50%;position:absolute;top:2px;left:0;transition:all .3s ease-in-out;transform:translateX(-50%)}.ez-field-edit--ezboolean .ez-data-source__label.is-checked{background-color:#0f6d95}.ez-field-edit--ezboolean .ez-data-source__label.is-checked .ez-data-source__indicator{transform:translateX(50%)}.ez-field-edit--ezboolean .ez-data-source__label.is-checked:before{background-color:#0f6d95}.ez-field-edit--ezboolean .ez-data-source__label.is-checked:after{background-color:#0f6d95}.ez-field-edit--ezboolean .ez-data-source__label:before,.ez-field-edit--ezboolean .ez-data-source__label:after{content:'';height:2.25rem;width:2.25rem;border-radius:50%;position:absolute;top:50%;background-color:#bbb;z-index:-1}.ez-field-edit--ezboolean .ez-data-source__label:before{left:0;transform:translate(-50%, -50%)}.ez-field-edit--ezboolean .ez-data-source__label:after{right:0;transform:translate(50%, -50%)}.ez-field-edit--ezurl .ez-field-edit__data{background-color:#e5e3e3;padding:1rem}.ez-field-edit--ezurl.is-invalid .ez-data-source__field--link{color:#cb2540} +/*# sourceMappingURL=ezplatform.min.css.map */ diff --git a/src/bundle/Resources/public/scss/_icons.scss b/src/bundle/Resources/public/scss/_icons.scss index f0161a72c8..f571206a6e 100644 --- a/src/bundle/Resources/public/scss/_icons.scss +++ b/src/bundle/Resources/public/scss/_icons.scss @@ -29,3 +29,9 @@ height: 1.5rem; } } + +.ez-icon-search-button{ + fill: $ez-white; + height: 1rem; + width: 1rem; +} diff --git a/src/bundle/Resources/translations/search.en.xliff b/src/bundle/Resources/translations/search.en.xliff new file mode 100644 index 0000000000..72e375327e --- /dev/null +++ b/src/bundle/Resources/translations/search.en.xliff @@ -0,0 +1,96 @@ + + + +
+ + The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message. +
+ + + Search results (%total%) + Search results (%total%) + key: search.header + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Search + Search + key: search.headline + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/search.html.twig + + + search.list + search.list + key: search.list + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Modified + Modified + key: search.modified + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Name + Name + key: search.name + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Sorry, no results were found for "%query%". + Sorry, no results were found for "%query%". + key: search.no_result + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + search.perform + search.perform + key: search.perform + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/search.html.twig + + + Check spelling of keywords. + Check spelling of keywords. + key: search.tips.check_spelling + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Try different keywords. + Try different keywords. + key: search.tips.different_keywords + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Try fewer keywords. Reducing keywords result in more matches. + Try fewer keywords. Reducing keywords result in more matches. + key: search.tips.fewer_keywords + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Some helpful search tips: + Some helpful search tips: + key: search.tips.headline + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Try more general keywords. + Try more general keywords. + key: search.tips.more_general_keywords + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Content Type + Content Type + key: search.type + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + + Viewing %viewing% out of %total% sub-items + Viewing %viewing% out of %total% sub-items + key: search.viewing + /../../../../vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/views/admin/search/list.html.twig + + +
+
diff --git a/src/bundle/Resources/views/admin/search/list.html.twig b/src/bundle/Resources/views/admin/search/list.html.twig new file mode 100644 index 0000000000..6391bf7147 --- /dev/null +++ b/src/bundle/Resources/views/admin/search/list.html.twig @@ -0,0 +1,72 @@ +{% extends "EzPlatformAdminUiBundle::layout.html.twig" %} + +{% trans_default_domain 'search' %} + +{% block pageTitle %}{% endblock %} + +{% block content %} +
+
+ + {% block left_sidebar %} + {{ parent() }} + {% endblock left_sidebar %} + +
+
+ {% include '@EzPlatformAdminUi/parts/page_title.html.twig' with { title: 'search.headline'|trans|desc('Search'), iconName: 'search' } %} + + {% include '@EzPlatformAdminUi/admin/search/search_form.html.twig' with { form: form } %} + +
+
{{ 'search.header'|trans({'%total%': pagerfanta.nbResults})|desc('Search results (%total%)') }}
+
+ + {% if results is empty %} + + + + +
+ {{ 'search.no_result'|trans({'%query%': form.vars.value.query})|desc('Sorry, no results were found for "%query%".') }} +
+
+
{{ 'search.tips.headline'|trans|desc('Some helpful search tips:') }}
+
    +
  • {{ 'search.tips.check_spelling'|trans|desc('Check spelling of keywords.') }}
  • +
  • {{ 'search.tips.different_keywords'|trans|desc('Try different keywords.') }}
  • +
  • {{ 'search.tips.more_general_keywords'|trans|desc('Try more general keywords.') }}
  • +
  • {{ 'search.tips.fewer_keywords'|trans|desc('Try fewer keywords. Reducing keywords result in more matches.') }}
  • +
+
+ {% else %} + + + + + + + + + + + {% for row in results %} + {% include '@EzPlatformAdminUi/admin/search/search_table_row.html.twig' with { row: row } %} + {% endfor %} + +
{{ 'search.name'|trans|desc('Name') }}{{ 'search.modified'|trans|desc('Modified') }}{{ 'search.type'|trans|desc('Content Type') }}
+
+
{{ 'search.viewing'|trans({'%viewing%': pagerfanta.currentPageResults|length, '%total%': pagerfanta.nbResults})|desc('Viewing %viewing% out of %total% sub-items') }}
+
+
+ {% if pagerfanta.haveToPaginate %} + {{ pagination|raw }} + {% endif %} +
+ {% endif %} +
+
+
+{% endblock %} + +{% block title %}{{ 'search.list'|trans }}{% endblock %} diff --git a/src/bundle/Resources/views/admin/search/search.html.twig b/src/bundle/Resources/views/admin/search/search.html.twig new file mode 100644 index 0000000000..d305bba196 --- /dev/null +++ b/src/bundle/Resources/views/admin/search/search.html.twig @@ -0,0 +1,25 @@ +{% extends "EzPlatformAdminUiBundle::layout.html.twig" %} + +{% trans_default_domain 'search' %} + +{% block pageTitle %}{% endblock %} + +{% block content %} +
+
+ + {% block left_sidebar %} + {{ parent() }} + {% endblock left_sidebar %} + +
+
+ {% include '@EzPlatformAdminUi/parts/page_title.html.twig' with { title: 'search.headline'|trans|desc('Search'), iconName: 'search' } %} + + {% include '@EzPlatformAdminUi/admin/search/search_form.html.twig' with { form: form } %} +
+
+
+{% endblock %} + +{% block title %}{{ 'search.perform'|trans }}{% endblock %} diff --git a/src/bundle/Resources/views/admin/search/search_form.html.twig b/src/bundle/Resources/views/admin/search/search_form.html.twig new file mode 100644 index 0000000000..5af83b9132 --- /dev/null +++ b/src/bundle/Resources/views/admin/search/search_form.html.twig @@ -0,0 +1,13 @@ +{{ form_start(form) }} +
+ {{ form_widget(form.query, {'attr': {'class': 'form-control'} }) }} + + + + +
+{{ form_end(form) }} diff --git a/src/bundle/Resources/views/admin/search/search_table_row.html.twig b/src/bundle/Resources/views/admin/search/search_table_row.html.twig new file mode 100644 index 0000000000..b0663d60e1 --- /dev/null +++ b/src/bundle/Resources/views/admin/search/search_table_row.html.twig @@ -0,0 +1,16 @@ + + + {{ row.name }} + + {{ row.modified|date('M d, Y h:iA') }} + {{ row.type }} + + + + + + \ No newline at end of file diff --git a/src/bundle/Resources/views/admin/trash/list.html.twig b/src/bundle/Resources/views/admin/trash/list.html.twig index ef80f6573a..4d54d45c9c 100644 --- a/src/bundle/Resources/views/admin/trash/list.html.twig +++ b/src/bundle/Resources/views/admin/trash/list.html.twig @@ -7,9 +7,11 @@ {% block content %}
-
{# @todo sidebars should be moved to layout.html.twig !! #} - {{ knp_menu_render('ezplatform_admin_ui.menu.content.sidebar_left', {'template': '@EzPlatformAdminUi/parts/menu/sidebar_left.html.twig'}) }} -
+ + {% block left_sidebar %} + {{ parent() }} + {% endblock left_sidebar %} +
{% include '@EzPlatformAdminUi/parts/page_title.html.twig' with { title: 'trash.headline'|trans|desc('Trash'), iconName: 'trash' } %} @@ -78,7 +80,6 @@ {% block javascripts %} {% javascripts 'bundles/ezplatformadminui/js/scripts/admin.trash.list.js' - 'bundles/ezplatformadminui/js/scripts/udw/browse.js' %} {% endjavascripts %} diff --git a/src/bundle/Resources/views/content/locationview.html.twig b/src/bundle/Resources/views/content/locationview.html.twig index 7fdbb740d4..7b5cc3ed2f 100644 --- a/src/bundle/Resources/views/content/locationview.html.twig +++ b/src/bundle/Resources/views/content/locationview.html.twig @@ -14,9 +14,11 @@ data-parent-content-type-identifier="{{ contentType.identifier }}" data-parent-content-type-id="{{ contentType.id }}">
-
- {{ knp_menu_render('ezplatform_admin_ui.menu.content.sidebar_left', {'template': '@EzPlatformAdminUi/parts/menu/sidebar_left.html.twig'}) }} -
+ + {% block left_sidebar %} + {{ parent() }} + {% endblock left_sidebar %} +
@@ -77,7 +79,6 @@ {% javascripts 'bundles/ezplatformadminui/js/scripts/admin.location.view.js' 'bundles/ezplatformadminui/js/scripts/admin.location.tab.js' - 'bundles/ezplatformadminui/js/scripts/udw/browse.js' 'bundles/ezplatformadminui/js/scripts/udw/move.js' 'bundles/ezplatformadminui/js/scripts/udw/copy.js' 'bundles/ezplatformadminui/js/scripts/udw/swap.js' diff --git a/src/bundle/Resources/views/dashboard/dashboard.html.twig b/src/bundle/Resources/views/dashboard/dashboard.html.twig index b217da8682..a3054f7c88 100644 --- a/src/bundle/Resources/views/dashboard/dashboard.html.twig +++ b/src/bundle/Resources/views/dashboard/dashboard.html.twig @@ -6,9 +6,11 @@ {% block content %}
-
- {{ knp_menu_render('ezplatform_admin_ui.menu.content.sidebar_left', {'template': '@EzPlatformAdminUi/parts/menu/sidebar_left.html.twig'}) }} -
+ + {% block left_sidebar %} + {{ parent() }} + {% endblock left_sidebar %} +
diff --git a/src/bundle/Resources/views/layout.html.twig b/src/bundle/Resources/views/layout.html.twig index 3d5359893b..9407fd8b12 100644 --- a/src/bundle/Resources/views/layout.html.twig +++ b/src/bundle/Resources/views/layout.html.twig @@ -44,7 +44,15 @@
- {% block content %}{% endblock %} + {% block content %} + + {% block left_sidebar %} +
{# @todo sidebars should be moved to layout.html.twig !! #} + {{ knp_menu_render('ezplatform_admin_ui.menu.content.sidebar_left', {'template': '@EzPlatformAdminUi/parts/menu/sidebar_left.html.twig'}) }} +
+ {% endblock left_sidebar %} + + {% endblock content %}
{% for label, messages in app.flashes %} @@ -67,6 +75,7 @@ 'assets/vendor/bootstrap/dist/js/bootstrap.min.js' 'bundles/ezplatformadminuimodules/js/UniversalDiscovery.module.js' 'bundles/ezplatformadminui/js/scripts/button.trigger.js' + 'bundles/ezplatformadminui/js/scripts/udw/browse.js' %} {% endjavascripts %} diff --git a/src/lib/Form/Data/Search/SearchData.php b/src/lib/Form/Data/Search/SearchData.php new file mode 100644 index 0000000000..ecf0a7a680 --- /dev/null +++ b/src/lib/Form/Data/Search/SearchData.php @@ -0,0 +1,107 @@ +limit = $limit; + $this->page = $page; + $this->query = $query; + } + + /** + * @param int $limit + * + * @return SearchData + */ + public function setLimit(int $limit): SearchData + { + $this->limit = $limit; + + return $this; + } + + /** + * @param int $page + * + * @return SearchData + */ + public function setPage(int $page): SearchData + { + $this->page = $page; + + return $this; + } + + /** + * @param string|null $query + * + * @return SearchData + */ + public function setQuery(?string $query): SearchData + { + $this->query = $query; + + return $this; + } + + /** + * @return int + */ + public function getLimit(): int + { + return $this->limit; + } + + /** + * @return int + */ + public function getPage(): int + { + return $this->page; + } + + /** + * @return string|null + */ + public function getQuery(): ?string + { + return $this->query; + } +} diff --git a/src/lib/Form/Factory/FormFactory.php b/src/lib/Form/Factory/FormFactory.php index 8a05d3ef4f..8869ccf8e2 100644 --- a/src/lib/Form/Factory/FormFactory.php +++ b/src/lib/Form/Factory/FormFactory.php @@ -29,6 +29,7 @@ use EzSystems\EzPlatformAdminUi\Form\Data\Role\RoleCreateData; use EzSystems\EzPlatformAdminUi\Form\Data\Role\RoleDeleteData; use EzSystems\EzPlatformAdminUi\Form\Data\Role\RoleUpdateData; +use EzSystems\EzPlatformAdminUi\Form\Data\Search\SearchData; use EzSystems\EzPlatformAdminUi\Form\Data\Section\SectionContentAssignData; use EzSystems\EzPlatformAdminUi\Form\Data\Section\SectionCreateData; use EzSystems\EzPlatformAdminUi\Form\Data\Section\SectionDeleteData; @@ -57,6 +58,7 @@ use EzSystems\EzPlatformAdminUi\Form\Type\Role\RoleCreateType; use EzSystems\EzPlatformAdminUi\Form\Type\Role\RoleDeleteType; use EzSystems\EzPlatformAdminUi\Form\Type\Role\RoleUpdateType; +use EzSystems\EzPlatformAdminUi\Form\Type\Search\SearchType; use EzSystems\EzPlatformAdminUi\Form\Type\Section\SectionContentAssignType; use EzSystems\EzPlatformAdminUi\Form\Type\Section\SectionCreateType; use EzSystems\EzPlatformAdminUi\Form\Type\Section\SectionDeleteType; @@ -525,4 +527,21 @@ public function deletePolicy( return $this->formFactory->createNamed($name, PolicyDeleteType::class, $data); } + + /** + * @param SearchData|null $data + * @param null|string $name + * @param array $options + * + * @return FormInterface + */ + public function createSearchForm( + SearchData $data = null, + ?string $name = null, + array $options = [] + ): FormInterface { + $name = $name ?: StringUtil::fqcnToBlockPrefix(SearchData::class); + + return $this->formFactory->createNamed($name, SearchType::class, $data, $options); + } } diff --git a/src/lib/Form/Type/Search/SearchType.php b/src/lib/Form/Type/Search/SearchType.php new file mode 100644 index 0000000000..baebc7e3dc --- /dev/null +++ b/src/lib/Form/Type/Search/SearchType.php @@ -0,0 +1,27 @@ +add('query', CoreSearchType::class) + ->add('page', HiddenType::class) + ->add('limit', HiddenType::class) + ; + } +} diff --git a/src/lib/Menu/LeftSidebarBuilder.php b/src/lib/Menu/LeftSidebarBuilder.php index e6367a4aa5..9b29d6bf55 100644 --- a/src/lib/Menu/LeftSidebarBuilder.php +++ b/src/lib/Menu/LeftSidebarBuilder.php @@ -47,8 +47,8 @@ public function createStructure(array $options): ItemInterface self::ITEM__SEARCH => $this->createMenuItem( self::ITEM__SEARCH, [ + 'route' => 'ezplatform.search', 'extras' => ['icon' => 'search'], - 'attributes' => ['disabled' => 'disabled'], ] ), self::ITEM__BROWSE => $this->createMenuItem(