wip file field

This commit is contained in:
2024-09-28 18:36:18 +03:00
parent 5ed57838fc
commit 39e7a3aed4
25 changed files with 674 additions and 44 deletions
@@ -0,0 +1,50 @@
@php
$schema = $channel->schemas->firstWhere("name",$reference->schema);
@endphp
<div class="preview-file">
<div style="display: flex;align-items: center;gap: 10px;">
<div class="image">
@include("lucent::records-editor.fields.file.thumb", ["size" => "small", "record" => $reference])
</div>
<div class="title">
<div>
<a class="record-title" href="{{lucent_url("records")}}/{{$record->id}}">
{{$viewModel->getRecordName($reference)}}
</a>
<small class="d-block">
from {{$schema->label}}
@if ($record->status === "draft")
@include("lucent::records-editor.status", ["status" => $record->status])
@endif
</small>
</div>
</div>
</div>
{{-- <div style="display: flex;gap:4px; align-items: center; margin-right: 10px;">--}}
{{-- {#if hasInsert}--}}
{{-- <div class="reference-action">--}}
{{-- <Dropdown>--}}
{{-- <div slot="button">--}}
{{-- <Icon icon="photo-film"/>--}}
{{-- </div>--}}
{{-- <button class="dropdown-item button" on:click={e => insert(e,null)}>original</button>--}}
{{-- {#each imagePresets as preset}--}}
{{-- <button class="dropdown-item button" on:click={e => insert(e,preset)}>{preset}</button>--}}
{{-- {/each}--}}
{{-- </Dropdown>--}}
{{-- </div>--}}
{{-- {/if}--}}
{{-- {#if hasDelete}--}}
{{-- <div class="reference-action">--}}
{{-- <button--}}
{{-- class="button"--}}
{{-- on:click={remove}--}}
{{-- >--}}
{{-- <Icon icon="trash-can"/>--}}
{{-- </button>--}}
{{-- </div>--}}
{{-- {/if}--}}
{{-- </div>--}}
</div>
@@ -0,0 +1,59 @@
@php
$imageSide = 256;
$fileSide = 32;
$fontSize = "20";
$showFilename = $showFilename ?? false;
if ($size === "medium") {
$imageSide = 128;
$fileSide = 12;
$fontSize = "17";
} else if ($size === "small") {
$imageSide = 64;
$fileSide = 12;
$fontSize = "15";
} else if ($size === "tiny") {
$imageSide = 42;
$fileSide = 12;
$fontSize = "13";
}
@endphp
<div style="display: flex;align-items: center;gap: 5px;">
@if(str_starts_with($record->_file->mime, "image"))
<a
href="{{lucent_url("records")}}/{{$record->id}}"
title="{{$record->_file->originalName}}"
style="width:{{$imageSide}}px;height:{{$imageSide}}px"
>
<img
class="rounded w-100"
style="border-radius: 12px;padding: 4px;"
src={{lucent_thumbnail($record)}}
alt="{{$record->_file->path}}"
/>
</a>
@else
<a
href="{{lucent_url("records")}}/{{$record->id}}"
title="{{$record->_file->path}}"
class="file-preview-small"
style="width:{{$imageSide}}px;height:{{$imageSide}}px"
>
<x-lucent::icon icon="file" :width="$fileSide" :height="$fileSide"></x-lucent::icon>
<span class="ms-2"
>.{{pathinfo($record->_file->path, PATHINFO_EXTENSION)}}</span
>
</a>
@endif
@if ($showFilename)
<a
href="{{lucent_url("records")}}/{{$record->id}}"
title="{{$record->_file->path}}"
class="preview-file-filename lx-small-text text-decoration-none"
>{{$record->_file->path}} </a>
@endif
</div>