Skip to content

Commit e8cad42

Browse files
committed
string interpolation moved to print function
1 parent c99964f commit e8cad42

9 files changed

+27
-38
lines changed

dist/form-viewer.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/viewer/form-confirmation-page.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mwFormViewer')
2121
},
2222
link: function (scope, ele, attrs, mwFormViewer){
2323
var ctrl = scope.ctrl;
24-
24+
ctrl.print = mwFormViewer.print;
2525
}
2626
};
2727
});

src/viewer/form-question.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ angular.module('mwFormViewer').factory("FormQuestionId", function(){
119119
},
120120
link: function (scope, ele, attrs, mwFormViewer){
121121
var ctrl = scope.ctrl;
122-
122+
ctrl.print = mwFormViewer.print;
123123
}
124124
};
125125
});

src/viewer/form-viewer.directive.js

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,31 +119,13 @@ angular.module('mwFormViewer').directive('mwFormViewer', function () {
119119
ctrl.buttons.nextPage.visible=!formSubmit;
120120
}
121121
};
122-
123-
ctrl.applyTemplateDataToElement = function(element){
124-
if (ctrl.templateData){
125-
if (element.paragraph){
126-
element.paragraph.displayHtml = $interpolate(element.paragraph.html)(ctrl.templateData);
127-
}
128-
if (element.question){
129-
element.question.displayText = $interpolate(element.question.text)(ctrl.templateData);
130-
131-
if (element.question.offeredAnswers){
132-
element.question.offeredAnswers.forEach(function (offeredAnswer){
133-
offeredAnswer.displayValue = $interpolate(offeredAnswer.value)(ctrl.templateData);
134-
});
135-
}
136-
}
137-
}
138-
};
139122

140123
ctrl.initResponsesForCurrentPage = function(){
141124
ctrl.currentPage.elements.forEach(function(element){
142125
var question = element.question;
143126
if(question && !ctrl.responseData[question.id]){
144127
ctrl.responseData[question.id]={};
145128
}
146-
ctrl.applyTemplateDataToElement(element);
147129
});
148130
};
149131

@@ -235,6 +217,13 @@ angular.module('mwFormViewer').directive('mwFormViewer', function () {
235217
});
236218
}
237219

