Skip to content

Commit

Permalink
add min/max ranges to proper fiels
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemitchel committed Jan 31, 2025
1 parent d874869 commit b39aeb3
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 58 deletions.
8 changes: 8 additions & 0 deletions src/mobile/pages/fields/field/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ export const FieldVM = DefineMap.extend('FieldVM', {
get () {
const min = this.field.min || 'any'
const max = this.field.max || 'any'
const isDateMDY = this.field.type === 'datemdy'

if (isDateMDY) {
let minDate = moment(min, 'MMDDYYYY').format('MM/DD/YYYY')
let maxDate = moment(max, 'MMDDYYYY').format('MM/DD/YYYY')
return `(${minDate} ~~~ ${maxDate})`
}

return `(${min} ~~~ ${max})`
}
},
Expand Down
16 changes: 7 additions & 9 deletions src/mobile/pages/fields/field/views/datemdy.stache
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
{{#if(field.required)}}<small class="text-danger">({{lang.Required}})</small>{{/if}}
</label>
<div class="datepicker-field-field">
<input
type="text"
id:from="this.idFromLabelHTML(field.label)"
name="{{field.name}}"
value:bind="field._answerVm.textValue"
on:change="validateField(null, scope.element)"
{{#if(field.required)}}required{{/if}}
class="form-control datepicker-input" />
<input type="text" id:from="this.idFromLabelHTML(field.label)" name="{{field.name}}"
value:bind="field._answerVm.textValue" on:change="validateField(null, scope.element)"
{{#if(field.required)}}required{{/if}} class="form-control datepicker-input" />
</div>
{{#if(showMinMaxPrompt)}}
{{minMaxPrompt}}
{{/if}}
</div>

{{> invalid-prompt-tpl }}
</div>
</div>
15 changes: 6 additions & 9 deletions src/mobile/pages/fields/field/views/invalid-prompt.stache
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{{#if(showInvalidPrompt)}}
<div class="alert alert-danger" role="alert">
<span class="glyphicon-attention" aria-hidden="true">
{{{ parseText(scope.vm.invalidPrompt) }}}
{{#if(showMinMaxPrompt)}}
{{minMaxPrompt}}
{{/if}}
</span>
</div>
{{/if}}
<div class="alert alert-danger" role="alert">
<span class="glyphicon-attention" aria-hidden="true">
{{{ parseText(scope.vm.invalidPrompt) }}}
</span>
</div>
{{/if}}
33 changes: 13 additions & 20 deletions src/mobile/pages/fields/field/views/number.stache
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,19 @@
{{#if(field.required)}}<small class="text-danger">({{lang.Required}})</small>{{/if}}
</label>
<div class="number-field">
<input
type="text"
inputmode="decimal"
id="{{idFromLabelHTML(field.label)}}"
name="{{field.name}}"
{{#if(field.required)}}required{{/if}}
class="form-control"
on:input="preValidateNumber(null, scope.element)"
on:change="validateField(null, scope.element)"
value:bind="field._answerVm.textValue"/>
{{#if(field.calculator)}}
<button
aria-label="Expand Calculator"
class="btn btn-default expand-calc pull-right"
on:click="showCalculator(field)"
aui-action="open">
<span class="icon calc-icon glyphicon-calc" aria-hidden="true"></span>
</button>
{{/if}}
<input type="text" inputmode="decimal" id="{{idFromLabelHTML(field.label)}}" name="{{field.name}}"
{{#if(field.required)}}required{{/if}} class="form-control" on:input="preValidateNumber(null, scope.element)"
on:change="validateField(null, scope.element)" value:bind="field._answerVm.textValue" />
{{#if(field.calculator)}}
<button aria-label="Expand Calculator" class="btn btn-default expand-calc pull-right"
on:click="showCalculator(field)" aui-action="open">
<span class="icon calc-icon glyphicon-calc" aria-hidden="true"></span>
</button>
{{/if}}
</div>
{{#if(showMinMaxPrompt)}}
{{minMaxPrompt}}
{{/if}}
</div>
{{> invalid-prompt-tpl }}
</div>
</div>
33 changes: 13 additions & 20 deletions src/mobile/pages/fields/field/views/numberdollar.stache
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,20 @@

<div class="numberdollar-field">
<span>$</span>
<input
type="text"
inputmode="decimal"
id="{{idFromLabelHTML(field.label)}}"
name="{{field.name}}"
{{#if(field.required)}}required{{/if}}
class="form-control"
on:input="preValidateNumber(null, scope.element)"
on:change="validateField(null, scope.element)"
value:bind="field._answerVm.values"/>
{{#if(field.calculator)}}
<button
aria-label="Expand Calculator"
class="btn btn-default expand-calc pull-right"
on:click="showCalculator(field)"
aui-action="open">
<span class="icon calc-icon glyphicon-calc" aria-hidden="true"></span>
</button>
{{/if}}
<input type="text" inputmode="decimal" id="{{idFromLabelHTML(field.label)}}" name="{{field.name}}"
{{#if(field.required)}}required{{/if}} class="form-control" on:input="preValidateNumber(null, scope.element)"
on:change="validateField(null, scope.element)" value:bind="field._answerVm.values" />
{{#if(field.calculator)}}
<button aria-label="Expand Calculator" class="btn btn-default expand-calc pull-right"
on:click="showCalculator(field)" aui-action="open">
<span class="icon calc-icon glyphicon-calc" aria-hidden="true"></span>
</button>
{{/if}}
</div>
{{#if(showMinMaxPrompt)}}
{{minMaxPrompt}}
{{/if}}
</div>

{{> invalid-prompt-tpl }}
</div>
</div>

0 comments on commit b39aeb3

Please sign in to comment.