From 213fc02d236503751ca1da13b975c71aae9bd45c Mon Sep 17 00:00:00 2001
From: blavenie <benoit.lavenier@e-is.pro>
Date: Tue, 7 Nov 2017 11:38:53 +0100
Subject: [PATCH] [enh] ES Document search: open JSON document on item click

---
 www/plugins/es/js/controllers/document-controllers.js | 9 ++++++---
 www/plugins/es/templates/document/item_document.html  | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/www/plugins/es/js/controllers/document-controllers.js b/www/plugins/es/js/controllers/document-controllers.js
index f2274f6c..77f3a36e 100644
--- a/www/plugins/es/js/controllers/document-controllers.js
+++ b/www/plugins/es/js/controllers/document-controllers.js
@@ -25,7 +25,7 @@ angular.module('cesium.es.document.controllers', ['cesium.es.services'])
 ;
 
 function ESDocumentLookupController($scope, $ionicPopover, $location, $timeout,
-                                    csSettings, csWallet, UIUtils, esDocument) {
+                                    csSettings, csWallet, UIUtils, esHttp, esDocument) {
   'ngInject';
 
   $scope.search = {
@@ -157,8 +157,11 @@ function ESDocumentLookupController($scope, $ionicPopover, $location, $timeout,
       });
   };
 
-  $scope.selectDocument = function(doc) {
-    console.debug("Selected document: ", doc);
+  $scope.selectDocument = function(event, doc) {
+    console.debug("Selected document: ", doc, esHttp);
+
+    var url = esHttp.getUrl('/{0}/{1}/_search?pretty&q=_id:{2}'.format(doc.index, doc.type, doc.id));
+    return $scope.openLink(event, url);
   };
 
   $scope.toggleSort = function(sort){
diff --git a/www/plugins/es/templates/document/item_document.html b/www/plugins/es/templates/document/item_document.html
index 2f9a8d80..c2f764fc 100644
--- a/www/plugins/es/templates/document/item_document.html
+++ b/www/plugins/es/templates/document/item_document.html
@@ -1,6 +1,6 @@
 <ion-item id="doc-{{::doc.id}}"
           class="item item-document item-icon-left ink {{::ionItemClass}} no-padding-top no-padding-bottom"
-          ng-click="selectDocument(doc)">
+          ng-click="selectDocument($event, doc)">
 
   <i class="icon ion-document stable" ng-if=":rebind:!doc.avatar"></i>
   <i class="avatar" ng-if=":rebind:doc.avatar" style="background-image: url('{{:rebind:doc.avatar.src}}')"></i>
-- 
GitLab