Skip to content

Commit

Permalink
limit search to not use payload (with option to still search docuement)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Pope committed Mar 1, 2017
1 parent dbcc002 commit 74fc110
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
14 changes: 11 additions & 3 deletions app/assets/stylesheets/admin.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3374,13 +3374,21 @@ input[type="submit"].btn-block, input[type="reset"].btn-block, input[type="butto
.navbar-form {
margin-left: -15px;
margin-right: -15px;
padding: 10px 15px;
border-top: 1px solid transparent;
border-bottom: 1px solid transparent;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 1px 0 rgba(255, 255, 255, .1);
margin-top: 8px;
margin-bottom: 8px;
margin-top: 0px;
margin-bottom: 0px;

.input-group {
padding: 8px 0;
}

.checkbox {
padding: 15px 0;
color: #fff;
}
}
@media (max-width: 767px) {
.navbar-form .form-group {
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,11 @@ def logout
end

def search page=params[:page], per=25
search_document_text = ''

@documents = Document.where("organization_id IN (#{@organizations.pluck(:id).join(',')}) AND (lms_course_id = '#{params[:q]}' OR name LIKE '%#{params[:q]}%' OR edit_id LIKE '#{params[:q]}%' OR view_id LIKE '#{params[:q]}%' OR template_id LIKE '#{params[:q]}%' OR payload LIKE '%#{params[:q]}%')").page(page).per(per)
search_document_text = "OR payload LIKE '%#{params[:q]}%'" if params[:search_document_text]

@documents = Document.where("organization_id IN (#{@organizations.pluck(:id).join(',')}) AND (lms_course_id = '#{params[:q]}' OR name LIKE '%#{params[:q]}%' OR edit_id LIKE '#{params[:q]}%' OR view_id LIKE '#{params[:q]}%' OR template_id LIKE '#{params[:q]}%' #{search_document_text})").page(page).per(per)
end


Expand Down
19 changes: 14 additions & 5 deletions app/views/admin/_topbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,28 @@
<a class="navbar-brand" href="/">Salsa</a>
</div>

<div class="col-sm-3 col-md-3">
<%= form_tag(admin_search_path, method: 'get', class: "form-horizontal col-md-9 navbar-form", role: "search" ) do |f| %>
<%= form_tag(admin_search_path, method: 'get', class: "form-horizontal col-md-9 navbar-form", role: "search" ) do |f| %>
<% if session[:admin_authorized] %>
<div class="col-sm-6">

<% if session[:admin_authorized] %>
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="srch-term" value="<%= params[:q] %>">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
<% end %>
</div>

<div class="col-sm-6">
<div class="checkbox">
<label>
<input type="checkbox" name="search_document_text" value="1" <% if(params[:search_document_text]) %>checked<% end %>>
Search documents?
</label>
</div>
</div>
<% end %>
</div>
<% end %>

<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
Expand Down

0 comments on commit 74fc110

Please sign in to comment.