mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 05:53:58 +00:00
Admin Workflow - Fix Tested Issues - upload 3 documents at one step
This commit is contained in:
+2
-2
@@ -115,7 +115,7 @@ class UpdateNextQuestionV1AdminWFLogic extends AbstractControllerLogic
|
||||
}
|
||||
|
||||
//Save answer given by user (both next and previous)
|
||||
$filesUpload = $request->input('files');
|
||||
$filesUpload = $request->only(['files', 'filesA', 'filesB', 'filesC']);
|
||||
$answerOptionId = 0;
|
||||
if ($request->has('answerObj')) {
|
||||
$answerOptionId = intval($request->answerObj['id']);
|
||||
@@ -187,4 +187,4 @@ class UpdateNextQuestionV1AdminWFLogic extends AbstractControllerLogic
|
||||
|
||||
return $this->resourceResponse(new QuestionResource($returnQuestion, $userId, $request->has('isPrevious'), $isNoGoingBack, $previousAnswer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace App\Classes\Modules\Questionnaires\Processors;
|
||||
use App\Models\QAUserAnswerSelected;
|
||||
use App\Classes\Modules\Documents\Processors\UploadDocumentProcessor;
|
||||
use App\Classes\ValueObjects\Constants\QAType;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SaveAnswerV1AdminWFProcessor
|
||||
{
|
||||
@@ -27,7 +28,7 @@ class SaveAnswerV1AdminWFProcessor
|
||||
public function execute($userId, $sourceId, $questionId, $questionType, $questionMetadata, $answerInText, $answerOptionId, $filesUpload, $timeUsedSeconds, $isPrevious, $reference = null){
|
||||
|
||||
$answer = null;
|
||||
$attachments = null;
|
||||
$attachments = [];
|
||||
|
||||
if(is_null($answer))
|
||||
{
|
||||
@@ -46,16 +47,25 @@ class SaveAnswerV1AdminWFProcessor
|
||||
$answer->save(); //cief todo: why 2 save() in this file, this is wrong
|
||||
|
||||
if($filesUpload){
|
||||
$result = $this->uploadDocumentForProcessor->execute($filesUpload, $answer, 'questionnaires');
|
||||
$attachments = array_map(function ($item) {
|
||||
return [
|
||||
'document_id' => $item->document_id,
|
||||
'file_id' => $item->id,
|
||||
];
|
||||
}, $result);
|
||||
if (isset($filesUpload['filesA']))
|
||||
{
|
||||
foreach ($filesUpload as $key => $files) {
|
||||
$attachments[$key] = $this->saveFile($answer, $files);
|
||||
}
|
||||
}
|
||||
else if (isset($filesUpload['files']) && $filesUpload['files'])
|
||||
{
|
||||
$attachments = $this->saveFile($answer, $filesUpload['files']);
|
||||
}
|
||||
}
|
||||
|
||||
if($questionType === QAType::REMARKS_WITH_DOCUMENT_UPLOAD){
|
||||
if($questionType === QAType::SUBMIT_1688_3_TYPES_DOCUMENTS){
|
||||
$structuredAnswer = [
|
||||
'files' => $attachments,
|
||||
];
|
||||
$answer->answer = json_encode($structuredAnswer);
|
||||
}
|
||||
else if($questionType === QAType::REMARKS_WITH_DOCUMENT_UPLOAD){
|
||||
$structuredAnswer = [
|
||||
'text' => $answerInText,
|
||||
'files' => $attachments,
|
||||
@@ -75,4 +85,16 @@ class SaveAnswerV1AdminWFProcessor
|
||||
|
||||
return $answer;
|
||||
}
|
||||
|
||||
private function saveFile($answer, $files){
|
||||
$result = $this->uploadDocumentForProcessor->execute($files, $answer, 'questionnaires');
|
||||
$attachment = array_map(function ($item) {
|
||||
return [
|
||||
'name' => $item->document_id,
|
||||
'file_id' => $item->id,
|
||||
];
|
||||
}, $result);
|
||||
|
||||
return $attachment;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@
|
||||
Upload the English PO
|
||||
</h2>
|
||||
<!-- <file-upload-component :data="externalApiResponse" section="section"></file-upload-component> -->
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<file-input-component :validator="$v.filesA" v-model="filesA">
|
||||
<template slot="label">
|
||||
<div class="font-heading fs-11 all-caps">Photo or File</div>
|
||||
</template>
|
||||
@@ -229,7 +229,7 @@
|
||||
<h2>
|
||||
Upload the China PO
|
||||
</h2>
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<file-input-component :validator="$v.filesB" v-model="filesB">
|
||||
<template slot="label">
|
||||
<div class="font-heading fs-11 all-caps">Photo or File</div>
|
||||
</template>
|
||||
@@ -239,7 +239,7 @@
|
||||
<h2>
|
||||
Upload Bank Slip
|
||||
</h2>
|
||||
<file-input-component :validator="$v.files" v-model="files">
|
||||
<file-input-component :validator="$v.filesC" v-model="filesC">
|
||||
<template slot="label">
|
||||
<div class="font-heading fs-11 all-caps">Photo or File</div>
|
||||
</template>
|
||||
@@ -400,6 +400,9 @@
|
||||
section: 'adminWorkFlowForm',
|
||||
showAnswerInput: false,
|
||||
showUploadInput: false,
|
||||
showUploadInputA: false,
|
||||
showUploadInputB: false,
|
||||
showUploadInputC: false,
|
||||
formTouched: false,
|
||||
question: null,
|
||||
answer: '',
|
||||
@@ -407,6 +410,9 @@
|
||||
direction: 'next',
|
||||
documentType: 1,
|
||||
files: [],
|
||||
filesA: [], //English PO
|
||||
filesB: [], //China PO
|
||||
filesC: [], //Bank Slip
|
||||
error: null,
|
||||
|
||||
// From AdminWorkFlowSectionComponent
|
||||
@@ -430,6 +436,15 @@
|
||||
},
|
||||
files: {
|
||||
required: this.formTouched && this.showUploadInput ? required : false,
|
||||
},
|
||||
filesA: {
|
||||
required: this.formTouched && this.showUploadInputA ? required : false, //English PO
|
||||
},
|
||||
filesB: {
|
||||
required: this.formTouched && this.showUploadInputB ? required : false, //China PO
|
||||
},
|
||||
filesC: {
|
||||
required: this.formTouched && this.showUploadInputC ? required : false, //Bank Slip
|
||||
}
|
||||
};
|
||||
},
|
||||
@@ -577,7 +592,6 @@
|
||||
this.parameters.answer = this.answer;
|
||||
this.parameters.answerId = this.answerId;
|
||||
this.parameters.answerObj = this.question.question_answers.find(item => item.id === Number(this.answerId));
|
||||
this.parameters.files = this.files;
|
||||
this.parameters.extra = {};
|
||||
|
||||
this.error = null;
|
||||
@@ -585,6 +599,7 @@
|
||||
if(this.question.question_type === 3){
|
||||
this.showAnswerInput = false;
|
||||
this.showUploadInput = true;
|
||||
this.parameters.files = this.files;
|
||||
}
|
||||
else if(this.question.question_type === 1 || (this.question.question_type === 2)){
|
||||
this.showAnswerInput = true;
|
||||
@@ -593,6 +608,17 @@
|
||||
else if(this.question.question_type === 7){
|
||||
this.showAnswerInput = true;
|
||||
this.showUploadInput = false;
|
||||
this.parameters.files = this.files;
|
||||
}
|
||||
else if(this.question.question_type === 8){
|
||||
this.showAnswerInput = false;
|
||||
this.showUploadInput = false;
|
||||
this.showUploadInputA = true;
|
||||
this.showUploadInputB = true;
|
||||
this.showUploadInputC = true;
|
||||
this.parameters.filesA = this.filesA;
|
||||
this.parameters.filesB = this.filesB;
|
||||
this.parameters.filesC = this.filesC;
|
||||
}
|
||||
|
||||
this.parameters.extra.timeUsedSeconds = this.stepTime;
|
||||
@@ -621,13 +647,12 @@
|
||||
this.parameters.extra.session_id = this.sessionId;
|
||||
|
||||
if(direction === 'next'){
|
||||
|
||||
if (this.parameters.answer === 'start_work') this.startWork();
|
||||
if (this.parameters.answer === 'stop_working') this.stopTimer();
|
||||
|
||||
this.submit(this.route('api.questionnaires.next.question'), 'post', this.section, false, false);
|
||||
}
|
||||
else if(direction === 'previous'){
|
||||
console.log('previous');
|
||||
this.formTouched = false;
|
||||
this.parameters.isPrevious = true;
|
||||
this.submit(this.route('api.questionnaires.next.question'), 'post', this.section, false, false);
|
||||
@@ -638,9 +663,15 @@
|
||||
this.answer = '';
|
||||
this.answerId = 0;
|
||||
this.files = [];
|
||||
this.filesA = [];
|
||||
this.filesB = [];
|
||||
this.filesC = [];
|
||||
this.formTouched = false;
|
||||
this.showAnswerInput = false;
|
||||
this.showUploadInput = false;
|
||||
this.showUploadInputA = false;
|
||||
this.showUploadInputB = false;
|
||||
this.showUploadInputC = false;
|
||||
this.error = null;
|
||||
this.stepTime = 0;
|
||||
this.externalApiUrl = "";
|
||||
|
||||
Reference in New Issue
Block a user