Skip to content

Commit

Permalink
Merge pull request #997 from PlanoramaEvents/plan-949-filter-submissi…
Browse files Browse the repository at this point in the history
…ons-by-person

PLAN-949 Fixed so that the responses are filtered by the id of the person passed in
  • Loading branch information
balen authored Mar 8, 2024
2 parents 3be6446 + 5ad73de commit 5d87840
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/javascript/surveys/manage-survey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<edit-survey :survey-id="id"></edit-survey>
</b-tab>
<b-tab v-if="survey" title="Responses" :active="!!responses" lazy>
<view-responses :survey-id="id"></view-responses>
<view-responses :survey-id="id" :person_id="person_id"></view-responses>
</b-tab>
<survey-settings-tab v-if="survey" lazy></survey-settings-tab>
<b-tab v-if="survey" title="Audit Log" disabled lazy>
Expand Down Expand Up @@ -59,7 +59,8 @@ export default {
EditSurvey
},
data: () => ({
SURVEY_PUBLIC_NO_EDIT
SURVEY_PUBLIC_NO_EDIT,
person_id: null
}),
computed: {
questionsTitle() {
Expand All @@ -68,6 +69,7 @@ export default {
},
methods: {
init() {
this.person_id = this.$route.query.person_id
this.selectSurvey(this.id);
this.fetchSelectedSurvey();
},
Expand Down
20 changes: 20 additions & 0 deletions app/javascript/surveys/view-responses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ref="responses-table"
model="submission_flat"
:defaultUrl="defaultUrl"
:defaultFilter="defaultFilter"
:show-add="false"
:show-settings="false"
:columns="question_columns"
Expand Down Expand Up @@ -49,6 +50,10 @@ export default {
surveyId: {
type: String,
default: null
},
person_id: {
type: String,
default: null
}
},
components: {
Expand All @@ -65,6 +70,21 @@ export default {
defaultUrl() {
return `/survey/${this.surveyId}/submissions/flat`
},
defaultFilter() {
if (this.person_id) {
let filter = {
"op": "all",
"queries":[
["person_id", "=", this.person_id]
]
}
return JSON.stringify(filter)
} else {
return null;
}
},
downloadLink() {
return `/survey/${this.surveyId}/submissions.xlsx`
},
Expand Down

0 comments on commit 5d87840

Please sign in to comment.