Skip to content

Fix for #1523. Adds multiline text boxes for text entry. #1586

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Paco-Server/ear/default/web/partials/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
</div>

<div ng-if="input.responseType === 'open text'" class="input">
<div>
<div ng-if="input.multiline" >
<md-input-container md-no-float>
<textarea name="bio" ng-model="responses[input.name]" placeholder="answer"
rows="{{input.multilineNumber}}"></textarea>
</md-input-container>
</div>
<div ng-if="!input.multiline" >
<md-input-container md-no-float>
<input type="text" placeholder="answer"
ng-model="responses[input.name]" ng-disabled="readonly"></input>
Expand Down
30 changes: 18 additions & 12 deletions Paco-Server/ear/default/web/partials/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<md-select-header>
<span>Response Type</span>
</md-select-header>
<md-option ng-repeat="option in responseTypes" ng-value="option.id">{{option.name}}</option>
<md-option ng-repeat="option in responseTypes" ng-value="option.id">{{option.name}}</md-option>
</md-select>
</md-input-container>
<md-checkbox ng-model="input.required" aria-label="Required">
Expand All @@ -34,30 +34,36 @@
</div>

<div class="column1">
<div layout="row">

<md-input-container flex="100">
<label>Question for the Participant</label>
<textarea ng-model="input.text" md-no-resize md-maxlength=500></textarea>
</md-input-container>
</div>
<div layout="row">
<md-input-container flex="100">
<label>Question for the Participant</label>
<textarea ng-model="input.text" md-no-resize md-maxlength=500></textarea>
</md-input-container>
</div>
<div layout="row">
<md-input-container class="medium" flex="25">
<label>Input {{$index + 1}} Variable Name</label>
<input ng-model="input.name" ng-trim="true" ng-change="input.name = input.name.split(' ').join('_')" >
</md-input-container>

<md-input-container ng-if="input.conditional" flex="75">
<md-input-container ng-if="input.conditional" flex="75">
<label>Condition</label>
<input ng-model="input.conditionExpression">
</md-input-container>

<paco-help tip="conditional" ng-if="input.conditional">
Help: Conditional Logic
</paco-help>



</div>
<div ng-if="input.responseType === 'open text'">
<md-checkbox ng-model="input.multiline" aria-label="Multiple lines"
ng-change="input.multilineNumber = input.multiline ? 2 : input.multilineNumber">
Multiple lines
</md-checkbox>
<div ng-if="input.multiline">
<label>Number of lines</label>
<input ng-model="input.multilineNumber" type="number" min="2" max="9" ng-pattern="/^[2-9]*$/">
</div>
</div>

<div ng-if="input.responseType === 'list'">
Expand Down
6 changes: 6 additions & 0 deletions Paco/src/com/pacoapp/paco/model/ExperimentProviderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@ public static void copyAllPropertiesFromJsonToExperimentDAO(ExperimentDAO experi
if (inputNode.has("multiselect")) {
input.setMultiselect(inputNode.path("multiselect").getBooleanValue());
}
if (inputNode.has("multiline")) {
input.setMultiline(inputNode.path("multiline").getBooleanValue());
}
if (inputNode.has("multilineNumber")) {
input.setMultilineNumber(inputNode.path("multilineNumber").getIntValue());
}
List<String> listChoices = Lists.newArrayList();
ArrayNode listChoicesNode = (ArrayNode) inputNode.path("listChoices");
for (int l = 0; l < listChoicesNode.size(); l++) {
Expand Down
18 changes: 15 additions & 3 deletions Paco/src/com/pacoapp/paco/ui/InputLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.Date;
import java.util.List;

import android.view.Gravity;
import android.view.inputmethod.EditorInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -482,7 +484,7 @@ private View getInputResponseTypeView(Input2 input2) {
if (questionType.equals(Input2.LIKERT_SMILEYS)) {
return renderGeistNowSmilerLikert(input2.getLikertSteps());
} else if (questionType.equals(Input2.OPEN_TEXT)) {
return renderOpenText();
return renderOpenText(input2);
} else if (questionType.equals(Input2.LIKERT)) {
return renderLikert(input2);
} else if (questionType.equals(Input2.LIST)) {
Expand Down Expand Up @@ -907,8 +909,8 @@ private int getRadioGroupLayoutId(Integer steps) {

}

private View renderOpenText() {
View likertView = ((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
private View renderOpenText(Input2 input2) {
((LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(
R.layout.open_text, this, true);
openTextView = (AutoCompleteTextView) findViewById(R.id.open_text_answer);
openTextView.setThreshold(1);
Expand All @@ -919,6 +921,16 @@ private View renderOpenText() {
//ensureAutoCompleteDatabase();
//openTextView.setAdapter(new AutocompleteUsageFilteringArrayAdapter(getContext(), android.R.layout.simple_dropdown_item_1line, autocompleteDatabase));
//openTextView.setTokenizer(new AutoCompleteTextView(getContext()));
if (input2.getMultiline() != null && input2.getMultiline()) {
if (input2.getMultilineNumber() != null && input2.getMultilineNumber() > 1) {
openTextView.setSingleLine(false);
openTextView.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
openTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
| InputType.TYPE_TEXT_FLAG_AUTO_CORRECT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE);
openTextView.setLines(input2.getMultilineNumber());
openTextView.setGravity(Gravity.LEFT | Gravity.TOP);
}
}
openTextView.setOnFocusChangeListener(new OnFocusChangeListener() {

public void onFocusChange(View v, boolean hasFocus) {
Expand Down
27 changes: 25 additions & 2 deletions Shared/src/com/pacoapp/paco/shared/model2/Input2.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public class Input2 extends ModelBase implements Validatable, Serializable {
private List<String> listChoices;
private Boolean multiselect = false;

private boolean multiline;
private int multilineNumber;

/**
*
*/
Expand All @@ -72,10 +75,12 @@ public class Input2 extends ModelBase implements Validatable, Serializable {
* @param rightSideLabel
* @param listChoices
* @param multiselect
* @param multiline
* @param multilineNumber
*/
public Input2(String name, String responseType, String text, Boolean required,
Integer likertSteps, Boolean conditional, String conditionExpr, String leftSideLabel,
String rightSideLabel, List<String> listChoices, Boolean multiselect) {
String rightSideLabel, List<String> listChoices, Boolean multiselect, Boolean multiline, Integer multilineNumber) {
this.text = text;
this.required = required != null ? required : false;
this.responseType = responseType;
Expand All @@ -87,12 +92,14 @@ public Input2(String name, String responseType, String text, Boolean required,
this.rightSideLabel = rightSideLabel;
this.listChoices = listChoices;
this.multiselect = multiselect != null ? multiselect : false;
this.multiline = multiline != null ? multiline : false;
this.multilineNumber = multilineNumber != null ? multilineNumber : 0;
}

// visible for testing
public Input2(String name, String text) {
this(name, LIKERT, text, false, null, false, null, null, null, null,
null);
null, null, null);
}

public Input2() {
Expand Down Expand Up @@ -189,6 +196,22 @@ public void setMultiselect(Boolean multiselect) {
this.multiselect = multiselect;
}

public Boolean getMultiline() {
return multiline;
}

public void setMultiline(Boolean multiline) {
this.multiline = multiline;
}

public Integer getMultilineNumber() {
return multilineNumber;
}

public void setMultilineNumber(Integer multilineNumber) {
this.multilineNumber = multilineNumber;
}

public void validateWith(Validator validator) {
// System.out.println("VALIDATING Input");
validator.isNonEmptyString(name, "input name is not properly initialized");
Expand Down