Skip to content

Commit

Permalink
Merge branch 'testing' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart-Johnson committed Aug 29, 2017
2 parents 12d635e + 22ad482 commit 4651634
Show file tree
Hide file tree
Showing 41 changed files with 252 additions and 92 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
@@ -1,6 +1,8 @@
sudo: false
language: ruby
cache: bundler
dist: precise

before_install:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -10,6 +10,7 @@ gem 'autoprefixer-rails'
gem 'axlsx_rails'
gem 'bootstrap-sass'
gem 'bootstrap-select-rails'
gem 'bootstrap-toggle-rails'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.37'
gem 'coffee-rails', '~> 4.0.0'
gem 'daemons'
Expand All @@ -24,6 +25,7 @@ gem 'haml-rails'
gem 'hashie-forbidden_attributes'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'letter_opener'
gem 'momentjs-rails', '>= 2.9.0'
gem 'mysql2'
gem 'net-ldap'
Expand Down
22 changes: 14 additions & 8 deletions Gemfile.lock
Expand Up @@ -67,6 +67,7 @@ GEM
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.2.19)
bootstrap-select-rails (1.6.3)
bootstrap-toggle-rails (2.2.1.0)
bootstrap3-datetimepicker-rails (4.17.37)
momentjs-rails (>= 2.8.1)
builder (3.2.3)
Expand All @@ -87,14 +88,15 @@ GEM
sshkit (~> 1.2)
capistrano3-delayed-job (1.4.0)
capistrano (>= 3.0.0)
capybara (2.5.0)
capybara (2.13.0)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.7.1)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-webkit (1.7.1)
capybara (>= 2.3.0, < 2.6.0)
capybara-webkit (1.14.0)
capybara (>= 2.3.0, < 2.14.0)
json
choice (0.2.0)
climate_control (0.0.3)
Expand Down Expand Up @@ -221,6 +223,8 @@ GEM
json (1.8.6)
launchy (2.4.3)
addressable (~> 2.3)
letter_opener (1.4.1)
launchy (~> 2.2)
libv8 (3.16.14.15)
loofah (2.0.3)
nokogiri (>= 1.5.9)
Expand All @@ -241,7 +245,7 @@ GEM
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
netrc (0.10.3)
nokogiri (1.7.1)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
Expand Down Expand Up @@ -271,7 +275,7 @@ GEM
slop (~> 3.4)
puma (2.11.3)
rack (>= 1.1, < 2.0)
rack (1.6.5)
rack (1.6.8)
rack-accept (0.4.5)
rack (>= 0.4)
rack-mini-profiler (0.10.1)
Expand Down Expand Up @@ -420,8 +424,8 @@ GEM
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.0.7)
xpath (2.0.0)
nokogiri (~> 1.7.1)
xpath (2.1.0)
nokogiri (~> 1.3)
yajl-ruby (1.2.1)

PLATFORMS
Expand All @@ -437,6 +441,7 @@ DEPENDENCIES
axlsx_rails
bootstrap-sass
bootstrap-select-rails
bootstrap-toggle-rails
bootstrap3-datetimepicker-rails (~> 4.17.37)
capistrano (~> 3.0)
capistrano-passenger
Expand All @@ -462,6 +467,7 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
launchy
letter_opener
momentjs-rails (>= 2.9.0)
mysql2
net-ldap
Expand Down
Binary file modified app/assets/images/sctr_header.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -30,6 +30,7 @@
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.

//= require bootstrap-toggle
//= require bootstrap-table-export
//= require bootstrap-table-custom
//= require tableExport
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/show_task.js.coffee
@@ -0,0 +1,6 @@
$ ->
id = $('#task_id').val()

$.ajax
type: 'GET'
url: "/tasks/#{id}.js"
27 changes: 4 additions & 23 deletions app/assets/javascripts/tasks.js.coffee
Expand Up @@ -57,27 +57,8 @@ $ ->

$("table.tasks").bootstrapTable('hideColumn', 'id')

$(document).on "change", "#complete, #all_tasks", ->
scope = if $("#all_tasks").prop("checked") then "all" else "mine"
status = if $("#complete").prop("checked") then "complete" else "incomplete"

$(document).on "click", "#complete", ->
scope = $(this).prop('value')

if scope == 'complete'
$(this).text("Show Incomplete")
$(this).prop('value', 'incomplete')
else
$(this).text("Show Complete")
$(this).prop('value', 'complete')
$('#task-list').bootstrapTable('refresh', {url: "/tasks.json?scope=" + scope, silent: "true"})

$(document).on 'click', "#all_tasks", ->
scope = $(this).prop('value')

if scope == 'all'
$(this).text('Show My Tasks')
$(this).prop('value', 'mine')
else
$(this).text('Show All Tasks')
$(this).prop('value', 'all')
$('#task-list').bootstrapTable('refresh', {url: "/tasks.json?scope=" + scope, silent: "true"})


