Signature block (img) (#39)
* Signature block (img) * Singature input UI changes * Style the signature input Co-authored-by: Julien Nahum <jhumanj@MacBook-Pro-de-Julien.local>
This commit is contained in:
@@ -124,6 +124,7 @@ class AnswerFormRequest extends FormRequest
|
||||
switch ($property['type']) {
|
||||
case 'text':
|
||||
case 'phone_number':
|
||||
case 'signature':
|
||||
return ['string'];
|
||||
case 'number':
|
||||
return ['numeric'];
|
||||
|
||||
@@ -41,7 +41,7 @@ class FormSubmissionResource extends JsonResource
|
||||
$data = $this->data;
|
||||
$formFields = collect($this->form->properties)->concat(collect($this->form->removed_properties));
|
||||
$fileFields = $formFields->filter(function ($field) {
|
||||
return $field['type'] == 'files';
|
||||
return in_array($field['type'], ['files', 'signature']);
|
||||
});
|
||||
foreach ($fileFields as $field) {
|
||||
if (isset($data[$field['id']]) && !empty($data[$field['id']])) {
|
||||
|
||||
@@ -89,6 +89,11 @@ class StoreFormSubmissionJob implements ShouldQueue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For Singrature
|
||||
if($this->form->is_pro && $field['type'] == 'signature') {
|
||||
$finalData[$field['id']] = $this->storeSignature($answerValue);
|
||||
}
|
||||
}
|
||||
|
||||
return $finalData;
|
||||
@@ -130,6 +135,21 @@ class StoreFormSubmissionJob implements ShouldQueue
|
||||
return $fileNameParser->getMovedFileName();
|
||||
}
|
||||
|
||||
private function storeSignature(?string $value)
|
||||
{
|
||||
if ($value == null || !isset(explode(',', $value)[1])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$fileName = 'sign_'.(string) Str::uuid().'.png';
|
||||
$newPath = Str::of(PublicFormController::FILE_UPLOAD_PATH)->replace('?', $this->form->id);
|
||||
$completeNewFilename = $newPath.'/'.$fileName;
|
||||
|
||||
Storage::disk('s3')->put($completeNewFilename, base64_decode(explode(',', $value)[1]));
|
||||
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds prefill from hidden fields
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user