Commit 48f8942b authored by Bryan Tarpley's avatar Bryan Tarpley
Browse files

adding ability to delete configured searches

parent 9ff54a1f
Showing with 15 additions and 1 deletion
+15 -1
......@@ -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()
......
......@@ -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')}`
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment