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

wth - RMID Functionalities - Part 1 #858

Merged
merged 1 commit into from Jan 10, 2017
Merged

Conversation

wtholt
Copy link
Contributor

@wtholt wtholt commented Jan 4, 2017

Add Research Master ID field and validate field to be number only and
for presence if the Human Subjects checkbox is checked. [#136737011]

@@ -260,6 +266,10 @@ def active?
study_type_question_group.nil? ? false : study_type_question_group.active
end

def has_human_subject_info?
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

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'
Copy link
Contributor

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")

Copy link
Contributor Author

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', ->
Copy link
Contributor

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')
Copy link
Contributor

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'
Copy link
Contributor

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
Copy link
Contributor

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'
Copy link
Contributor

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?

Copy link
Contributor Author

@wtholt wtholt Jan 5, 2017

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

@wtholt wtholt force-pushed the wth-sparc-rmid-part-1 branch 3 times, most recently from 756f853 to 75af6be Compare January 9, 2017 15:21
Add Research Master ID field and validate field to be number only and
for presence if the Human Subjects checkbox is checked. [#136737011]
@jleonardw9 jleonardw9 merged commit a133f5c into master Jan 10, 2017
@jleonardw9 jleonardw9 deleted the wth-sparc-rmid-part-1 branch January 10, 2017 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants