Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl move core filter #413

Merged
merged 3 commits into from
May 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/assets/javascripts/dashboard/protocols.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ $(document).ready ->
if data["filterrific[with_status][]"].length
data["filterrific[with_status][]"] = $("#filterrific_with_status").val()

if data["filterrific[with_core][]"].length
data["filterrific[with_core][]"] = $("#filterrific_with_core").val()
if data["filterrific[with_organization][]"].length
data["filterrific[with_organization][]"] = $("#filterrific_with_organization").val()

$.ajax
type: 'GET'
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/dashboard/protocol.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ textarea {
.view-protocol-details-modal {
width: 50% !important;
}

.drop-underneath {
margin-top: 20px;
}
2 changes: 1 addition & 1 deletion app/controllers/dashboard/protocols_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def index
default_filter_params: default_filter_params,
select_options: {
with_status: AVAILABLE_STATUSES.invert,
with_core: admin_orgs.map { |org| [org.name, org.id] }
with_organization: admin_orgs.map { |org| [org.name, org.id] }
},
persistence_id: false #resets filters on page reload
) || return
Expand Down
4 changes: 2 additions & 2 deletions app/models/protocol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Protocol < ActiveRecord::Base
:for_admin,
:show_archived,
:with_status,
:with_core
:with_organization
]
)

Expand Down Expand Up @@ -182,7 +182,7 @@ class Protocol < ActiveRecord::Base
where(sub_service_requests: { status: status }).distinct
}

scope :with_core, -> (org_id) {
scope :with_organization, -> (org_id) {
# returns protocols with ssrs in org_id
return nil if org_id == "" or org_id == [""]
joins(:sub_service_requests).
Expand Down
6 changes: 3 additions & 3 deletions app/models/protocol_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ProtocolFilter < ActiveRecord::Base

belongs_to :identity

serialize :with_core, Array
serialize :with_organization, Array
serialize :with_status, Array

attr_accessible :identity_id
Expand All @@ -32,7 +32,7 @@ class ProtocolFilter < ActiveRecord::Base
attr_accessible :for_admin
attr_accessible :for_identity_id
attr_accessible :search_query
attr_accessible :with_core
attr_accessible :with_organization
attr_accessible :with_status

scope :latest_for_user, -> (identity_id, limit) {
Expand All @@ -49,7 +49,7 @@ def href
for_admin: self.for_admin,
for_identity_id: self.for_identity_id,
search_query: self.search_query,
with_core: self.with_core,
with_organization: self.with_organization,
with_status: self.with_status
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
= form.label :with_status, t(:dashboard)[:protocol_filters][:status], class: 'col-lg-3 control-label'
.col-lg-9
= form.select :with_status, filterrific.select_options[:with_status], {}, class: "form-control selectpicker status-select", multiple: true, data: { none_selected_text: t(:constants)[:prompts][:any] }

.form-group.row
= form.label :with_organization, t(:dashboard)[:protocol_filters][:organization], class: 'col-lg-3 control-label'
.col-lg-9.drop-underneath
= form.select :with_organization, filterrific.select_options[:with_organization], {}, class: "form-control selectpicker core-select", multiple: true, data: { none_selected_text: t(:constants)[:prompts][:any] }
- if admin
%hr
.form-group.row
Expand All @@ -58,11 +63,6 @@
.col-lg-2
= form.check_box :for_admin, {}, current_user.id, "0"

.form-group.row
= form.label :with_core, t(:dashboard)[:protocol_filters][:core], class: 'col-lg-3 control-label'
.col-lg-9
= form.select :with_core, filterrific.select_options[:with_core], {}, class: "form-control selectpicker core-select", multiple: true, data: { none_selected_text: t(:constants)[:prompts][:any] }

.panel-footer
.pull-right
%button.btn.btn-default#apply-filter-button{type: "submit"}
Expand Down
4 changes: 2 additions & 2 deletions app/views/dashboard/protocol_filters/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
= form.hidden_field :for_admin
= form.hidden_field :for_identity_id
= form.hidden_field :search_query
- protocol_filter.with_core.each do |core_id|
= form.hidden_field :with_core, multiple: true, value: core_id
- protocol_filter.with_organization.each do |core_id|
= form.hidden_field :with_organization, multiple: true, value: core_id
- protocol_filter.with_status.each do |status|
= form.hidden_field :with_status, multiple: true, value: status
.form-group
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ en:
status: "Status"
my_protocols: "My Protocols"
my_admin_orgs: "My Admin Organizations"
core: "Core"
organization: "Organization"
filter: "Filter"
saved_filters:
header: "Recently Saved Filters"
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20160525190420_fix_with_core_column_name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class FixWithCoreColumnName < ActiveRecord::Migration
def change
rename_column :protocol_filters, :with_core, :with_organization
end
end
17 changes: 8 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160523164445) do
ActiveRecord::Schema.define(version: 20160525190420) do

create_table "admin_rates", force: :cascade do |t|
t.integer "line_item_id", limit: 4
Expand Down Expand Up @@ -381,7 +381,6 @@

add_index "identities", ["approved"], name: "index_identities_on_approved", using: :btree
add_index "identities", ["email"], name: "index_identities_on_email", using: :btree
add_index "identities", ["first_name", "last_name"], name: "full_name", type: :fulltext
add_index "identities", ["last_name"], name: "index_identities_on_last_name", using: :btree
add_index "identities", ["ldap_uid"], name: "index_identities_on_ldap_uid", unique: true, using: :btree
add_index "identities", ["reset_password_token"], name: "index_identities_on_reset_password_token", unique: true, using: :btree
Expand Down Expand Up @@ -632,14 +631,14 @@
add_index "project_roles", ["protocol_id"], name: "index_project_roles_on_protocol_id", using: :btree

create_table "protocol_filters", force: :cascade do |t|
t.integer "identity_id", limit: 4
t.string "search_name", limit: 255
t.integer "identity_id", limit: 4
t.string "search_name", limit: 255
t.boolean "show_archived"
t.integer "for_admin", limit: 4
t.integer "for_identity_id", limit: 4
t.string "search_query", limit: 255
t.string "with_core", limit: 255
t.string "with_status", limit: 255
t.integer "for_admin", limit: 4
t.integer "for_identity_id", limit: 4
t.string "search_query", limit: 255
t.string "with_organization", limit: 255
t.string "with_status", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end
Expand Down
4 changes: 2 additions & 2 deletions spec/views/dashboard/protocols/index.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
assign(:filterrific, double('filterrific',
select_options: {
with_status: [],
with_core: []
with_organization: []
},
with_status: [],
search_query: '',
show_archived: 0,
for_identity_id: jug2.id,
for_admin: false,
with_core: false
with_organization: false
))
end

Expand Down