Skip to content

Commit

Permalink
Merge branch 'stable-after-caching' into OSC-17
Browse files Browse the repository at this point in the history
  • Loading branch information
kirykr committed Oct 31, 2022
2 parents 36a091d + 3f93fb4 commit 4f43039
Show file tree
Hide file tree
Showing 190 changed files with 4,882 additions and 898 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ db_create_test:
# docker-compose run --no-deps -e RAILS_ENV=test --entrypoint "rake db:drop" app
docker-compose run --no-deps -e RAILS_ENV=test --entrypoint "rake db:create" app
docker-compose run --no-deps -e RAILS_ENV=test --entrypoint "rake db:schema:load" app
# docker exec -it mongo mongo --authenticationDatabase admin --host localhost -u mongo -p 123456789 oscar_history_test --eval "db.dropUser('oscar'); db.createUser({user: 'oscar', pwd: '123456789', roles: [{role: 'readWrite', db: 'oscar_history_test'}]});"
docker-compose exec -T mongo mongo --authenticationDatabase admin --host localhost -u mongo -p 123456789 oscar_history_test --eval "db.dropUser('oscar'); db.createUser({user: 'oscar', pwd: '123456789', roles: [{role: 'readWrite', db: 'oscar_history_test'}]});"

# If the container is NOT running and you want to get a bash terminal then run this command
Expand Down
Binary file added app/assets/images/cb_dmat/1-5-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/1-year.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/12-months.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/18-months.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/2-5-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/2-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/3-months.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/3-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/4-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/5-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/6-months.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/6-years.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/cb_dmat/9-months.png
Loading
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/advanced_filter_builder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CIF.AdvancedFilterBuilder

window.customGroup["#{addRule.id}"] = addRule if window.customGroup["#{addRule.id}"] == undefined
$('#builder_group_0').find('.rules-group-body .btn-custom-group').hide()
$('#builder_group_0').find('.rules-group-body .btn-default-group').hide()

$(@element.selector).on 'beforeDeleteGroup.queryBuilder', (parent, group) ->
if $('body#clients-index').length
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
//= require settings/research_module
//= require settings/client_forms
//= require settings/integration
//= require settings/risk_assessment
//= require settings/customize_case_note
//= require prevent_required_file_uploader
//= require format_special_characters
Expand All @@ -148,3 +149,4 @@
//= require case_conferences/form
//= require internal_referrals/form
//= require service_receives/form
//= require screening_assessments/form
62 changes: 62 additions & 0 deletions app/assets/javascripts/application_with_pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// FRAMEWORK
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require bootstrap-sprockets
//= require jquery.steps.min
//= require jquery.validate
//= require jquery.validate.additional-methods
//= require jquery.nicescroll.min

//= require editable/bootstrap-editable
//= require editable/rails
//= require jQuery.print

//= require image_upload_previewer/image_upload_previewer
//= require image_upload
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.en-GB.js
//= require datepicker
//= require metisMenu/jquery.metisMenu.js
//= require lodash/lodash.min.js
// require query_builder/query-builder.standalone.min.js
//= require jquery.extendext
//= require doT
//= require query-builder

//remove query_builder/utils, query_builder/model and query_builder/plugin bcuz conflict with form-builder select option not show

//= require moment
//= require fullcalendar
//= require bootstrap_file_input/purify.min.js
//= require bootstrap_file_input/fileinput.js
//= require bootstrap_file_input/fa/theme.min.js
//= require bootstrap_file_input/explorer/theme.min.js

// WRAPBOOTSTRAP
//= require iCheck/icheck.min.js
//= require wrapbootstrap/inspinia.js
//= require slimscroll/jquery.slimscroll.min.js
//= require toastr/toastr.min.js
//= require bootstrap-tour/bootstrap-tour.js

// LADDA
//= require ladda/spin.min
//= require ladda/ladda.min
//= require ladda/ladda.jquery.min

//LOAD MODULE
//= require namespace
//= require util
//= require initializer
//= require common
//= require jquery.infinitescroll.min
//= require footable.all.min

//APPLICATION JS
//= require calendars/index
//= require clients/index
//= require report_creator
//= require clients/show
//= require clients/form
//= require clients/book
81 changes: 49 additions & 32 deletions app/assets/javascripts/assessments/form.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.AssessmentsUpdate = do ->
_init = ->
window.domainOptionScores = {}
forms = $('form.assessment-form')

for form in forms
Expand Down Expand Up @@ -73,7 +74,7 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
currentTabLabels = $(@).siblings()
currentTabLabels.removeClass('active-label')


domainOptionScores[@.dataset.domainId] = @.dataset.score
$('.score_option').removeClass('is_error')
labelColors = 'btn-danger btn-warning btn-primary btn-success btn-secondary'
currentTabLabels.removeClass(labelColors)
Expand All @@ -85,6 +86,7 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
$($(@).siblings().get(-1)).val(score)

