Skip to content

Commit

Permalink
Fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp-work committed Apr 18, 2024
1 parent 88e8d4b commit 9f07a9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/api/app/assets/javascripts/webui/canned_responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ function setupCannedResponses() { // jshint ignore:line
$('[data-canned-controller]').on('click', '[data-canned-response]', function(e) {
$(e.target).closest('[data-canned-controller]').find('textarea').val(e.target.dataset.cannedResponse);
// let's make sure this exists first, to avoid errors
if ($(e.target).closest('[data-canned-controller]').find('#decision_type').length != 0) {
if ($(e.target).closest('[data-canned-controller]').find('#decision_type').length !== 0) {
// we gather up all the possible options, to make sure whatever we click doesn't wipe out the selection box
var options_html = $(e.target).closest('[data-canned-controller]').find('#decision_type')[0].options;
var options = Array.from(options_html).map(el => el.value);
var optionsHtml = $(e.target).closest('[data-canned-controller]').find('#decision_type')[0].options;
var options = Array.from(optionsHtml).map(el => el.value);
// and if whatever we are trying to set exists within the options, we set it, otherwise we don't change the select box
if (options.includes(e.target.dataset.decisionType))
$(e.target).closest('[data-canned-controller]').find('#decision_type').val(e.target.dataset.decisionType);
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/decision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def description

# List of all viable types for a reportable, used in the decision creation form
def self.types(reportable)
TYPES.filter_map do |type|
[type.display_name, type.name] if type.display?(reportable)
TYPES.filter_map do |decision_type|
[decision_type.display_name, decision_type.name] if decision_type.display?(reportable)
end.compact.to_h
end

Expand Down

0 comments on commit 9f07a9e

Please sign in to comment.