Skip to content

Commit

Permalink
Merge pull request #2184 from Children-in-Families/merge-23082023
Browse files Browse the repository at this point in the history
Merge 23082023
  • Loading branch information
kirykr authored Aug 23, 2023
2 parents b79d35c + a114fd4 commit ef51bec
Show file tree
Hide file tree
Showing 23 changed files with 214 additions and 113 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/advanced_filter_builder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class CIF.AdvancedFilterBuilder
rules = $("a[data-save-search-#{advancedSearchId}]").data("save-search-#{advancedSearchId}")
$('button.client-advance-search').click()
self.handleAddHotlineFilter()
$('.program-stream-column li.visibility, .hotline-call-column li.visibility').each ->
$('.program-stream-column li.visibility, .hotline-call-column li.visibility, .assessment-column li.visibility').each ->
fieldCheckedBoxValue = $($(this).find('input')[0]).val()
values = self.getSaveSearchFields(rules.rules)
$($(this).find('input')[0]).iCheck('check') if values.includes(fieldCheckedBoxValue)
Expand Down
43 changes: 25 additions & 18 deletions app/assets/javascripts/client_advance_search.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -122,39 +122,40 @@ class CIF.ClientAdvanceSearch

$('#assessment-select').on 'change', (e)->
$(".assessment-data-dropdown li").addClass("hide")
self.hideCSIFilters()
self.showAssessmentColumns("")

value = $('#assessment-select').select2('data') && $('#assessment-select').select2('data').id
$(".assessment-data-dropdown li.csi-#{value}").removeClass("hide")
$("input[id$='_advanced_search_assessment_selected']").val("[#{value}]")

if value == "0" && $("body").attr("id").indexOf("families") == -1
self.toggleAdvanceReportSection($("#assessment-checkbox").data("custom"))
self.toggleAdvanceReportSection($("#assessment-checkbox").data("csi"), false)
else
self.toggleAdvanceReportSection($("#assessment-checkbox").data("csi"))
self.toggleAdvanceReportSection($("#assessment-checkbox").data("custom"), false)
self.showAssessmentColumns($('#assessment-select option:selected').data("selectGroup"))

unless $("#assessment-checkbox").is(":checked")
$(".assessment-data-dropdown li").addClass("hide")
$("input[id$='_advanced_search_assessment_selected']").val("[]")
self.hideCSIFilters()
self.showAssessmentColumns("")

$('#assessment-select').trigger('change')

hideCSIFilters: ->
@.toggleAdvanceReportSection($("#assessment-checkbox").data("custom"))
@.toggleAdvanceReportSection($("#assessment-checkbox").data("csi"))

toggleAdvanceReportSection: (sectionText, hide = true) ->
console.log(sectionText, hide)
$options = $("optgroup[label='#{sectionText}'] option")
showAssessmentColumns: (sectionText) ->
self = @

if hide
$options.attr("disabled", "disabled")
else
# Toggle domain score fields
$.each $('#assessment-select option'), (index, item) ->
$options = $("optgroup[label='#{$(item).data("selectGroup")}'] option")

if $(item).data("selectGroup") == sectionText
$options.attr("disabled", false)
else
$options.attr("disabled", "disabled")

# Toggle custom assessment fields
$options = $("optgroup[label='Custom Assessment'] option")

if sectionText != undefined && sectionText.indexOf(" | ") > -1
$options.attr("disabled", false)
else
$options.attr("disabled", "disabled")

$('#builder select').select2(width: '250px')

Expand Down Expand Up @@ -304,6 +305,9 @@ class CIF.ClientAdvanceSearch
ruleFiltersSelect.select2('destroy')
ruleFiltersSelect.parents('.rule-container').find('.rule-header button').trigger('click')

$(".custom-assessment-setting input[type='checkbox']").iCheck("uncheck")
$('.assessment-column a.dropdown-toggle').addClass('disabled')

$(".custom-assessment-setting").hide()

