file uploads

This commit is contained in:
2026-05-06 18:11:42 +03:00
parent 16e50e2d49
commit 5587e8b4b6
41 changed files with 685 additions and 1067 deletions
-68
View File
@@ -1,68 +0,0 @@
<script>
import {getContext} from "svelte";
import Preview from "../files/Preview.svelte";
import {selectRecord} from "./functions/recordSelect.js";
const channel = getContext("channel");
export let schema;
export let records;
export let isWritable;
export let selected = [];
function select(record) {
selected = selectRecord(record, selected)
}
</script>
<div class="row" style="max-width:1000px">
{#each records as record (record.id)}
<div class="col-6 col-md-4">
<div
class="file-wrapper rounded p-2 mb-4 bg-light"
class:selected={selected.includes(record)}
>
{#if isWritable}
<div class="form-check">
<input
on:change={() => select(record)}
class="form-check-input "
type="checkbox"
checked={selected.find(
(r) => r.id === record.id
)}
value={record}
/>
</div>
{/if}
<div class="d-flex justify-content-center">
<Preview {record} size="medium"/>
</div>
<a
href="{channel.lucentUrl}/records/{record.id}"
title={record._file.path}
class="d-block text-center overflow-hidden text-nowrap my-2 "
style="
text-overflow: ellipsis;
font-size: 13px;
color: #333;
">{record._file.path}</a
>
<span
class="lx-small-text text-muted d-block text-center"
>{record._file.mime}</span
>
</div>
</div>
{/each}
</div>
<style>
.form-check {
display: inline-block;
margin-bottom: 0;
}
</style>
+32 -34
View File
@@ -3,7 +3,7 @@
import Pagination from "./pagination/Pagination.svelte";
import ActionsOnSelected from "./ActionsOnSelected.svelte";
import Table from "./Table.svelte";
import {getContext} from "svelte";
import { getContext } from "svelte";
const axios = getContext("axios");
export let schema;
@@ -47,51 +47,49 @@
</script>
<div class="">
<div class="{inModal ? 'mt-0' : 'mt-5'}">
<h3 class="header-normal mb-5 ">
<div class={inModal ? "mt-0" : "mt-5"}>
<h3 class="header-normal mb-5">
{schema.label}
</h3>
{#if selected.length > 0 && !inModal && isWritable}
<ActionsOnSelected {schema} {selected} {filter}/>
<ActionsOnSelected {schema} {selected} {filter} />
{:else}
<Tools
bind:schema
bind:records
{systemFields}
{sortParam}
{sortField}
{operators}
{filter}
{graph}
{inModal}
{modalUrl}
{isWritable}
on:refresh={refresh}
bind:schema
bind:records
{systemFields}
{sortParam}
{sortField}
{operators}
{filter}
{graph}
{inModal}
{modalUrl}
{isWritable}
on:refresh={refresh}
/>
{/if}
<Table
{records}
{graph}
{schema}
{sortParam}
{sortField}
{systemFields}
{inModal}
{users}
{isWritable}
bind:selected
{records}
{graph}
{schema}
{sortParam}
{sortField}
{systemFields}
{inModal}
{users}
{isWritable}
bind:selected
/>
</div>
<Pagination
{limit}
{skip}
{total}
on:refresh={refresh}
{inModal}
{modalUrl}
{limit}
{skip}
{total}
on:refresh={refresh}
{inModal}
{modalUrl}
/>
</div>
+20 -13
View File
@@ -2,8 +2,8 @@
import RenderField from "./RenderField.svelte";
import Avatar from "../account/Avatar.svelte";
import Status from "../records/Status.svelte";
import {usernameById} from "../account/users";
import {friendlyDate} from "../../helpers";
import { usernameById } from "../account/users";
import { friendlyDate } from "../../helpers";
export let schema;
export let users;
@@ -12,7 +12,6 @@
export let sortParam;
export let sortField;
export let visibleColumns;
</script>
{#each visibleColumns as field, index}
@@ -20,7 +19,7 @@
class="field-ui-{field.info.name}"
class:is-sort={field.name === sortField.name}
>
<RenderField {record} {schema} {graph} {field}/>
<RenderField {record} {schema} {graph} {field} />
</td>
{/each}
{#if schema.visible?.includes("status")}
@@ -28,32 +27,40 @@
class="text-center"
class:is-sort={"-status" == sortParam || "status" == sortParam}
>
<Status status={record.status}/>
<Status status={record.status} />
</td>
{/if}
{#if schema.visible?.includes("_sys.createdBy")}
<td
class="text-center"
class:is-sort={"-_sys.createdBy" == sortParam || "_sys.createdBy" == sortParam}
class:is-sort={"-_sys.createdBy" == sortParam ||
"_sys.createdBy" == sortParam}
>
<Avatar name={usernameById(users, record._sys.createdBy)} side={24}/>
<Avatar name={usernameById(users, record.createdBy)} side={24} />
</td>
{/if}
{#if schema.visible?.includes("_sys.updatedBy")}
<td
class="text-center"
class:is-sort={"-_sys.updatedBy" == sortParam || "_sys.updatedBy" == sortParam}
class:is-sort={"-_sys.updatedBy" == sortParam ||
"_sys.updatedBy" == sortParam}
>
<Avatar name={usernameById(users, record._sys.updatedBy)} side={24}/>
<Avatar name={usernameById(users, record.updatedBy)} side={24} />
</td>
{/if}
{#if schema.visible?.includes("_sys.createdAt")}
<td class:is-sort={"-_sys.createdAt" == sortParam || "_sys.createdAt" == sortParam}>
{friendlyDate(record._sys.createdAt)}
<td
class:is-sort={"-_sys.createdAt" == sortParam ||
"_sys.createdAt" == sortParam}
>
{friendlyDate(record.createdAt)}
</td>
{/if}
{#if schema.visible?.includes("_sys.updatedAt")}
<td class:is-sort={"-_sys.updatedAt" == sortParam || "_sys.updatedAt" == sortParam}>
{friendlyDate(record._sys.updatedAt)}
<td
class:is-sort={"-_sys.updatedAt" == sortParam ||
"_sys.updatedAt" == sortParam}
>
{friendlyDate(record.updatedAt)}
</td>
{/if}
+60 -91
View File
@@ -1,13 +1,13 @@
<script>
import RecordRow from "./RecordRow.svelte";
import {previewTitle} from "../records/Preview";
import {usernameById} from "../account/users";
import {getContext} from "svelte";
import { previewTitle } from "../records/Preview";
import { usernameById } from "../account/users";
import { getContext } from "svelte";
import Avatar from "../account/Avatar.svelte";
import {selectRecord, toggleAll} from "./functions/recordSelect.js";
import { selectRecord, toggleAll } from "./functions/recordSelect.js";
import Checkbox from "../common/Checkbox.svelte";
import Preview from "../files/Preview.svelte";
import {fileurl} from "../files/imageserver.js";
import { fileurl } from "../files/imageserver.js";
const channel = getContext("channel");
@@ -23,107 +23,80 @@
export let selected = [];
function eventToggleAll(e) {
selected = toggleAll(e, records, selected)
selected = toggleAll(e, records, selected);
}
function select(record) {
selected = selectRecord(record, selected)
selected = selectRecord(record, selected);
}
$: visibleColumns = schema.fields.filter(c => schema.visible?.includes(c.name) ?? [])
$: visibleColumns = schema.fields.filter(
(c) => schema.visible?.includes(c.name) ?? [],
);
</script>
<div class="table mt-5 ">
<div class="table mt-5">
<table>
<thead>
<tr>
{#if isWritable}
<th>
<Checkbox
<tr>
{#if isWritable}
<th>
<Checkbox
value=""
on:change={eventToggleAll}
indeterminate={selected.length > 0 && selected.length < records.length}
indeterminate={selected.length > 0 &&
selected.length < records.length}
checked={selected.length === records.length}
>
</Checkbox>
</th>
{/if}
></Checkbox>
</th>
{/if}
{#each visibleColumns as field}
<th
{#each visibleColumns as field}
<th
class="field-ui-{field.info.name ?? field.ui}"
class:is-sort={field.name === sortField.name}
scope="col"
title={field.help}
>{field.label}</th
>
{/each}
{#each systemFields.filter(c => schema.visible?.includes(c.name)) as sysField}
<th class:is-sort={sysField.name === sortField.name}>{sysField.label}</th>
{/each}
<th></th>
</tr>
title={field.help}>{field.label}</th
>
{/each}
{#each systemFields.filter( (c) => schema.visible?.includes(c.name), ) as sysField}
<th class:is-sort={sysField.name === sortField.name}
>{sysField.label}</th
>
{/each}
<th></th>
</tr>
</thead>
<tbody>
{#each records as record (record.id)}
<tr>
<td class="title-td">
<div
class="title-td-contents"
>
{#if isWritable}
<Checkbox
{#each records as record (record.id)}
<tr>
<td class="title-td">
<div class="title-td-contents">
{#if isWritable}
<Checkbox
on:change={() => select(record)}
checked={selected.find((r) => r.id === record.id)}
checked={selected.find(
(r) => r.id === record.id,
)}
value={record}
>
</Checkbox>
></Checkbox>
{/if}
{/if}
{#if record._file?.path}
<div class="file-table-row">
<Preview record={record} size={record._file?.width > 0 ? "medium" : "small"}/>
<div>
{#if record.status === "draft"}
<span style="text-transform: uppercase;font-size:10px">{record.status}</span>
{/if}
<a
href="{channel.lucentUrl}/records/{record.id}"
target={inModal ? "_blank" : "_self"}
>
{previewTitle(channel.schemas, record, graph)}
</a>
<span>{(record._file.size / 1024).toFixed(1)}kB</span>
{#if record._file.width > 0}
<span>{record._file.width + "x" + record._file.height}</span>
{/if}
<a
href="{fileurl(channel,record)}"
target="_blank"
>
Download
</a>
</div>
</div>
{:else}
<a
href="{channel.lucentUrl}/records/{record.id}"
target={inModal ? "_blank" : "_self"}
href="{channel.lucentUrl}/records/{record.id}"
target={inModal ? "_blank" : "_self"}
>
{#if record.status === "draft"}
<span style="text-transform: uppercase;font-size:10px">{record.status}</span>
<span
style="text-transform: uppercase;font-size:10px"
>{record.status}</span
>
{/if}
{previewTitle(channel.schemas, record, graph)}
</a>
{/if}
</div>
</td>
<RecordRow
</div>
</td>
<RecordRow
{record}
{graph}
{schema}
@@ -131,19 +104,15 @@
{sortParam}
{sortField}
{users}
/>
<td>
<Avatar
name={usernameById(
users,
record._sys.updatedBy
)}
side={24}
/>
</td>
</tr>
{/each}
<td>
<Avatar
name={usernameById(users, record.updatedBy)}
side={24}
/>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
@@ -1,6 +1,5 @@
<script>
import FilterFields from "./FilterFields.svelte";
import Uploader from "../../files/Uploader.svelte";
import Icon from "../../common/Icon.svelte";
import SortFields from "./SortFields.svelte";
import AppliedFilter from "./AppliedFilter.svelte";