forked from sparc-request/sparc-request
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Built form to send data over to RedCap. [#142789871] [#142789881] Keeping old code of Feedback, adding in constant for testing of new version. added js error handling Changing how we convert the date.
- Loading branch information
1 parent
0cead37
commit 89ac31f
Showing
5 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,4 @@ | |
//= require surveyor/surveys | ||
//= require sweetalert.min | ||
//= require update_visit_group | ||
//= require feedback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$.fn.clear_form_errors = () -> | ||
this.find('.form-group').removeClass('has-error') | ||
this.find('span.help-block').remove() | ||
|
||
$.fn.render_form_errors = (model_name, errors) -> | ||
form = this | ||
this.clear_form_errors() | ||
|
||
$.each(errors, (field, messages) -> | ||
input = form.find('input, select, textarea').filter(-> | ||
name = $(this).attr('name') | ||
if name | ||
name.match(new RegExp(model_name + '\\[' + field + '\\(?')) | ||
) | ||
input.closest('.form-group').addClass('has-error') | ||
input.parent().append('<span class="help-block">' + $.map(messages, (m) -> m.charAt(0).toUpperCase() + m.slice(1)).join('<br />') + '</span>') | ||
) | ||
|
||
$ -> | ||
|
||
$('#modal_place').on 'shown.bs.modal', -> | ||
$(document).ajaxError (e, data) -> | ||
$('.new_feedback').render_form_errors('feedback', JSON.parse(data.responseText)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
<% if @feedback.valid? %> | ||
$('#modal_place').modal('hide') | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters