Initial commit of filter UX behaviour

This commit is contained in:
Dean 2023-04-27 12:46:40 +01:00
parent 0769e332a6
commit 4093516a0d
1 changed files with 35 additions and 9 deletions

View File

@ -28,6 +28,10 @@
let inviting = false let inviting = false
let searchFocus = false let searchFocus = false
//Or searching = true?
let filtered = true
$: console.log("filtering enabled ", filtered)
let appInvites = [] let appInvites = []
let filteredInvites = [] let filteredInvites = []
let filteredUsers = [] let filteredUsers = []
@ -52,15 +56,31 @@
} }
const filterInvites = async query => { const filterInvites = async query => {
appInvites = await getInvites() if (!prodAppId) {
if (!query || query == "") {
filteredInvites = appInvites
return return
} }
filteredInvites = appInvites.filter(invite => invite.email.includes(query))
appInvites = await getInvites()
//On Focus behaviour
if (!filtered && (!query || query == "")) {
filteredInvites = [...appInvites]
return
}
filteredInvites = appInvites.filter(invite => {
const inviteInfo = invite.info?.apps
if ((!query || query == "") && inviteInfo && prodAppId) {
return Object.keys(inviteInfo).includes(prodAppId)
}
return invite.email.includes(query)
})
} }
$: filterInvites(query) $: filtered, prodAppId, filterInvites(query)
$: if (searchFocus === true) {
filtered = false
}
const usersFetch = fetchData({ const usersFetch = fetchData({
API, API,
@ -351,7 +371,7 @@
onMount(() => { onMount(() => {
rendered = true rendered = true
searchFocus = true // searchFocus = true
}) })
function handleKeyDown(evt) { function handleKeyDown(evt) {
@ -417,7 +437,6 @@
autocomplete="off" autocomplete="off"
disabled={inviting} disabled={inviting}
value={query} value={query}
autofocus
on:input={e => { on:input={e => {
query = e.target.value.trim() query = e.target.value.trim()
}} }}
@ -428,16 +447,20 @@
<span <span
class="search-input-icon" class="search-input-icon"
class:searching={query} class:searching={query || !filtered}
on:click={() => { on:click={() => {
if (!filtered) {
filtered = true
}
if (!query) { if (!query) {
return return
} }
query = null query = null
userOnboardResponse = null userOnboardResponse = null
filtered = true
}} }}
> >
<Icon name={query ? "Close" : "Search"} /> <Icon name={!filtered || query ? "Close" : "Search"} />
</span> </span>
</div> </div>
@ -481,6 +504,8 @@
</div> </div>
</div> </div>
<div class="auth-entity-access"> <div class="auth-entity-access">
<!-- {#key filteredInvites} -->
<!-- {invite.info.apps?.[prodAppId]} -->
<RoleSelect <RoleSelect
placeholder={false} placeholder={false}
value={invite.info.apps?.[prodAppId]} value={invite.info.apps?.[prodAppId]}
@ -496,6 +521,7 @@
autoWidth autoWidth
align="right" align="right"
/> />
<!-- {/key} -->
</div> </div>
</div> </div>
{/each} {/each}