forked from rubyforgood/casa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rubyforgood#5564 from afogel/5309_update_contact_t…
…ype_selection 5309 update contact type selection
- Loading branch information
Showing
41 changed files
with
302 additions
and
290 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="badge rounded-pill bg-primary active px-3"> | ||
${escape(data.text)} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class Form::MultipleSelect::ItemComponent < ViewComponent::Base | ||
strip_trailing_whitespace | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="select-style-1 mr-8" | ||
data-controller="multiple-select" | ||
data-multiple-select-options-value="<%= @options %>" | ||
data-multiple-select-selected-items-value="<%= @selected_items %>" | ||
data-multiple-select-with-options-value="true"> | ||
|
||
<template data-multiple-select-target="option"> | ||
<div class="d-flex align-items-baseline"> | ||
<span class='mr-5'>DATA_LABEL</span> | ||
<% if @render_option_subtext %> | ||
<small class="fst-italic fw-lighter"><em>DATA_SUB_TEXT</em></small> | ||
<% end %> | ||
</div> | ||
</template> | ||
|
||
<template data-multiple-select-target="item"> | ||
<div class="badge rounded-pill bg-primary active px-3">DATA_LABEL</div> | ||
</template> | ||
|
||
<%= @form.select @name, {}, { multiple: true } , { | ||
data: { "multiple-select-target": "select", } , class: "form-control-lg form-select form-select-lg input-group-lg" | ||
} %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Form::MultipleSelectComponent < ViewComponent::Base | ||
def initialize(form:, name:, options:, selected_items:, render_option_subtext: false) | ||
@form = form | ||
@name = name | ||
@options = options.to_json | ||
@selected_items = selected_items | ||
@render_option_subtext = render_option_subtext | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class ContactTypeDecorator < Draper::Decorator | ||
include ActionView::Helpers::DateHelper | ||
delegate_all | ||
|
||
def hash_for_multi_select_with_cases(casa_case_ids) | ||
if casa_case_ids.nil? | ||
casa_case_ids = [] | ||
end | ||
|
||
{value: object.id, text: object.name, group: object.contact_type_group.name, subtext: last_time_used_with_cases(casa_case_ids)} | ||
end | ||
|
||
def last_time_used_with_cases(casa_case_ids) | ||
last_contact = CaseContact.joins(:contact_types).where(casa_case_id: casa_case_ids, contact_types: {id: object.id}).order(occurred_at: :desc).first | ||
|
||
last_contact.nil? ? "never" : "#{time_ago_in_words(last_contact.occurred_at)} ago" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.