Skip to content
Permalink
Browse files

Merge branch 'develop' into feature/COLAB-2978/Regular-file-upload-fo…

…r-documents-and-others
  • Loading branch information
carlosbpf committed Nov 19, 2019
2 parents bb9a93d + 28e59b3 commit becf747d9ad3ed83e4825a7bf1f84fb145fe167f
@@ -292,18 +292,54 @@ public String getStringValue() {
.collect(Collectors.toList());
}

@JsonIgnore
public List<String> getColumnOptionsForRadioTable() {
String[] a = this.getAllowedValues().split("\\|");
if(a!= null && a.length > 1) {
return Stream.of(a[0].split(";"))
.map(String::trim)
.collect(Collectors.toList());
} else {
return new ArrayList<>();
}
}
@JsonIgnore
public List<String> getRowOptionsForRadioTable() {
String[] a = this.getAllowedValues().split("\\|");
if(a!= null && a.length > 1) {
return Stream.of(a[1].split(";"))
.map(String::trim)
.collect(Collectors.toList());
} else {
return new ArrayList<>();
}
}

@JsonIgnore
public List<String> getOptionsForCheckbox() {
return Stream.of(this.getAllowedValues().split(";"))
.map(String::trim)
.collect(Collectors.toList());
}

@JsonIgnore
private List<String> getSelectedValuesForRadioTable(){
return Arrays.asList(this.getStringValue().split(";"));
}
@JsonIgnore
private List<String> getSelectedValuesForCheckbox() {
return Arrays.asList(this.getStringValue().split(";"));
}

