diff --git a/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php b/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php index ec72aaadd7..1f265f7134 100644 --- a/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php +++ b/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php @@ -185,6 +185,7 @@ public function listPublicationAction(PhraseaApplication $app, Request $request) { $exposeName = $request->get('exposeName'); $page = empty($request->get('page')) ? 1 : $request->get('page'); + $title = urlencode($request->get('title')); if ($exposeName == null) { return $app->json([ @@ -253,7 +254,8 @@ public function listPublicationAction(PhraseaApplication $app, Request $request) $exposeClient = $proxyConfig->getClientWithOptions($clientOptions); try { - $uri = '/publications?flatten=true&order[createdAt]=desc&page=' . $page; + $uri = '/publications?flatten=true&order[createdAt]=desc&page=' . $page . '&title=' . $title; + if ($request->get('mine') && $exposeConfiguration['connection_kind'] === 'password') { $uri .= '&mine=true'; } @@ -307,9 +309,22 @@ public function listPublicationAction(PhraseaApplication $app, Request $request) $exposeFrontBasePath = \p4string::addEndSlash($exposeConfiguration['expose_front_uri']); if ($request->get('format') == 'pub-list') { + $publicationsList = []; + + foreach ($publications as $key => $publication) { + $publicationsList[$key]['id'] = $basePath . '/' . $publication['id']; + $publicationsList[$key]['text'] = $publication['title']; + } + + $pagination = ['more' => false]; + if ($nextPage) { + $pagination = ['more' => true]; + } + return $app->json([ - 'publications' => $publications, - 'basePath' => $basePath + 'publications' => $publicationsList, + 'basePath' => $basePath, + 'pagination' => $pagination ]); } diff --git a/package.json b/package.json index ed013eae32..b9cf58b97d 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "npm-modernizr": "^2.8.3", "pusher-js": "^8.3.0", "requirejs": "^2.3.5", + "select2": "^4.1.0-rc.0", "tinymce": "^4.0.28", "underscore": "^1.8.3", "zxcvbn": "^4.4.2" diff --git a/resources/gulp/build.js b/resources/gulp/build.js index 9ac912d5e5..4f7cc205da 100644 --- a/resources/gulp/build.js +++ b/resources/gulp/build.js @@ -51,6 +51,7 @@ gulp.task('build-vendors', [ 'build-jquery-test-paths', 'build-simple-colorpicker', 'build-jquery-datetimepicker', - 'build-pusher-js' + 'build-pusher-js', + 'build-select2' ], function () { }); diff --git a/resources/gulp/components/vendors/select2.js b/resources/gulp/components/vendors/select2.js new file mode 100644 index 0000000000..66826eced0 --- /dev/null +++ b/resources/gulp/components/vendors/select2.js @@ -0,0 +1,8 @@ +var gulp = require('gulp'); +var config = require('../../config.js'); +var utils = require('../../utils.js'); + +gulp.task('build-select2', [], function(){ + return gulp.src([config.paths.nodes + 'select2/**']) + .pipe(gulp.dest(config.paths.build + 'vendors/select2')); +}); diff --git a/templates/web/prod/WorkZone/ExposeEdit.html.twig b/templates/web/prod/WorkZone/ExposeEdit.html.twig index 9e207466b3..1dafd340c0 100644 --- a/templates/web/prod/WorkZone/ExposeEdit.html.twig +++ b/templates/web/prod/WorkZone/ExposeEdit.html.twig @@ -44,13 +44,13 @@
-
+
{% if publication.parent.id %} {% set parentId = publication.parent.id %} {% endif %} - +
+
@@ -158,6 +157,33 @@ } $(document).ready(function () { + + $("#publication_parent").select2({ + ajax: { + url: `/prod/expose/list-publication/`, + data: function (params) { + let exposeName = $('#expose_list').val(); + // Query parameters will be ?title=[term]&exposeName=[exposeName]&format=pub-list&page=[page] + + return { + title: params.term, + exposeName: exposeName, + format: 'pub-list', + editable: 1, + page: params.page || 1 + }; + }, + processResults: function (data) { + return { + results: data.publications, + pagination: data.pagination + }; + }, + delay: 250 + }, + dropdownParent: $('#DIALOG-expose-add') + }); + $.datetimepicker.setLocale('{{ app['locale'] }}'); $(".new-use-datepicker").datetimepicker({ @@ -345,17 +371,6 @@ removeSecurityFieldDialogAdd(); }); - /**Selected Parent info **/ - $(document).on('change', '#publication_parent', function (e) { - var selectedparent = $(this).children('option:selected'); - if (selectedparent.val() !== "") { - $('#parent_info').html('').append('

Title : ' + selectedparent.data('title') + '

Slug: ' + selectedparent.data('slug') + '

'); - } else { - $('#parent_info').html(''); - } - }); - - $('#DIALOG-expose-add').on('submit', '#publication-json', function (e) { e.preventDefault(); removeSecurityFieldDialogAdd(); @@ -436,18 +451,6 @@ $('#DIALOG-expose-add').dialog('close'); }); - $.ajax({ - type: "GET", - url: `/prod/expose/list-publication/?format=pub-list&exposeName=` + exposeName, - success: function (data) { - $('#DIALOG-expose-add #publication_parent').empty().html(''); - var i = 0; - for ( ;i < data.publications.length; i++) { - $('#DIALOG-expose-add select#publication_parent').append(''); - } - } - }); - $.ajax({ type: "GET", url: `/prod/expose/list-profile?exposeName=` + exposeName, @@ -478,5 +481,12 @@ .publication-block .ui-widget.hide { display: none; } + .select2-dropdown { + z-index: 4000; + } + .select2-container { + color: #555; + font-size: 14px; + } {% endmacro %} diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index a7dba2e875..519c46f298 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -68,6 +68,8 @@ {% block stylesheet %} + +