$('.assessment-form').hide()
Expand All @@ -321,6 +325,9 @@ class CIF.ClientAdvanceSearch
$('.assessment-form').show()
assessmentSelectValue = $('#assessment-select').find(':selected').val()

$('.assessment-column a.dropdown-toggle').removeClass('disabled')
# self.initSelect2()

$("div[data-custom-assessment-setting-id='#{assessmentSelectValue}']").show()
self.assessmentSelected = $('select.assessment-select').val()
$.ajax
Expand Down
17 changes: 11 additions & 6 deletions app/assets/javascripts/clients/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,24 @@ CIF.ClientsIndex = CIF.ClientsWelcome = do ->
_initClientColumnFilter()

_initClientColumnFilter = ->
searchBox = $('.client-column ul.columns-visibility #column-search-box')
searchBox = $('ul.columns-visibility .column-search-box')
searchBox.keyup ->
valThis = $(this).val().toLowerCase()

if valThis == ''
$('.client-column ul.columns-visibility > li').show()
$('ul.columns-visibility li').show()
else
$('.client-column ul.columns-visibility > li:not(:first-child)').each ->
text = $(this).text().toLowerCase()
$('ul.columns-visibility li:not(:first-child)').each ->
text = $(this).find("label").text().toLowerCase().trim()

if text.indexOf(valThis) >= 0 then $(this).show() else $(this).hide()
return
return

$('.client-column ul.columns-visibility .btn-clear-text').click ->
$('ul.columns-visibility .btn-clear-text').click ->
searchBox.val ''
searchBox.focus()
$('.client-column ul.columns-visibility > li').show()
$('ul.columns-visibility li').show()
return

_reOrderRuleContainer = ->
Expand Down Expand Up @@ -113,6 +115,9 @@ CIF.ClientsIndex = CIF.ClientsWelcome = do ->
b - a

_addDataTableToAssessmentScoreData = ->
if $("body#clients-welcome").length > 0 || $("body#families-welcome").length > 0
return

advanceFilter = new CIF.ClientAdvanceSearch()
advanceFilter.prepareSearchParams("search")

Expand Down
22 changes: 22 additions & 0 deletions app/assets/javascripts/families/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ CIF.FamiliesIndex = CIF.FamiliesWelcome = do ->
# _setDefaultCheckColumnVisibilityAll()
_initCheckbox()
_quantitativeCaesByQuantitativeType()
_initColumnFilter()

_initColumnFilter = ->
searchBox = $('ul.columns-visibility .column-search-box')
searchBox.keyup ->
valThis = $(this).val().toLowerCase()

if valThis == ''
$('ul.columns-visibility li').show()
else
$('ul.columns-visibility li:not(:first-child)').each ->
text = $(this).find("label").text().toLowerCase().trim()

if text.indexOf(valThis) >= 0 then $(this).show() else $(this).hide()
return
return

$('ul.columns-visibility .btn-clear-text').click ->
searchBox.val ''
searchBox.focus()
$('ul.columns-visibility li').show()
return

_initCheckbox = ->
$('.i-checks').iCheck
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/clients/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ body[id='clients-welcome'] {
margin-bottom: 20px;
}

