[issue #428] Added filter by advisory_id to Advisories

This commit is contained in:
George Vinogradov 2012-06-20 21:51:08 +04:00
parent 3d38adcb94
commit e4f62ea592
10 changed files with 57 additions and 2 deletions

View File

@ -1094,3 +1094,25 @@ form.mass_build section.right {
.packages_info_container ul.platforms {
padding: 0;
}
/* remove this lines after change to backbone */
table.tablesorter.advisories thead tr.search th {
padding: 0 5px;
}
table.tablesorter.advisories thead tr.search th input[type='text'] {
width: 640px;
}
table.tablesorter.advisories thead tr.search th form {
float: left;
}
table.tablesorter.advisories thead tr.search th form.button_to {
padding: 3px 0 0 7px;
}
table.tablesorter tr td.no_results {
text-align: center;
}
/* end */

View File

@ -6,7 +6,9 @@ class AdvisoriesController < ApplicationController
authorize_resource
def index
@advisories = @advisories.scoped(:include => :platforms).paginate(:page => params[:page])
@advisories = @advisories.scoped(:include => :platforms)
@advisories = @advisories.search_by_id(params[:q]) if params[:q]
@advisories = @advisories.paginate(:page => params[:page])
respond_to do |format|
format.html
format.atom

View File

@ -12,6 +12,7 @@ class Advisory < ActiveRecord::Base
TYPES = {'security' => 'SA', 'bugfix' => 'A'}
scope :by_project, lambda {|p| where('project_id' => p.try(:id) || p)}
scope :search_by_id, lambda { |aid| where('advisory_id ILIKE ?', "%#{aid.to_s.strip}%") }
default_scope order('created_at DESC')
def to_param

View File

@ -4,5 +4,29 @@
%th.th1= t("activerecord.attributes.advisory.advisory_id")
%th.th2= t("layout.advisories.affected_versions")
%th.th3= t("activerecord.attributes.advisory.description")
%tr.search
-# TODO: change filter to Backbone.js
%th{:colspan => 3, :rowspan => 1}
= form_tag advisories_path, :method => :get do |f|
= text_field_tag('q', params[:q], :placeholder => t("layout.advisories.search_by_id"), :class => params[:q].present? ? 'black' : 'gray')
%input{:type => 'submit', :value => t("layout.search.header")}
=# link_to t('layout.back'), advisories_path, :class => 'button'
= button_to t('layout.clear'), {:action => :index} , :method => :get
%tbody
- if list.size > 0
= render :partial => 'list_item', :collection => list, :as => :advisory
- else
%tr.odd
%td.no_results{:colspan => 3}
= t("layout.search.no_results", :query => params[:q])
:javascript
$(function() {
var $search = $('tr.search > th input[type="text"]');
$search.on('blur focus', function() {
if ($search.val() === '') {
$search.toggleClass('gray black');
}
});
});

View File

@ -14,6 +14,7 @@ en:
read_access: read-only
by: by
clear: Clear
remove: Remove

View File

@ -14,6 +14,7 @@ ru:
read_access: только чтение
by: ''
clear: Очистить
remove: Убрать

View File

@ -4,6 +4,7 @@ en:
header: Search
advanced: Advanced search
all: Show All
no_results: Nothing found for "%{query}".
types:
all: All
projects: Projects

View File

@ -4,6 +4,7 @@ ru:
header: Поиск
advanced: Расширенный поиск
all: Показать все
no_results: По запросу "%{query}" ничего не найдено.
types:
all: Все
projects: Проекты

View File

@ -10,6 +10,7 @@ en:
ref_comment: Add links one by row
no_: No
new: New
search_by_id: Search advisory by it's ID
flash:
advisories:

View File

@ -10,6 +10,7 @@ ru:
ref_comment: Вставляйте ссылки по одной на строку
no_: Нет
new: Новый
search_by_id: Искать бюллетень по его ID
flash:
advisories: