diff --git a/src/app/controllers/encrypt-submissions.server.controller.js b/src/app/controllers/encrypt-submissions.server.controller.js index 4733f561f1..095d28cbdf 100644 --- a/src/app/controllers/encrypt-submissions.server.controller.js +++ b/src/app/controllers/encrypt-submissions.server.controller.js @@ -202,44 +202,15 @@ exports.saveResponseToDb = function (req, res, next) { */ exports.getMetadata = function (req, res) { let pageSize = 10 - let { page, submissionId } = req.query || {} + let { page } = req.query || {} let numToSkip = parseInt(page - 1 || 0) * pageSize - let matchClause = { - form: req.form._id, - submissionType: 'encryptSubmission', - } - - if (submissionId) { - if (mongoose.Types.ObjectId.isValid(submissionId)) { - matchClause._id = mongoose.Types.ObjectId(submissionId) - Submission.findOne(matchClause, { created: 1 }).exec((err, result) => { - if (err) { - logger.error(getRequestIp(req), req.url, req.headers, err) - return res.status(HttpStatus.INTERNAL_SERVER_ERROR).send({ - message: errorHandler.getMongoErrorMessage(err), - }) - } - if (!result) { - return res.status(HttpStatus.OK).send({ metadata: [], count: 0 }) - } - let entry = { - number: 1, - refNo: result._id, - submissionTime: moment(result.created) - .tz('Asia/Singapore') - .format('Do MMM YYYY, h:mm:ss a'), - } - return res.status(HttpStatus.OK).send({ metadata: [entry], count: 1 }) - }) - } else { - return res.status(HttpStatus.OK).send({ metadata: [], count: 0 }) - } - } - Submission.aggregate([ { - $match: matchClause, + $match: { + form: req.form._id, + submissionType: 'encryptSubmission', + }, }, { $sort: { created: -1 }, diff --git a/src/public/modules/forms/admin/controllers/view-responses.client.controller.js b/src/public/modules/forms/admin/controllers/view-responses.client.controller.js index 86c5778bbf..551e2ded4e 100644 --- a/src/public/modules/forms/admin/controllers/view-responses.client.controller.js +++ b/src/public/modules/forms/admin/controllers/view-responses.client.controller.js @@ -38,8 +38,6 @@ function ViewResponsesController( vm.isEncryptResponseMode = vm.myform.responseMode === responseModeEnum.ENCRYPT vm.encryptionKey = null // will be set to an instance of EncryptionKey when form is unlocked successfully vm.csvDownloading = false // whether CSV export is in progress - vm.filterBySubmissionRefId = '' // whether to filter submissions by a specific ID - vm.filterBySubmissionRefIdTextbox = '' // Three views: // 1 - Unlock view for verifying form password @@ -238,15 +236,12 @@ function ViewResponsesController( } }) - vm.filterBySubmissionChanged = function () { - vm.filterBySubmissionRefId = vm.filterBySubmissionRefIdTextbox - vm.tableParams.reload() - } - // Called by child directive unlockResponsesForm after key is verified to get responses - vm.loadResponses = function () { + vm.loadResponses = function (formPassword) { + vm.formPassword = formPassword vm.currentView = 2 vm.loading = true + vm.tableParams = new NgTableParams( { page: 1, // show first page @@ -257,7 +252,6 @@ function ViewResponsesController( let { page } = params.url() return Submissions.getMetadata({ formId: vm.myform._id, - filterBySubmissionRefId: vm.filterBySubmissionRefId, page, }) .then((data) => { diff --git a/src/public/modules/forms/admin/views/view-responses.client.view.html b/src/public/modules/forms/admin/views/view-responses.client.view.html index 8d857b169b..5006c43cf5 100644 --- a/src/public/modules/forms/admin/views/view-responses.client.view.html +++ b/src/public/modules/forms/admin/views/view-responses.client.view.html @@ -31,9 +31,7 @@
-
+
-
+
-
+
{{vm.responsesCount}} response(s) to @@ -76,18 +74,7 @@ >
-
-
-
- -
-
+
-
+
-
-
- -
No results found
-
- Did you enter the right reference number? We can't seem to find - the response. -
-
-