220+
ctrl.print=function(input){
221+
if (ctrl.templateData){
222+
return $interpolate(input)(ctrl.templateData);
223+
}
224+
return input;
225+
}
226+
238227
},
239228
link: function (scope, ele, attrs){
240229
var ctrl = scope.ctrl;

src/viewer/mw-form-confirmation-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="mw-form-confirmation-page">
22
<div class="mw-confirmation-message" ng-if="ctrl.submitStatus=='SUCCESS'">
3-
<span ng-if="ctrl.confirmationMessage"> {{ctrl.confirmationMessage}}</span>
3+
<span ng-if="ctrl.confirmationMessage"> {{::ctrl.print(ctrl.confirmationMessage)}}</span>
44
<span ng-if="!ctrl.confirmationMessage" translate="mwForm.confirmationPage.defaultMessage"> Twoja odpowiedź została zapisana</span>
55
</div>
66
<div class="mw-error-message" ng-if="ctrl.submitStatus=='ERROR'">

src/viewer/mw-form-question.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="mw-form-question">
22

33
<div class="mw-question-text">
4-
{{ctrl.question.displayText}} <span ng-if="ctrl.question.required">*</span>
4+
{{::ctrl.print(ctrl.question.text)}} <span ng-if="ctrl.question.required">*</span>
55
</div>
66

77
<div class="mw-question-answers" ng-switch="ctrl.question.type">
@@ -15,7 +15,7 @@
1515
<div class="radio" ng-repeat="answer in ctrl.question.offeredAnswers">
1616
<label>
1717
<input type="radio" ng-model="ctrl.questionResponse.selectedAnswer" ng-value="answer.id" name="answer-for-question-{{ctrl.question.id}}" ng-change="ctrl.selectedAnswerChanged()" ng-required="ctrl.question.required &&!ctrl.isOtherAnswer" ng-disabled="ctrl.readOnly">
18-
{{answer.displayValue}}
18+
{{::ctrl.print(answer.value)}}
1919
</label>
2020
</div>
2121
<div class="radio" ng-if="ctrl.question.otherAnswer">
@@ -33,7 +33,7 @@
3333
<div class="checkbox" ng-repeat="answer in ::ctrl.question.offeredAnswers">
3434
<label>
3535
<input type="checkbox" name="answer-for-question-{{ctrl.question.id}}" ng-checked="ctrl.questionResponse.selectedAnswers.indexOf(answer.id) != -1" ng-click="ctrl.toggleSelectedAnswer(answer)" ng-disabled="ctrl.readOnly">
36-
{{::answer.displayValue}}
36+
{{::ctrl.print(answer.value)}}
3737
</label>
3838
</div>
3939
<div class="checkbox" ng-if="ctrl.question.otherAnswer">
@@ -55,15 +55,15 @@
5555
<tr>
5656
<td></td>
5757
<td ng-repeat="col in ::ctrl.question.grid.cols">
58-
<label>{{::col.label}}</label>
58+
<label>{{::ctrl.print(col.label)}}</label>
5959
</td>
6060
</tr>
6161

6262
</thead>
6363
<tbody>
6464
<tr ng-repeat="row in ::ctrl.question.grid.rows">
6565
<td>
66-
{{::row.label}}
66+
{{::ctrl.print(row.label)}}
6767
</td>
6868
<td ng-repeat="col in ::ctrl.question.grid.cols">
6969
<input type="radio" ng-model="ctrl.questionResponse[row.id]" ng-value="col.id" name="answer-for-question-{{row.id}}" ng-required="ctrl.question.required" ng-disabled="ctrl.readOnly">
@@ -78,10 +78,10 @@
7878
<div class="form-inline" style="margin-bottom: 5px" ng-repeat="item in ctrl.question.divisionList">
7979
<div class="form-group">
8080
<label>
81-
{{item.value}}
81+
{{::ctrl.print(item.value)}}
8282
</label>
8383
<input type="number" class="form-control" ng-model="ctrl.questionResponse[item.id]" min="0" max="{{ctrl.question.quantity}}" required style="width: 80px" ng-change="ctrl.computeDivisionSum()" ng-readonly="ctrl.readOnly">
84-
<span>{{::ctrl.question.unit}}</span>
84+
<span>{{::ctrl.print(ctrl.question.unit)}}</span>
8585
</div>
8686

8787
</div>

src/viewer/mw-form-viewer-content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h2 class="mw-page-title" ng-if="ctrl.currentPage.namedPage && ctrl.currentPage.
2121
</figure>
2222
</div>
2323
<div ng-switch-when="paragraph">
24-
<p ng-bind-html="pageElement.paragraph.displayHtml"></p>
24+
<p ng-bind-html="::ctrl.print(pageElement.paragraph.html)"></p>
2525
</div>
2626

2727
</div>

src/viewer/mw-priority-list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<div class="mw-item" ng-repeat="item in ctrl.questionResponse.priorityList">
1515

16-
<strong>{{$index+1}}.</strong> {{::ctrl.idToItem[item.id].value}}
16+
<strong>{{$index+1}}.</strong> {{::ctrl.print(ctrl.idToItem[item.id].value)}}
1717
</div>
1818

1919

@@ -23,7 +23,7 @@
2323

2424
<div class="mw-item" ng-repeat="item in ctrl.availableItems">
2525

26-
{{::ctrl.idToItem[item.id].value}}
26+
{{::ctrl.print(ctrl.idToItem[item.id].value)}}
2727
</div>
2828

2929
</td>

src/viewer/priority-list.directive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ angular.module('mwFormViewer')
9393
});
9494

9595
},
96-
link: function (scope, ele, attrs, mwFormViewer){
96+
link: function (scope, ele, attrs, mwFormQuestion){
9797
var ctrl = scope.ctrl;
98-
98+
ctrl.print = mwFormQuestion.print;
9999
}
100100
};
101101
});

0 commit comments

Comments
 (0)