Skip to content

Commit

Permalink
Merge pull request SerpicoProject#409 from MaxNad/fix402
Browse files Browse the repository at this point in the history
Fixed the other search forms (related to SerpicoProject#402)
  • Loading branch information
BuffaloWill authored Feb 2, 2018
2 parents 6fc5c03 + 46d3810 commit fe9c493
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 38 deletions.
29 changes: 28 additions & 1 deletion public/js/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
//used to confirm deletion
// Used to search in tables
// credit to http://www.redotheweb.com/2013/05/15/client-side-full-text-search-in-css.html for this
function initSearch() {
var searchBox = document.getElementById('search');
var searchStyle = document.getElementById('search_style');

if (searchBox && searchStyle) {
// If the page loads with a value already present in the tables,
// lets run the search right away
if (searchBox.value) {
searchStyle.innerHTML = ".searchable:not([data-index*=\"" + searchBox.value.toLowerCase().replace(/</g, '&lt;').replace(/>/g, '&rt;').replace(/"/g, '&quot;') + "\"]) { display: none; }";
}

searchBox.addEventListener('input', function() {
if (!this.value) {
searchStyle.innerHTML = "";
return;
}
searchStyle.innerHTML = ".searchable:not([data-index*=\"" + this.value.toLowerCase().replace(/</g, '&lt;').replace(/>/g, '&rt;').replace(/"/g, '&quot;') + "\"]) { display: none; }";
});
}
}

$(document).ready(function(){
initSearch();
});

// Used to confirm deletion
function confirmDelete(evt) {
if (!confirm('Are you sure you want to permanently delete the selected element(s) ?')) {
evt.preventDefault();
Expand Down
14 changes: 2 additions & 12 deletions views/findings_add.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@
%input.form-control#search{ :type => "text", :placeholder => "Finding Name Search" }
%style#search_style
%span.input-group-btn
%script{ :type => "text/javascript" }
// credit to http://www.redotheweb.com/2013/05/15/client-side-full-text-search-in-css.html for this
var searchStyle = document.getElementById('search_style');
document.getElementById('search').addEventListener('input', function() {
if (!this.value) {
searchStyle.innerHTML = "";
return;
}
searchStyle.innerHTML = ".searchable:not([data-index*=\"" + this.value.toLowerCase().replace(/</g, '&rt;').replace(/>/g, '&lt;').replace(/"/g, '&quot;') + "\"]) { display: none; }";
});
%form.form-inline{ :method => "post", :action => "/report/#{@report.id}/findings_add" }
.table
%table{ :style => "width: 90%" }
Expand All @@ -45,7 +35,7 @@
- @findings.each do |finding|
- if finding.type == type
%tr
%td.searchable{ :style => "width: 80%", :"data-index" => "#{finding.title.downcase.gsub(' ','')}" }
%td.searchable{ :style => "width: 80%", :"data-index" => "#{finding.title.downcase}" }
- if @autoadd
- if @autoadd_findings.include?(finding.id.to_s) and not @dup_findings.include?(finding.id)
%input{ :id => "finding_#{finding.id}", :type => "checkbox", :name => "finding[]", :value => "#{finding.id}", :checked => "" }
Expand All @@ -69,7 +59,7 @@
.label.label-default #{ip}
- iplist = @autoadd_hosts[x].join(",")
%input{ :type => "hidden", :name => "finding#{finding.id.to_s}", :value => "#{iplist}" }
%td.searchable{ :style => "width: 20%", :"data-index" => "#{finding.title.downcase.gsub(' ','')}" }
%td.searchable{ :style => "width: 20%", :"data-index" => "#{finding.title.downcase}" }
- if @master
%a.btn.btn-warning{ :href => "/master/findings/#{finding.id}/edit" }
%i.icon-pencil.icon-white{ :title => "Edit" }
Expand Down
10 changes: 0 additions & 10 deletions views/findings_list.haml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
%br
%style#search_style
%span.input-group-btn
%script{ :type=>"text/javascript" }
// credit to http://www.redotheweb.com/2013/05/15/client-side-full-text-search-in-css.html for this
var searchStyle = document.getElementById('search_style');
document.getElementById('search').addEventListener('input', function() {
if (!this.value) {
searchStyle.innerHTML = "";
return;
}
searchStyle.innerHTML = ".searchable:not([data-index*=\"" + this.value.toLowerCase().replace(/</g, '&lt;').replace(/>/g, '&rt;').replace(/"/g, '&quot;') + "\"]) { display: none; }";
});
&nbsp;
- settings.finding_types.each do |type|
%tr
Expand Down
20 changes: 5 additions & 15 deletions views/reports_list.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
%input.form-control#search{ :type => "text", :placeholder => "Report Name Search" }
%style#search_style
%span.input-group-btn
%script{ :type=>"text/javascript" }
// credit to http://www.redotheweb.com/2013/05/15/client-side-full-text-search-in-css.html for this
var searchStyle = document.getElementById('search_style');
document.getElementById('search').addEventListener('input', function() {
if (!this.value) {
searchStyle.innerHTML = "";
return;
}
searchStyle.innerHTML = ".searchable:not([data-index*=\"" + this.value.toLowerCase().replace(/</g, '&lt;').replace(/>/g, '&rt;').replace(/"/g, '&quot;') + "\"]) { display: none; }";
});
%br
%br
%a.btn.btn-danger#deletemultiple{ :href => "/report/remove/" }
Expand All @@ -36,15 +26,15 @@
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Actions
- @reports.each do |report|
%tr
%td.searchable{ :"data-index" => "#{report.report_name.downcase.gsub(' ','')}" }
%td.searchable{ :"data-index" => "#{report.report_name.downcase}" }
%input.checkbox{ :type => "checkbox", :name => "#{report.id}" }
%td.searchable{ :style => "width: 70%", :"data-index" => "#{report.report_name.downcase.gsub(' ','')}" }
%td.searchable{ :style => "width: 70%", :"data-index" => "#{report.report_name.downcase}" }
#{report.report_name}
%td.searchable{ :style => "width: 10%", :"data-index" => "#{report.report_name.downcase.gsub(' ','')}" }
%td.searchable{ :style => "width: 10%", :"data-index" => "#{report.report_name.downcase}" }
#{report.full_company_name}
%td.searchable{ :style => "width: 10%", :"data-index" => "#{report.report_name.downcase.gsub(' ','')}" }
%td.searchable{ :style => "width: 10%", :"data-index" => "#{report.report_name.downcase}" }
#{report.owner}
%td.searchable{ :style => "width: 20%", :"data-index" => "#{report.report_name.downcase.gsub(' ','')}" }
%td.searchable{ :style => "width: 20%", :"data-index" => "#{report.report_name.downcase}" }
- if @master
%a.btn.btn-warning{ :href => "/master/reports/#{finding.id}" }
%i.icon-pencil.icon-white{ :title => "Edit" }
Expand Down

0 comments on commit fe9c493

Please sign in to comment.