$('#task-list').bootstrapTable('refresh', {url: "/tasks.json?scope=" + scope + "&status=" + status, silent: "true"})
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.sass
Expand Up @@ -21,6 +21,7 @@
// Example of overriding bootstrap defaults
// $link-color: #FF69d6
@import "bootstrap-toggle"
@import "bootstrap-sprockets"
@import "bootstrap"
@import "bootstrap-select"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/fulfillments_controller.rb
Expand Up @@ -44,7 +44,7 @@ def create
@line_item = LineItem.find(fulfillment_params[:line_item_id])
service = @line_item.service
funding_source = @line_item.protocol.sparc_funding_source
@fulfillment = Fulfillment.new(fulfillment_params.merge!({ creator: current_identity, service: service, service_name: service.name, service_cost: service.cost(funding_source) }))
@fulfillment = Fulfillment.new(fulfillment_params.merge!({ creator: current_identity, service: service, service_name: service.name, service_cost: @line_item.cost(funding_source) }))
if @fulfillment.valid?
@fulfillment.save
update_components_and_create_notes('create')
Expand Down
31 changes: 23 additions & 8 deletions app/controllers/tasks_controller.rb
Expand Up @@ -25,19 +25,23 @@ class TasksController < ApplicationController
respond_to :json, :html

def index
@task_id = params[:id]

respond_to do |format|
format.html { render }
format.json do

@tasks = scoped_tasks

render
end
end
end

def show
@partial = ["show", @task.assignable_type.downcase, "task"].join("_")
respond_to do |format|
format.html
format.js
end
end

def new
Expand All @@ -63,6 +67,8 @@ def create
end
create_note
flash[:success] = t(:task)[:flash_messages][:created]
email_identity = Identity.find(task_params[:assignee_id])
TaskMailer.task_confirmation(email_identity, @task).deliver_now
else
@errors = @task.errors
end
Expand All @@ -88,7 +94,7 @@ def create_note
if create_procedure_note?
@appointment = @procedure.present? ? @procedure.appointment : Procedure.find(task_params[:notes][:notable_id]).appointment
@statuses = @appointment.appointment_statuses.map{|x| x.status}

notes_params = task_params[:notes]
notes_params[:identity] = current_identity

Expand All @@ -115,14 +121,23 @@ def task_params
end

def scoped_tasks
if params[:scope].present?
if (params[:scope] == 'mine') || (params[:scope] == 'incomplete')
return Task.mine(current_identity)
if !params[:scope] || params[:scope] == 'mine'
if params[:status]
Task.json_info.mine(current_identity).send(params[:status])
else
return Task.send(params[:scope])
Task.json_info.mine(current_identity).incomplete
end
else
return Task.mine(current_identity)
if params[:status]
Task.json_info.send(params[:status])
else
Task.json_info
end
end
end
end





18 changes: 13 additions & 5 deletions app/helpers/participant_helper.rb
Expand Up @@ -56,11 +56,19 @@ def editFormatter(participant)
end

def deleteFormatter(participant)
[
"<a class='remove remove-participant' href='javascript:void(0)' title='Remove' protocol_id='#{participant.protocol_id}' participant_id='#{participant.id}' participant_name='#{participant.full_name}'>",
"<i class='glyphicon glyphicon-remove'></i>",
"</a>"
].join ""
if participant.can_be_destroyed?
[
"<a class='remove remove-participant' href='javascript:void(0)' title='Remove' protocol_id='#{participant.protocol_id}' participant_id='#{participant.id}' participant_name='#{participant.full_name}'>",
"<i class='glyphicon glyphicon-remove'></i>",
"</a>"
].join ""
else
[
"<div data-toggle='tooltip' data-placement='left' data-animation='false' title='Participants with procedure data cannot be deleted.'>",
"<i class='glyphicon glyphicon-remove' style='cursor:default'></i>"
].join ""
end

end

def changeArmFormatter(participant)
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/task_helper.rb
Expand Up @@ -37,15 +37,15 @@ def format_checkbox task

def format_task_type task
task_type = task.assignable_type
task_type += " (#{task.assignable.service_name})" if task_type == "Procedure"
task_type += " (#{task.procedure.service_name})" if task_type == "Procedure"

task_type
end

def format_task_protocol_id task
case task.assignable_type
when 'Procedure'
Procedure.find(task.assignable_id).protocol.srid
task.procedure.protocol.srid
else
'-'
end
Expand All @@ -65,7 +65,7 @@ def format_due_date task
def format_org task
case task.assignable_type
when 'Procedure'
core = Procedure.find(task.assignable_id).core
core = task.procedure.core
program = core.parent

