Skip to content

Commit

Permalink
JBPM-10077 Field with LocalDateTime is forcing to enter value even th…
Browse files Browse the repository at this point in the history
…ough its not marked mandatory
  • Loading branch information
bxf12315 committed May 13, 2022
1 parent 0110963 commit 2df8972
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public String renderCase(String containerId, CaseDefinition caseDefinition, Form
return finalOutput;
}


public String renderProcess(String containerId, ProcessDefinition processDesc, FormInstance form) {

List<String> scriptDataList = new ArrayList<>();
Expand Down Expand Up @@ -784,11 +783,9 @@ protected String appendExtractionExpression(String type, String name, String id,
.append("')")
.append(getExtractionValue(jsType));
} else {
jsonTemplate.append("document.getElementById('")
jsonTemplate.append("getLocalDateWithoutTime('")
.append(id)
.append("') ")
.append(getExtractionValue(jsType))
.append(" + 'T00:00'");
.append("') ");
}
} else {
jsonTemplate.append("document.getElementById('")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
<strong style="color: red">*</strong>
</#if>
<#if item.showTime >
<input id="${item.id}" name="${item.name}" type="datetime-local" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} pattern="${item.pattern}"/>
<input id="${item.id}" name="${item.name}" type="datetime-local" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} ${(item.readOnly)?string('disabled', '')} />
<#elseif !item.showTime >
<input id="${item.id}" name="${item.name}" type="date" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} pattern="${item.pattern}"/>
<input id="${item.id}" name="${item.name}" type="date" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} ${(item.readOnly)?string('disabled', '')} />
</#if>
</div>
<#elseif item.type == "slider">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,3 +556,11 @@ function closeCreationForm(fieldId) {
currentRow = null;
}

function getLocalDateWithoutTime(elementId) {
console.log('LocalDateWithoutTime Element =' + document.getElementById(elementId).value);
if (document.getElementById(elementId).value === '') {
return document.getElementById(elementId).value;
} else {
return document.getElementById(elementId).value + 'T00:00';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
<strong style="color: red">*</strong>
</#if>
<#if item.showTime >
<input id="${item.id}" name="${item.name}" type="datetime-local" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} pattern="${item.pattern}"/>
<input id="${item.id}" name="${item.name}" type="datetime-local" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} ${(item.readOnly)?string('disabled', '')}/>
<#elseif !item.showTime >
<input id="${item.id}" name="${item.name}" type="date" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} pattern="${item.pattern}"/>
<input id="${item.id}" name="${item.name}" type="date" class="form-control" value="${item.value}" ${(item.required)?string('required', '')} ${(item.readOnly)?string('disabled', '')}/>
</#if>
</div>
<#elseif item.type == "documentCollection">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void testProcessFormRendererWithDate() {

BootstrapFormRenderer bootstrapFormRenderer = new BootstrapFormRenderer();
String outString = bootstrapFormRenderer.renderProcess("test-containerId", processAssetDesc, form);
assertThat(outString).contains("'dateBirth' : String(document.getElementById('field_1703386699666296E12') .value + 'T00:00')");
assertThat(outString).contains("<input id=\"field_1703386699666296E12\" name=\"dateBirth\" type=\"date\" class=\"form-control\" value=\"\" pattern=\"(\\d+)(-|\\/)(\\d+)(?:-|\\/)(?:(\\d+)\\s+(\\d+):(\\d+)(?::(\\d+))?(?:\\.(\\d+))?)?\"/>");
assertThat(outString).contains("'dateBirth' : String(getLocalDateWithoutTime('field_1703386699666296E12') )");
assertThat(outString).contains("<input id=\"field_1703386699666296E12\" name=\"dateBirth\" type=\"date\" class=\"form-control\" value=");
}

@Test
Expand All @@ -49,7 +49,7 @@ public void testProcessFormRendererWithDateTime() {
BootstrapFormRenderer bootstrapFormRenderer = new BootstrapFormRenderer();
String outString = bootstrapFormRenderer.renderProcess("test-containerId", processAssetDesc, form);

assertThat(outString).contains("'dateBirth' : String(document.getElementById('field_1703386699666296E12').value");
assertThat(outString).contains("<input id=\"field_1703386699666296E12\" name=\"dateBirth\" type=\"datetime-local\" class=\"form-control\" value=\"\" pattern=\"(\\d+)(-|\\/)(\\d+)(?:-|\\/)(?:(\\d+)\\s+(\\d+):(\\d+)(?::(\\d+))?(?:\\.(\\d+))?)?\"/>");
assertThat(outString).contains("'dateBirth' : String(document.getElementById('field_1703386699666296E12').value)");
assertThat(outString).contains("<input id=\"field_1703386699666296E12\" name=\"dateBirth\" type=\"datetime-local\" class=\"form-control\" value=");
}
}

0 comments on commit 2df8972

Please sign in to comment.