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

SAW - Permissible Value Finishing Changes #1042

Merged
merged 4 commits into from
Aug 14, 2017
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
2 changes: 0 additions & 2 deletions app/models/available_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ class AvailableStatus < ApplicationRecord

attr_accessor :new
attr_accessor :position

TYPES = PermissibleValue.get_hash('status')
end
5 changes: 0 additions & 5 deletions app/models/permissible_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ def self.get_value(category, key)
PermissibleValue.where(category: category, key: key).first.try(:value)
end

# Get an array of PermissibleValue values with the given category
def self.get_value_list(category)
PermissibleValue.where(category: category).pluck(:value)
end

# Get an array of PermissibleValue keys with the given category
def self.get_key_list(category, default=nil)
unless default.nil?
Expand Down
4 changes: 2 additions & 2 deletions app/models/study.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def populate_for_edit

def setup_study_types
position = 1
obj_names = StudyType::TYPES.map{|k,v| k}
obj_names = PermissibleValue.get_key_list('study_type')
obj_names.each do |obj_name|
study_type = study_types.detect{|obj| obj.name == obj_name}
study_type = study_types.build(:name => obj_name, :new => true) unless study_type
Expand Down Expand Up @@ -88,7 +88,7 @@ def setup_impact_areas

def setup_affiliations
position = 1
obj_names = Affiliation::TYPES.map{|k,v| k}
obj_names = PermissibleValue.get_key_list('affiliation_type')
obj_names.each do |obj_name|
affiliation = affiliations.detect{|obj| obj.name == obj_name}
affiliation = affiliations.build(:name => obj_name, :new => true) unless affiliation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
= form.fields_for :affiliations, protocol.affiliations.sort_by(&:position) do |affiliations_form|
- checked = !affiliations_form.object.new && !affiliations_form.object.marked_for_destruction?
.form-group.row{ class: affiliations_form.object.name }
= affiliations_form.label :name, "#{Affiliation::TYPES[affiliations_form.object.name]}:", class: 'col-lg-2 control-label'
= affiliations_form.label :name, "#{PermissibleValue.get_value('affiliation_type', affiliations_form.object.name)}:", class: 'col-lg-2 control-label'
.col-lg-1
= affiliations_form.check_box "_destroy", { checked: checked, class: 'form-control' }, false, true
= affiliations_form.hidden_field :name, value: affiliations_form.object.name
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
= form.fields_for :study_types, protocol.study_types.sort_by(&:position) do |st_form|
- checked = !st_form.object.new && !st_form.object.marked_for_destruction?
.form-group.row{ class: st_form.object.name }
= st_form.label :name, "#{StudyType::TYPES[st_form.object.name]}:", class: 'col-lg-2 control-label'
= st_form.label :name, "#{PermissibleValue.get_value('study_type', st_form.object.name)}:", class: 'col-lg-2 control-label'
.col-lg-1
= st_form.check_box "_destroy", { checked: checked, class: 'form-control' }, false, true
= st_form.hidden_field :name, value: st_form.object.name
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
= form.fields_for :affiliations, protocol.affiliations.sort_by(&:position) do |affiliations_form|
- checked = !affiliations_form.object.new && !affiliations_form.object.marked_for_destruction?
.form-group.row{ class: affiliations_form.object.name }
= affiliations_form.label :name, "#{Affiliation::TYPES[affiliations_form.object.name]}:", class: 'col-lg-2 control-label'
= affiliations_form.label :name, "#{PermissibleValue.get_value('affiliation_type', affiliations_form.object.name)}:", class: 'col-lg-2 control-label'
.col-lg-1
= affiliations_form.check_box "_destroy", { checked: checked, class: 'form-control' }, false, true
= affiliations_form.hidden_field :name, value: affiliations_form.object.name
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
= form.fields_for :study_types, protocol.study_types.sort_by(&:position) do |st_form|
- checked = !st_form.object.new && !st_form.object.marked_for_destruction?
.form-group.row{ class: st_form.object.name }
= st_form.label :name, "#{StudyType::TYPES[st_form.object.name]}:", class: 'col-lg-2 control-label'
= st_form.label :name, "#{PermissibleValue.get_value('study_type', st_form.object.name)}:", class: 'col-lg-2 control-label'
.col-lg-1
= st_form.check_box "_destroy", { checked: checked, class: 'form-control' }, false, true
= st_form.hidden_field :name, value: st_form.object.name
2 changes: 1 addition & 1 deletion app/views/protocols/view_details/_affiliations.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
%tr.row
%td
.col-lg-12
= "- " + Affiliation::TYPES[affiliation.name]
= "- " + PermissibleValue.get_value('affiliation_type', affiliation.name)
- else
.panel-body
= render partial: 'shared/alert', locals: { message: t(:protocols)[:studies][:affiliations][:none] }
2 changes: 1 addition & 1 deletion app/views/protocols/view_details/_study_type.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
%tr.row
%td
.col-lg-12
= "- " + StudyType::TYPES[study_type.name]
= "- " + PermissibleValue.get_value('study_type', study_type.name)
- else
.panel-body
= render partial: 'shared/alert', locals: { message: t(:protocols)[:studies][:study_type][:none] }