From 03ae728dbd3157a79c9412fc6554b5205fe6d4ad Mon Sep 17 00:00:00 2001 From: kgamauf Date: Tue, 15 Apr 2014 10:45:47 +0200 Subject: [PATCH 1/2] Added the possibility to add custom fields to the query via a input field. --- app/controllers/collection.php | 3 ++- js/collection.js | 20 +++++++++++++++++++- themes/default/views/collection/index.php | 3 ++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/controllers/collection.php b/app/controllers/collection.php index a53382c..8455082 100644 --- a/app/controllers/collection.php +++ b/app/controllers/collection.php @@ -162,6 +162,7 @@ public function doIndex() { if (!is_array($this->queryFields)) { $this->queryFields = array(); } + $this->nativeFields = array_merge($this->nativeFields, $this->queryFields); $this->indexFields = $db->selectCollection($this->collection)->getIndexInfo(); $this->recordsCount = $db->selectCollection($this->collection)->count(); @@ -1073,4 +1074,4 @@ public function doCollectionImport() { } } -?> \ No newline at end of file +?> diff --git a/js/collection.js b/js/collection.js index c723975..fddb1b0 100644 --- a/js/collection.js +++ b/js/collection.js @@ -1216,8 +1216,26 @@ function showMoreDocMenus(button, index) { }); } } + +/** + * Add a custom field to query + */ +function addCustomFieldToQuery() { + var obj = $('#add_custom_field'); + var field_name = obj.val(); + + if (field_name.length === 0) { + return; + } + + $('#query_fields_list ul').append('
  • '); + obj.val(''); + + return false; +} + $(function () { $(document).click(function () { $(".doc_menu").hide(); }); -}); \ No newline at end of file +}); diff --git a/themes/default/views/collection/index.php b/themes/default/views/collection/index.php index c15667e..fa0ca93 100644 --- a/themes/default/views/collection/index.php +++ b/themes/default/views/collection/index.php @@ -101,6 +101,7 @@ /> +
    @@ -412,4 +413,4 @@ \ No newline at end of file +
    From 740c30f67be292d662181987d4e763c72e921b59 Mon Sep 17 00:00:00 2001 From: kgamauf Date: Tue, 15 Apr 2014 10:53:48 +0200 Subject: [PATCH 2/2] Bugfix: Only show every field only once in the list of fields. --- app/controllers/collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/collection.php b/app/controllers/collection.php index 8455082..36d7135 100644 --- a/app/controllers/collection.php +++ b/app/controllers/collection.php @@ -162,7 +162,7 @@ public function doIndex() { if (!is_array($this->queryFields)) { $this->queryFields = array(); } - $this->nativeFields = array_merge($this->nativeFields, $this->queryFields); + $this->nativeFields = array_unique(array_merge($this->nativeFields, $this->queryFields)); $this->indexFields = $db->selectCollection($this->collection)->getIndexInfo(); $this->recordsCount = $db->selectCollection($this->collection)->count();