-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chg: refactor tag component, show taxonomy predicates and entries in …
…taxonomy view
- Loading branch information
Showing
13 changed files
with
289 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup> | ||
import { tagHelper } from "@/helpers"; | ||
const props = defineProps({ | ||
value: { | ||
type: String, | ||
required: true | ||
}, | ||
colour: { | ||
type: String, | ||
default: '#000000' | ||
}, | ||
namespace: { | ||
type: String, | ||
default: '' | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<span class="badge mx-1 tag" :style="{ backgroundColor: tagHelper.getBackgroundColor(props.colour), color: tagHelper.getContrastColor(props.colour) }" :title="props.value"> | ||
{{ tagHelper.getTag(props.namespace, props.value) }} | ||
</span> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<script setup> | ||
import Badge from "@/components/misc/Badge.vue"; | ||
const props = defineProps(['taxonomy', 'status']); | ||
function handleTaxonomyDeleted(event) { | ||
router.go(-1); | ||
} | ||
</script> | ||
|
||
<style> | ||
.single-stat-card .card-body { | ||
font-size: x-large; | ||
text-align: center; | ||
padding: 0; | ||
} | ||
div.row h3 { | ||
margin-bottom: 0; | ||
} | ||
.single-stat-card .card-body p { | ||
margin-bottom: 0; | ||
} | ||
</style> | ||
<template> | ||
<div class="card"> | ||
<div class="taxonomy-title card-header border-bottom"> | ||
<div class="row"> | ||
<div class="col-10"> | ||
<h3>Taxonomy #{{ taxonomy.id }}</h3> | ||
</div> | ||
<div class="col-2 text-end"> | ||
<div class="flex-wrap" :class="{ 'btn-group-vertical': $isMobile, 'btn-group': !$isMobile }" | ||
aria-label="Taxonomy Actions"> | ||
<button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" | ||
:data-bs-target="'#deleteTaxonomyModal-' + taxonomy.id"> | ||
<font-awesome-icon icon="fa-solid fa-trash" /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row m-1"> | ||
<div class="mt-2"> | ||
<div class="card"> | ||
<div class="card-body d-flex flex-column"> | ||
<div class="table-responsive-sm"> | ||
<table class="table table-striped"> | ||
<tbody> | ||
<tr> | ||
<th>id</th> | ||
<td>{{ taxonomy.id }}</td> | ||
</tr> | ||
<tr> | ||
<th>description</th> | ||
<td>{{ taxonomy.description }}</td> | ||
</tr> | ||
<tr> | ||
<th>version</th> | ||
<td>{{ taxonomy.version }}</td> | ||
</tr> | ||
<tr> | ||
<th>enabled</th> | ||
<td>{{ taxonomy.enabled }}</td> | ||
</tr> | ||
<tr> | ||
<th>exclusive</th> | ||
<td>{{ taxonomy.exclusive }}</td> | ||
</tr> | ||
<tr> | ||
<th>required</th> | ||
<td>{{ taxonomy.required }}</td> | ||
</tr> | ||
<tr> | ||
<th>highlighted</th> | ||
<td>{{ taxonomy.highlighted }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="mt-2"> | ||
<div class="card"> | ||
<div class="card-body d-flex flex-column"> | ||
<div class="table-responsive-sm"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">id</th> | ||
<th scope="col">tag</th> | ||
<th scope="col">expanded</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<template v-for="predicate in taxonomy.predicates" :key="predicate.id"> | ||
<tr v-if="predicate.entries.length" v-for="entry in predicate.entries" :key="entry.id"> | ||
<td>{{ entry.id }}</td> | ||
<td> | ||
<Badge :value="entry.value" :namespace="taxonomy.namespace" :colour="entry.colour" /> | ||
</td> | ||
<td>{{ entry.expanded }}</td> | ||
</tr> | ||
<tr v-if="!predicate.entries.length" > | ||
<td>{{ predicate.id }}</td> | ||
<td> | ||
<Badge :value="predicate.value" :namespace="taxonomy.namespace" :colour="predicate.colour" /> | ||
</td> | ||
<td>{{ predicate.expanded }}</td> | ||
</tr> | ||
</template> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<DeleteTaxonomyModal @taxonomy-deleted="handleTaxonomyDeleted" :taxonomy_id="taxonomy.id" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./fetch-wrapper"; | ||
export * from "./error-handler"; | ||
export * from "./tags"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export const tagHelper = { | ||
getContrastColor, | ||
getBackgroundColor, | ||
getTag | ||
}; | ||
|
||
function getTag(namspace, tag) { | ||
if (!namspace || !tag) return ""; | ||
return `${namspace}:${tag}`; | ||
} | ||
|
||
function getBackgroundColor(hex) { | ||
if (!hex) return "#DDD"; | ||
return hex; | ||
}; | ||
|
||
|
||
function getContrastColor(hex) { | ||
|
||
if (!hex) return "#000000"; | ||
|
||
hex = hex.replace("#", ""); | ||
|
||
// Convert the hex color to RGB | ||
const r = parseInt(hex.substring(0, 2), 16); | ||
const g = parseInt(hex.substring(2, 4), 16); | ||
const b = parseInt(hex.substring(4, 6), 16); | ||
|
||
// Calculate the luminance | ||
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255; | ||
|
||
// If luminance is high, use black text; otherwise, use white text | ||
return luminance > 0.5 ? "#000000" : "#FFFFFF"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.