permissions

This commit is contained in:
2023-10-17 22:57:25 +03:00
parent 4b9e9cb4f6
commit 632684f514
29 changed files with 370 additions and 223 deletions
+45 -40
View File
@@ -23,6 +23,7 @@
export let inModal;
export let modalUrl;
export let selected = [];
export let isWritable = false;
function selectRecord(e, record) {
@@ -62,68 +63,72 @@
<h3 class="header-normal mb-5 ">
{schema.label}
</h3>
{#if selected.length > 0 && !inModal}
{#if selected.length > 0 && !inModal && isWritable}
<ActionsOnSelected {schema} {selected} {inModal} {filter}/>
{:else}
<Tools
bind:schema
bind:records
{systemFields}
{sort}
{operators}
{filter}
{inModal}
{modalUrl}
on:refresh={refresh}
bind:schema
bind:records
{systemFields}
{sort}
{operators}
{filter}
{inModal}
{modalUrl}
{isWritable}
on:refresh={refresh}
/>
{/if}
{#if schema.type === "collection"}
<Table
{records}
{graph}
{schema}
{sort}
{systemFields}
{inModal}
{users}
bind:selected
{records}
{graph}
{schema}
{sort}
{systemFields}
{inModal}
{users}
{isWritable}
bind:selected
/>
{:else}
<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)}
class="file-wrapper rounded p-2 mb-4 bg-light"
class:selected={selected.includes(record)}
>
<div class="form-check">
<input
on:change={(e) => selectRecord(e, record)}
class="form-check-input "
type="checkbox"
checked={selected.find(
{#if isWritable}
<div class="form-check">
<input
on:change={(e) => selectRecord(e, record)}
class="form-check-input "
type="checkbox"
checked={selected.find(
(r) => r.id === record.id
)}
value={record}
/>
</div>
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="
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"
class="lx-small-text text-muted d-block text-center"
>{record._file.mime}</span
>
</div>
@@ -134,12 +139,12 @@
</div>
<Pagination
{limit}
{skip}
{total}
on:refresh={refresh}
{inModal}
{modalUrl}
{limit}
{skip}
{total}
on:refresh={refresh}
{inModal}
{modalUrl}
/>
</div>
+23 -18
View File
@@ -14,6 +14,7 @@
export let systemFields;
export let sort;
export let inModal;
export let isWritable;
export let selected = [];
function toggleAll(e) {
@@ -44,16 +45,18 @@
<table class="">
<thead class="table-light">
<tr>
<th>
<input
on:change|preventDefault={toggleAll}
indeterminate={selected.length > 0 &&
{#if isWritable}
<th>
<input
on:change|preventDefault={toggleAll}
indeterminate={selected.length > 0 &&
selected.length < records.length}
checked={selected.length == records.length}
class="form-check-input"
type="checkbox"
/>
</th>
checked={selected.length == records.length}
class="form-check-input"
type="checkbox"
/>
</th>
{/if}
{#each visibleColumns as field}
<th
@@ -79,18 +82,20 @@
class="title-td-contents d-inline-flex justify-content-between w-100 align-items-center"
>
<div class="d-flex align-items-center ">
<div class="form-check">
<input
on:change={(e) =>
{#if isWritable}
<div class="form-check">
<input
on:change={(e) =>
selectRecord(e, record)}
class="form-check-input "
type="checkbox"
checked={selected.find(
class="form-check-input "
type="checkbox"
checked={selected.find(
(r) => r.id === record.id
)}
value={record}
/>
</div>
value={record}
/>
</div>
{/if}
<a
+12 -9
View File
@@ -15,6 +15,7 @@
export let filter;
export let inModal;
export let modalUrl;
export let isWritable;
export let records;
export let systemFields = [];
// export let visibleFields = [];
@@ -83,7 +84,7 @@
<div class="d-flex align-items-center ">
{#if schema.type === "collection"}
{#if !inModal}
{#if !inModal && isWritable}
<a
href="{channel.lucentUrl}/records/new?schema={schema.name}"
class="btn btn-sm btn-primary"
@@ -109,14 +110,16 @@
<ul class="dropdown-menu">
{#if filter["status_in"] === "trashed"}
<li>
<a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}/emptyTrash"
>
Empty trash
</a>
</li>
{#if isWritable}
<li>
<a
class="dropdown-item"
href="{channel.lucentUrl}/content/{schema.name}/emptyTrash"
>
Empty trash
</a>
</li>
{/if}
{:else}
<li>