glib-web 4.35.9 → 4.35.10
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.
|
@@ -2,7 +2,12 @@ import { popovers } from "../../store";
|
|
|
2
2
|
|
|
3
3
|
function isExist(properties) {
|
|
4
4
|
const isPoped = popovers.value.map((v) => v.spec.key).includes(properties.key);
|
|
5
|
-
return
|
|
5
|
+
return isPoped;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function closeAllExcept(properties) {
|
|
9
|
+
const items = popovers.value.filter((v) => v.spec.key != properties.key);
|
|
10
|
+
items.forEach((popover) => popover.close());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { isExist, closeAllExcept };
|
package/actions/popovers/open.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import eventBus from "../../utils/eventBus";
|
|
2
2
|
import http from "../../utils/http";
|
|
3
|
-
import { isExist } from "./helper";
|
|
3
|
+
import { closeAllExcept, isExist } from "./helper";
|
|
4
4
|
|
|
5
5
|
export default class {
|
|
6
6
|
execute(properties, component) {
|
|
7
|
+
closeAllExcept(properties);
|
|
7
8
|
// show loading text
|
|
8
9
|
const prop = Object.assign({}, properties, { body: { childViews: [{ view: 'label', text: 'loading...', }] } }, { styleClasses: ['popovers-open'] });
|
|
9
10
|
|
|
10
11
|
if (!isExist(prop)) {
|
|
11
12
|
Utils.launch.popover.open(prop, component);
|
|
13
|
+
} else if (!prop.updateExisting) {
|
|
14
|
+
Utils.launch.popover.close(prop);
|
|
15
|
+
return;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
// send req to server and show response immediately
|
|
@@ -17,13 +21,8 @@ export default class {
|
|
|
17
21
|
'GET',
|
|
18
22
|
component,
|
|
19
23
|
(page) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} else {
|
|
23
|
-
prop.body = page.body;
|
|
24
|
-
Utils.launch.popover.open(prop, component);
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
prop.body = page.body;
|
|
25
|
+
Utils.launch.popover.open(prop, component);
|
|
27
26
|
},
|
|
28
27
|
() => {
|
|
29
28
|
const page = { body: { childViews: [{ view: 'label', text: 'Something went wrong' }] } };
|
package/actions/popovers/show.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isExist } from "./helper";
|
|
1
|
+
import { closeAllExcept, isExist } from "./helper";
|
|
3
2
|
|
|
4
3
|
export default class {
|
|
5
4
|
execute(properties, component) {
|
|
5
|
+
closeAllExcept(properties);
|
|
6
6
|
if (isExist(properties)) {
|
|
7
|
-
|
|
7
|
+
Utils.launch.popover.close(properties);
|
|
8
8
|
} else {
|
|
9
9
|
Utils.launch.popover.open(properties, component);
|
|
10
10
|
}
|
package/components/popover.vue
CHANGED
|
@@ -25,6 +25,7 @@ import bus from "../utils/eventBus";
|
|
|
25
25
|
import { driver } from "driver.js";
|
|
26
26
|
import 'driver.js/dist/driver.css';
|
|
27
27
|
import { strandom } from "./helper";
|
|
28
|
+
import { APP_ID } from "..";
|
|
28
29
|
|
|
29
30
|
export default {
|
|
30
31
|
props: ['spec', 'reference', 'placeholder', 'styleClass'],
|
|
@@ -44,18 +45,19 @@ export default {
|
|
|
44
45
|
mounted() {
|
|
45
46
|
popovers.value.push(this);
|
|
46
47
|
bus.$on(`popovers/open-${this.spec.key}`, (body) => {
|
|
47
|
-
Object.assign(this.spec, body);
|
|
48
|
+
Object.assign(this.spec, { body });
|
|
48
49
|
this.key = strandom();
|
|
49
50
|
});
|
|
50
51
|
},
|
|
51
52
|
methods: {
|
|
52
53
|
$mounted() {
|
|
54
|
+
const appEl = document.getElementById(APP_ID);
|
|
53
55
|
bus.$once(`popover/close-${this.spec.key}`, (options) => {
|
|
54
|
-
|
|
56
|
+
appEl.removeEventListener('click', this.handleClose);
|
|
55
57
|
this.close();
|
|
56
58
|
});
|
|
57
59
|
if (!this.spec.persistent) {
|
|
58
|
-
|
|
60
|
+
appEl.addEventListener('click', this.handleClose);
|
|
59
61
|
window.addEventListener('resize', () => this.close());
|
|
60
62
|
}
|
|
61
63
|
if (this.spec.overlay) {
|
|
@@ -67,7 +69,7 @@ export default {
|
|
|
67
69
|
bus.$off(`popover/close-${this.spec.key}`);
|
|
68
70
|
bus.$off(`popover/open-${this.spec.key}`);
|
|
69
71
|
if (!this.spec.persistent) {
|
|
70
|
-
|
|
72
|
+
appEl.removeEventListener('click', this.handleClose);
|
|
71
73
|
window.removeEventListener('resize', () => this.close());
|
|
72
74
|
}
|
|
73
75
|
},
|
package/index.js
CHANGED
|
@@ -10,6 +10,8 @@ import './app.scss';
|
|
|
10
10
|
// lib for deep merge
|
|
11
11
|
import merge from 'lodash.merge';
|
|
12
12
|
|
|
13
|
+
const APP_ID = 'app';
|
|
14
|
+
|
|
13
15
|
const Vue = createApp({
|
|
14
16
|
setup() {
|
|
15
17
|
const themeConfig = useTheme();
|
|
@@ -142,7 +144,7 @@ Vue.use(vPhoneInput);
|
|
|
142
144
|
|
|
143
145
|
|
|
144
146
|
document.addEventListener("DOMContentLoaded", () => {
|
|
145
|
-
Vue.mount(
|
|
147
|
+
Vue.mount(`#${APP_ID}`);
|
|
146
148
|
});
|
|
147
149
|
|
|
148
150
|
function useGlibErrorReporter(endpointUrl = '/glib/errors') {
|
|
@@ -189,4 +191,4 @@ function useGlibErrorReporter(endpointUrl = '/glib/errors') {
|
|
|
189
191
|
});
|
|
190
192
|
}
|
|
191
193
|
|
|
192
|
-
export { Vue, settings, vueApp, useGlibErrorReporter };
|
|
194
|
+
export { Vue, settings, vueApp, useGlibErrorReporter, APP_ID };
|
package/package.json
CHANGED
package/utils/launch/popover.js
CHANGED
|
@@ -5,9 +5,16 @@ import { autoUpdate, computePosition, shift, offset, arrow, flip } from "@floati
|
|
|
5
5
|
|
|
6
6
|
import bus from "../eventBus";
|
|
7
7
|
import { htmlElement } from "../../components/helper";
|
|
8
|
+
import { isExist } from "../../actions/popovers/helper";
|
|
9
|
+
import eventBus from "../eventBus";
|
|
8
10
|
|
|
9
11
|
export default class LaunchPopover {
|
|
10
12
|
static open(properties, component) {
|
|
13
|
+
if (isExist(properties)) {
|
|
14
|
+
eventBus.$emit(`popovers/open-${properties.key}`, properties.body);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
const placeholder = document.createElement('div');
|
|
12
19
|
const arrowEl = document.createElement('div');
|
|
13
20
|
arrowEl.classList.add('popover-arrow');
|