Now with hide files from launcher working. event_file.hide

This commit is contained in:
Scott Idem
2024-07-25 18:20:17 -04:00
parent 4a70869896
commit 86c8aa6c83
6 changed files with 98 additions and 15 deletions

View File

@@ -16,6 +16,7 @@ import { ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_st
import { db_events } from "$lib/db_events";
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
import { events_func } from '$lib/ae_events_functions';
import { hide } from '@floating-ui/dom';
export let container_class_li: string|Array<string> = [];
export let link_to_type: string;
@@ -67,10 +68,16 @@ onMount(() => {
db_events.files.clear();
let params = {
qry__enabled: 'all',
qry__hidden: 'all',
}
events_func.handle_load_ae_obj_li__event_file({
api_cfg: $ae_api,
for_obj_type: link_to_type,
for_obj_id: link_to_id,
params: params,
try_cache: false
});
@@ -80,7 +87,7 @@ onMount(() => {
// ae_tmp.show__file_li = true;
}}
class="btn btn-sm p-1 m-1 variant-soft-tertiary hover:variant-ghost-warning transition hover:transition-all *:hover:inline"
class:hidden={display_mode != 'default' && !$ae_loc.administrator_access}
class:hidden={!$ae_loc.authenticated_access}
title="Refresh the list of files"
>
<span class="fas fa-sync-alt mx-1"></span>
@@ -96,6 +103,7 @@ onMount(() => {
ae_tmp.show__direct_download = !ae_tmp.show__direct_download;
}}
class="btn btn-sm p-1 m-1 variant-soft-tertiary hover:variant-ghost-warning transition hover:transition-all *:hover:inline"
class:hidden={!$ae_loc.trusted_access}
title="Toggle direct download link and copy link button"
>
<span class="fas fa-download mx-1"></span>
@@ -151,7 +159,10 @@ onMount(() => {
<tbody>
{#each $lq__event_file_obj_li as event_file_obj}
<tr class="ae_obj obj_event_file border-t border-b border-gray-200 hover:bg-gray-50 hover:border-gray-300">
<tr
class="ae_obj obj_event_file border-t border-b border-gray-200 hover:bg-gray-50 hover:border-gray-300"
class:dim={event_file_obj?.hide}
>
<td class="event_file__file align-middle">
{#if $events_sess.pres_mgmt?.show_field_edit__filename != event_file_obj.event_file_id_random}
<button
@@ -255,10 +266,10 @@ onMount(() => {
};
ae_promises.update__event_file_obj = events_func.handle_update_ae_obj__event_file({
api_cfg: $ae_api,
event_file_id: event_file_obj.event_file_id_random,
data_kv: event_file_data,
log_lvl: 1
api_cfg: $ae_api,
event_file_id: event_file_obj.event_file_id_random,
data_kv: event_file_data,
log_lvl: 0
})
.then (function (update_results) {
console.log(`Update results:`, update_results);
@@ -310,15 +321,62 @@ onMount(() => {
Rename
{/if}
</button>
<button
disabled={!allow_basic || !allow_moderator || !$ae_loc.administrator_access}
class:hidden={!$ae_loc.administrator_access}
disabled={!allow_basic && !$ae_loc.trusted_access}
on:click={async () => {
let event_file_data = {
hide: !event_file_obj.hide,
};
ae_promises.update__event_file_obj = events_func.handle_update_ae_obj__event_file({
api_cfg: $ae_api,
event_file_id: event_file_obj.event_file_id_random,
data_kv: event_file_data,
log_lvl: 1
})
.then (function (update_results) {
console.log(`Update results:`, update_results);
let params = {
qry__enabled: 'all',
qry__hidden: 'all',
}
events_func.handle_load_ae_obj_li__event_file({
api_cfg: $ae_api,
for_obj_type: link_to_type,
for_obj_id: link_to_id,
params: params,
try_cache: false
});
});
}}
class="btn btn-sm variant-glass-tertiary hover:variant-soft-success"
title="Hide this file from the presentation launcher"
>
<span class="fas fa-eye mx-1"></span>
Hide
<!-- Users see this as the "Archive" option button -->
<!-- {@html (event_file_obj?.hide ? '<span class="fas fa-archive m-1"></span> Unarchive' : '<span class="fas fa-archive m-1"></span> Archive')} -->
{#await ae_promises.update__event_file_obj}
<span class="fas fa-spinner fa-spin mx-1"></span>
<span class="">Saving {event_file_obj.extension}</span>
{:then}
{#if event_file_obj.hide}
<span class="fas fa-eye m-1"></span> Unhide File
{:else}
<span class="fas fa-eye-slash m-1"></span> Hide
{/if}
<!-- {@html (event_file_obj?.hide ? '<span class="fas fa-eye m-1"></span> Unhide?' : '<span class="fas fa-eye-slash m-1"></span> Hide?')} -->
<!-- <span class="fas fa-save mx-1"></span>
Save {event_file_obj.extension} filename? -->
{/await}
</button>
<button
disabled={!allow_basic && !$ae_loc.trusted_access}
on:click={async () => {
@@ -421,8 +479,8 @@ onMount(() => {
<td class="event_file_info file_meta text-gray-500">
<div
class="flex flex-col gap:1 text-sm"
class:text-xs={display_mode != 'default'}
class="flex flex-col gap-0.5 text-xs"
>
<!-- {event_file_obj.hosted_file_content_type} -->