diff --git a/app/controllers/reports/people_reports_controller.rb b/app/controllers/reports/people_reports_controller.rb index 3c1f0c1d3..3e3e9f26a 100644 --- a/app/controllers/reports/people_reports_controller.rb +++ b/app/controllers/reports/people_reports_controller.rb @@ -203,7 +203,7 @@ def record_stream_permissions end send_data workbook.read_string, - filename: "PeopleRecordStream-#{Time.now.strftime('%m-%d-%Y')}.xlsx", + filename: "PeopleSessionPermissions-#{Time.now.strftime('%m-%d-%Y')}.xlsx", disposition: 'attachment' end end diff --git a/app/controllers/survey/submissions_controller.rb b/app/controllers/survey/submissions_controller.rb index f2b4e6539..3157c4ef2 100644 --- a/app/controllers/survey/submissions_controller.rb +++ b/app/controllers/survey/submissions_controller.rb @@ -116,7 +116,7 @@ def collection_to_xls header = ['Created At', 'Updated At', 'Email'] response_columns = {} posn = 3 - survey.questions.each do |question| + survey.questions.sorted.each do |question| next if [:hr, :textonly].include? question.question_type next unless can_access_question?(question, current_person) diff --git a/app/javascript/people/people_sidebar.vue b/app/javascript/people/people_sidebar.vue index 537362a98..3a56a4ca9 100644 --- a/app/javascript/people/people_sidebar.vue +++ b/app/javascript/people/people_sidebar.vue @@ -28,7 +28,7 @@ - + diff --git a/app/javascript/profile/person_surveys.vue b/app/javascript/profile/person_surveys.vue index 73af6ec25..12463bf12 100644 --- a/app/javascript/profile/person_surveys.vue +++ b/app/javascript/profile/person_surveys.vue @@ -41,19 +41,16 @@ export default { }), watch: { person: { - handler(person) { - if(person?.id) { + handler(newVal, oldVal) { + if(newVal?.id && (newVal?.id != oldVal?.id)) { + console.debug("Get surveys for ", newVal.id) this.loading = true; - this.getPersonSurveys({person}).then(data => { + + this.getPersonSurveys({person: newVal}).then(data => { const {_jv, ...surveys} = data; this.surveys = Object.values(data).map(s => ({name: s.name, id: s.id})) this.loading = false; }) - // this.getSurveysForPerson(newVal).then(data => { - // // I expect this to come back in [{name: "foo", id: "abc123"}] - // this.surveys = data; - // this.loading = false; - // }) } }, immediate: true diff --git a/app/javascript/sessions/datetime_picker.vue b/app/javascript/sessions/datetime_picker.vue index fc52c52c5..04d153d0d 100644 --- a/app/javascript/sessions/datetime_picker.vue +++ b/app/javascript/sessions/datetime_picker.vue @@ -30,10 +30,10 @@ export default { }), computed: { day() { - return this.value ? DateTime.fromISO(this.value, {zone: 'utc'}).setZone(this.conventionTimezone).toFormat('D', {locale: "en-US"}) : null; + return this.value ? DateTime.fromISO(this.value).setZone(this.conventionTimezone).toFormat('D', {locale: "en-US"}) : null; }, time() { - return this.value ? DateTime.fromISO(this.value, {zone: 'utc'}).setZone(this.conventionTimezone).toFormat('HH:mm:ss', {locale: "en-US"}) : null; + return this.value ? DateTime.fromISO(this.value).setZone(this.conventionTimezone).toFormat('HH:mm:ss', {locale: "en-US"}) : null; }, dayOptionsWithNull() { return [{text: "No day selected", value: null}, ...this.dayOptions]; @@ -41,7 +41,7 @@ export default { }, methods: { changeDay(newDay) { - let retDate = this.value ? DateTime.fromISO(this.value, {zone: 'utc'}).setZone(this.conventionTimezone) : DateTime.fromObject({hour: 0, minute: 0}, {zone: this.conventionTimezone}); + let retDate = this.value ? DateTime.fromISO(this.value).setZone(this.conventionTimezone) : DateTime.fromObject({hour: 0, minute: 0}, {zone: this.conventionTimezone}); if (newDay) { let date = DateTime.fromFormat(newDay, 'D', {locale: "en-US" }); //, {zone: this.conventionTimezone}); retDate = retDate.set({ @@ -50,12 +50,12 @@ export default { day: date.day, }) retDate = retDate.toUTC(); - console.log('***** retDate', retDate.toISO()); + // console.log('***** retDate', retDate.toISO()); this.$emit('input', retDate.toISO()); } }, changeTime(newTime) { - let retDate = this.value ? DateTime.fromISO(this.value, {zone: 'utc'}) : DateTime.fromISO(this.conventionStart, {zone: 'utc'}); + let retDate = this.value ? DateTime.fromISO(this.value).setZone(this.conventionTimezone) : DateTime.fromISO(this.conventionStart).setZone(this.conventionTimezone); if (newTime) { console.log('val', newTime, DateTime.fromFormat(newTime, 'HH:mm:ss')) let time = DateTime.fromFormat(newTime, 'HH:mm:ss', {zone: this.conventionTimezone}).toUTC(); diff --git a/app/javascript/surveys/manage-survey.vue b/app/javascript/surveys/manage-survey.vue index 068760e3b..e2f879c1a 100644 --- a/app/javascript/surveys/manage-survey.vue +++ b/app/javascript/surveys/manage-survey.vue @@ -26,7 +26,7 @@ - + @@ -59,7 +59,8 @@ export default { EditSurvey }, data: () => ({ - SURVEY_PUBLIC_NO_EDIT + SURVEY_PUBLIC_NO_EDIT, + person_id: null }), computed: { questionsTitle() { @@ -68,6 +69,7 @@ export default { }, methods: { init() { + this.person_id = this.$route.query.person_id this.selectSurvey(this.id); this.fetchSelectedSurvey(); }, diff --git a/app/javascript/surveys/view-responses.vue b/app/javascript/surveys/view-responses.vue index 7a2518bec..819a5c5c5 100644 --- a/app/javascript/surveys/view-responses.vue +++ b/app/javascript/surveys/view-responses.vue @@ -8,6 +8,7 @@ ref="responses-table" model="submission_flat" :defaultUrl="defaultUrl" + :defaultFilter="defaultFilter" :show-add="false" :show-settings="false" :columns="question_columns" @@ -49,6 +50,10 @@ export default { surveyId: { type: String, default: null + }, + person_id: { + type: String, + default: null } }, components: { @@ -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` }, diff --git a/app/models/survey/question.rb b/app/models/survey/question.rb index 2ae209eca..af564da31 100644 --- a/app/models/survey/question.rb +++ b/app/models/survey/question.rb @@ -35,11 +35,10 @@ class Survey::Question < ApplicationRecord # Scopes to deal with the soft deletes scope :not_deleted, -> { where(deleted_at: nil) } scope :deleted, -> { where('survey_questions.deleted_at is not null') } + scope :sorted, -> {includes(:page).order(['survey_pages.sort_order asc', 'survey_questions.sort_order asc'])} has_paper_trail versions: { class_name: 'Audit::SurveyVersion' }, ignore: [:updated_at, :created_at, :lock_version, :sort_order] - # default_scope {includes(:page).order(['survey_pages.sort_order asc', 'survey_questions.sort_order asc'])} - belongs_to :page, class_name: 'Survey::Page', foreign_key: 'page_id',