Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Added the possibility to add custom fields to the query #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public function doIndex() {
if (!is_array($this->queryFields)) {
$this->queryFields = array();
}
$this->nativeFields = array_unique(array_merge($this->nativeFields, $this->queryFields));

$this->indexFields = $db->selectCollection($this->collection)->getIndexInfo();
$this->recordsCount = $db->selectCollection($this->collection)->count();
Expand Down Expand Up @@ -1079,4 +1080,4 @@ public function doCollectionImport() {
}
}

?>
?>
20 changes: 19 additions & 1 deletion js/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1277,8 +1277,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('<li><label><input type="checkbox" name="query_fields[]" value="' + field_name + '" checked="checked"/> ' + field_name + '</label></li>');
obj.val('');

return false;
}

$(function () {
$(document).click(function () {
$(".doc_menu").hide();
});
});
});
3 changes: 2 additions & 1 deletion themes/default/views/collection/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
/> <?php h($field); ?></label></li>
<?php endforeach; ?>
</ul>
<input type="text" value="" placeholder="Custom field" onkeydown="if (event.keyCode == 13) document.getElementById('add_custom_field_button').click()" id="add_custom_field"/> <input type="button" onclick="addCustomFieldToQuery();return false;" id="add_custom_field_button" value="+"/>
</div>
<div id="query_hints_list" class="fieldsmenu">
<div align="right" style="padding-right:10px;background:#999"><a href="#" onclick="closeQueryHints();return false;" title="Click to close"><img src="<?php render_theme_path() ?>/images/accept.png" width="14"/></a></div>
Expand Down Expand Up @@ -415,4 +416,4 @@
<!-- Show query history dialog -->
<div id="field_dialog_history" style="display:none">

</div>
</div>