glib-web 3.24.0 → 3.24.2
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.
- package/components/treeView.vue +33 -14
- package/nav/sheet.vue +5 -0
- package/package.json +1 -1
- package/utils/http.js +3 -2
package/components/treeView.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div :class="cls()" :style="$styles()">
|
|
3
3
|
|
|
4
4
|
<template v-for="(item, index) in items" :key="'parent' + index">
|
|
5
|
-
<div :class="`parent ${item._selected ? 'active' : ''}
|
|
5
|
+
<div :class="`parent ${item._selected ? 'active' : ''} ${item._dragover ? 'hover' : ''}`"
|
|
6
6
|
@dragleave="(event) => handleDragLeave(event, item)" @drop="(event) => handleDrop(event, item)"
|
|
7
7
|
@dragover="(event) => handleDragOver(event, item)" @click="handleAction(item)">
|
|
8
8
|
<div class="label">
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
<v-icon v-else icon="expand_more" @click.stop="item._open = true"></v-icon>
|
|
16
16
|
</div>
|
|
17
17
|
<template v-if="item.children && item._open">
|
|
18
|
-
<div :class="`child ${citem._selected ? 'active' : ''}
|
|
19
|
-
:key="'child' + cindex" @drop="(event) => handleDrop(event, citem)"
|
|
20
|
-
@
|
|
18
|
+
<div :class="`child ${citem._selected ? 'active' : ''} ${citem._dragover ? 'hover' : ''}`"
|
|
19
|
+
v-for="(citem, cindex) in item.children" :key="'child' + cindex" @drop="(event) => handleDrop(event, citem)"
|
|
20
|
+
@click="handleAction(citem)" @dragleave="(event) => handleDragLeave(event, citem)"
|
|
21
21
|
@dragover="(event) => handleDragOver(event, citem)">
|
|
22
22
|
<v-icon size="8" :color="citem.color || '#A7ADB5'" icon="fiber_manual_record"></v-icon>
|
|
23
23
|
<label>{{ citem.label }}</label>
|
|
@@ -80,6 +80,12 @@
|
|
|
80
80
|
margin-bottom: 2px;
|
|
81
81
|
cursor: pointer;
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
/* disable drag event on child element */
|
|
85
|
+
.gtreeview .parent *:not(.v-icon),
|
|
86
|
+
.gtreeview .child *:not(.v-icon) {
|
|
87
|
+
pointer-events: none;
|
|
88
|
+
}
|
|
83
89
|
</style>
|
|
84
90
|
|
|
85
91
|
<script>
|
|
@@ -112,6 +118,7 @@ export default defineComponent({
|
|
|
112
118
|
|
|
113
119
|
setBusyWhenUploading({ files });
|
|
114
120
|
|
|
121
|
+
// if all file uploaded send http post
|
|
115
122
|
watch(uploaded, (val) => {
|
|
116
123
|
if (val) {
|
|
117
124
|
GLib.action.execute({
|
|
@@ -141,16 +148,23 @@ export default defineComponent({
|
|
|
141
148
|
}));
|
|
142
149
|
const items = ref(makeItems());
|
|
143
150
|
|
|
151
|
+
// update items when selected item is changed
|
|
144
152
|
watch(selected, () => items.value = makeItems());
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
item
|
|
151
|
-
|
|
154
|
+
const lastDragItem = ref(undefined);
|
|
155
|
+
watch(lastDragItem, (item, oldItem) => {
|
|
156
|
+
if (oldItem) oldItem._dragover = false;
|
|
157
|
+
|
|
158
|
+
if (item) {
|
|
159
|
+
if (item.children) item._open = true;
|
|
160
|
+
item._dragover = true;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
152
164
|
const handleDragLeave = (event, item) => {
|
|
153
|
-
if (event.target
|
|
165
|
+
if (!event.target || !event.relatedTarget) return false;
|
|
166
|
+
if (event.target.contains(event.relatedTarget) || event.relatedTarget.contains(event.target)) return false;
|
|
167
|
+
lastDragItem.value = null;
|
|
154
168
|
};
|
|
155
169
|
const handleAction = (context) => {
|
|
156
170
|
GLib.action.execute(context.onClick, ctx);
|
|
@@ -160,6 +174,9 @@ export default defineComponent({
|
|
|
160
174
|
dropData = item.dropData;
|
|
161
175
|
event.preventDefault();
|
|
162
176
|
|
|
177
|
+
// there is two kind of drop:
|
|
178
|
+
// 1. files
|
|
179
|
+
// 2. other components
|
|
163
180
|
if (event.dataTransfer.files.length > 0) {
|
|
164
181
|
uploadFiles({
|
|
165
182
|
droppedFiles: event.dataTransfer.files,
|
|
@@ -178,12 +195,14 @@ export default defineComponent({
|
|
|
178
195
|
dropData = null;
|
|
179
196
|
}
|
|
180
197
|
};
|
|
181
|
-
|
|
182
198
|
const handleDragOver = (event, item) => {
|
|
183
|
-
if (item.dropData)
|
|
199
|
+
if (item.dropData) {
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
lastDragItem.value = item;
|
|
202
|
+
}
|
|
184
203
|
};
|
|
185
204
|
|
|
186
|
-
return { selected, handleDragOver,
|
|
205
|
+
return { selected, handleDragOver, handleDragLeave, handleAction, handleDrop, items };
|
|
187
206
|
},
|
|
188
207
|
methods: {
|
|
189
208
|
cls() {
|
package/nav/sheet.vue
CHANGED
package/package.json
CHANGED
package/utils/http.js
CHANGED
|
@@ -232,12 +232,13 @@ export default class {
|
|
|
232
232
|
|
|
233
233
|
static startIndicator(component) {
|
|
234
234
|
this._showIndicator();
|
|
235
|
-
|
|
235
|
+
// TODO: this code from vue2, it is deprecated or still related?
|
|
236
|
+
if (component.$data) component.$data._isBusy = true;
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
static stopIndicator(component) {
|
|
239
240
|
this._hideIndicator();
|
|
240
|
-
component.$data._isBusy = false;
|
|
241
|
+
if (component.$data) component.$data._isBusy = false;
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
static _showIndicator() {
|