bfg-common 1.3.76 → 1.3.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +1,120 @@
1
- <template>
2
- <div class="tasks">
3
- <common-headline
4
- :headline="localization.taskConsole"
5
- class="tasks__headline"
6
- />
7
-
8
- <div class="btn-group">
9
- <button
10
- id="task-previous-button"
11
- class="btn btn-sm btn-link nav-link"
12
- :disabled="pagination.page === 1"
13
- @click="onClickButton('previous')"
14
- >
15
- {{ localization.previous }}
16
- </button>
17
-
18
- <button
19
- id="task-next-button"
20
- class="btn btn-sm btn-link nav-link"
21
- :disabled="pagination.page === tasksList?.total_pages"
22
- @click="onClickButton('next')"
23
- >
24
- {{ localization.next }}
25
- </button>
26
- </div>
27
-
28
- <templates-tasks-table-view
29
- :data-table="tasksList?.items || []"
30
- :total-items="tasksList?.total_items || 0"
31
- :total-pages="tasksList?.total_pages || 1"
32
- :pagination="pagination"
33
- :loading="isLoading"
34
- @pagination="onUpdatePagination"
35
- @sort="onSortTable"
36
- />
37
- </div>
38
- </template>
39
-
40
- <script lang="ts" setup>
41
- import type {
42
- UI_I_Localization,
43
- } from '~/lib/models/interfaces'
44
- import type {
45
- UI_I_Pagination,
46
- UI_I_DataTableQuery,
47
- } from '~/lib/models/table/interfaces'
48
- import type { UI_I_Task } from '~/lib/models/store/tasks/interfaces'
49
-
50
- definePageMeta({
51
- middleware: ['auth'],
52
- })
53
-
54
- const localization = computed<UI_I_Localization>(() => useLocal())
55
- const { $store }: any = useNuxtApp()
56
-
57
- const pagination = ref<UI_I_Pagination>({
58
- page: 1,
59
- pageSize: 100,
60
- })
61
- const sort = ref<string | null>(null)
62
-
63
- const tasksList = computed<UI_I_Task>(() => $store.getters['tasks/getTaskList'])
64
-
65
- const onClickButton = (status: string): void => {
66
- if (status === 'next') {
67
- pagination.value.page += 1
68
- return
69
- }
70
-
71
- pagination.value.page -= 1
72
- }
73
-
74
- const getTasks = async (): Promise<void> => {
75
- pauseGlobalRefresh()
76
-
77
- const payload: UI_I_DataTableQuery = {
78
- ...pagination.value,
79
- sortBy: sort.value || '',
80
- }
81
- await $store.dispatch('tasks/A_GET_TASKS', payload)
82
- }
83
-
84
- const onUpdatePagination = (event: UI_I_Pagination): void => {
85
- pagination.value = event
86
- getTasks()
87
- }
88
-
89
- const onSortTable = (event: string): void => {
90
- sort.value = event
91
- getTasks()
92
- }
93
-
94
- const isLoading = computed<boolean>(() =>
95
- $store.getters['tasks/getLoading']('tasks')
96
- )
97
- const pauseGlobalRefresh = (): void => {
98
- const tasksLastRequestType = $store.getters['tasks/getTasksLastRequestType']
99
- $store.dispatch('main/A_PAUSE_GLOBAL_REFRESH', tasksLastRequestType)
100
- }
101
- onUnmounted(() => {
102
- pauseGlobalRefresh()
103
- })
104
- </script>
105
-
106
- <style lang="scss">
107
- @import '~/node_modules/bfg-common/assets/scss/common/mixins';
108
- .tasks {
109
- @include flex($dir: column);
110
- height: 100%;
111
- padding-left: 10px;
112
- &__headline {
113
- padding-left: 10px;
114
- margin-bottom: 0.6rem;
115
- }
116
- .btn {
117
- text-transform: uppercase;
118
- }
119
- }
120
- </style>
1
+ <template>
2
+ <div class="tasks">
3
+ <common-headline
4
+ :headline="localization.taskConsole"
5
+ class="tasks__headline"
6
+ />
7
+
8
+ <div class="btn-group">
9
+ <button
10
+ id="task-previous-button"
11
+ class="btn btn-sm btn-link nav-link"
12
+ :disabled="pagination.page === 1"
13
+ @click="onClickButton('previous')"
14
+ >
15
+ {{ localization.previous }}
16
+ </button>
17
+
18
+ <button
19
+ id="task-next-button"
20
+ class="btn btn-sm btn-link nav-link"
21
+ :disabled="pagination.page === tasksList?.total_pages"
22
+ @click="onClickButton('next')"
23
+ >
24
+ {{ localization.next }}
25
+ </button>
26
+ </div>
27
+
28
+ <templates-tasks-table-view
29
+ :data-table="tasksList?.items || []"
30
+ :total-items="tasksList?.total_items || 0"
31
+ :total-pages="tasksList?.total_pages || 1"
32
+ :pagination="pagination"
33
+ :loading="isLoading"
34
+ @pagination="onUpdatePagination"
35
+ @sort="onSortTable"
36
+ />
37
+ </div>
38
+ </template>
39
+
40
+ <script lang="ts" setup>
41
+ import type {
42
+ UI_I_Localization,
43
+ } from '~/lib/models/interfaces'
44
+ import type {
45
+ UI_I_Pagination,
46
+ UI_I_DataTableQuery,
47
+ } from '~/lib/models/table/interfaces'
48
+ import type { UI_I_Task } from '~/lib/models/store/tasks/interfaces'
49
+
50
+ definePageMeta({
51
+ middleware: ['auth'],
52
+ })
53
+
54
+ const localization = computed<UI_I_Localization>(() => useLocal())
55
+ const { $store }: any = useNuxtApp()
56
+
57
+ const pagination = ref<UI_I_Pagination>({
58
+ page: 1,
59
+ pageSize: 100,
60
+ })
61
+ const sort = ref<string | null>(null)
62
+
63
+ const tasksList = computed<UI_I_Task>(() => $store.getters['tasks/getTaskList'])
64
+
65
+ const onClickButton = (status: string): void => {
66
+ if (status === 'next') {
67
+ pagination.value.page += 1
68
+ return
69
+ }
70
+
71
+ pagination.value.page -= 1
72
+ }
73
+
74
+ const getTasks = async (): Promise<void> => {
75
+ pauseGlobalRefresh()
76
+
77
+ const payload: UI_I_DataTableQuery = {
78
+ ...pagination.value,
79
+ sortBy: sort.value || '',
80
+ }
81
+ await $store.dispatch('tasks/A_GET_TASKS', payload)
82
+ }
83
+
84
+ const onUpdatePagination = (event: UI_I_Pagination): void => {
85
+ pagination.value = event
86
+ getTasks()
87
+ }
88
+
89
+ const onSortTable = (event: string): void => {
90
+ sort.value = event
91
+ getTasks()
92
+ }
93
+
94
+ const isLoading = computed<boolean>(() =>
95
+ $store.getters['tasks/getLoading']('tasks')
96
+ )
97
+ const pauseGlobalRefresh = (): void => {
98
+ const tasksLastRequestType = $store.getters['tasks/getTasksLastRequestType']
99
+ $store.dispatch('main/A_PAUSE_GLOBAL_REFRESH', tasksLastRequestType)
100
+ }
101
+ onUnmounted(() => {
102
+ pauseGlobalRefresh()
103
+ })
104
+ </script>
105
+
106
+ <style lang="scss">
107
+ @import '~/node_modules/bfg-common/assets/scss/common/mixins';
108
+ .tasks {
109
+ @include flex($dir: column);
110
+ height: 100%;
111
+ padding-left: 10px;
112
+ &__headline {
113
+ padding-left: 10px;
114
+ margin-bottom: 0.6rem;
115
+ }
116
+ .btn {
117
+ text-transform: uppercase;
118
+ }
119
+ }
120
+ </style>
@@ -1,203 +1,203 @@
1
- <template>
2
- <div class="recursion-tree">
3
- <div v-for="node in nodes" :key="`${node.type}_${node.id}`">
4
- <div
5
- :id="`tree-node-${node.type}-${node.id}`"
6
- class="clr-tree-node"
7
- @click="selectNode(node)"
8
- >
9
- <button
10
- v-if="node.hasNodes"
11
- :id="`tree-node-${node.type}-${node.id}-toggle-button`"
12
- class="clr-treenode-caret"
13
- @click.stop="getNodes({ node })"
14
- >
15
- <i
16
- v-if="loading[`${node.id}_${node.type}`]"
17
- class="fa clr-tree-node-caret-icon spinner spinner-sm"
18
- />
19
- <atoms-the-icon
20
- v-else
21
- :class="['clr-tree-node-caret-icon', { down: node.nodesShow }]"
22
- name="angle"
23
- />
24
- </button>
25
- <div
26
- :class="[
27
- 'tree-node-text-drag',
28
- { 'no-child': !node.hasNodes, 'dark-mode': hasDarkMode },
29
- ]"
30
- @contextmenu.prevent="showContextMenuAndSelectNode($event, node)"
31
- >
32
- <div
33
- :class="[
34
- 'clr-treenode-link tree-node-text',
35
- { active: node.isActive },
36
- ]"
37
- >
38
- <span :class="node.iconClassName" />
39
- {{ node.name }}
40
- </div>
41
- </div>
42
- </div>
43
-
44
- <common-recursion-tree
45
- v-if="node.nodesShow && node.nodes.length"
46
- :nodes="node.nodes"
47
- :style="{ 'padding-left': node.nodesShow ? '20px' : '' }"
48
- @get-nodes="getNodes($event)"
49
- @select-node="selectNode($event)"
50
- @contextmenu.prevent
51
- @show-context-menu="showContextMenu"
52
- />
53
- </div>
54
- </div>
55
- </template>
56
-
57
- <script setup lang="ts">
58
- import { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
59
-
60
- const { $store } = useNuxtApp()
61
-
62
- interface UI_I_Loading {
63
- [key: string]: boolean
64
- }
65
-
66
- const props = defineProps<{
67
- nodes: UI_I_TreeNode[]
68
- }>()
69
- const emits = defineEmits<{
70
- (event: 'get-nodes', value: any): void
71
- (event: 'select-node', value: UI_I_TreeNode): void
72
- (event: 'show-context-menu', value: any): void
73
- }>()
74
-
75
- const loading = ref<UI_I_Loading>({})
76
- watch(props.nodes, (nodes) => {
77
- nodes.forEach((node) => {
78
- loading.value[`${node.id}_${node.type}`] = false
79
- })
80
- })
81
-
82
- const hasDarkMode = computed<boolean>(
83
- () => $store.getters['main/getInterfaceThemeMode'] === 'DARK'
84
- )
85
-
86
- const getNodes = (data: any): void => {
87
- const node: UI_I_TreeNode = data.node
88
- const cb: Function | undefined = data.cb
89
-
90
- loading.value[`${node.id}_${node.type}`] = true
91
- const collBack = () => {
92
- loading.value[`${node.id}_${node.type}`] = false
93
- }
94
- emits('get-nodes', {
95
- node,
96
- cb: cb || collBack,
97
- })
98
- }
99
- const selectNode = (node: UI_I_TreeNode): void => {
100
- emits('select-node', node)
101
- }
102
- const showContextMenu = (event: any, node: UI_I_TreeNode): void => {
103
- // Если данные приходят от потомка, то нужно так обработать, из-за рекурсии
104
- if (event.node && event.event) {
105
- emits('show-context-menu', { ...event })
106
- return
107
- }
108
- emits('show-context-menu', { event, node })
109
- }
110
- const showContextMenuAndSelectNode = (
111
- event: any,
112
- node: UI_I_TreeNode
113
- ): void => {
114
- selectNode(node)
115
-
116
- setTimeout(() => {
117
- showContextMenu(event, node)
118
- }, 0)
119
- }
120
- </script>
121
-
122
- <style scoped lang="scss">
123
- .recursion-tree {
124
- .clr-tree-node {
125
- width: 100%;
126
- overflow: hidden;
127
- display: flex;
128
- flex: 1 1 0;
129
- align-items: center;
130
- margin-bottom: 1px;
131
-
132
- .clr-treenode-caret {
133
- outline: none;
134
-
135
- .clr-tree-node-caret-icon {
136
- position: static;
137
- transform: rotate(90deg);
138
- width: 11px;
139
- height: 11px;
140
- fill: var(--tree-node-caret-icon);
141
-
142
- &.down {
143
- transform: rotate(180deg);
144
- }
145
- }
146
- }
147
- .tree-node-text-drag {
148
- width: 100%;
149
- overflow: hidden;
150
- display: flex;
151
- cursor: grab;
152
-
153
- &.no-child {
154
- margin-left: 30px;
155
- }
156
- .tree-node-text {
157
- width: 100%;
158
- box-sizing: border-box;
159
- text-overflow: ellipsis;
160
- overflow: hidden;
161
- white-space: nowrap;
162
- padding: 0;
163
- border-radius: 0;
164
- border-bottom: 1px solid transparent;
165
-
166
- &.active {
167
- background: var(--vertical-nav-active-bg-color);
168
- color: var(--vertical-nav-active-item-color);
169
- border-bottom: 1px solid transparent;
170
- }
171
- &:hover {
172
- border-color: var(--vertical-nav-hover-border-color);
173
- &:not(.active) {
174
- background: var(--vertical-nav-hover-bg-color);
175
- }
176
- }
177
- span {
178
- display: inline-block;
179
- vertical-align: text-bottom;
180
- margin: 1px 4px 0;
181
- }
182
- }
183
- }
184
- }
185
- }
186
- </style>
187
-
188
- <style>
189
- :root {
190
- --vertical-nav-active-item-color: #fff;
191
- --vertical-nav-active-bg-color: #29414e;
192
- --vertical-nav-hover-bg-color: #e8e8e8;
193
- --vertical-nav-hover-border-color: #666;
194
- --tree-node-caret-icon: #666;
195
- }
196
- :root.dark-theme {
197
- --vertical-nav-active-item-color: #000;
198
- --vertical-nav-active-bg-color: #d8e3e9;
199
- --vertical-nav-hover-bg-color: #324f61;
200
- --vertical-nav-hover-border-color: #fff;
201
- --tree-node-caret-icon: #acbac3;
202
- }
203
- </style>
1
+ <template>
2
+ <div class="recursion-tree">
3
+ <div v-for="node in nodes" :key="`${node.type}_${node.id}`">
4
+ <div
5
+ :id="`tree-node-${node.type}-${node.id}`"
6
+ class="clr-tree-node"
7
+ @click="selectNode(node)"
8
+ >
9
+ <button
10
+ v-if="node.hasNodes"
11
+ :id="`tree-node-${node.type}-${node.id}-toggle-button`"
12
+ class="clr-treenode-caret"
13
+ @click.stop="getNodes({ node })"
14
+ >
15
+ <i
16
+ v-if="loading[`${node.id}_${node.type}`]"
17
+ class="fa clr-tree-node-caret-icon spinner spinner-sm"
18
+ />
19
+ <atoms-the-icon
20
+ v-else
21
+ :class="['clr-tree-node-caret-icon', { down: node.nodesShow }]"
22
+ name="angle"
23
+ />
24
+ </button>
25
+ <div
26
+ :class="[
27
+ 'tree-node-text-drag',
28
+ { 'no-child': !node.hasNodes, 'dark-mode': hasDarkMode },
29
+ ]"
30
+ @contextmenu.prevent="showContextMenuAndSelectNode($event, node)"
31
+ >
32
+ <div
33
+ :class="[
34
+ 'clr-treenode-link tree-node-text',
35
+ { active: node.isActive },
36
+ ]"
37
+ >
38
+ <span :class="node.iconClassName" />
39
+ {{ node.name }}
40
+ </div>
41
+ </div>
42
+ </div>
43
+
44
+ <common-recursion-tree
45
+ v-if="node.nodesShow && node.nodes.length"
46
+ :nodes="node.nodes"
47
+ :style="{ 'padding-left': node.nodesShow ? '20px' : '' }"
48
+ @get-nodes="getNodes($event)"
49
+ @select-node="selectNode($event)"
50
+ @contextmenu.prevent
51
+ @show-context-menu="showContextMenu"
52
+ />
53
+ </div>
54
+ </div>
55
+ </template>
56
+
57
+ <script setup lang="ts">
58
+ import { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
59
+
60
+ const { $store } = useNuxtApp()
61
+
62
+ interface UI_I_Loading {
63
+ [key: string]: boolean
64
+ }
65
+
66
+ const props = defineProps<{
67
+ nodes: UI_I_TreeNode[]
68
+ }>()
69
+ const emits = defineEmits<{
70
+ (event: 'get-nodes', value: any): void
71
+ (event: 'select-node', value: UI_I_TreeNode): void
72
+ (event: 'show-context-menu', value: any): void
73
+ }>()
74
+
75
+ const loading = ref<UI_I_Loading>({})
76
+ watch(props.nodes, (nodes) => {
77
+ nodes.forEach((node) => {
78
+ loading.value[`${node.id}_${node.type}`] = false
79
+ })
80
+ })
81
+
82
+ const hasDarkMode = computed<boolean>(
83
+ () => $store.getters['main/getInterfaceThemeMode'] === 'DARK'
84
+ )
85
+
86
+ const getNodes = (data: any): void => {
87
+ const node: UI_I_TreeNode = data.node
88
+ const cb: Function | undefined = data.cb
89
+
90
+ loading.value[`${node.id}_${node.type}`] = true
91
+ const collBack = () => {
92
+ loading.value[`${node.id}_${node.type}`] = false
93
+ }
94
+ emits('get-nodes', {
95
+ node,
96
+ cb: cb || collBack,
97
+ })
98
+ }
99
+ const selectNode = (node: UI_I_TreeNode): void => {
100
+ emits('select-node', node)
101
+ }
102
+ const showContextMenu = (event: any, node: UI_I_TreeNode): void => {
103
+ // Если данные приходят от потомка, то нужно так обработать, из-за рекурсии
104
+ if (event.node && event.event) {
105
+ emits('show-context-menu', { ...event })
106
+ return
107
+ }
108
+ emits('show-context-menu', { event, node })
109
+ }
110
+ const showContextMenuAndSelectNode = (
111
+ event: any,
112
+ node: UI_I_TreeNode
113
+ ): void => {
114
+ selectNode(node)
115
+
116
+ setTimeout(() => {
117
+ showContextMenu(event, node)
118
+ }, 0)
119
+ }
120
+ </script>
121
+
122
+ <style scoped lang="scss">
123
+ .recursion-tree {
124
+ .clr-tree-node {
125
+ width: 100%;
126
+ overflow: hidden;
127
+ display: flex;
128
+ flex: 1 1 0;
129
+ align-items: center;
130
+ margin-bottom: 1px;
131
+
132
+ .clr-treenode-caret {
133
+ outline: none;
134
+
135
+ .clr-tree-node-caret-icon {
136
+ position: static;
137
+ transform: rotate(90deg);
138
+ width: 11px;
139
+ height: 11px;
140
+ fill: var(--tree-node-caret-icon);
141
+
142
+ &.down {
143
+ transform: rotate(180deg);
144
+ }
145
+ }
146
+ }
147
+ .tree-node-text-drag {
148
+ width: 100%;
149
+ overflow: hidden;
150
+ display: flex;
151
+ cursor: grab;
152
+
153
+ &.no-child {
154
+ margin-left: 30px;
155
+ }
156
+ .tree-node-text {
157
+ width: 100%;
158
+ box-sizing: border-box;
159
+ text-overflow: ellipsis;
160
+ overflow: hidden;
161
+ white-space: nowrap;
162
+ padding: 0;
163
+ border-radius: 0;
164
+ border-bottom: 1px solid transparent;
165
+
166
+ &.active {
167
+ background: var(--vertical-nav-active-bg-color);
168
+ color: var(--vertical-nav-active-item-color);
169
+ border-bottom: 1px solid transparent;
170
+ }
171
+ &:hover {
172
+ border-color: var(--vertical-nav-hover-border-color);
173
+ &:not(.active) {
174
+ background: var(--vertical-nav-hover-bg-color);
175
+ }
176
+ }
177
+ span {
178
+ display: inline-block;
179
+ vertical-align: text-bottom;
180
+ margin: 1px 4px 0;
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ </style>
187
+
188
+ <style>
189
+ :root {
190
+ --vertical-nav-active-item-color: #fff;
191
+ --vertical-nav-active-bg-color: #29414e;
192
+ --vertical-nav-hover-bg-color: #e8e8e8;
193
+ --vertical-nav-hover-border-color: #666;
194
+ --tree-node-caret-icon: #666;
195
+ }
196
+ :root.dark-theme {
197
+ --vertical-nav-active-item-color: #000;
198
+ --vertical-nav-active-bg-color: #d8e3e9;
199
+ --vertical-nav-hover-bg-color: #324f61;
200
+ --vertical-nav-hover-border-color: #fff;
201
+ --tree-node-caret-icon: #acbac3;
202
+ }
203
+ </style>