.hotline-call-column {
.hotline-call-column, .assessment-column {
a.disabled {
color: #333333 !important;
cursor: not-allowed;
Expand Down
1 change: 1 addition & 0 deletions app/classes/advanced_searches/client_association_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def initialize(clients, field, operator, values)

def get_sql
sql_string = 'clients.id IN (?)'

case @field
when 'user_id'
values = user_id_field_query
Expand Down
24 changes: 22 additions & 2 deletions app/classes/advanced_searches/custom_domain_score_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,29 @@ class CustomDomainScoreFields
extend AdvancedSearchHelper

def self.render(domain_type = 'client')
address_translation
domain_type == 'client' ? render_client_fields(domain_type) : render_family_fields(domain_type)
end

def self.render_client_fields(domain_type)
domain_score_group = 'Custom Assessment'
custom_assessment_fields = []
custom_assessment_fields += ['custom_assessment'].map { |item| drop_list_options(item, format_header(item, domain_type), domain_score_group) }
custom_assessment_fields += ['custom_completed_date'].map { |item| date_picker_options(item, format_header(item, domain_type), domain_score_group) }
custom_assessment_fields += ['custom_assessment_created_at', 'date_of_custom_assessments'].map { |item| date_picker_options(item, format_header(item, domain_type), domain_score_group) }
custom_assessment_fields += ['All Custom Domains'].map { |item| number_filter_type(item.downcase.gsub(' ', '_'), domain_score_format(item), domain_score_group) }

CustomAssessmentSetting.only_enable_custom_assessment.each do |cas|
domain_score_group = "#{format_header('custom_csi_domain_scores', domain_type)} | #{cas.custom_assessment_name}"
domain_options_ = Domain.custom_csi_domains.order_by_identity.where(custom_assessment_setting_id: cas.id).map { |domain| "domainscore__#{domain.id}__#{domain.identity}" }
custom_assessment_fields += domain_options_.map { |item| number_filter_type(item, domain_score_format(item), domain_score_group) }
end

custom_assessment_fields.sort_by { |f| f[:label].downcase }
end

def self.render_family_fields(domain_type)
domain_score_group = format_header('custom_csi_domain_scores', domain_type)
csi_domain_options = domain_options(domain_type).map { |item| number_filter_type(item, domain_score_format(item), domain_score_group) }
csi_domain_options = domain_options.map { |item| number_filter_type(item, domain_score_format(item), domain_score_group) }
custom_assessments = ['custom_assessment'].map { |item| drop_list_options(item, format_header(item, domain_type), domain_score_group) }
assessment_completed_date = ['custom_completed_date'].map { |item| date_picker_options(item, format_header(item, domain_type), domain_score_group) }
date_of_assessments = ['date_of_custom_assessments', 'custom_assessment_created_at'].map { |item| date_picker_options(item, format_header(item, domain_type), domain_score_group) }
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ def enable_custom_assessment?
end

def assessment_options
@assessment_options ||= (Setting.cache_first.enable_default_assessment? ? [[0, Setting.cache_first.default_assessment, { "data-type" => :default }]] : []) + CustomAssessmentSetting.all.where(enable_custom_assessment: true).pluck(:id, :custom_assessment_name).to_a
@assessment_options ||= (Setting.cache_first.enable_default_assessment? ? [[0, Setting.cache_first.default_assessment, { "data-type" => :default, "data-select-group" => t('advanced_search.fields.csi_domain_scores') }]] : []) + CustomAssessmentSetting.all.where(enable_custom_assessment: true).pluck(:id, :custom_assessment_name).map{ |item| [item.first, item.last, { "data-select-group" => "#{t('advanced_search.fields.custom_csi_domain_scores')} | #{item.last}" }]}
end

def family_assessment_options
[
[0, t('families.family_assessment'), { "data-type" => :default }]
[0, t('families.family_assessment'), { "data-type" => :default, "data-select-group" => t('advanced_search.fields.family_assessment_domain_scores') }]
]
end

Expand Down
16 changes: 10 additions & 6 deletions app/views/assessments/_assessment_date_section.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
.ibox
.ibox-title
%h5
= "#{@assessment.client.name}"
%span= t('assessments.assessment_form')
.ibox-tools
= link_to client_assessments_path(@client), class: 'btn btn-default btn-back-default button' do
= t('.back')
.row
.col-xs-12.col-sm-6.co-md-6
%h5
= link_to @assessment.client do
= "#{@assessment.client.name}"
%span= t('assessments.assessment_form')
.col-xs-12.col-sm-6.col-md-6
.ibox-tools
= link_to client_assessments_path(@client), class: 'btn btn-default btn-back-default button' do
= t('.back')
.ibox-content
.row
.col-xs-12.col-md-6
Expand Down
6 changes: 5 additions & 1 deletion app/views/client_enrolled_program_trackings/_form.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
= simple_form_for([@client, @enrollment, @client_enrollment_tracking], url: client_enrollment_tracking_form_action_path, html: { class: 'client-enrolled-program-tracking' }) do |f|
.ibox-content
%h3= "#{@client.en_and_local_name} - #{@tracking.name} - #{@program_stream.name}"
%h3
= link_to @client do
= @client.en_and_local_name
%span= " - #{@tracking.name} - #{@program_stream.name}"

= f.simple_fields_for :properties, OpenStruct.new(@client_enrollment_tracking.properties) do |prop_f|
- @tracking.fields.each do |field|
.row
Expand Down
16 changes: 11 additions & 5 deletions app/views/client_enrolled_program_trackings/index.haml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
.ibox
.ibox-title
%h5= "#{@client.en_and_local_name} - #{t('.tracking_lists')}"
.ibox-tools
= link_to client_client_enrollments_path(@client) do
.btn.btn-primary.btn-outline
= t('.programs_list')
.row
.col-xs-12.col-sm-6.co-md-6
%h5
= link_to @client do
= @client.en_and_local_name
%span= t('.tracking_lists')
.col-xs-12.col-sm-6.col-md-6
.ibox-tools
= link_to client_client_enrollments_path(@client) do
.btn.btn-primary.btn-outline
= t('.programs_list')
.ibox-content
.table-responsive
= datagrid_table @tracking_grid, html: { class: 'table table-bordered table-striped table-hover client_enrolled_program_tracking'}
Expand Down
20 changes: 13 additions & 7 deletions app/views/client_enrolled_program_trackings/report.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
.col-xs-12
.ibox
.ibox-title
%h5= "#{@client.en_and_local_name} - #{@tracking.name} - #{@program_stream.name}"
.ibox-tools
- unless @enrollment.program_stream.tracking_required?
- if can? :manage, ClientEnrollmentTracking
= client_enrolled_tracking_new_link
= link_to client_client_enrolled_program_client_enrolled_program_trackings_path(@client, @enrollment, tracking_id: @tracking.id) do
.btn.btn-success.btn-outline= t('.back')
.row
.col-xs-12.col-sm-6.co-md-6
%h5
= link_to @client do
= @client.en_and_local_name
%span= " - #{@tracking.name} - #{@program_stream.name}"
.col-xs-12.col-sm-6.col-md-6
.ibox-tools
- unless @enrollment.program_stream.tracking_required?
- if can? :manage, ClientEnrollmentTracking
= client_enrolled_tracking_new_link
= link_to client_client_enrolled_program_client_enrolled_program_trackings_path(@client, @enrollment, tracking_id: @tracking.id) do
.btn.btn-success.btn-outline= t('.back')
.ibox-content
- @client_enrollment_trackings.each_slice(2) do |n_enrollment_trackings|
.row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
%label= t('.program_stream_column')
= render 'clients/client_advanced_searches/program_stream_column', program_stream_columns: @program_stream_columns
.col-xs-12{ class: current_setting.try(:enable_hotline) ? 'col-md-2' : 'col-md-3' }
%label= t('.assessment')
= render 'clients/client_advanced_searches/assessment_columns'
- if current_setting.try(:enable_hotline) == true
.col-xs-12.col-md-3
%label= t('.hotline_column')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.assessment-column
%ul.check-columns-visibility
%li.dropdown
%a.dropdown-toggle.btn.btn-default{ class: assessment_values.blank? && 'disabled' , 'data-toggle' => 'dropdown', href: '#' }
= t('datagrid.columns.select_columns')
%span.caret
%ul.dropdown-menu.columns-visibility.append-child
- if enable_default_assessment?
.custom-assessment-setting{ data: { custom_assessment_setting_id: 0 }, style: 'display: none;' }
- if current_organization.try(:aht) == true
%li.custom-assessment-devider{ style: 'padding-left: 15px; padding-bottom: 5px;'}
%strong= t('.result_framework_assessment')
%li
- else
%li.custom-assessment-devider{ style: 'padding-left: 15px; padding-bottom: 5px;'}
%strong= t('.csi_domain_scores')

%li
.visibility.col-sm-12
= check_box_tag 'all_csi_assessments_', 'all_csi_assessments', checked = saved_search_column_visibility('all_csi_assessments_'), class: 'i-checks'
- if current_organization.try(:aht) == true
= label_tag 'all_result_framework_assessments_', t('datagrid.columns.all_result_framework_assessment')
- else
= label_tag 'all_csi_assessments_', t('datagrid.columns.all_csi_assessments', assessment: t('clients.show.assessment'))
%li
.visibility.col-sm-12
= check_box_tag 'assessment_created_at_', 'assessment_created_at', checked = saved_search_column_visibility('assessment_created_at_'), class: 'i-checks'
= label_tag 'assessment_created_at_', t('datagrid.columns.assessment_created_at', assessment: t('clients.show.assessment'))
%li
.visibility.col-sm-12
= check_box_tag 'date_of_assessments_', 'date_of_assessments', checked = saved_search_column_visibility('date_of_assessments_'), class: 'i-checks'
= label_tag 'date_of_assessments_', t('datagrid.columns.date_of_assessments', assessment: t('clients.show.assessment'))
%li
.visibility.col-sm-12
= check_box_tag 'completed_date_', 'completed_date', checked = saved_search_column_visibility('completed_date_'), class: 'i-checks'
= label_tag 'completed_date_', t('datagrid.columns.assessment_completed_date', assessment: t('clients.show.assessment'))

= render partial: 'datagrid/domain_score_columns_picker', collection: Domain.csi_domains.order_by_identity, as: :domain
- if enable_custom_assessment?
- CustomAssessmentSetting.only_enable_custom_assessment.each do |cas|
.custom-assessment-setting{ data: { custom_assessment_setting_id: cas.id }, style: 'display: none;' }
= render partial: 'datagrid/custom_domain_score', locals: { custom_assessment_setting_name: cas.custom_assessment_name, custom_domains: Domain.custom_csi_domains.order_by_identity.where(custom_assessment_setting_id: cas.id) }
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
.row
.col-xs-12
.form-group
= check_box_tag :nil, '1', assessment_values.present?, { class: 'i-checks assessment-checkbox', id: 'assessment-checkbox', data: { custom: t('advanced_search.fields.custom_csi_domain_scores'), csi: t('advanced_search.fields.csi_domain_scores') } }
= check_box_tag :nil, '1', assessment_values.present?, { class: 'i-checks assessment-checkbox', id: 'assessment-checkbox' }
%label= t('.assessment_form')
.row.assessment-form
.col-xs-12
Expand Down
2 changes: 1 addition & 1 deletion app/views/clients/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
%span.caret
%ul.dropdown-menu.assessment-data-dropdown
- assessment_options.each do |assessment|
- if assessment[2].present?
- if assessment[2] && assessment[2].key?('data-type')
%li.csi-0
= link_to '#', class: 'btn btn-default', 'data-target': "#assessment-domain-score", 'data-toggle': 'modal' do
= assessment[1]
Expand Down
2 changes: 1 addition & 1 deletion app/views/datagrid/_domain_score_columns_picker.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%li
.visibility.col-sm-12
- domain_text = domain.custom_domain ? "custom_#{domain.convert_identity}_" : "#{domain.convert_identity}_"
= check_box_tag domain_text, domain.convert_identity, checked = default_setting(domain_text, @client_default_columns) || params[:"#{domain_text}"].present? || saved_search_column_visibility(domain_text) || saved_search_column_visibility('all_csi_assessments_') || saved_search_column_visibility('all_custom_csi_assessments_'), class: 'i-checks'
= check_box_tag domain_text, domain.convert_identity, checked = default_setting(domain_text, @client_default_columns) || params[:"#{domain_text}"].present? || saved_search_column_visibility(domain_text), class: 'i-checks'
= label_tag "#{domain.convert_identity}_", domain.identity
Loading

0 comments on commit ef51bec

Please sign in to comment.