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
+2
View File
@@ -23,9 +23,11 @@
export let data;
// export let layout;
export let channel;
export let readableSchemas;
setContext("channel", channel);
setContext("readableSchemas", channel.schemas.filter((s) => readableSchemas.includes(s.name)));
setContext("user", user);
</script>
+4 -3
View File
@@ -5,11 +5,12 @@
export let schema;
const channel = getContext("channel");
const readableSchemas = getContext("readableSchemas");
const user = getContext("user");
let contentIsOpen = false;
const fileSchemas = channel.schemas.filter((sc) => sc.type === "files");
const otherSchemas = channel.schemas.filter((sc) => !sc.isEntry && sc.type === "collection");
const fileSchemas = readableSchemas.filter((sc) => sc.type === "files");
const otherSchemas = readableSchemas.filter((sc) => !sc.isEntry && sc.type === "collection");
</script>
@@ -57,7 +58,7 @@
aria-labelledby="panelsStayOpen-headingMain">
<div class="accordion-body">
<NavbarMenu
schemas={ channel.schemas.filter((sc) => sc.isEntry)}
schemas={ readableSchemas.filter((sc) => sc.isEntry)}
schema={schema}
/>
</div>
+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>
@@ -7,11 +7,26 @@
export let member;
export let roles;
function update(e, newRole) {
function removeFrom(e, aRole) {
e.preventDefault();
let newRoles = member.roles.filter((r) => r !== aRole);
dispatch("update", {
user: member.id,
role: newRole,
roles: newRoles,
});
}
function addTo(e, aRole) {
e.preventDefault();
let newRoles = [...member.roles, aRole];
console.log(member.roles)
console.log(aRole)
console.log(newRoles)
dispatch("update", {
user: member.id,
roles: newRoles,
});
}
@@ -19,11 +34,11 @@
</script>
<div
transition:fly={{ duration: 200 }}
class="d-flex justify-content-between align-items-center mb-3 "
transition:fly={{ duration: 200 }}
class="d-flex justify-content-between align-items-center mb-3 "
>
<div class="d-flex align-items-center status-{member.role}">
<Avatar name={member.name ?? "" } side="32"/>
<div class="d-flex align-items-center status-{member.roles.includes('removed') ? 'removed' : 'active'}">
<Avatar name={member.name ?? "" } side={32}/>
<div class="ms-3 ">
<div>
<span class="fs-5">
@@ -36,21 +51,37 @@
<div>
<div class="dropdown dropdown-center">
<button
class=" dropdown-toggle btn btn-light"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false"
class=" dropdown-toggle btn btn-light"
type="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
{member.role}
Roles
</button>
<div class="dropdown-menu">
<h6 class="dropdown-header">Remove role</h6>
{#each roles as role}
{#if member.role !== role}
{#if member.roles.includes(role)}
<button
class="dropdown-item"
on:click={(e) => update(e,role)}
class="dropdown-item text-capitalize"
on:click={(e) => removeFrom(e,role)}
>
Convert to {role}
{role}
</button>
{/if}
{/each}
<div>
<hr class="dropdown-divider">
</div>
<h6 class="dropdown-header">Add role</h6>
{#each roles as role}
{#if !member.roles.includes(role)}
<button
class="dropdown-item text-capitalize"
on:click={(e) => addTo(e,role)}
>
{role}
</button>
{/if}
{/each}
+4 -5
View File
@@ -9,7 +9,6 @@
const channel = getContext("channel");
export let users;
export let roles;
let name;
let email;
let role;
@@ -28,7 +27,7 @@
.post(channel.lucentUrl + "/members/invite", {
name: newName,
email: newEmail,
role: newRole,
roles: [newRole],
})
.then((response) => {
successAlert.show("User was invited");
@@ -49,7 +48,7 @@
axios
.post(channel.lucentUrl + "/members/update", {
id: e.detail.user,
role: e.detail.role,
roles: e.detail.roles,
})
.then((response) => {
successAlert.show("Users updated");
@@ -96,7 +95,7 @@
</div>
<div class="me-3">
{#each roles.filter((r) => r !== "removed") as arole}
{#each channel.roles.filter((r) => r !== "removed") as arole}
<Radio
bind:group={role}
value={arole}
@@ -117,7 +116,7 @@
{#each users as user}
<MemberSettingsCard
member={user}
roles={roles}
roles={channel.roles}
on:update={update}
on:reinvite={(e) => invite(e.detail.email, e.detail.role)}
/>
+2 -1
View File
@@ -21,6 +21,7 @@
};
export let recordHistory;
export let isCreateMode;
export let isWritable = false;
export let users;
let originalContent;
let activeContentTab = "";
@@ -155,7 +156,7 @@
<Manager managerRecords={recordHistory} {graph}/>
<EditHeader {schema} {record} {isCreateMode} {graph} bind:activeContentTab/>
{#if !["_graph", "_info"].includes(activeContentTab)}
{#if !["_graph", "_info"].includes(activeContentTab) && isWritable}
<div class="shadow-lg "
style="position:fixed;bottom:0;left:0px;width:100%;background: rgb(206, 223, 210);z-index:1050"
>
+2 -1
View File
@@ -1,9 +1,10 @@
<script>
export let title;
</script>
<div class="wrapper-normal ">
<div class="header-normal">
Record Not Found
{title}
</div>
</div>