Skip to content

Commit

Permalink
Merge pull request #34684 from dimagi/jls/b5-reminders
Browse files Browse the repository at this point in the history
[B5] reminders / keywords
  • Loading branch information
orangejenny authored Jun 13, 2024
2 parents cb81425 + 05c4833 commit d3d0b80
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@
"notifications": {
"in_progress": true
},
"reminders": {
"is_complete": true
},
"reports": {
"in_progress": true
},
Expand Down
204 changes: 91 additions & 113 deletions corehq/apps/reminders/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from corehq.apps.app_manager.dbaccessors import get_app
from corehq.apps.groups.models import Group
from corehq.apps.hqwebapp import crispy as hqcrispy
from corehq.apps.hqwebapp.widgets import BootstrapCheckboxInput
from corehq.apps.reminders.util import DotExpandedDict, get_form_list, split_combined_id
from corehq.apps.sms.models import Keyword

Expand Down Expand Up @@ -128,9 +129,12 @@ class KeywordForm(Form):
keyword = CharField(label=gettext_noop("Keyword"))
description = TrimmedCharField(label=gettext_noop("Description"))
override_open_sessions = BooleanField(
label="",
required=False,
initial=False,
label=gettext_noop("Override open SMS Surveys"),
widget=BootstrapCheckboxInput(
inline_label=gettext_lazy("Override open SMS Surveys"),
),
)
allow_keyword_use_by = ChoiceField(
required=False,
Expand Down Expand Up @@ -186,19 +190,28 @@ class KeywordForm(Form):
)
use_custom_delimiter = BooleanField(
required=False,
label=gettext_noop("Use Custom Delimiter"),
label="",
widget=BootstrapCheckboxInput(
inline_label=gettext_lazy("Use Custom Delimiter"),
),
)
delimiter = TrimmedCharField(
required=False,
label=gettext_noop("Please Specify Delimiter"),
)
use_named_args_separator = BooleanField(
required=False,
label=gettext_noop("Use Joining Character"),
label="",
widget=BootstrapCheckboxInput(
inline_label=gettext_lazy("Use Joining Character"),
),
)
use_named_args = BooleanField(
required=False,
label=gettext_noop("Use Named Answers"),
label="",
widget=BootstrapCheckboxInput(
inline_label=gettext_lazy("Use Named Answers"),
),
)
named_args_separator = TrimmedCharField(
required=False,
Expand Down Expand Up @@ -239,9 +252,8 @@ def __init__(self, *args, **kwargs):

from corehq.apps.reminders.views import KeywordsListView
self.helper = FormHelper()
self.helper.form_class = "form form-horizontal"
self.helper.label_class = 'col-sm-3 col-md-2'
self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
self.helper.form_class = "form"
self.helper.label_class = "form-label"

layout_fields = [
crispy.Fieldset(
Expand All @@ -268,87 +280,58 @@ def __init__(self, *args, **kwargs):
data_bind="value: structuredSmsAppAndFormUniqueId",
css_class="hqwebapp-select2",
),
hqcrispy.B3MultiField(
_("Delimiters"),
crispy.Div(
crispy.Div(
InlineField(
twbscrispy.PrependedText('use_custom_delimiter', '',
data_bind="checked: useCustomDelimiter, "
"click: updateExampleStructuredSMS"),

block_css_class="span2",
),
css_class='col-md-4 col-lg-4'
),
crispy.Div(
InlineField(
'delimiter',
data_bind="value: delimiter, "
"valueUpdate: 'afterkeydown', "
"event: {keyup: updateExampleStructuredSMS},"
"visible: useCustomDelimiter",
block_css_class="span4",
),
css_class='col-md-4 col-lg-4'
)

),
twbscrispy.PrependedText('use_custom_delimiter', '',
data_bind="checked: useCustomDelimiter, "
"click: updateExampleStructuredSMS"),
InlineField(
'delimiter',
data_bind="value: delimiter, "
"valueUpdate: 'afterkeydown', "
"event: {keyup: updateExampleStructuredSMS},"
"visible: useCustomDelimiter",
css_class="mb-3",
),
hqcrispy.B3MultiField(
_("Named Answers"),
twbscrispy.PrependedText('use_named_args', '',
data_bind="checked: useNamedArgs, "
"click: updateExampleStructuredSMS"),
hqcrispy.ErrorsOnlyField('named_args'),
crispy.Div(
data_bind="template: {"
" name: 'ko-template-named-args', "
" data: $data"
"}, "
"visible: useNamedArgs",
css_class="mb-3",
),
crispy.Div(
crispy.Div(
InlineField(
twbscrispy.PrependedText('use_named_args', '',
data_bind="checked: useNamedArgs, "
"click: updateExampleStructuredSMS"),

twbscrispy.PrependedText(
'use_named_args_separator', '',
data_bind="checked: useNamedArgsSeparator, "
"click: updateExampleStructuredSMS"
),
),
css_class='col-md-4 col-lg-4'
),

hqcrispy.ErrorsOnlyField('named_args'),
crispy.Div(
data_bind="template: {"
" name: 'ko-template-named-args', "
" data: $data"
"}, "
"visible: useNamedArgs",
),
),
hqcrispy.B3MultiField(
_("Joining Characters"),
crispy.Div(
crispy.Div(
InlineField(
twbscrispy.PrependedText(
'use_named_args_separator', '',
data_bind="checked: useNamedArgsSeparator, "
"click: updateExampleStructuredSMS"
),
),
css_class='col-md-4 col-lg-4'
InlineField(
'named_args_separator',
data_bind="value: namedArgsSeparator, "
"valueUpdate: 'afterkeydown', "
"event: {keyup: updateExampleStructuredSMS},"
"visible: useJoiningCharacter",
),

crispy.Div(
InlineField(
'named_args_separator',
data_bind="value: namedArgsSeparator, "
"valueUpdate: 'afterkeydown', "
"event: {keyup: updateExampleStructuredSMS},"
"visible: useJoiningCharacter",
),
css_class='col-md-6 col-lg-4'
)

),
data_bind="visible: useNamedArgs",
css_class="mb-3",
),
hqcrispy.B3MultiField(
_("Example Structured Message"),
crispy.HTML('<pre style="background: white;" '
crispy.HTML('<span class="font-monospace badge rounded-pill bg-secondary" '
'data-bind="text: exampleStructuredSms">'
'</pre>'),
css_class="mb-3",
),
disabled=self.readonly,
),
Expand Down Expand Up @@ -379,44 +362,41 @@ def __init__(self, *args, **kwargs):
'other_recipient_content_type',
data_bind="value: otherRecipientContentType",
),
hqcrispy.B3MultiField(
"",
crispy.Div(
crispy.HTML(
'<h4>%s</h4>'
% _("Recipient Information"),
),
crispy.Field(
'other_recipient_type',
data_bind="value: otherRecipientType",
),
crispy.Div(
crispy.HTML(
'<h4 style="margin-bottom: 20px;">%s</h4>'
% _("Recipient Information"),
),
crispy.Field(
'other_recipient_type',
data_bind="value: otherRecipientType",
),
crispy.Div(
crispy.Field(
'other_recipient_id',
data_bind="value: otherRecipientId",
),
data_bind="visible: showRecipientGroup",
'other_recipient_id',
data_bind="value: otherRecipientId",
),
crispy.Div(
crispy.Field(
'other_recipient_message',
data_bind="value: otherRecipientMessage",
),
data_bind="visible: otherRecipientContentType() == 'sms'",
data_bind="visible: showRecipientGroup",
),
crispy.Div(
crispy.Field(
'other_recipient_message',
data_bind="value: otherRecipientMessage",
),
crispy.Div(
crispy.Field(
'other_recipient_app_and_form_unique_id',
data_bind="value: otherRecipientAppAndFormUniqueId",
css_class="hqwebapp-select2",
),
data_bind="visible: otherRecipientContentType() == 'survey'",
data_bind="visible: otherRecipientContentType() == 'sms'",
),
crispy.Div(
crispy.Field(
'other_recipient_app_and_form_unique_id',
data_bind="value: otherRecipientAppAndFormUniqueId",
css_class="hqwebapp-select2",
),
css_class="well",
data_bind="visible: notifyOthers",
data_bind="visible: otherRecipientContentType() == 'survey'",
),
css_class="well",
data_bind="visible: notifyOthers",
disabled=self.readonly,
),
disabled=self.readonly,
),
crispy.Fieldset(
_("Advanced Options"),
Expand All @@ -427,16 +407,14 @@ def __init__(self, *args, **kwargs):
'allow_keyword_use_by',
disabled=self.readonly,
),
hqcrispy.FormActions(
twbscrispy.StrictButton(
_("Save"),
css_class='btn-primary',
type='submit',
disabled=self.readonly,
),
crispy.HTML('<a href="%s" class="btn btn-default">Cancel</a>'
% reverse(KeywordsListView.urlname, args=[self.domain]))
twbscrispy.StrictButton(
_("Save"),
css_class='btn-primary',
type='submit',
disabled=self.readonly,
),
crispy.HTML('<a href="%s" class="btn btn-outline-primary">%s</a>'
% (reverse(KeywordsListView.urlname, args=[self.domain]), _("Cancel")))
])
self.helper.layout = crispy.Layout(*layout_fields)

Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/reminders/static/reminders/js/keywords_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ hqDefine('reminders/js/keywords_list', [
"knockout",
"hqwebapp/js/initial_page_data",
"hqwebapp/js/multiselect_utils",
"hqwebapp/js/bootstrap3/crud_paginated_list",
"hqwebapp/js/bootstrap5/crud_paginated_list",
], function ($, ko, initialPageData, multiselectUtils, CRUDPaginatedList) {
$(function () {
multiselectUtils.createFullMultiselectWidget('keyword-selector', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ hqDefine("reminders/js/reminders.keywords.ko", [
"jquery",
"knockout",
"hqwebapp/js/initial_page_data",
"hqwebapp/js/bootstrap3/widgets", // .hqwebapp-select2 for survey dropdown
"hqwebapp/js/bootstrap5/widgets", // .hqwebapp-select2 for survey dropdown
], function (
$,
ko,
Expand Down
10 changes: 5 additions & 5 deletions corehq/apps/reminders/templates/reminders/keyword.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% extends "hqwebapp/bootstrap5/base_section.html" %}
{% load hq_shared_tags %}
{% load crispy_forms_tags %}
{% load i18n %}

{% requirejs_main 'reminders/js/reminders.keywords.ko' %}
{% requirejs_main_b5 'reminders/js/reminders.keywords.ko' %}

{% block page_content %}
{% initial_page_data 'current_values' form.current_values %}
Expand All @@ -12,7 +12,7 @@
</div>

<script type="text/html" id="ko-template-named-args">
<table class="table table-bordered table-striped col-md-6 col-lg-6">
<table class="table table-bordered table-striped col-lg-6 col-xl-6">
<thead>
<tr>
<th>{% trans "Name" %}</th>
Expand All @@ -37,13 +37,13 @@
attr: {name : ('named_args.' + $index() + '.xpath')}
" /></td>
<td><button type="button"
class="btn btn-danger"
class="btn btn-outline-danger"
data-bind="click: $parent.removeNamedArg">
<i class="fa fa-remove"></i> {% trans "Remove" %}</button></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary pull-left"
<button class="btn btn-outline-primary"
type="button"
data-bind="click: addNamedArg">
<i class="fa fa-plus"></i> {% trans 'Add Named Answer' %}
Expand Down
Loading

0 comments on commit d3d0b80

Please sign in to comment.