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
wth - RMID Functionalities - Part 1 #858
Conversation
@@ -260,6 +266,10 @@ def active? | |||
study_type_question_group.nil? ? false : study_type_question_group.active | |||
end | |||
|
|||
def has_human_subject_info? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActiveRecord provides #human_subject_info?
, so I think this method is a little redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to add validation on the fly here in the form of a hidden field. If a user checks the Human Subject Info checkbox, it sets the has_human_subject_info hidden field to true which will then require the presence of a RMID.
This is just a way of doing it. I agree that naming conventions here aren't the best, open to any suggestions.
@@ -46,3 +46,7 @@ textarea | |||
|
|||
.gray_note | |||
color: gray | |||
|
|||
label.required-field:after |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like what you did here. I wasn't aware of this functionality. There's already a class for required fields, ".required", but it didn't have this css being used on it, and instead used a function in global.js.coffee to add the *s. Could you change this class to .required and perhaps remove the javascript function and calls to it?
attr_accessible :research_master_id | ||
attr_accessible :has_human_subject_info | ||
|
||
validates :research_master_id, numericality: true, allow_blank: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this allow non-integers to be entered? Shouldn't we use numericality: { only_integer: true }
@@ -29,7 +29,7 @@ | |||
.form-group.row.human_subjects | |||
= rt_form.label :human_subjects, t(:protocols)[:studies][:research_involving][:humans][:header], class: 'col-lg-2 control-label' | |||
.col-lg-1 | |||
= rt_form.check_box :human_subjects, class: 'form-control' | |||
= rt_form.check_box :human_subjects, class: 'form-control human-subjects' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding the class, you can select using $("#protocol_research_types_info_attributes_human_subjects")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding a class is cleaner. No real difference here.
@@ -19,6 +19,15 @@ | |||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
|
|||
$(document).ready -> | |||
|
|||
$(document).on 'click', '.human-subjects', -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Select using $("#protocol_research_types_info_attributes_human_subjects")
@@ -19,6 +19,15 @@ | |||
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
|
|||
$(document).ready -> | |||
|
|||
$(document).on 'click', '.human-subjects', -> | |||
if $('.rm-id').hasClass('required-field') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments about ".required"
@@ -29,7 +29,7 @@ | |||
.form-group.row.human_subjects | |||
= rt_form.label :human_subjects, t(:protocols)[:studies][:research_involving][:humans][:header], class: 'col-lg-2 control-label' | |||
.col-lg-1 | |||
= rt_form.check_box :human_subjects, class: 'form-control' | |||
= rt_form.check_box :human_subjects, class: 'form-control human-subjects' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be replicated in "app/views/dashboard/protocols/form/study_form_sections/_research_involving.html.haml"
@@ -27,6 +27,13 @@ | |||
= t(:protocols)[:studies][:information][:subtext] | |||
.panel-body.container-fluid | |||
.form-group.row | |||
= form.label :research_master_id, class: 'col-lg-2 control-label rm-id' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be replicated in "app/views/dashboard/protocols/form/study_form_sections/_study_information.html.haml"
= link_to t(:protocols)[:studies][:information][:research_master_id], RESEARCH_MASTER_LINK | ||
.col-lg-10 | ||
= form.text_field :research_master_id, class: 'form-control' | ||
= form.hidden_field :has_human_subject_info, value: false, class: 'has-human-subject-info' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this hidden field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have to add validation to a RMID on the fly. This is a hidden field set to default to false. If a user checks the Human Subjects Info checkbox, sets this field to true which then will require presence validation on the RMID attribute.
This was just my idea of doing it, probably other ways
@@ -0,0 +1,5 @@ | |||
class AddResearchMasterIdToProtocols < ActiveRecord::Migration | |||
def change | |||
add_column :protocols, :research_master_id, :integer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there also be an index added here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No association
@@ -0,0 +1,5 @@ | |||
class AddHasHsInfoToProtocols < ActiveRecord::Migration | |||
def change | |||
add_column :protocols, :has_human_subject_info, :boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unnecessary coupling and could lead to data inconsistencies. We already have access to either protocol.research_types_info.human_subjects? or protocol.human_subjects.present?
756f853
to
75af6be
Compare
75af6be
to
8a3838a
Compare
Add Research Master ID field and validate field to be number only and for presence if the Human Subjects checkbox is checked. [#136737011]
8a3838a
to
51e922e
Compare
Add Research Master ID field and validate field to be number only and
for presence if the Human Subjects checkbox is checked. [#136737011]