$('.score_option input').attr('required','required')

$('.col-xs-12').on 'click', '.score_option label', ->
return if $(@).closest(".root-wizard").attr("id") == 'readonly-rootwizard'

Expand Down Expand Up @@ -149,7 +151,7 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
currentTab = "#{rootId}-p-#{currentIndex}"
domainId = $("#{currentTab}").find('.score_option').data('domain-id')

return true if _disableRequiredFields() || rootId == '#readonly-rootwizard'
return true if _disableRequiredFields() || rootId == '#readonly-rootwizard' || domainId == undefined

form.validate().settings.ignore = ':disabled,:hidden'
form.valid()
Expand All @@ -167,7 +169,8 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
_formEdit(rootId, currentIndex)
$('a#btn-save').show()

if currentStep.hasClass('domain-last') or $(rootId).find('a[href="#finish"]:visible').length
if (currentStep.hasClass('domain-last') or $(rootId).find('a[href="#finish"]:visible').length)
_setTotalRiskAssessment()
if $(rootId).find('a[href="#finish"]:visible').length
console.log 'hiding save button'
$("#{rootId} a[href='#save']").hide()
Expand All @@ -179,9 +182,7 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
form.validate().settings.ignore = ':disabled'
form.valid()

currentStep = $("#{rootId}-p-" + currentIndex)

_filedsValidator(currentIndex,newIndex)
_filedsValidator(currentIndex, newIndex)

onFinished: ->
return if rootId == '#readonly-rootwizard'
Expand All @@ -191,6 +192,20 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
$('.actions a:contains("Done")').removeAttr('href')
form.submit()

_setTotalRiskAssessment = ->
scoreColors = $('.score_option.with-def')[0].dataset
total = 0
$.each $('.risk-assessment-domain-score'), (index, element) ->
scoreValue = domainOptionScores[element.dataset.domainId]
if !_.isEmpty(domainOptionScores) && scoreValue
color = scoreColors["score-#{scoreValue}"]
$(element).addClass("btn-#{color || 'primary'}")
$(element).html(scoreValue)
total += parseInt($(element).html())

total = Math.round(parseFloat(total) / $('.risk-assessment-domain-score').length)
$('#btn-total').html(total) if total != 0

_appendSaveButton = ->
if $('#rootwizard').find('a[href="#finish"]:visible').length == 0 && $("#btn-save").length == 0
$('#rootwizard').find("[aria-label=Pagination]").append("<li><a id='btn-save' href='#save' class='btn btn-info' style='background: #21b9bb;'></a></li>")
Expand Down Expand Up @@ -227,36 +242,38 @@ CIF.AssessmentsNew = CIF.AssessmentsEdit = CIF.AssessmentsCreate = CIF.Assessmen
scoreOption = $("#{currentTab} .score_option.without-def")
chosenScore = scoreOption.find('label input:checked').val()

scoreColor = scoreOption.data("score-#{chosenScore}")
scoreOption.find("label label:contains(#{chosenScore})").addClass("label-default active-label")

btnScore = scoreOption.find('input:hidden').val()
$(scoreOption.find("div[data-score='#{btnScore}']").get(0)).addClass("btn-secondary")
domainName = $(@).data('goal-option')
name = 'assessment[assessment_domains_attributes]['+ "#{currentIndex}" +'][goal_required]\']'
radioName = '\'' + name
goalRequiredValue = $("input[name=#{radioName}:checked").val()
select = $(currentTab).find('textarea.goal')

if scoreColor == 'primary'
if goalRequiredValue == 'false'
$(select).val('')
$(select).prop('readonly', true)
$(select).addClass('valid')
else if goalRequiredValue == 'true'
$(select).prop('readonly', false)
$(select).removeClass('valid')
$(select).addClass('valid') if $(select).val() != ''
else
if $(select).val() != ''
$(select).addClass('valid')
if chosenScore
scoreColor = scoreOption.data("score-#{chosenScore}")
scoreOption.find("label label:contains(#{chosenScore})").addClass("label-default active-label")

btnScore = scoreOption.find('input:hidden').val()
$(scoreOption.find("div[data-score='#{btnScore}']").get(0)).addClass("btn-secondary")
domainName = $(@).data('goal-option')
name = 'assessment[assessment_domains_attributes]['+ "#{currentIndex}" +'][goal_required]\']'
radioName = '\'' + name
goalRequiredValue = $("input[name=#{radioName}:checked").val()
select = $(currentTab).find('textarea.goal')

