Unverified Commit b7b48f9e authored by Alberto Nale's avatar Alberto Nale Committed by GitHub
Browse files

[KNOWAGE-7030][KNOWAGE-7075][KNOWAGE-7057][KNOWAGE-7001][KNOWAGE-7007]

Possible bugfix: KNOWAGE-7030

Bugfix:
KNOWAGE-7075
KNOWAGE-7057
KNOWAGE-7001
KNOWAGE-7007
parents d191830b 00299720
......@@ -1971,6 +1971,7 @@
},
"timespan": {
"cloneAlreadyDefined": "The next timespan is already defiend",
"hint": "No timespan selected",
"invalidDatesError": "The dates are not valid",
"noIntervalError": "Please define at least one interval",
"startDateGreaterError": "Start date greater than end date",
......
......@@ -11,7 +11,7 @@
<div v-if="metadata">
<div v-if="metadata.generalMetadata.length > 0">
<h2>{{ $t('documentExecution.main.customMetadata') }}</h2>
<h2>{{ $t('common.documentDetails') }}</h2>
<div class="p-grid p-ai-center">
<template v-for="(meta, index) in metadata.generalMetadata" :key="index">
<div v-if="meta.value && index !== metadata.generalMetadata.length - 1" :class="{ 'p-col-4': index !== 3, 'p-col-12': index === 3 }">
......@@ -24,7 +24,7 @@
</div>
<div v-if="metadata.shortText.length > 0 || metadata.longText.length > 0">
<h2>{{ $t('common.documentDetails') }}</h2>
<h2>{{ $t('documentExecution.main.customMetadata') }}</h2>
<div v-show="metadata.shortText.length > 0" class="p-grid">
<div v-for="(meta, index) in metadata.shortText" :key="index" class="p-col-4">
......@@ -64,7 +64,7 @@
<template #footer>
<div class="p-d-flex p-flex-row p-jc-end">
<Button class="kn-button kn-button--primary" @click="closeDialog"> {{ $t('common.close') }}</Button>
<Button class="kn-button kn-button--primary" @click="save"> {{ $t('common.save') }}</Button>
<Button class="kn-button kn-button--primary" :disabled="!canModify" @click="save"> {{ $t('common.save') }}</Button>
</div>
</template>
</Dialog>
......
......@@ -22,6 +22,7 @@
<InputText id="search-input" class="kn-material-input" v-model="searchWord" :placeholder="$t('common.search')" @input="filterGlossaryTree" data-test="search-input" />
</div>
<Tree
v-if="!loading"
id="glossary-tree"
:value="nodes"
selectionMode="multiple"
......@@ -53,7 +54,7 @@
</div>
</div>
<GlossaryUsageInfoDialog v-show="infoDialogVisible" :visible="infoDialogVisible" :contentInfo="contentInfo" :selectedWords="selectedWords" @close="infoDialogVisible = false"></GlossaryUsageInfoDialog>
<GlossaryUsageInfoDialog v-show="infoDialogVisible" :visible="infoDialogVisible" :contentInfo="contentInfo" :selectedWords="selectedWords" @close="infoDialogVisible = false" @loading="setLoading"></GlossaryUsageInfoDialog>
<div class="p-col-8 p-sm-8 p-md-9 p-p-0 p-m-0">
<GlossaryUsageHint v-if="!selectedGlossaryId" data-test="no-glossary-selected-hint"></GlossaryUsageHint>
......@@ -64,183 +65,186 @@
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { iGlossary, iNode } from './GlossaryUsage'
import { AxiosResponse } from 'axios'
import Dropdown from 'primevue/dropdown'
import glossaryUsageDescriptor from './GlossaryUsageDescriptor.json'
import GlossaryUsageInfoDialog from './GlossaryUsageInfoDialog.vue'
import GlossaryUsageHint from './GlossaryUsageHint.vue'
import GlossaryUsageDetail from './GlossaryUsageDetail.vue'
import Message from 'primevue/message'
import Tree from 'primevue/tree'
import { defineComponent } from 'vue'
import { iGlossary, iNode } from './GlossaryUsage'
import { AxiosResponse } from 'axios'
import Dropdown from 'primevue/dropdown'
import glossaryUsageDescriptor from './GlossaryUsageDescriptor.json'
import GlossaryUsageInfoDialog from './GlossaryUsageInfoDialog.vue'
import GlossaryUsageHint from './GlossaryUsageHint.vue'
import GlossaryUsageDetail from './GlossaryUsageDetail.vue'
import Message from 'primevue/message'
import Tree from 'primevue/tree'
export default defineComponent({
name: 'glossary-usage',
components: {
Dropdown,
GlossaryUsageInfoDialog,
GlossaryUsageHint,
GlossaryUsageDetail,
Message,
Tree
export default defineComponent({
name: 'glossary-usage',
components: {
Dropdown,
GlossaryUsageInfoDialog,
GlossaryUsageHint,
GlossaryUsageDetail,
Message,
Tree
},
data() {
return {
glossaryUsageDescriptor,
glossaryList: [] as iGlossary[],
selectedGlossaryId: null as number | null,
nodes: [] as iNode[],
buttonVisible: [],
infoDialogVisible: false,
contentInfo: null,
searchWord: null,
timer: null as any,
expandedKeys: {},
selectedKeys: [],
selectedWords: [] as any[],
loading: false
}
},
async created() {
await this.loadGlossary()
},
methods: {
async loadGlossary() {
this.loading = true
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + '1.0/glossary/listGlossary')
.then((response: AxiosResponse<any>) => (this.glossaryList = response.data))
.finally(() => (this.loading = false))
},
data() {
return {
glossaryUsageDescriptor,
glossaryList: [] as iGlossary[],
selectedGlossaryId: null as number | null,
nodes: [] as iNode[],
buttonVisible: [],
infoDialogVisible: false,
contentInfo: null,
searchWord: null,
timer: null as any,
expandedKeys: {},
selectedKeys: [],
selectedWords: [] as any[],
loading: false
async listContents(glossaryId: number, parent: any) {
this.loading = true
if (!parent) {
this.selectedWords = []
this.selectedKeys = []
}
},
async created() {
await this.loadGlossary()
},
methods: {
async loadGlossary() {
this.loading = true
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + '1.0/glossary/listGlossary')
.then((response: AxiosResponse<any>) => (this.glossaryList = response.data))
.finally(() => (this.loading = false))
},
async listContents(glossaryId: number, parent: any) {
this.loading = true
if (!parent) {
this.selectedWords = []
this.selectedKeys = []
}
if (parent?.WORD_ID || this.searchWord) {
this.loading = false
return
}
if (parent?.WORD_ID || this.searchWord) {
this.loading = false
return
}
const parentId = parent ? parent.id : null
let content = [] as iNode[]
await this.$http.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `1.0/glossary/listContents?GLOSSARY_ID=${glossaryId}&PARENT_ID=${parentId}`).then((response: AxiosResponse<any>) => {
response.data.forEach((el: any) => content.push(this.createNode(el)))
content.sort((a: iNode, b: iNode) => (a.label > b.label ? 1 : -1))
})
const parentId = parent ? parent.id : null
let content = [] as iNode[]
await this.$http.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `1.0/glossary/listContents?GLOSSARY_ID=${glossaryId}&PARENT_ID=${parentId}`).then((response: AxiosResponse<any>) => {
response.data.forEach((el: any) => content.push(this.createNode(el)))
content.sort((a: iNode, b: iNode) => (a.label > b.label ? 1 : -1))
this.attachContentToTree(parent, content)
this.loading = false
},
attachContentToTree(parent: iNode, content: iNode[]) {
if (parent) {
parent.children = []
parent.children = content
} else {
this.nodes = []
this.nodes = content
}
},
async showInfo(content: any) {
this.loading = true
const url = content.CONTENT_ID ? `1.0/glossary/getContent?CONTENT_ID=${content.CONTENT_ID}` : `1.0/glossary/getWord?WORD_ID=${content.WORD_ID}`
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + url)
.then((response: AxiosResponse<any>) => {
this.contentInfo = response.data
this.infoDialogVisible = true
})
this.attachContentToTree(parent, content)
this.loading = false
},
attachContentToTree(parent: iNode, content: iNode[]) {
if (parent) {
parent.children = []
parent.children = content
} else {
this.nodes = []
this.nodes = content
}
},
async showInfo(content: any) {
.finally(() => (this.loading = false))
},
async filterGlossaryTree() {
if (this.timer) {
clearTimeout(this.timer)
this.timer = null
}
let tempData = []
this.timer = setTimeout(() => {
this.loading = true
const url = content.CONTENT_ID ? `1.0/glossary/getContent?CONTENT_ID=${content.CONTENT_ID}` : `1.0/glossary/getWord?WORD_ID=${content.WORD_ID}`
await this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + url)
.then((response: AxiosResponse<any>) => {
this.contentInfo = response.data
this.infoDialogVisible = true
})
.finally(() => (this.loading = false))
},
async filterGlossaryTree() {
if (this.timer) {
clearTimeout(this.timer)
this.timer = null
}
let tempData = []
this.timer = setTimeout(() => {
this.loading = true
this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `1.0/glossary/glosstreeLike?WORD=${this.searchWord}&GLOSSARY_ID=${this.selectedGlossaryId}`)
.then((response: AxiosResponse<any>) => (tempData = response.data))
.finally(() => {
this.createGlossaryTree(tempData)
this.loading = false
})
}, 1000)
},
createGlossaryTree(data: any) {
this.nodes = []
this.expandedKeys = {}
data.GlossSearch.SBI_GL_CONTENTS.forEach((el: any) => {
const tempNode = this.createNode(el)
el.CHILD?.forEach((el: any) => {
tempNode.children.push(this.createNode(el))
this.$http
.get(process.env.VUE_APP_RESTFUL_SERVICES_PATH + `1.0/glossary/glosstreeLike?WORD=${this.searchWord}&GLOSSARY_ID=${this.selectedGlossaryId}`)
.then((response: AxiosResponse<any>) => (tempData = response.data))
.finally(() => {
this.createGlossaryTree(tempData)
this.loading = false
})
this.nodes.push(tempNode)
}, 1000)
},
createGlossaryTree(data: any) {
this.nodes = []
this.expandedKeys = {}
data.GlossSearch.SBI_GL_CONTENTS.forEach((el: any) => {
const tempNode = this.createNode(el)
el.CHILD?.forEach((el: any) => {
tempNode.children.push(this.createNode(el))
})
this.expandAll()
},
createNode(el: any) {
return {
key: el.CONTENT_ID ?? el.WORD_ID,
id: el.CONTENT_ID ?? el.WORD_ID,
label: el.CONTENT_NM ?? el.WORD,
children: [] as iNode[],
data: el,
style: this.glossaryUsageDescriptor.node.style,
leaf: !(el.HAVE_WORD_CHILD || el.HAVE_CONTENTS_CHILD),
selectable: !(el.HAVE_WORD_CHILD || el.HAVE_CONTENTS_CHILD)
}
},
expandAll() {
for (let node of this.nodes) {
this.expandNode(node)
}
this.expandedKeys = { ...this.expandedKeys }
},
expandNode(node: iNode) {
if (node.children && node.children.length) {
this.expandedKeys[node.key] = true
for (let child of node.children) {
this.expandNode(child)
}
this.nodes.push(tempNode)
})
this.expandAll()
},
createNode(el: any) {
return {
key: el.CONTENT_ID ?? el.WORD_ID,
id: el.CONTENT_ID ?? el.WORD_ID,
label: el.CONTENT_NM ?? el.WORD,
children: [] as iNode[],
data: el,
style: this.glossaryUsageDescriptor.node.style,
leaf: !(el.HAVE_WORD_CHILD || el.HAVE_CONTENTS_CHILD),
selectable: !(el.HAVE_WORD_CHILD || el.HAVE_CONTENTS_CHILD)
}
},
expandAll() {
for (let node of this.nodes) {
this.expandNode(node)
}
this.expandedKeys = { ...this.expandedKeys }
},
expandNode(node: iNode) {
if (node.children && node.children.length) {
this.expandedKeys[node.key] = true
for (let child of node.children) {
this.expandNode(child)
}
},
showNavigationItemInfo(info: any) {
this.contentInfo = info
this.infoDialogVisible = true
},
onNodeSelect(node: iNode) {
this.selectedWords.push(node.data)
},
onNodeUnselect(node: iNode) {
const index = this.selectedWords.findIndex((el: any) => el.id === node.data.WORD_ID)
this.selectedWords.splice(index, 1)
},
onDragStart(event: any, node: iNode) {
event.dataTransfer.setData('text/plain', JSON.stringify(node.data))
event.dataTransfer.dropEffect = 'move'
event.dataTransfer.effectAllowed = 'move'
},
setFilteredWords(words: any) {
this.nodes = []
words.forEach((el: any) => this.nodes.push(this.createNode(el)))
}
},
showNavigationItemInfo(info: any) {
this.contentInfo = info
this.infoDialogVisible = true
},
onNodeSelect(node: iNode) {
this.selectedWords.push(node.data)
},
onNodeUnselect(node: iNode) {
const index = this.selectedWords.findIndex((el: any) => el.id === node.data.WORD_ID)
this.selectedWords.splice(index, 1)
},
onDragStart(event: any, node: iNode) {
event.dataTransfer.setData('text/plain', JSON.stringify(node.data))
event.dataTransfer.dropEffect = 'move'
event.dataTransfer.effectAllowed = 'move'
},
setFilteredWords(words: any) {
this.nodes = []
words.forEach((el: any) => this.nodes.push(this.createNode(el)))
},
setLoading(value: boolean) {
this.loading = value
}
})
}
})
</script>
<style lang="scss" scoped>
#search-input {
width: 100%;
}
#search-input {
width: 100%;
}
#glossary-tree {
border: none;
}
#glossary-tree {
border: none;
}
</style>
......@@ -31,7 +31,7 @@ export default defineComponent({
name: 'glossary-usage-detail',
components: { GlossaryUsageNavigationCard, GlossaryUsageLinkCard },
props: { glossaryId: { type: Number }, selectedWords: { type: Array } },
emits: ['infoClicked', 'linkClicked', 'wordsFiltered'],
emits: ['infoClicked', 'linkClicked', 'wordsFiltered', 'loading'],
data() {
return {
glossaryUsageDescriptor,
......@@ -72,6 +72,7 @@ export default defineComponent({
methods: {
async loadNavigationItems(type: string, item: string) {
this.loading = true
this.$emit('loading', true)
const postData = {
type: type,
item: item,
......@@ -101,7 +102,10 @@ export default defineComponent({
msg: response
})
})
.finally(() => (this.loading = false))
.finally(() => {
this.loading = false
this.$emit('loading', false)
})
},
formatNavigationItems(data: any) {
if ('document' in data) {
......
......@@ -11,7 +11,7 @@
</template>
</Toolbar>
<ProgressBar mode="indeterminate" class="kn-progress-bar" v-if="loading" data-test="progress-bar" />
<KnListBox class="kn-height-full" :options="roles" :settings="rolesDecriptor.knListSettings" @click="showForm" @delete.stop="deleteRoleConfirm(slotProps.option.id)"></KnListBox>
<KnListBox class="kn-height-full" :options="roles" :settings="rolesDecriptor.knListSettings" @click="showForm" @delete.stop="deleteRoleConfirm"></KnListBox>
</div>
<div class="p-col-8 p-sm-8 p-md-9 p-p-0 p-m-0 kn-router-view">
......@@ -83,12 +83,13 @@ export default defineComponent({
})
}
},
deleteRoleConfirm(roleId: number) {
deleteRoleConfirm(event: any) {
if (!event.item) return
this.$confirm.require({
message: this.$t('common.toast.deleteMessage'),
header: this.$t('common.toast.deleteTitle'),
icon: 'pi pi-exclamation-triangle',
accept: () => this.deleteRole(roleId)
accept: () => this.deleteRole(event.item.id)
})
},
async deleteRole(roleId: number) {
......
......@@ -6,7 +6,7 @@ const routes = [
children: [
{
path: '',
component: () => import('@/modules/managers/timespan/TimespanDetail.vue')
component: () => import('@/modules/managers/timespan/TimespanHint.vue')
},
{
path: 'new-timespan',
......
import { mount } from '@vue/test-utils'
import { createRouter, createWebHistory } from 'vue-router'
import axios from 'axios'
import Button from 'primevue/button'
import FabButton from '@/components/UI/KnFabButton.vue'
import flushPromises from 'flush-promises'
import Timespan from './Timespan.vue'
import TimespanHint from './TimespanHint.vue'
import PrimeVue from 'primevue/config'
import ProgressBar from 'primevue/progressbar'
import Toolbar from 'primevue/toolbar'
......@@ -86,6 +88,29 @@ const $router = {
push: jest.fn()
}
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/',
component: TimespanHint
},
{
path: '/timespan',
component: TimespanHint
},
{
path: '/timespan/new-timespan',
component: null
},
{
path: '/timespan/edit-timespan',
props: (route) => ({ id: route.query.id, clone: route.query.clone }),
component: null
}
]
})
const factory = () => {
return mount(Timespan, {
provide: [PrimeVue],
......@@ -93,7 +118,7 @@ const factory = () => {
directives: {
tooltip() {}
},
plugins: [],
plugins: [router],
stubs: {
Button,
FabButton,
......
<template>
<KnHint :title="'managers.timespan.title'" :hint="'managers.timespan.hint'"></KnHint>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import KnHint from '@/components/UI/KnHint.vue'
export default defineComponent({
name: 'lovs-management-hint',
components: { KnHint }
})
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment