rework tagManagement modal render

This commit is contained in:
Christoph Kluge 2024-09-11 11:28:11 +02:00
parent 64cc19b252
commit f0de422c6e
2 changed files with 131 additions and 82 deletions

View File

@ -326,13 +326,13 @@
<Card class="mb-3"> <Card class="mb-3">
<CardBody> <CardBody>
<Row class="mb-2"> <Row class="mb-2">
<Col xs="auto">
{#if $initq.data} {#if $initq.data}
<Col xs="auto">
<Button outline on:click={() => (isMetricsSelectionOpen = true)} color="primary"> <Button outline on:click={() => (isMetricsSelectionOpen = true)} color="primary">
Select Metrics Select Metrics
</Button> </Button>
{/if}
</Col> </Col>
{/if}
</Row> </Row>
<hr/> <hr/>
<Row> <Row>

View File

@ -186,81 +186,130 @@
{/if} {/if}
</ModalHeader> </ModalHeader>
<ModalBody> <ModalBody>
<InputGroup class="mb-3">
<Input <Input
style="width: 100%;"
type="text" type="text"
placeholder="Search Tags" placeholder="Search Tags"
bind:value={filterTerm} bind:value={filterTerm}
/> />
<InputGroupText id={`tag-management-info-modal`} style="cursor:help; font-size:larger;align-content:center;">
<Alert color="info"> <Icon name=info-circle/>
Search using "<code>type: name</code>". If no tag matches your search, a </InputGroupText>
<Tooltip
target={`tag-management-info-modal`}
placement="right">
Search using "type: name". If no tag matches your search, a
button for creating a new one will appear. button for creating a new one will appear.
</Alert> </Tooltip>
<br /> </InputGroup>
<ul class="list-group">
{#each allTagsFiltered as tag} <div class="mb-3 scroll-group">
<ListGroupItem> {#if usedTagsFiltered.length > 0}
<Tag {tag} /> <ListGroup class="mb-3">
{#each usedTagsFiltered as utag}
<ListGroupItem color="primary">
<Tag tag={utag} />
<span style="float: right;"> <span style="float: right;">
{#if pendingChange === tag.id} {#if pendingChange === utag.id}
<Spinner size="sm" secondary />
{:else}
<Button
size="sm"
color="danger"
on:click={() => removeTagFromJob(utag)}
>
<Icon name="x" />
</Button>
{/if}
</span>
</ListGroupItem>
{/each}
</ListGroup>
{:else if filterTerm !== ""}
<ListGroup class="mb-3">
<ListGroupItem disabled>
<i>No attached tags matching.</i>
</ListGroupItem>
</ListGroup>
{:else}
<ListGroup class="mb-3">
<ListGroupItem disabled>
<i>Job has no attached tags.</i>
</ListGroupItem>
</ListGroup>
{/if}
{#if unusedTagsFiltered.length > 0}
<ListGroup class="">
{#each unusedTagsFiltered as uutag}
<ListGroupItem color="dark">
<Tag tag={uutag} />
<span style="float: right;">
{#if pendingChange === uutag.id}
<Spinner size="sm" secondary /> <Spinner size="sm" secondary />
{:else if job.tags.find((t) => t.id == tag.id)}
<Button
size="sm"
outline
color="danger"
on:click={() => removeTagFromJob(tag)}
>
<Icon name="x" />
</Button>
{:else} {:else}
<Button <Button
size="sm" size="sm"
outline
color="success" color="success"
on:click={() => addTagToJob(tag)} on:click={() => addTagToJob(uutag)}
> >
<Icon name="plus" /> <Icon name="plus" />
</Button> </Button>
{/if} {/if}
</span> </span>
</ListGroupItem> </ListGroupItem>
{:else}
<ListGroupItem disabled>
<i>No tags matching</i>
</ListGroupItem>
{/each} {/each}
</ul> </ListGroup>
<br /> {:else if filterTerm !== ""}
<ListGroup class="">
<ListGroupItem disabled>
<i>No unused tags matching.</i>
</ListGroupItem>
</ListGroup>
{:else}
<ListGroup class="">
<ListGroupItem disabled>
<i>No unused tags available.</i>
</ListGroupItem>
</ListGroup>
{/if}
</div>
{#if newTagType && newTagName && isNewTag(newTagType, newTagName)} {#if newTagType && newTagName && isNewTag(newTagType, newTagName)}
<div class="d-flex"> <Row>
<Col xs={isAdmin ? 7 : 12} md={12} lg={isAdmin ? 7 : 12} xl={12} xxl={isAdmin ? 7 : 12} class="mb-2">
<Button <Button
style="margin-right: 10px;"
outline outline
style="width:100%;"
color="success" color="success"
on:click={(e) => ( on:click={(e) => (
e.preventDefault(), createTag(newTagType, newTagName, newTagScope) e.preventDefault(), createTag(newTagType, newTagName, newTagScope)
)} )}
> >
Create & Add Tag: Add new tag:
<Tag tag={{ type: newTagType, name: newTagName, scope: newTagScope }} clickable={false}/> <Tag tag={{ type: newTagType, name: newTagName, scope: newTagScope }} clickable={false}/>
</Button> </Button>
{#if roles && authlevel >= roles.admin} </Col>
<select {#if isAdmin}
style="max-width: 175px;" <Col xs={5} md={12} lg={5} xl={12} xxl={5} class="mb-2" style="align-content:center;">
class="form-select" <Input type="select" bind:value={newTagScope}>
bind:value={newTagScope}
>
<option value={username}>Scope: Private</option> <option value={username}>Scope: Private</option>
<option value={"global"}>Scope: Global</option> <option value={"global"}>Scope: Global</option>
<option value={"admin"}>Scope: Admin</option> <option value={"admin"}>Scope: Admin</option>
</select> </Input>
</Col>
{/if} {/if}
</div> </Row>
{:else if allTagsFiltered.length == 0} {:else if filterTerm !== "" && allTagsFiltered.length == 0}
<Alert>Search Term is not a valid Tag (<code>type: name</code>)</Alert> <Alert color="info">
Search Term is not a valid Tag (<code>type: name</code>)
</Alert>
{:else if filterTerm == "" && unusedTagsFiltered.length == 0}
<Alert color="info">
Type "<code>type: name</code>" into the search field to create a new tag.
</Alert>
{/if} {/if}
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
@ -271,6 +320,7 @@
<Button outline on:click={() => (isOpen = true)}> <Button outline on:click={() => (isOpen = true)}>
Manage Tags <Icon name="tags" /> Manage Tags <Icon name="tags" />
</Button> </Button>
{:else} {:else}
<InputGroup class="mb-3"> <InputGroup class="mb-3">
@ -399,9 +449,8 @@
{/if} {/if}
<style> <style>
ul.list-group { .scroll-group {
max-height: 450px; max-height: 500px;
margin-bottom: 10px; overflow-y: auto;
overflow: scroll;
} }
</style> </style>