"#{program.name} / #{core.name}"
Expand Down
4 changes: 4 additions & 0 deletions app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout 'mailer'
end
13 changes: 13 additions & 0 deletions app/mailers/task_mailer.rb
@@ -0,0 +1,13 @@
class TaskMailer < ApplicationMailer

# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.task_mailer.task_confirmation.subject
#
def task_confirmation(identity, task)
@identity = identity
@task = task
mail to: identity.email, subject: "(SPARCFulfillment) New Task Assigned"
end
end
5 changes: 5 additions & 0 deletions app/models/participant.rb
Expand Up @@ -141,6 +141,10 @@ def first_middle
[first_name, middle_initial].join(' ')
end

def can_be_destroyed?
procedures.where.not(status: 'unstarted').empty?
end

private

def update_faye
Expand All @@ -162,4 +166,5 @@ def appointments_for_visit_groups visit_groups
self.appointments.create(visit_group_id: vg.id, visit_group_position: vg.position, position: nil, name: vg.name, arm_id: vg.arm_id)
end
end

end
5 changes: 4 additions & 1 deletion app/models/task.rb
Expand Up @@ -28,6 +28,8 @@ class Task < ActiveRecord::Base
class_name: "Identity"
belongs_to :assignable, polymorphic: true

belongs_to :procedure, ->{ joins(:tasks).where( tasks: { id: Task.where(assignable_type: 'Procedure' ) } ) }, foreign_key: :assignable_id

validates :assignee_id, presence: true
validates :due_at, presence: true

Expand All @@ -37,7 +39,8 @@ class Task < ActiveRecord::Base

scope :incomplete, -> { where(complete: false) }
scope :complete, -> { where(complete: true) }
scope :mine, -> (identity) { incomplete.where(assignee: identity) }
scope :mine, -> (identity) { where(["identity_id = ? OR assignee_id = ?", identity.id, identity.id]) }
scope :json_info, -> { includes(:identity, procedure: [protocol: [:sub_service_request], core: [:parent]]) }

def due_at=(due_date)
write_attribute(:due_at, Time.strptime(due_date, "%m/%d/%Y")) if due_date.present?
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/mailer.html.haml
@@ -0,0 +1,3 @@
%hmtl
%body
= yield
1 change: 1 addition & 0 deletions app/views/layouts/mailer.text.haml
@@ -0,0 +1 @@
= yield
13 changes: 13 additions & 0 deletions app/views/task_mailer/task_confirmation.html.haml
@@ -0,0 +1,13 @@
= t(:task)[:emails][:greeting] + "#{@identity.first_name},"
%br
%br
= t(:task)[:emails][:assigned_new_task]
= link_to t(:task)[:emails][:new_task_link], tasks_url(id: @task.id)
%br
%br
%h3= t(:task)[:emails][:details]
= t(:task)[:emails][:creator] + "#{@task.identity.full_name}"
%br
= t(:task)[:emails][:date] + "#{@task.due_at}"
%br
= t(:task)[:emails][:content] + "#{@task.body}"
9 changes: 6 additions & 3 deletions app/views/tasks/_tasks.html.haml
Expand Up @@ -18,12 +18,16 @@
-# 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.~
- if @task_id
= hidden_field_tag 'task_id', @task_id
= javascript_include_tag 'show_task'

%h1 Task List
.bootstrap-table-dropdown-overflow
#custom_tool_buttons
%button.btn.btn-primary.new-task{type: "button", aria: {label: "Create Task"}}=t(:task)[:new_task]
%button{class: "btn btn-default btn-primary", id: 'complete', value: 'complete'}= t(:task)[:show_complete]
%button{class: "btn btn-default btn-primary", id: 'all_tasks', value: 'all'}= t(:task)[:all_tasks]
= check_box_tag("complete", '', false, data: { toggle: "toggle", on: t(:task)[:show_complete], off: t(:task)[:show_incomplete], onstyle: "success" } )
= check_box_tag("all_tasks", '', false, { data: { toggle: "toggle", on: t(:task)[:all_tasks], off: t(:task)[:my_tasks], onstyle: "success" } } )
%table.tasks.custom_striped{style: "padding: 0px 0px;",id: "task-list", data: {"idField" => "id", toggle: 'table', search: "true", "show-columns" => "true", "show-refresh" => "true", "show-toggle" => "true", url: tasks_path(scope: 'mine', format: :json), "sort-name" => "due_at", "sort-order" => 'asc', striped: "true", toolbar: "#custom_tool_buttons", "show-export" => "true", "export-types" => ['excel']}}
%thead
%tr
Expand All @@ -45,4 +49,3 @@
= t(:task)[:reschedule]
%th{data: {class: 'org', align: 'left', field: 'organization', visible: "false", sortable: "true"}}
= t(:procedure)[:prog_core]

0 comments on commit 4651634

Please sign in to comment.