Skip to content

Commit

Permalink
Merge pull request #189 from sparc-request/go-visit-calendar-jump-to
Browse files Browse the repository at this point in the history
Go visit calendar jump to
  • Loading branch information
ctt3 committed Nov 10, 2015
2 parents 16c0d33 + 2ba82d0 commit 0e57a67
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/controllers/service_calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ def rename_visit
def set_day
day = params[:day]
position = params[:position].to_i
arm = Arm.find params[:arm_id]
portal = params[:portal]
@arm = Arm.find params[:arm_id]
@portal = params[:portal]

if !arm.update_visit_group_day(day, position, portal)
if !@arm.update_visit_group_day(day, position, @portal)
respond_to do |format|
format.js { render :status => 418, :json => clean_messages(arm.errors.messages) }
format.js { render :status => 418, :json => clean_messages(@arm.errors.messages) }
end
end
end
Expand Down
10 changes: 8 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def generate_visit_header_row arm, service_request, page, sub_service_request, p
raw(returning_html)
end

def visits_select_options arm, pages
def visits_select_options(arm, pages)
num_pages = (arm.visit_count / 5.0).ceil
arr = []
selected = pages[arm.id].to_i == 0 ? 1 : pages[arm.id].to_i
Expand All @@ -174,7 +174,13 @@ def visits_select_options arm, pages
arr << option

(beginning_visit..ending_visit).each do |y|
arr << ["--#{arm.visit_groups[y - 1].name}".html_safe, :parent_page => page]
visit_group = arm.visit_groups[y - 1]

if visit_group.day.present?
arr << ["--#{visit_group.name}/Day #{visit_group.day}".html_safe, parent_page: page]
else
arr << ["--#{visit_group.name}".html_safe, parent_page: page]
end
end
end

Expand Down
1 change: 1 addition & 0 deletions app/views/service_calendars/_visit_selector.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= generate_visit_navigation(arm, service_request, tab, portal)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%th.your_cost_header{:rowspan => 2}= t(:calendar_page)[:headers][:your_cost]
%th.number_of_subjects_header{:rowspan => 2}= t(:calendar_page)[:headers][:subjects]
%th{:colspan => 5, :height => 40, :width => 375}
= generate_visit_navigation arm, @service_request, @pages, tab, portal
= render partial: 'visit_selector', locals: { arm: arm, service_request: @service_request, pages: @pages, tab: tab, portal: portal }
%th{:rowspan => 2}= t(:calendar_page)[:headers][:total_per_patient]
%th.total_per_study{:rowspan => 2}= t(:calendar_page)[:headers][:total_per_study]

Expand All @@ -41,7 +41,7 @@
%th.qty_type_header{:rowspan => 2}= t(:calendar_page)[:headers][:clinical_qty]
%th.number_of_subjects_header{:rowspan => 2}= t(:calendar_page)[:headers][:subjects]
%th{:colspan => 5, :height => 40, :width => 375}
= generate_visit_navigation arm, @service_request, @pages, @tab, @portal
= render partial: 'visit_selector', locals: { arm: arm, service_request: @service_request, pages: @pages, tab: tab, portal: portal }
%th{:rowspan => 2}= t(:calendar_page)[:headers][:total_per_patient]
%th.total_per_study{:rowspan => 2}= t(:calendar_page)[:headers][:total_per_study]

Expand All @@ -60,7 +60,7 @@
-if @tab == 'template'
%th
%th{:colspan => 5, :height => 40, :width => 375}
= generate_visit_navigation arm, service_request, @pages, @tab, @portal
= render partial: 'visit_selector', locals: { arm: arm, service_request: @service_request, pages: @pages, tab: tab, portal: portal }
%th{:colspan => 2}= image_tag 'spinner.gif', :class => 'service_calendar_spinner'

%tr.table_header
Expand All @@ -73,4 +73,4 @@
%th &nbsp;
- else
%th= t(:calendar_page)[:headers][:total_per_patient]
%th.total_per_study= t(:calendar_page)[:headers][:total_per_study]
%th.total_per_study= t(:calendar_page)[:headers][:total_per_study]
3 changes: 3 additions & 0 deletions app/views/service_calendars/set_day.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# 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.

$('.jump_to_visit').
empty().
html("<%= escape_javascript(render(partial: 'visit_selector', locals: { arm: @arm, service_request: @service_request, tab: 'calendar', portal: @portal })) %>");

0 comments on commit 0e57a67

Please sign in to comment.