Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handles AL custom birthdate field #217

Merged
merged 2 commits into from
May 4, 2021
Merged

Handles AL custom birthdate field #217

merged 2 commits into from
May 4, 2021

Conversation

plocket
Copy link
Collaborator

@plocket plocket commented May 3, 2021

See tests at https://github.com/SuffolkLITLab/docassemble-MA209AProtectiveOrder/runs/2492735082?check_suite_focus=true. They will fail, but they should get to at least the question id children-user-is-parent-of. Don't worry about the messages there about multiple items found on the page (for now).

Custom fields will sometimes have to be handled separately. This one replaces one input date field with three other fields to make it easier to input birthdates.

Example html of the fields in their question:

<section id="daquestion" class="tab-pane active col-xl-6 col-lg-6 col-md-9">
  <div class="progress mt-2">
    <div class="progress-bar" role="progressbar" aria-valuenow="18.549374999999998" aria-valuemin="0" aria-valuemax="100" style="width: 18.549374999999998%;"></div>
  </div>
  <p><code>id: user birthdate</code><br>
    <code>Package: docassemble.playground12MA209ARecalcAffidavit playground; AL-2.0.15.1</code></p>
  <div data-variable="dXNlcnNbMF0uYmlydGhkYXRl" id="sought_variable" aria-hidden="true" style="display: none;"></div>
  <div class="daaudiovideo-control al_custom_media_controls">
    <audio title="Read this screen out loud" class="daaudio-control" preload="none" style="display: none;">
      <source src="/speakfile?i=docassemble.playground12MA209ARecalcAffidavit%3A209a_package.yml&amp;question=162&amp;digest=beabcf9ff22cbe6b4465fb09f613c71a&amp;type=question&amp;format=mp3&amp;language=en&amp;dialect=us" type="audio/mpeg">
      <source src="/speakfile?i=docassemble.playground12MA209ARecalcAffidavit%3A209a_package.yml&amp;question=162&amp;digest=beabcf9ff22cbe6b4465fb09f613c71a&amp;type=question&amp;format=ogg&amp;language=en&amp;dialect=us" type="audio/ogg">
      <a target="_blank" href="/speakfile?i=docassemble.playground12MA209ARecalcAffidavit%3A209a_package.yml&amp;question=162&amp;digest=beabcf9ff22cbe6b4465fb09f613c71a&amp;type=question&amp;format=ogg&amp;language=en&amp;dialect=us">Listen</a>
    </audio>
    <div id="page_reader_substitute_1" class="btn-group"> <button class="media-action play btn btn-sm btn-outline-secondary"> <svg class="svg-inline--fa fa-volume-up fa-w-18" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="volume-up" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg="">
          <path fill="currentColor" d="M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zm233.32-51.08c-11.17-7.33-26.18-4.24-33.51 6.95-7.34 11.17-4.22 26.18 6.95 33.51 66.27 43.49 105.82 116.6 105.82 195.58 0 78.98-39.55 152.09-105.82 195.58-11.17 7.32-14.29 22.34-6.95 33.5 7.04 10.71 21.93 14.56 33.51 6.95C528.27 439.58 576 351.33 576 256S528.27 72.43 448.35 19.97zM480 256c0-63.53-32.06-121.94-85.77-156.24-11.19-7.14-26.03-3.82-33.12 7.46s-3.78 26.21 7.41 33.36C408.27 165.97 432 209.11 432 256s-23.73 90.03-63.48 115.42c-11.19 7.14-14.5 22.07-7.41 33.36 6.51 10.36 21.12 15.14 33.12 7.46C447.94 377.94 480 319.54 480 256zm-141.77-76.87c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.38-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.88s-17.54-61.32-45.78-76.86z"></path>
        </svg><!-- <i class="fas fa-volume-up"></i> Font Awesome fontawesome.com --><span>&nbsp;Listen&nbsp;</span> <svg class="svg-inline--fa fa-play fa-w-14" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="play" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg="">
          <path fill="currentColor" d="M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"></path>
        </svg><!-- <i class="fas fa-play"></i> Font Awesome fontawesome.com --> </button> <button class="media-action restart btn btn-sm btn-outline-secondary" aria-hidden="true" style="display: none;"> <svg class="svg-inline--fa fa-volume-up fa-w-18" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="volume-up" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg="">
          <path fill="currentColor" d="M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zm233.32-51.08c-11.17-7.33-26.18-4.24-33.51 6.95-7.34 11.17-4.22 26.18 6.95 33.51 66.27 43.49 105.82 116.6 105.82 195.58 0 78.98-39.55 152.09-105.82 195.58-11.17 7.32-14.29 22.34-6.95 33.5 7.04 10.71 21.93 14.56 33.51 6.95C528.27 439.58 576 351.33 576 256S528.27 72.43 448.35 19.97zM480 256c0-63.53-32.06-121.94-85.77-156.24-11.19-7.14-26.03-3.82-33.12 7.46s-3.78 26.21 7.41 33.36C408.27 165.97 432 209.11 432 256s-23.73 90.03-63.48 115.42c-11.19 7.14-14.5 22.07-7.41 33.36 6.51 10.36 21.12 15.14 33.12 7.46C447.94 377.94 480 319.54 480 256zm-141.77-76.87c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.38-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.88s-17.54-61.32-45.78-76.86z"></path>
        </svg><!-- <i class="fas fa-volume-up"></i> Font Awesome fontawesome.com --><span>&nbsp;Listen&nbsp;</span> <svg class="svg-inline--fa fa-undo fa-w-16" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="undo" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg="">
          <path fill="currentColor" d="M212.333 224.333H12c-6.627 0-12-5.373-12-12V12C0 5.373 5.373 0 12 0h48c6.627 0 12 5.373 12 12v78.112C117.773 39.279 184.26 7.47 258.175 8.007c136.906.994 246.448 111.623 246.157 248.532C504.041 393.258 393.12 504 256.333 504c-64.089 0-122.496-24.313-166.51-64.215-5.099-4.622-5.334-12.554-.467-17.42l33.967-33.967c4.474-4.474 11.662-4.717 16.401-.525C170.76 415.336 211.58 432 256.333 432c97.268 0 176-78.716 176-176 0-97.267-78.716-176-176-176-58.496 0-110.28 28.476-142.274 72.333h98.274c6.627 0 12 5.373 12 12v48c0 6.627-5.373 12-12 12z"></path>
        </svg><!-- <i class="fas fa-undo"></i> Font Awesome fontawesome.com --> </button> <button class="media-action pause btn btn-sm btn-outline-secondary" aria-hidden="true" style="display: none;"> <svg class="svg-inline--fa fa-volume-up fa-w-18" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="volume-up" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg="">
          <path fill="currentColor" d="M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zm233.32-51.08c-11.17-7.33-26.18-4.24-33.51 6.95-7.34 11.17-4.22 26.18 6.95 33.51 66.27 43.49 105.82 116.6 105.82 195.58 0 78.98-39.55 152.09-105.82 195.58-11.17 7.32-14.29 22.34-6.95 33.5 7.04 10.71 21.93 14.56 33.51 6.95C528.27 439.58 576 351.33 576 256S528.27 72.43 448.35 19.97zM480 256c0-63.53-32.06-121.94-85.77-156.24-11.19-7.14-26.03-3.82-33.12 7.46s-3.78 26.21 7.41 33.36C408.27 165.97 432 209.11 432 256s-23.73 90.03-63.48 115.42c-11.19 7.14-14.5 22.07-7.41 33.36 6.51 10.36 21.12 15.14 33.12 7.46C447.94 377.94 480 319.54 480 256zm-141.77-76.87c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.38-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.88s-17.54-61.32-45.78-76.86z"></path>
        </svg><!-- <i class="fas fa-volume-up"></i> Font Awesome fontawesome.com --><span>&nbsp;Listen&nbsp;</span> <svg class="svg-inline--fa fa-pause fa-w-14" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="pause" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg="">
          <path fill="currentColor" d="M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z"></path>
        </svg><!-- <i class="fas fa-pause"></i> Font Awesome fontawesome.com --> </button> <button class="media-action stop btn btn-sm btn-outline-secondary"> <svg class="svg-inline--fa fa-stop fa-w-14" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="stop" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" data-fa-i2svg="">
          <path fill="currentColor" d="M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"></path>
        </svg><!-- <i class="fas fa-stop"></i> Font Awesome fontawesome.com --> </button></div>
  </div>
  <form aria-labelledby="daMainQuestion" action="/interview?i=docassemble.playground12MA209ARecalcAffidavit%3A209a_package.yml" id="daform" class="form-horizontal" method="POST" novalidate="novalidate">
    <div class="da-page-header">
      <h1 class="h3" id="daMainQuestion">Are you at least 18 years old?</h1>
      <div class="daclear"></div>
    </div>
    <div class="da-subquestion">
      <p>We can only help people under 18 if a parent, guardian, or advocate files for them.</p>
    </div>
    <div class="form-group row darequired da-field-container da-field-container-datatype-BirthDate"><label for="dXNlcnNbMF0uYmlydGhkYXRl" class="col-md-4 col-form-label da-form-label datext-right">What is your birthdate?</label>
      <div class="col-md-8 dafieldpart">
        <div class="form-row">
          <div class="col">
            <div style="text-align:center">Month</div><select class="form-control" style="width:7.5em" required="">
              <option value=""> </option>
              <option value="01">January</option>
              <option value="02">February</option>
              <option value="03">March</option>
              <option value="04">April</option>
              <option value="05">May</option>
              <option value="06">June</option>
              <option value="07">July</option>
              <option value="08">August</option>
              <option value="09">September</option>
              <option value="10">October</option>
              <option value="11">November</option>
              <option value="12">December</option>
            </select>
          </div>
          <div class="col">
            <div style="text-align:center">Day</div><input type="text" class="form-control" min="1" max="31" required="">
          </div>
          <div class="col">
            <div style="text-align:center">Year</div><input type="text" class="form-control" required="">
          </div>
        </div><input alt="Input box" class="form-control da-BirthDate" type="hidden" name="dXNlcnNbMF0uYmlydGhkYXRl" id="dXNlcnNbMF0uYmlydGhkYXRl" value="//" style="display: none;">
      </div>
    </div>
    <fieldset class="da-field-buttons">
      <legend class="sr-only">Press one of the following buttons:</legend>
      <div class="form-actions">
        <button type="button" class="btn btn-link btn-da daquestionbackbutton danonsubmit" title="Go back to the previous question"><span><svg class="svg-inline--fa fa-chevron-left fa-w-10" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="chevron-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512" data-fa-i2svg="">
              <path fill="currentColor" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"></path>
            </svg><!-- <i class="fas fa-chevron-left"></i> Font Awesome fontawesome.com --> Undo</span></button>
        <button class="btn btn-da btn-primary" type="submit"><span>Next</span></button></div>
    </fieldset>
    <div class="daundertext">
      <p>Feedback, suggestions, or comments? <a data-linknum="1" href="https://apps-dev.suffolklitlab.org/interview?i=docassemble.MAVirtualCourt%3Afeedback.yml&amp;github_repo=docassemble-AssemblyLine&amp;github_user=suffolklitlab&amp;variable=users%5B0%5D.birthdate&amp;question_id=user+birthdate&amp;package_version=playground&amp;reset=1&amp;from_list=1" target="_blank">Complete this survey</a>.</p>
    </div> <input type="hidden" name="csrf_token" value="ImViYmUzOTA3ZTYwYzBiMzA5ZjY1ZTQ3NGZlOWQyODhiZWY5NDA5NjYi.YI6mmw.PpwhhchSwhHTD5P9ytxsDR8ANC0">
    <input type="hidden" name="_event" value="WyJ1c2Vyc1swXS5iaXJ0aGRhdGUiXQ">
    <input type="hidden" name="_question_name" value="ID user birthdate">
    <input type="hidden" name="_tracker" value="5">
    <input type="hidden" name="_datatypes" value="eyJkWE5sY25OYk1GMHVZbWx5ZEdoa1lYUmwiOiAiQmlydGhEYXRlIn0">
    <input type="hidden" name="_visible" value="">
    <input type="hidden" name="_varnames" value="eyJYMlpwWld4a1h6QSI6ICJkWE5sY25OYk1GMHVZbWx5ZEdoa1lYUmwifQ">
  </form>
</section>

See tests at https://github.com/SuffolkLITLab/docassemble-MA209AProtectiveOrder/runs/2492735082?check_suite_focus=true. They will fail, but they should get to at least the question id 'children-user-is-parent-of'. Don't worry about the messages there about multiple items found on the page (for now).
@plocket plocket requested a review from niharikasingh May 3, 2021 14:19
lib/scope.js Show resolved Hide resolved
// Handle setting values for da custom datatypes
// E.g. `da-field-container-datatype-BirthDate`
// TODO: Make this more easily extensible
setCustomDatatype: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we make setCustomDatatype more easily extensible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(at some point in the future)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good start. This seems extensible, although the exact particulars will depend on what other custom fields we come across.

@plocket
Copy link
Collaborator Author

plocket commented May 3, 2021

Tangentially: That test actually got through way more question ids than I can get locally. Wat? I need it to pass locally too to keep developing. Any ideas are welcome...

@plocket plocket merged commit 34013ac into main May 4, 2021
@plocket plocket deleted the birthdate branch May 4, 2021 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants