Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bryan Tarpley
wp_corpora
Commits
48f8942b
Commit
48f8942b
authored
1 year ago
by
Bryan Tarpley
Browse files
Options
Download
Email Patches
Plain Diff
adding ability to delete configured searches
parent
9ff54a1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
index.php
+10
-1
index.php
js/corpora.js
+5
-0
js/corpora.js
with
15 additions
and
1 deletion
+15
-1
index.php
+
10
-
1
View file @
48f8942b
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
js/corpora.js
+
5
-
0
View file @
48f8942b
...
...
@@ -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
'
)}
`
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help