Skip to content

Commit

Permalink
add tags icon on the dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
PlushZ committed Dec 3, 2024
1 parent 5bb0918 commit faa5bfd
Showing 1 changed file with 38 additions and 54 deletions.
92 changes: 38 additions & 54 deletions client/src/components/Tool/ToolForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
@onClick="onExecute(config, currentHistoryId)" />
</template>
<template v-slot:buttons>
<div class="tagging-section">
<div class="tagging-section" ref="tagContainer">

Check failure on line 100 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Attribute "ref" should go before "class"
<div class="run-tool-container">
<ButtonSpinner
title="Run Tool"
Expand All @@ -106,20 +106,21 @@
:wait="showExecuting"
:tooltip="tooltip"
@onClick="onExecute(config, currentHistoryId)" />
<button
type="button"
class="mt-3 mb-3 run-tool-btn"
@click="toggleDropdown"
:title="'Add tags for output datasets'">
{{ isDropdownVisible ? "▲" : "▼" }}
</button>
<BButton
type="button"
class="btn btn-secondary"
v-b-tooltip.hover.bottom

Check failure on line 112 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Attribute "v-b-tooltip.hover.bottom" should go before "class"
title="Add tags for output datasets"
@click="toggleTagsContainer">
<FontAwesomeIcon icon="fa-tags" />
</BButton>
</div>
<div
v-if="isDropdownVisible"
class="tags-container">
<div class="existing-tags">
<div class="tag-list">
<tag
<Tag
v-for="(tag, index) in tags"
:key="index"
:option="tag"
Expand All @@ -130,10 +131,10 @@
</div>
<div class="add-tag-section">
<input
class="tag-input"
v-model="newTag"

Check failure on line 135 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Attribute "v-model" should go before "class"
@keyup.enter="addTag"
placeholder="Add tag and press Enter"
class="tag-input"
@keyup.enter="addTag"
/>
</div>
</div>
Expand Down Expand Up @@ -168,6 +169,13 @@ import { allowCachedJobs } from "./utilities";
import FormSelect from "@/components/Form/Elements/FormSelect.vue";
import Tag from "@/components/TagsMultiselect/Tag.vue";
import { library } from "@fortawesome/fontawesome-svg-core";
import { faTags } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { ref, onMounted, onBeforeUnmount } from "vue";

Check failure on line 175 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

'ref' is defined but never used. Allowed unused vars must match /_.+/u

Check failure on line 175 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

'onMounted' is defined but never used. Allowed unused vars must match /_.+/u

Check failure on line 175 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

'onBeforeUnmount' is defined but never used. Allowed unused vars must match /_.+/u
import { BButton } from "bootstrap-vue";
library.add(faTags);
export default {
components: {
Expand All @@ -181,6 +189,8 @@ export default {
ToolRecommendation,
Heading,
Tag,
FontAwesomeIcon,
BButton,
},
props: {
id: {
Expand Down Expand Up @@ -304,9 +314,6 @@ export default {
},
methods: {
...mapActions(useJobStore, ["saveLatestResponse"]),
toggleDropdown() {
this.isDropdownVisible = !this.isDropdownVisible;
},
emailAllowed(config, user) {
return config.server_mail_configured && !user.isAnonymous;
},
Expand Down Expand Up @@ -459,6 +466,9 @@ export default {
}
);
},
toggleTagsContainer() {
this.isDropdownVisible = !this.isDropdownVisible;
},
addTag() {
if (this.newTag.trim() && !this.tags.includes(this.newTag.trim())) {
this.tags.push(this.newTag.trim());
Expand All @@ -468,6 +478,18 @@ export default {
removeTag(index) {
this.tags.splice(index, 1);
},
handleClickOutside(event) {
const tagContainer = this.$refs.tagContainer;
if (tagContainer && !tagContainer.contains(event.target)) {
this.isDropdownVisible = false;
}
},
},
mounted() {

Check failure on line 488 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

The "mounted" property should be above the "methods" property on line 315
document.addEventListener("click", this.handleClickOutside);
},
beforeUnmount() {

Check failure on line 491 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

The "beforeUnmount" property should be above the "methods" property on line 315
document.removeEventListener("click", this.handleClickOutside);
},
};
</script>
Expand All @@ -484,65 +506,27 @@ export default {
align-items: center;
position: relative;
}
/*
.arrow-toggle-btn {
background: inherit;
color: inherit;
border: none;
cursor: pointer;
font-size: 1rem;
height: 100%;
padding: 0 0.5rem;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border-radius: 4px;
}
.arrow-toggle-btn:hover {
background: #ddd;
}
.arrow-toggle-btn[title]:hover::after {
content: attr(title);
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background: #333;
color: #fff;
padding: 0.25rem 0.5rem;
border-radius: 4px;
font-size: 0.8rem;
white-space: nowrap;
z-index: 20;
}
*/
.tags-container {
position: absolute;
top: 100%;
left: 0;
margin-top: 0;
margin-top: -15px;
padding: 0.5rem;
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
min-width: max-content;
max-width: 200px;
word-wrap: break-word;
max-width: max-content;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
z-index: 10;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.tag-input {
Expand Down

0 comments on commit faa5bfd

Please sign in to comment.