if scoreColor == 'primary'
if goalRequiredValue == 'false'
$(select).val('')
$(select).prop('readonly', true)
$(select).addClass('valid')
else if goalRequiredValue == 'true'
$(select).prop('readonly', false)
$(select).removeClass('valid')
$(select).addClass('valid') if $(select).val() != ''
else
$(select).removeClass('valid').addClass('required')
if $(select).val() != ''
$(select).addClass('valid')
else
$(select).removeClass('valid').addClass('required')

_filedsValidator = (currentIndex, newIndex ) ->
return true if _disableRequiredFields()

currentTab = "#rootwizard-p-#{currentIndex}"

return true if _disableRequiredFields() || $("#{currentTab}.domain-client-wellbeing-score").length

scoreOption = $("#{currentTab} .score_option")
reason = $("#{currentTab} .reason").val()
return false unless reason
Expand Down
65 changes: 63 additions & 2 deletions app/assets/javascripts/client_advance_search.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class CIF.ClientAdvanceSearch
@filterTranslation = ''
@customFormSelected = []
@programSelected = []
@assessmentSelected = ''
optionTranslation = $('#opt-group-translation')

@enrollmentCheckbox = $('#enrollment-checkbox')
Expand All @@ -16,6 +17,7 @@ class CIF.ClientAdvanceSearch
@ENROLLMENT_URL = '/api/client_advanced_searches/get_enrollment_field'
@TRACKING_URL = '/api/client_advanced_searches/get_tracking_field'
@EXIT_PROGRAM_URL = '/api/client_advanced_searches/get_exit_program_field'
@PROGRAM_STREAM_URL = '/api/client_advanced_searches/get_program_stream_search_field'

@DOMAIN_SCORES_TRANSLATE = $(optionTranslation).data('csiDomainScores')
@BASIC_FIELD_TRANSLATE = $(optionTranslation).data('basicFields')
Expand All @@ -34,6 +36,7 @@ class CIF.ClientAdvanceSearch
setValueToBuilderSelected: ->
@customFormSelected = $('#custom-form-data').data('value')
@programSelected = $('#program-stream-data').data('value')
@assessmentSelected = $('#assessment-form-data').data('value')
@wizardCustomFormSelected = $('#wizard-custom-form-data').data('value')
@wizardProgramSelected = $('#wizard-program-stream-data').data('value')

Expand Down Expand Up @@ -92,11 +95,11 @@ class CIF.ClientAdvanceSearch


