diff --git a/index.php b/index.php
index f7e569206bf53173ff4e18dba749cde3b6ca6fc3..b6b1a7bf02cfa1deddf7b44061e04362ecc38121 100644
--- a/index.php
+++ b/index.php
@@ -857,7 +857,10 @@
searches.map((search, search_index) => {
searches_table.append(`
<tr>
- <td><a href="javascript:edit_search(${search_index});" class="button button-primary">Edit</a></td>
+ <td>
+ <a href="javascript:edit_search(${search_index});" class="button button-primary">Edit</a>
+ <a href="javascript:delete_search(${search_index});" class="button button-danger"><span class="dashicons dashicons-trash" style="margin-top: 4px;"></span></a>
+ </td>
<td>[corpora_search id="${search.slug}"]</td>
<td>${search.name}</td>
<td>${search.content_type}</td>
@@ -1037,6 +1040,12 @@
tb_remove()
}
+ function delete_search(search_index) {
+ searches.splice(search_index, 1)
+ searches_field.val(JSON.stringify(searches))
+ setup_searches(corpus)
+ }
+
function render_field_search_options(opts) {
let field_table = jQuery('#corpora_search_field_options_table')
field_table.empty()
diff --git a/js/corpora.js b/js/corpora.js
index 676216b37415c2452e2ff47ed9568b9d2e3e0ae7..091a306de916d3009f64522192fc2266670593a2 100644
--- a/js/corpora.js
+++ b/js/corpora.js
@@ -321,6 +321,8 @@ class CorpusSearch {
this.total_indicator = jQuery(`#corpora_search_table_${this.search.slug}_total_indicator`)
this.table_header = jQuery(`#corpora_serach_table_${this.search.slug}_header`)
this.table_body = jQuery(`#corpora_serach_table_${this.search.slug}_body`)
+
+ // setup column headers
this.fields.forEach(f => {
if (f.show_in_searches) {
this.table_header.append(corporaTemplates.searchHeader({
@@ -337,12 +339,14 @@ class CorpusSearch {
})
if (this.fields.length > 1) this.field_selector.show()
+ // default search settings
this.search_timer = null
this.search_params = {
'page-size': this.search.page_size,
'page': 1,
}
+ // setup default sorting, if configured
if (this.search.default_sort && this.search.default_sort.field) {
this.search_params[`s_${this.search.default_sort.field}`] = this.search.default_sort.direction
jQuery(`th.corpora-search-table-header-cell[data-field="${this.search.default_sort.field}"]`).addClass(this.search.default_sort.direction)
@@ -398,6 +402,7 @@ class CorpusSearch {
}, 1000);
})
+ // column header click for sorting
jQuery('.corpora-search-table-header-cell[data-sortable=true]').click(function() {
let cell = jQuery(this)
let param = `s_${cell.data('field')}`