mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 16:56:07 +00:00
Allow to disable nav header and specials (#2707)
Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
parent
5320b6378c
commit
126098d2ba
@ -184,6 +184,18 @@
|
|||||||
height: auto;
|
height: auto;
|
||||||
margin-bottom: .5rem;
|
margin-bottom: .5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
|
||||||
|
.an-element__icon {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.an-element__label {
|
||||||
|
color: rgb(var(--caption-color) / 40%);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.antiNav-divider {
|
.antiNav-divider {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
export let app: string | undefined = undefined
|
export let app: string | undefined = undefined
|
||||||
export let space: string | undefined = undefined
|
export let space: string | undefined = undefined
|
||||||
export let special: string | undefined = undefined
|
export let special: string | undefined = undefined
|
||||||
|
export let disabled = false
|
||||||
|
|
||||||
let loc = createLocation(getCurrentLocation(), app, space, special)
|
let loc = createLocation(getCurrentLocation(), app, space, special)
|
||||||
|
|
||||||
@ -62,6 +63,10 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#if disabled}
|
||||||
|
<slot />
|
||||||
|
{:else}
|
||||||
<a {href} on:click={clickHandler}>
|
<a {href} on:click={clickHandler}>
|
||||||
<slot />
|
<slot />
|
||||||
</a>
|
</a>
|
||||||
|
{/if}
|
||||||
|
@ -130,6 +130,10 @@
|
|||||||
|
|
||||||
return [result, requestIndex]
|
return [result, requestIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkIsDisabled (special: SpecialNavModel) {
|
||||||
|
return special.checkIsDisabled && (await (await getResource(special.checkIsDisabled))())
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if model}
|
{#if model}
|
||||||
@ -139,14 +143,17 @@
|
|||||||
{#if row > 0 && specials[row].position !== specials[row - 1].position}
|
{#if row > 0 && specials[row].position !== specials[row - 1].position}
|
||||||
<TreeSeparator />
|
<TreeSeparator />
|
||||||
{/if}
|
{/if}
|
||||||
<NavLink space={special.id}>
|
{#await checkIsDisabled(special) then disabled}
|
||||||
|
<NavLink space={special.id} {disabled}>
|
||||||
<SpecialElement
|
<SpecialElement
|
||||||
label={special.label}
|
label={special.label}
|
||||||
icon={special.icon}
|
icon={special.icon}
|
||||||
selected={special.id === currentSpecial}
|
selected={special.id === currentSpecial}
|
||||||
indent={'ml-2'}
|
indent={'ml-2'}
|
||||||
|
{disabled}
|
||||||
/>
|
/>
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
{/await}
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -392,6 +392,15 @@
|
|||||||
currentApplication?.checkIsHeaderHidden && (await (await getResource(currentApplication.checkIsHeaderHidden))())
|
currentApplication?.checkIsHeaderHidden && (await (await getResource(currentApplication.checkIsHeaderHidden))())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkIsHeaderDisabled () {
|
||||||
|
return (
|
||||||
|
currentApplication?.checkIsHeaderDisabled &&
|
||||||
|
(await (
|
||||||
|
await getResource(currentApplication.checkIsHeaderDisabled)
|
||||||
|
)())
|
||||||
|
)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if employee?.active === true}
|
{#if employee?.active === true}
|
||||||
@ -495,7 +504,9 @@
|
|||||||
{#if currentApplication.navHeaderComponent}
|
{#if currentApplication.navHeaderComponent}
|
||||||
{#await checkIsHeaderHidden() then isHidden}
|
{#await checkIsHeaderHidden() then isHidden}
|
||||||
{#if !isHidden}
|
{#if !isHidden}
|
||||||
<Component is={currentApplication.navHeaderComponent} props={{ currentSpace }} shrink />
|
{#await checkIsHeaderDisabled() then disabled}
|
||||||
|
<Component is={currentApplication.navHeaderComponent} props={{ currentSpace, disabled }} shrink />
|
||||||
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
export let notifications = 0
|
export let notifications = 0
|
||||||
export let actions: Action[] = []
|
export let actions: Action[] = []
|
||||||
export let selected: boolean = false
|
export let selected: boolean = false
|
||||||
|
export let disabled: boolean = false
|
||||||
export let indent: 'default' | 'ml-2' | 'ml-4' | 'ml-8' = 'default'
|
export let indent: 'default' | 'ml-2' | 'ml-4' | 'ml-8' = 'default'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -30,6 +31,7 @@
|
|||||||
<div
|
<div
|
||||||
class="antiNav-element"
|
class="antiNav-element"
|
||||||
class:selected
|
class:selected
|
||||||
|
class:disabled
|
||||||
class:ml-2={indent === 'ml-2'}
|
class:ml-2={indent === 'ml-2'}
|
||||||
class:ml-4={indent === 'ml-4'}
|
class:ml-4={indent === 'ml-4'}
|
||||||
class:ml-8={indent === 'ml-8'}
|
class:ml-8={indent === 'ml-8'}
|
||||||
|
@ -36,6 +36,7 @@ export interface Application extends Doc {
|
|||||||
|
|
||||||
navHeaderComponent?: AnyComponent
|
navHeaderComponent?: AnyComponent
|
||||||
checkIsHeaderHidden?: Resource<() => Promise<boolean>>
|
checkIsHeaderHidden?: Resource<() => Promise<boolean>>
|
||||||
|
checkIsHeaderDisabled?: Resource<() => Promise<boolean>>
|
||||||
navFooterComponent?: AnyComponent
|
navFooterComponent?: AnyComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ export interface SpecialNavModel {
|
|||||||
visibleIf?: Resource<(spaces: Space[]) => Promise<boolean>>
|
visibleIf?: Resource<(spaces: Space[]) => Promise<boolean>>
|
||||||
// If defined, will be used to find spaces for visibleIf
|
// If defined, will be used to find spaces for visibleIf
|
||||||
spaceClass?: Ref<Class<Space>>
|
spaceClass?: Ref<Class<Space>>
|
||||||
|
checkIsDisabled?: Resource<() => Promise<boolean>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user