initSelect2: ->
$('#custom-form-select, #wizard-custom-form-select, #program-stream-select, #wizard-program-stream-select, #quantitative-case-select').select2()
$('#custom-form-select, #wizard-custom-form-select, #program-stream-select, #wizard-program-stream-select, #quantitative-case-select, #assessment-select').select2()
$('#builder select').select2()
$('#wizard-builder select').select2()
setTimeout ( ->
ids = ['#custom-form-select', '#wizard-custom-form-select', '#program-stream-select', '#wizard-program-stream-select', '#quantitative-case-select', '#wizard-builder', '#builder']
ids = ['#custom-form-select', '#wizard-custom-form-select', '#program-stream-select', '#wizard-program-stream-select', '#quantitative-case-select', '#wizard-builder', '#builder', '#assessment-select']
$.each ids, (index, item) ->
$("#{item} .rule-filter-container select").select2(width: '250px')
$("#{item} .rule-operator-container select, .rule-value-container select").select2(width: 'resolve')
Expand All @@ -119,6 +122,7 @@ class CIF.ClientAdvanceSearch
wizardBasicQueryRules = $('#wizard-builder').data('basic-search-rules')
unless basicQueryRules == undefined or _.isEmpty(basicQueryRules.rules)
self.handleAddHotlineFilter()
console.log(basicQueryRules, 'basic query')
$('#builder').queryBuilder('setRules', basicQueryRules)
unless wizardBasicQueryRules == undefined or _.isEmpty(wizardBasicQueryRules.rules)
$('#wizard-builder').queryBuilder('setRules', wizardBasicQueryRules)
Expand Down Expand Up @@ -147,6 +151,11 @@ class CIF.ClientAdvanceSearch
$('#custom-form-column').removeClass('hidden')
$('#wizard-custom-form .loader').addClass('hidden')

assessmentSelectChange: ->
self = @
$('.main-report-builder .assessment-form-wrapper select').on 'select2-selecting', (element) ->
self.assessmentSelected = element.val

addCustomBuildersFields: (ids, url, loader=undefined) ->
self = @
action = _.last(url.split('/'))
Expand Down Expand Up @@ -231,6 +240,36 @@ class CIF.ClientAdvanceSearch
$('#custom-form-checkbox').on 'ifChecked', ->
$('.custom-form').show()

handleHideAssessmentSelect: ->
self = @
$('#assessment-checkbox').on 'ifUnchecked', ->
ruleFiltersSelect = $('.main-report-builder .rule-container .rule-filter-container select')
ruleFiltersSelect.select2('destroy')
ruleFiltersSelect.parents('.rule-container').find('.rule-header button').trigger('click')
self.assessmentSelected = ''
$('.assessment-form').hide()
$('#builder').queryBuilder('removeFilter', ['assessment_condition_last_two','assessment_condition_first_last'])
$('button[data-add="rule"]').trigger('click')
self.initSelect2()
return

handleShowAssessmentSelect: ->
self = @
if $('#assessment-checkbox').prop('checked')
$('.assessment-form').show()
$('#assessment-checkbox').on 'ifChecked', ->
$('.assessment-form').show()
self.assessmentSelected = $('select.assessment-select').val()
$.ajax
url: self.PROGRAM_STREAM_URL
data: { assesment_checked: true }
method: 'GET'
success: (response) ->
fieldList = response.client_advanced_searches
$('#builder').queryBuilder('addFilter', fieldList)
self.initSelect2()
return

######################################################################################################################

customFormSelectRemove: ->
Expand Down Expand Up @@ -258,6 +297,19 @@ class CIF.ClientAdvanceSearch
if $('#wizard_custom_form_filter').is(':checked')
self.handleRemoveFilterBuilder(removeValue, self.CUSTOM_FORM_TRANSLATE, '#wizard-builder')

assessmentSelectRemove: ->
self = @
$('.main-report-builder .assessment-form-wrapper select').on 'select2-removed', (element) ->
$.map self.assessmentSelected, (val, i) ->
if parseInt(val) == parseInt(element.val) then self.assessmentSelected.splice(i, 1)

removeActiveClientProgramOption: ->
$('.main-report-builder .rule-container .rule-filter-container select').select2('destroy')
$('.main-report-builder .rule-container').find('.rule-header button').trigger('click')
$('button[data-add="rule"]').trigger('click')
$('#builder').queryBuilder('removeFilter', ['active_client_program'])
@.initSelect2()

handleRemoveFilterBuilder: (resourceName, resourcelabel, elementBuilder = '#builder') ->
self = @
if elementBuilder == '#builder'
Expand Down Expand Up @@ -323,13 +375,17 @@ class CIF.ClientAdvanceSearch
$('.main-report-builder .program-association, .main-report-builder .program-stream').hide()
$('.main-report-builder .program-association input[type="checkbox"]').iCheck('uncheck')
$('.main-report-builder select.program-stream-select').select2("val", "")
self.removeActiveClientProgramOption()

handleProgramSelectChange: ->
self = @
$('.main-report-builder select.program-stream-select').on 'select2-selecting', (psElement) ->
programId = psElement.val
self.programSelected.push programId
$('.main-report-builder .program-association').show()
if self.programSelected.length == 1
self.addCustomBuildersFields(self.programSelected, self.PROGRAM_STREAM_URL, self.LOADER)

if $('#enrollment-checkbox').is(':checked')
self.LOADER.start()
self.addCustomBuildersFields(programId, self.ENROLLMENT_URL, self.LOADER)
Expand Down Expand Up @@ -679,6 +735,9 @@ class CIF.ClientAdvanceSearch
programStreamAssociation = $('.main-report-builder .program-association')
$(programStreamAssociation).find('.i-checks').iCheck('uncheck')
$(programStreamAssociation).hide()

if self.programSelected.length == 0
self.removeActiveClientProgramOption()

$('#report-builder-wizard .program-stream-select').on 'select2-removed', (element) ->
programName = element.choice.text
Expand Down Expand Up @@ -808,6 +867,7 @@ class CIF.ClientAdvanceSearch
builderForm = '.main-report-builder'
programValues = if self.programSelected.length > 0 then "[#{self.programSelected}]"
customFormValues = if self.customFormSelected.length > 0 then "[#{self.customFormSelected}]"
assessmentValues = if self.assessmentSelected.length > 0 then "[#{self.assessmentSelected}]"
else
builderElement = '#wizard-builder'
builderForm = '#report-builder-wizard'
Expand All @@ -823,6 +883,7 @@ class CIF.ClientAdvanceSearch
self.setValueToProgramAssociation()
$('#client_advanced_search_custom_form_selected').val(customFormValues)
$('#client_advanced_search_program_selected').val(programValues)
$('#client_advanced_search_assessment_selected').val(assessmentValues)
if $('#quantitative-type-checkbox').prop('checked') then $('#client_advanced_search_quantitative_check').val(1)
if $('#wizard_quantitative_filter').prop('checked') then $('#client_advanced_search_wizard_quantitative_check').val(1)
if $('#wizard_custom_form_filter').prop('checked') then $('#client_advanced_search_wizard_custom_form_check').val(1)
Expand Down
Loading

0 comments on commit 4f43039

Please sign in to comment.