-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * update ui * add all options to file input * implement useFileDialog for Settings * wip frontend * wip * show icons for uploads * update configure file test * use watcheffect * change test payload * upload route * first version of working upload * remove unused import * first version of downloadable files in submissions view * output download urls in submission export * wip file type validation * validate file on drop * update packages * add file upload progress to form button * fix focusing D9Input in ClickInteraction * change style and wording of block settings * update packages * fix file upload handline * hide file upload input if max files are reached * show validation on update event * update translations * change valid email translation * update translation keys * update lang keys * wip language * add validation to set files * update translations * update vue-tsc * update button test snapshot * fix has uploads getter * delete uploads when form session is deleted * display 404 when file not found * fix purging of submissions * fix webhook caller with file uploads * update vue * fix navigator * fix wrong key in navigation button * fix progress indicator * add json encoding to debug mode when saving form response
- Loading branch information
1 parent
6fc8372
commit 8c269fa
Showing
63 changed files
with
1,764 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Api; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Form; | ||
use App\Models\FormBlockInteraction; | ||
use Illuminate\Http\Request; | ||
|
||
class FormUploadController extends Controller | ||
{ | ||
public function __invoke(Request $request, Form $form) | ||
{ | ||
$request->validate([ | ||
'token' => 'required|string', | ||
'actionId' => 'required|string', | ||
'file' => 'file', | ||
]); | ||
|
||
$interaction = FormBlockInteraction::withUuid($request->input('actionId')) | ||
->firstOrFail(); | ||
|
||
// Validate that action belongs to the form | ||
if ($interaction->formBlock->form->id !== $form->id) { | ||
abort(404, 'Action not found'); | ||
} | ||
|
||
$session = $form->formSessions() | ||
->where('token', $request->input('token')) | ||
->firstOrFail(); | ||
|
||
$sessionResponse = $session->formSessionResponses->where('form_block_interaction_id', $interaction->id)->first(); | ||
|
||
$upload = $sessionResponse->saveUpload($request->file('file')); | ||
|
||
return response()->json($upload, 201); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Models\FormSessionUpload; | ||
use Illuminate\Support\Facades\Storage; | ||
|
||
class FormUploadsDownloadController extends Controller | ||
{ | ||
public function __invoke(Request $request, $upload) | ||
{ | ||
$upload = FormSessionUpload::whereUuid($upload)->firstOrFail(); | ||
|
||
if (!Storage::fileExists($upload->path)) { | ||
abort(404); | ||
} | ||
|
||
return Storage::download($upload->path, $upload->name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Support\Facades\URL; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Casts\Attribute; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
|
||
class FormSessionUpload extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $guarded = []; | ||
|
||
protected $appends = ['download_url']; | ||
|
||
public function formSessionResponse() | ||
{ | ||
return $this->belongsTo(FormSessionResponse::class); | ||
} | ||
|
||
public function downloadUrl(): Attribute | ||
{ | ||
return Attribute::make( | ||
get: fn (mixed $value, array $attributes) => URL::temporarySignedRoute('forms.submission-uploads.download', now()->addDays(7), $attributes['uuid']) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
database/migrations/2024_02_22_142342_create_form_session_uploads_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('form_session_uploads', function (Blueprint $table) { | ||
$table->id(); | ||
$table->uuid('uuid'); | ||
$table->string('name'); | ||
$table->string('path'); | ||
$table->string('type'); | ||
$table->string('size'); | ||
$table->unsignedBigInteger('form_session_response_id'); | ||
$table->timestamps(); | ||
}); | ||
|
||
Schema::table('form_session_uploads', function (Blueprint $table) { | ||
if (DB::getDriverName() !== 'sqlite') { | ||
$table->foreign('form_session_response_id') | ||
->references('id')->on('form_session_responses') | ||
->onDelete('CASCADE'); | ||
} | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.