@JsonIgnore
public boolean isOptionForRadioTableSelected(String line, String column){
for (String selectedValue : getSelectedValuesForRadioTable()) {
if (selectedValue.equals(line + "_" + column)) {
return true;
}
}
return false;
}
@JsonIgnore
public boolean isOptionForCheckboxSelected(String value) {
for (String selectedValue : getSelectedValuesForCheckbox()) {
@@ -6,6 +6,7 @@
TEXT,
DROPDOWN_MENU,
CHECKBOX_OPTION,
RADIO_TABLE,
SECTION_HEADER,
ONTOLOGY_REFERENCE,
PROPOSAL_REFERENCE,
@@ -4,6 +4,7 @@
TEXT_SECTION("", "Text section"),
//"IMAGE_SECTOR("IMAGE", "Image section"),
DROPDOWN_MENU("DROPDOWN_MENU", "Dropdown menu"),
RADIO_TABLE("RADIO_TABLE", "Radio table"),
CHECKBOX_OPTION("CHECKBOX_OPTION","Checkbox option"),
SECTION_HEADER("SECTION_HEADER","Section Header"),
INLINE_PROPOSAL_REFERENCE("PROPOSAL_LIST_TEXT_REFERENCE", "Inline proposal reference"),
@@ -82,6 +82,7 @@ public void updateProposal() {
switch (sectionType) {
case TEXT:
case PROPOSAL_LIST_TEXT_REFERENCE:
case RADIO_TABLE:
case DROPDOWN_MENU:
if (newSectionValue != null && !newSectionValue.trim().equals(section.getContent())) {
final String baseUri = PlatformAttributeKey.COLAB_URL.get();
@@ -222,11 +222,14 @@
<form:textarea path="sections[${x.index}].defaultText" data-form-name="defaultText" cssClass="form-control" /> <!-- cssClass="rte-editorPlaceholder" -->
<form:errors cssClass="invalid-feedback" path="sections[${x.index}].defaultText" />

<div class="js-sectionTypeDependent" data-section-type="DROPDOWN_MENU"
<div class="js-sectionTypeDependent" data-section-type="DROPDOWN_MENU|RADIO_TABLE"
style="display: none">
<strong >Options :</strong><small>(use ';' to separate the options)</small><br/>
<form:input path="sections[${x.index}].allowedValues" data-form-name="allowedValues" cssClass="form-control"/>
<strong >Options :</strong>
<div data-section-type="DROPDOWN_MENU" style="display: none"><small>(use ';' to separate the options)</small></div>
<div data-section-type="RADIO_TABLE" style="display: none"><small>(use ';' to separate the cells and | to separate columns from rows. Ex: col1;col2;col3|row1;row2;row3)</small></div>
<form:textarea path="sections[${x.index}].allowedValues" data-form-name="allowedValues" cssClass="form-control"/>
</div>

</div>
</div>
<script>
@@ -511,13 +514,35 @@
.each(function(i, element) {
var $element = jQuery(element);
var conditionalSectionTypeFragment = $element.data('section-type');
if (newSectionType.indexOf(conditionalSectionTypeFragment) >= 0) {
$element.show();
//console.log(" - newSectionType - "+newSectionType);
//setupInputFieldForAllowedValues(sectionIndex,newSectionType);

if(conditionalSectionTypeFragment.indexOf("|") >=0 ) {
var subtypes = conditionalSectionTypeFragment.split('|');
let found = false;
for(var i = 0; i < subtypes.length; i ++) {
//console.log("Checking if: " + subtypes[i] +" == >"+ newSectionType + "<");
if (newSectionType.indexOf(subtypes[i]) >= 0) {
//find the right sub strong item to display
$element.find(("[data-section-type='" + subtypes[i] + "']")).show();
found = true;
} else {
$element.find(("[data-section-type='" + subtypes[i] + "']")).hide();
}
}
if(found){
$element.show();
} else {
$element.hide();
}

} else {
$element.hide();
if (newSectionType.indexOf(conditionalSectionTypeFragment) >= 0) {
$element.show();
//console.log(" - newSectionType - "+newSectionType);
//setupInputFieldForAllowedValues(sectionIndex,newSectionType);

} else {
$element.hide();
}
}
});
}
@@ -55,6 +55,35 @@
</c:otherwise>
</c:choose>
</c:when>
<c:when test="${section.typeEnum == 'RADIO_TABLE' }">
<table class="table table-striped" >
<thead>
<tr>
<th></th>
<c:forEach var="value" items="${section.columnOptionsForRadioTable}">
<th style="font-weight: 100;line-height: normal;text-align: center;">${value}</th>
</c:forEach>
</tr>
</thead>
<tbody>
<c:forEach var="line" items="${section.rowOptionsForRadioTable}">
<tr>
<th class="row-header" style="width:500px;min-height:60px;text-align: left;font-weight: 100;line-height: normal;">${line}</th>
<c:forEach var="value" items="${section.columnOptionsForRadioTable}">
<td style="width:200px;text-align: center;vertical-align: middle;">
<c:choose>
<c:when test="${section.isOptionForRadioTableSelected(line,value)}">
${'&#x25C9;'}
</c:when>
</c:choose>

</td>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>
</c:when>
<c:when test="${section.typeEnum == 'CHECKBOX_OPTION' }">
<ul>
<c:forEach var="value" items="${section.optionsForCheckbox}">
@@ -63,6 +63,61 @@
</c:forEach>
</select>
</c:when>

<c:when test="${section.typeEnum == 'RADIO_TABLE'}">
<table class="table table-striped" >
<thead>
<tr>
<th></th>
<c:forEach var="value" items="${section.columnOptionsForRadioTable}">
<th style="font-weight: 100;line-height: normal;text-align: center;">${value}</th>
</c:forEach>
</tr>
</thead>
<tbody>
<c:forEach var="line" items="${section.rowOptionsForRadioTable}">
<tr>
<th class="row-header" style="width:500px;min-height:60px;text-align: left;font-weight: 100;line-height: normal;">${line}</th>
<c:forEach var="value" items="${section.columnOptionsForRadioTable}">
<td style="width:200px;text-align: center;vertical-align: middle;">
<c:choose>
<c:when test="${section.isOptionForRadioTableSelected(line,value)}">
<input type="radio" class="radioTable_${section.sectionDefinitionId }" data-section-id="${section.sectionDefinitionId}" name="${line}" onclick="handleRadioButtonClick(this);" value="${line}_${value}" checked="checked"/>
</c:when>
<c:otherwise>
<input type="radio" class="radioTable_${section.sectionDefinitionId }" data-section-id="${section.sectionDefinitionId}" name="${line}" onclick="handleRadioButtonClick(this);" value="${line}_${value}" />
</c:otherwise>
</c:choose>

</td>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>
<input type="hidden" id="hiddenRadioTable_${section.sectionDefinitionId }" name='sectionsContent[${section.sectionDefinitionId }]' value="${section.stringValue}"/>
<script>
function handleRadioButtonClick(objct){

var sectionId = $(objct).data("section-id");
var finalAnswer = "";
let allRadios = $(".radioTable_"+sectionId+":checked");
let i = 0;
for(let i = 0 ; i!= allRadios.length; i++ ){

finalAnswer+= $(allRadios[i]).val();
if(i +1 != allRadios.length){
finalAnswer+=";";
}
}
console.log("THIS IS RADIO BUTTON: " + finalAnswer);
$("#hiddenRadioTable_"+sectionId).val(finalAnswer);

}
</script>
</c:when>


<c:when test="${section.typeEnum == 'CHECKBOX_OPTION'}">

<c:forEach var="value" items="${section.optionsForCheckbox}">

0 comments on commit becf747

Please sign in to comment.
You can’t perform that action at this time.