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

JBPM-10077 Field with LocalDateTime is forcing to enter value even th… #2780

Merged
merged 1 commit into from May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
Expand Up @@ -556,3 +556,11 @@ function closeCreationForm(fieldId) {
currentRow = null;
}

function getLocalDateWithoutTime(elementId) {
var value = document.getElementById(elementId).value;
if (value === '') {
return value;
} else {
return value + 'T00:00';
}
}
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
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=");
}
}