DocumentBrowserCockpitContainer.vue 3.16 KB
Newer Older
1
<template>
dbulatovicx32's avatar
dbulatovicx32 committed
2
    <div id="cockpit-container" class="kn-height-full">
BojanSovticEngIT's avatar
Hotfix    
BojanSovticEngIT committed
3
4
5
6
7
8
9
10
11
        <DocumentExecution
            :id="name"
            v-show="mode === 'document-execution'"
            :propMode="mode"
            v-bind:style="[mode === 'document-execution' ? '' : 'display: none !important; ']"
            :parameterValuesMap="parameterValuesMap"
            :tabKey="tabKey"
            @parametersChanged="$emit('parametersChanged', $event)"
        ></DocumentExecution>
BojanSovticEngIT's avatar
BojanSovticEngIT committed
12
13
14
15
16
17
18
19
20
        <DocumentDetails
            v-show="mode === 'document-detail'"
            v-bind:style="[mode === 'document-detail' ? '' : 'display: none !important;']"
            :propMode="'execution'"
            :propDocId="item?.id"
            :propFolderId="functionalityId"
            @closeDetails="$emit('closeDetails', item)"
            @documentSaved="onDocumentsSaved"
        ></DocumentDetails>
dbulatovicx32's avatar
dbulatovicx32 committed
21
    </div>
22
23
24
25
26
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import DocumentExecution from '@/modules/documentExecution/main/DocumentExecution.vue'
BojanSovticEngIT's avatar
Routing    
BojanSovticEngIT committed
27
import DocumentDetails from '@/modules/documentExecution/documentDetails/DocumentDetails.vue'
28
29
30
31

export default defineComponent({
    name: 'document-browser-cockpit-container',
    components: {
BojanSovticEngIT's avatar
Routing    
BojanSovticEngIT committed
32
33
        DocumentExecution,
        DocumentDetails
34
    },
BojanSovticEngIT's avatar
BojanSovticEngIT committed
35
    props: { id: { type: String }, functionalityId: { type: String }, item: { type: Object }, parameterValuesMap: { type: Object }, tabKey: { type: String }, propMode: { type: String } },
BojanSovticEngIT's avatar
Update    
BojanSovticEngIT committed
36
    emits: ['iframeCreated', 'closeIframe', 'parametersChanged', 'closeDetails', 'documentSaved'],
37
38
39
40
41
42
43
44
45
46
47
48
    data() {
        return {
            url: '',
            mode: '',
            testIFrame: null as any,
            name: '' as string
        }
    },
    watch: {
        id() {
            this.name = this.id as string
            this.setMode()
49
50
51
        },
        propMode() {
            this.setMode()
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        }
    },
    created() {
        this.name = this.id as string
        this.createUrl()
        this.setMode()
    },
    activated() {
        this.setMode()
    },
    deactivated() {
        this.mode = ''
    },
    methods: {
        createUrl() {
            const user = (this.$store.state as any).user
            const language = user.locale.split('_')[0]
            const uniqueID = user.userUniqueIdentifier
            const country = user.locale.split('_')[1]

            this.url = process.env.VUE_APP_HOST_URL + `/knowagecockpitengine/api/1.0/pages/edit?NEW_SESSION=TRUE&SBI_LANGUAGE=${language}&user_id=${uniqueID}&SBI_COUNTRY=${country}&SBI_ENVIRONMENT=DOCBROWSER&IS_TECHNICAL_USER=true&documentMode=EDIT&FUNCTIONALITY_ID=${this.functionalityId}`
        },
        setMode() {
BojanSovticEngIT's avatar
BojanSovticEngIT committed
75
            if (this.propMode === 'documentDetail') {
BojanSovticEngIT's avatar
Routing    
BojanSovticEngIT committed
76
                this.mode = 'document-detail'
BojanSovticEngIT's avatar
BojanSovticEngIT committed
77
            } else if (this.propMode === 'execute') {
78
                this.mode = 'document-execution'
BojanSovticEngIT's avatar
BojanSovticEngIT committed
79
            } else if (this.propMode === 'createCockpit') {
80
81
82
                this.mode = 'cockpit'
                this.$emit('iframeCreated', { iframe: this.url, item: this.item })
            }
BojanSovticEngIT's avatar
Update    
BojanSovticEngIT committed
83
84
85
        },
        onDocumentsSaved(document: any) {
            this.$emit('documentSaved', document)
86
87
88
89
        }
    }
})
</script>