Skip to content

Commit

Permalink
[#3940] Show answer flag UI for option and number type of question
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Nov 29, 2022
1 parent efff939 commit c3dcdc1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Dashboard/app/js/lib/models/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ FLOW.Question = FLOW.BaseModel.extend({
personalData: DS.attr('boolean', {
defaultValue: false,
}),
answerStats: DS.attr('boolean', {
defaultValue: false,
}),
dependentFlag: DS.attr('boolean', {
defaultValue: false,
}),
Expand Down
25 changes: 21 additions & 4 deletions Dashboard/app/js/lib/views/surveys/question-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ FLOW.QuestionView = FLOW.View.extend(
questionTooltipValidationFailure: false,
caddisflyResourceUuid: null,
personalData: null,
answerStats: null,

showCaddisflyTests: Ember.computed(() =>
FLOW.router.caddisflyResourceController.get('testsFileLoaded')
Expand All @@ -75,14 +76,16 @@ FLOW.QuestionView = FLOW.View.extend(
.cacheable(),

amQuestionPublishingError: Ember.computed(function() {
if (!FLOW.selectedControl.get('publishingErrors')) { return false; }
if (!FLOW.selectedControl.get('publishingErrors')) {
return false;
}
const questionGroupId = this.content.get('questionGroupId');
const questionId = this.content.get('keyId');
const groupPublishingErrors = FLOW.selectedControl.get('publishingErrors')[questionGroupId];
return Boolean(groupPublishingErrors && groupPublishingErrors.find(x => x === questionId));
}).property('FLOW.selectedControl.publishingErrors'),

isTemplate: Ember.computed(function() {
isTemplate: Ember.computed(() => {
return FLOW.selectedControl.selectedSurveyGroup.get('template');
})
.property('FLOW.selectedControl.selectedSurveyGroup')
Expand Down Expand Up @@ -218,6 +221,15 @@ FLOW.QuestionView = FLOW.View.extend(
.property('this.type')
.cacheable(),

showAnswerStats: Ember.computed(function() {
if (!this.type) {
return false;
}
return this.type.get('value') == 'NUMBER' || this.type.get('value') == 'OPTION';
})
.property('this.type')
.cacheable(),

// TODO dependencies
// TODO options
doQuestionEdit() {
Expand Down Expand Up @@ -268,6 +280,7 @@ FLOW.QuestionView = FLOW.View.extend(
FLOW.selectedControl.selectedQuestion.get('caddisflyResourceUuid')
);
this.set('personalData', FLOW.selectedControl.selectedQuestion.get('personalData'));
this.set('answerStats', FLOW.selectedControl.selectedQuestion.get('answerStats'));

FLOW.optionListControl.set('content', []);

Expand Down Expand Up @@ -492,6 +505,7 @@ FLOW.QuestionView = FLOW.View.extend(
FLOW.selectedControl.selectedQuestion.set('tip', this.get('tip'));
FLOW.selectedControl.selectedQuestion.set('mandatoryFlag', this.get('mandatoryFlag'));
FLOW.selectedControl.selectedQuestion.set('personalData', this.get('personalData'));
FLOW.selectedControl.selectedQuestion.set('answerStats', this.get('answerStats'));

const minVal = Ember.empty(this.get('minVal')) ? null : this.get('minVal');
const maxVal = Ember.empty(this.get('maxVal')) ? null : this.get('maxVal');
Expand Down Expand Up @@ -616,7 +630,10 @@ FLOW.QuestionView = FLOW.View.extend(
const { selectedQuestion } = FLOW.selectedControl;
const questionKeyId = selectedQuestion.get('keyId');
const variableName = this.get('variableName') || '';
if (FLOW.Env.mandatoryQuestionID && (variableName.match(/^\s*$/) || variableName.length == 0)) {
if (
FLOW.Env.mandatoryQuestionID &&
(variableName.match(/^\s*$/) || variableName.length == 0)
) {
args.failure(Ember.String.loc('_variable_name_mandatory'));
} else if (!variableName.match(/^[A-Za-z0-9_-]*$/)) {
args.failure(Ember.String.loc('_variable_name_only_alphanumeric'));
Expand Down Expand Up @@ -964,7 +981,7 @@ FLOW.QuestionView = FLOW.View.extend(
},

variableNameOptional: Ember.computed(() => {
return FLOW.Env.mandatoryQuestionID != true
return FLOW.Env.mandatoryQuestionID != true;
}),

validateVariableNameObserver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
<label class="labelcheckbox">{{view Ember.Checkbox checkedBinding="view.personalData"}}
{{t _hold_personal_data}} {{tooltip _personal_data_tooltip}}</label>

{{#if view.showAnswerStats}}
<br/>
<label class="labelcheckbox">{{view Ember.Checkbox checkedBinding="view.answerStats"}}
{{t _show_answer_stats}} {{tooltip _show_answer_stats_tooltip}}</label>
{{/if}}

<!-- Question specific material -->
{{#if view.hasExtraSettings}}
<div class="questionOption floats-in">
Expand Down

0 comments on commit c3dcdc1

Please sign in to comment.