@signal24/vue-foundation 3.3.2 → 3.6.0
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/.eslintrc.js +16 -0
- package/.prettierrc.json +7 -0
- package/CHANGES.md +6 -3
- package/package.json +26 -13
- package/postcss.config.js +1 -1
- package/src/app.js +2 -2
- package/src/components/ajax-select.vue +10 -6
- package/src/components/alert.vue +28 -28
- package/src/components/index.js +6 -11
- package/src/components/modal.vue +18 -10
- package/src/components/smart-select.vue +57 -34
- package/src/config.js +1 -1
- package/src/directives/autofocus.js +4 -3
- package/src/directives/confirm-button.js +2 -2
- package/src/directives/date-input.js +7 -9
- package/src/directives/datetime.js +11 -9
- package/src/directives/disabled.js +4 -5
- package/src/directives/duration.js +7 -8
- package/src/directives/index.js +1 -1
- package/src/directives/infinite-scroll.js +1 -1
- package/src/directives/readonly.js +5 -6
- package/src/directives/tooltip.js +58 -61
- package/src/directives/user-text.js +1 -1
- package/src/filters/index.js +9 -6
- package/src/helpers/array.js +13 -14
- package/src/helpers/context-menu.js +16 -18
- package/src/helpers/delay.js +1 -1
- package/src/helpers/error.js +6 -9
- package/src/helpers/http.js +27 -25
- package/src/helpers/index.js +1 -1
- package/src/helpers/mask.js +27 -20
- package/src/helpers/number.js +2 -2
- package/src/helpers/string.js +17 -17
- package/src/helpers/vue.js +2 -2
- package/src/index.js +5 -5
- package/src/plugins/index.js +6 -6
- package/src/plugins/infinite-scroll/hook.js +2 -2
- package/src/plugins/infinite-scroll.js +20 -10
- package/src/plugins/resize-watcher.js +2 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
1
|
import $ from 'jquery';
|
|
3
2
|
|
|
3
|
+
import app from '../app';
|
|
4
|
+
|
|
4
5
|
app.directive('disabled', {
|
|
5
6
|
beforeMount: fn,
|
|
6
7
|
updated: fn,
|
|
@@ -13,10 +14,8 @@ function fn(el, binding) {
|
|
|
13
14
|
el = $(el).find('input')[0];
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
if (binding.value)
|
|
17
|
-
|
|
18
|
-
else
|
|
19
|
-
$(el).removeAttr('disabled');
|
|
17
|
+
if (binding.value) $(el).attr('disabled', 'disabled');
|
|
18
|
+
else $(el).removeAttr('disabled');
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
function unmounted(el) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
1
|
import moment from 'moment';
|
|
3
2
|
|
|
3
|
+
import app from '../app';
|
|
4
|
+
|
|
4
5
|
let durationEls = [];
|
|
5
6
|
|
|
6
7
|
function updateDurations() {
|
|
@@ -19,13 +20,12 @@ function applyDuration(el, binding) {
|
|
|
19
20
|
if (binding.value == binding.oldValue) return;
|
|
20
21
|
if (!binding.value) return removeDuration(el);
|
|
21
22
|
|
|
22
|
-
el.$includeSeconds = typeof
|
|
23
|
+
el.$includeSeconds = typeof el.attributes['no-seconds'] === 'undefined';
|
|
23
24
|
|
|
24
25
|
let baseTimeAttr = el.attributes['base-time'];
|
|
25
26
|
if (baseTimeAttr) {
|
|
26
|
-
el.$startTs = moment(baseTimeAttr.value).valueOf() -
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
27
|
+
el.$startTs = moment(baseTimeAttr.value).valueOf() - binding.value * 1000;
|
|
28
|
+
} else {
|
|
29
29
|
el.$startTs = moment(binding.value).valueOf();
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -65,9 +65,8 @@ function secondsToString(seconds, shouldSkipSeconds) {
|
|
|
65
65
|
if (!shouldSkipSeconds) {
|
|
66
66
|
seconds -= minutes * 60;
|
|
67
67
|
result.push(seconds + 's');
|
|
68
|
-
}
|
|
69
|
-
else if (!result.length) {
|
|
68
|
+
} else if (!result.length) {
|
|
70
69
|
result.push('0m');
|
|
71
70
|
}
|
|
72
71
|
return result.join(' ');
|
|
73
|
-
}
|
|
72
|
+
}
|
package/src/directives/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
1
|
import $ from 'jquery';
|
|
3
2
|
|
|
3
|
+
import app from '../app';
|
|
4
|
+
|
|
4
5
|
app.directive('readonly', {
|
|
5
6
|
beforeMount: fn,
|
|
6
7
|
updated: fn
|
|
@@ -11,8 +12,6 @@ function fn(el, binding) {
|
|
|
11
12
|
el = $(el).find('input')[0];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
if (binding.value)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
$(el).removeAttr('readonly');
|
|
18
|
-
}
|
|
15
|
+
if (binding.value) $(el).attr('readonly', 'readonly');
|
|
16
|
+
else $(el).removeAttr('readonly');
|
|
17
|
+
}
|
|
@@ -1,48 +1,43 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
1
|
import $ from 'jquery';
|
|
3
2
|
|
|
3
|
+
import app from '../app';
|
|
4
|
+
|
|
4
5
|
app.directive('tip', {
|
|
5
6
|
mounted: createTip,
|
|
6
7
|
updated: createTip,
|
|
7
8
|
unmounted: destroyTip
|
|
8
9
|
});
|
|
9
10
|
|
|
10
|
-
function createTip(el, binding
|
|
11
|
+
function createTip(el, binding) {
|
|
11
12
|
let tipText = el.attributes.tip ? el.attributes.tip.value : binding.value;
|
|
12
|
-
if (binding.value === false)
|
|
13
|
-
tipText = null;
|
|
13
|
+
if (binding.value === false) tipText = null;
|
|
14
14
|
if (tipText) {
|
|
15
15
|
let config = {};
|
|
16
16
|
config[binding.modifiers.html ? 'html' : 'text'] = tipText;
|
|
17
|
-
if (el.attributes['tip-class'])
|
|
18
|
-
config.class = el.attributes['tip-class'].value;
|
|
17
|
+
if (el.attributes['tip-class']) config.class = el.attributes['tip-class'].value;
|
|
19
18
|
$(el).vfTooltip(config);
|
|
20
|
-
}
|
|
21
|
-
else
|
|
22
|
-
$(el).vfTooltip('destroy');
|
|
19
|
+
} else $(el).vfTooltip('destroy');
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
function destroyTip(el) {
|
|
26
23
|
$(el).vfTooltip('destroy');
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
$.fn.vfTooltip = function(option) {
|
|
30
|
-
return this.each(function(index, el) {
|
|
26
|
+
$.fn.vfTooltip = function (option) {
|
|
27
|
+
return this.each(function (index, el) {
|
|
31
28
|
var tooltip = $(el).data('vf-tooltip');
|
|
32
29
|
|
|
33
|
-
if (typeof
|
|
30
|
+
if (typeof option == 'string') {
|
|
34
31
|
if (!tooltip) return;
|
|
35
32
|
tooltip[option]();
|
|
36
|
-
}
|
|
37
|
-
else if (tooltip) {
|
|
33
|
+
} else if (tooltip) {
|
|
38
34
|
tooltip.configure(option);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
$(el).data('vf-tooltip', tooltip);
|
|
35
|
+
} else {
|
|
36
|
+
var vfTooltip = new VfTooltip(el, option);
|
|
37
|
+
$(el).data('vf-tooltip', vfTooltip);
|
|
43
38
|
}
|
|
44
39
|
});
|
|
45
|
-
}
|
|
40
|
+
};
|
|
46
41
|
|
|
47
42
|
function VfTooltip(el, configIn) {
|
|
48
43
|
// exports
|
|
@@ -50,7 +45,11 @@ function VfTooltip(el, configIn) {
|
|
|
50
45
|
this.destroy = _destroy;
|
|
51
46
|
|
|
52
47
|
// state
|
|
53
|
-
var $tip,
|
|
48
|
+
var $tip,
|
|
49
|
+
config,
|
|
50
|
+
lastMoveEvt,
|
|
51
|
+
checkInterval,
|
|
52
|
+
shouldShow = false;
|
|
54
53
|
|
|
55
54
|
// apply config
|
|
56
55
|
this.configure(configIn);
|
|
@@ -62,9 +61,12 @@ function VfTooltip(el, configIn) {
|
|
|
62
61
|
config.now && _handleTargetMouseEnter(config.now);
|
|
63
62
|
|
|
64
63
|
function _configure(configIn) {
|
|
65
|
-
config = $.extend(
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
config = $.extend(
|
|
65
|
+
{
|
|
66
|
+
delay: 0
|
|
67
|
+
},
|
|
68
|
+
configIn
|
|
69
|
+
);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
function _handleTargetMouseEnter(e) {
|
|
@@ -72,61 +74,54 @@ function VfTooltip(el, configIn) {
|
|
|
72
74
|
|
|
73
75
|
shouldShow = true;
|
|
74
76
|
|
|
75
|
-
setTimeout(function() {
|
|
77
|
+
setTimeout(function () {
|
|
76
78
|
if (!shouldShow) return;
|
|
77
79
|
|
|
78
80
|
_renderTooltip();
|
|
79
81
|
|
|
80
|
-
if (config.static)
|
|
81
|
-
|
|
82
|
-
else
|
|
83
|
-
_handleMouseMove(e);
|
|
82
|
+
if (config.static) _placeStaticTooltip();
|
|
83
|
+
else _handleMouseMove(e);
|
|
84
84
|
|
|
85
85
|
$tip.show();
|
|
86
86
|
}, config.delay);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
function _handleTargetMouseLeave(
|
|
89
|
+
function _handleTargetMouseLeave() {
|
|
90
90
|
shouldShow = false;
|
|
91
91
|
_deferredRemoveTooltip();
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function _renderTooltip() {
|
|
95
|
-
if (!$tip)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
if (!$tip) config.static || $(window).on('mousemove', _handleMouseMove);
|
|
96
|
+
else $tip.remove();
|
|
97
|
+
|
|
98
|
+
$tip = $('<div class="vf-tooltip">')
|
|
99
|
+
.css('position', 'absolute')
|
|
100
|
+
.css('z-index', '1000000')
|
|
101
|
+
.addClass(config.class)
|
|
102
|
+
.appendTo(document.body);
|
|
101
103
|
config.title && $('<div class="title">').text(config.title).appendTo($tip);
|
|
102
104
|
var $content = $('<div class="content">').appendTo($tip);
|
|
103
105
|
|
|
104
|
-
if (config.callback)
|
|
105
|
-
|
|
106
|
-
else if (config.
|
|
107
|
-
$content.text(config.text).html($content.html().replace(/\n/g, '<br>'));
|
|
108
|
-
else if (config.html)
|
|
109
|
-
$content.html(config.html);
|
|
106
|
+
if (config.callback) config.callback($content[0]);
|
|
107
|
+
else if (config.text) $content.text(config.text).html($content.html().replace(/\n/g, '<br>'));
|
|
108
|
+
else if (config.html) $content.html(config.html);
|
|
110
109
|
|
|
111
110
|
if (config.static) {
|
|
112
|
-
$tip.mouseover(function() {
|
|
111
|
+
$tip.mouseover(function () {
|
|
113
112
|
shouldShow = true;
|
|
114
|
-
}).mouseout(function() {
|
|
113
|
+
}).mouseout(function () {
|
|
115
114
|
shouldShow = false;
|
|
116
115
|
_deferredRemoveTooltip();
|
|
117
116
|
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
else {
|
|
117
|
+
} else {
|
|
121
118
|
checkInterval = setInterval(_checkMoveEvent, 250);
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
|
|
125
122
|
function _deferredRemoveTooltip() {
|
|
126
|
-
if (config.static)
|
|
127
|
-
|
|
128
|
-
else
|
|
129
|
-
_removeTooltip();
|
|
123
|
+
if (config.static) setTimeout(_removeTooltip, 50);
|
|
124
|
+
else _removeTooltip();
|
|
130
125
|
}
|
|
131
126
|
|
|
132
127
|
function _removeTooltip() {
|
|
@@ -148,25 +143,27 @@ function VfTooltip(el, configIn) {
|
|
|
148
143
|
var tipX = targetPosition.left;
|
|
149
144
|
var tipY = targetPosition.top - tipHeight - 1;
|
|
150
145
|
if (tipY - 2 < 0) tipY = targetPosition.top + $target.outerHeight(true) + 1;
|
|
151
|
-
$tip.css('min-width', tipW + 'px')
|
|
146
|
+
$tip.css('min-width', tipW + 'px')
|
|
147
|
+
.css('left', tipX + 'px')
|
|
148
|
+
.css('top', tipY + 'px');
|
|
152
149
|
}
|
|
153
150
|
|
|
154
151
|
function _handleMouseMove(e) {
|
|
155
|
-
var tipWidth = $tip.outerWidth(),
|
|
156
|
-
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
152
|
+
var tipWidth = $tip.outerWidth(),
|
|
153
|
+
tipHeight = $tip.outerHeight();
|
|
154
|
+
var viewWidth = window.innerWidth,
|
|
155
|
+
viewHeight = window.innerHeight;
|
|
156
|
+
var tipX = e.pageX + 10,
|
|
157
|
+
tipY = e.pageY + 20;
|
|
158
|
+
if (tipX + tipWidth > viewWidth) tipX = e.pageX - 5 - tipWidth;
|
|
159
|
+
if (tipY + tipHeight > viewHeight) tipY = e.pageY - 5 - tipHeight;
|
|
162
160
|
$tip.css('left', tipX + 'px').css('top', tipY + 'px');
|
|
163
161
|
lastMoveEvt = e;
|
|
164
162
|
}
|
|
165
163
|
|
|
166
164
|
function _checkMoveEvent() {
|
|
167
165
|
if (!lastMoveEvt) return;
|
|
168
|
-
if (el != lastMoveEvt.target && !$.contains(el, lastMoveEvt.target))
|
|
169
|
-
_handleTargetMouseLeave();
|
|
166
|
+
if (el != lastMoveEvt.target && !$.contains(el, lastMoveEvt.target)) _handleTargetMouseLeave();
|
|
170
167
|
}
|
|
171
168
|
|
|
172
169
|
function _destroy() {
|
|
@@ -178,4 +175,4 @@ function VfTooltip(el, configIn) {
|
|
|
178
175
|
$target.off('mouseleave', _handleTargetMouseLeave);
|
|
179
176
|
$target.removeData('vf-tooltip');
|
|
180
177
|
}
|
|
181
|
-
}
|
|
178
|
+
}
|
package/src/filters/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import app from '../app';
|
|
|
2
2
|
|
|
3
3
|
const filterFns = {
|
|
4
4
|
bytes(value) {
|
|
5
|
-
var i = Math.floor(
|
|
5
|
+
var i = Math.floor(Math.log(value) / Math.log(1024));
|
|
6
6
|
return (value / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
|
7
7
|
},
|
|
8
8
|
|
|
@@ -51,7 +51,13 @@ const filterFns = {
|
|
|
51
51
|
},
|
|
52
52
|
|
|
53
53
|
usCurrency(value) {
|
|
54
|
-
return
|
|
54
|
+
return (
|
|
55
|
+
'$' +
|
|
56
|
+
Number(value)
|
|
57
|
+
.toFixed(3)
|
|
58
|
+
.replace(/0$/, '')
|
|
59
|
+
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
60
|
+
);
|
|
55
61
|
}
|
|
56
62
|
};
|
|
57
63
|
|
|
@@ -73,7 +79,4 @@ app.config.globalProperties.$filter = (value, ...filters) => {
|
|
|
73
79
|
return value;
|
|
74
80
|
};
|
|
75
81
|
|
|
76
|
-
export {
|
|
77
|
-
registerFilter,
|
|
78
|
-
registerFilters
|
|
79
|
-
};
|
|
82
|
+
export { registerFilter, registerFilters };
|
package/src/helpers/array.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(Array.prototype, 'diff', {
|
|
2
2
|
enumerable: false,
|
|
3
|
-
value: function(...args) {
|
|
3
|
+
value: function (...args) {
|
|
4
4
|
return this.filter(val => {
|
|
5
5
|
for (let i = 0; i < args.length; i++) {
|
|
6
6
|
if (args[i].includes(val)) {
|
|
@@ -15,14 +15,14 @@ Object.defineProperty(Array.prototype, 'diff', {
|
|
|
15
15
|
|
|
16
16
|
Object.defineProperty(Array.prototype, 'first', {
|
|
17
17
|
enumerable: false,
|
|
18
|
-
value: function() {
|
|
18
|
+
value: function () {
|
|
19
19
|
return this[0] || undefined;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
Object.defineProperty(Array.prototype, 'intersect', {
|
|
24
24
|
enumerable: false,
|
|
25
|
-
value: function(...args) {
|
|
25
|
+
value: function (...args) {
|
|
26
26
|
return this.filter(val => {
|
|
27
27
|
for (let i = 0; i < args.length; i++) {
|
|
28
28
|
if (args[i].includes(val)) {
|
|
@@ -37,7 +37,7 @@ Object.defineProperty(Array.prototype, 'intersect', {
|
|
|
37
37
|
|
|
38
38
|
Object.defineProperty(Array.prototype, 'keyBy', {
|
|
39
39
|
enumerable: false,
|
|
40
|
-
value: function(keyProp) {
|
|
40
|
+
value: function (keyProp) {
|
|
41
41
|
let result = {};
|
|
42
42
|
this.forEach(elem => {
|
|
43
43
|
result[elem[keyProp]] = elem;
|
|
@@ -48,16 +48,15 @@ Object.defineProperty(Array.prototype, 'keyBy', {
|
|
|
48
48
|
|
|
49
49
|
Object.defineProperty(Array.prototype, 'last', {
|
|
50
50
|
enumerable: false,
|
|
51
|
-
value: function() {
|
|
51
|
+
value: function () {
|
|
52
52
|
return this.length ? this[this.length - 1] : undefined;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
Object.defineProperty(Array.prototype, 'pluck', {
|
|
57
57
|
enumerable: false,
|
|
58
|
-
value: function(prop, keyProp) {
|
|
59
|
-
if (typeof keyProp === 'undefined')
|
|
60
|
-
return this.map(elem => elem[prop]);
|
|
58
|
+
value: function (prop, keyProp) {
|
|
59
|
+
if (typeof keyProp === 'undefined') return this.map(elem => elem[prop]);
|
|
61
60
|
|
|
62
61
|
let result = {};
|
|
63
62
|
this.forEach(elem => {
|
|
@@ -69,7 +68,7 @@ Object.defineProperty(Array.prototype, 'pluck', {
|
|
|
69
68
|
|
|
70
69
|
Object.defineProperty(Array.prototype, 'remove', {
|
|
71
70
|
enumerable: false,
|
|
72
|
-
value: function(element) {
|
|
71
|
+
value: function (element) {
|
|
73
72
|
const index = this.indexOf(element);
|
|
74
73
|
index > -1 && this.splice(index, 1);
|
|
75
74
|
}
|
|
@@ -77,7 +76,7 @@ Object.defineProperty(Array.prototype, 'remove', {
|
|
|
77
76
|
|
|
78
77
|
Object.defineProperty(Array.prototype, 'replace', {
|
|
79
78
|
enumerable: false,
|
|
80
|
-
value: function(element, replacement) {
|
|
79
|
+
value: function (element, replacement) {
|
|
81
80
|
const index = this.indexOf(element);
|
|
82
81
|
index > -1 && this.splice(index, 1, replacement);
|
|
83
82
|
}
|
|
@@ -85,7 +84,7 @@ Object.defineProperty(Array.prototype, 'replace', {
|
|
|
85
84
|
|
|
86
85
|
Object.defineProperty(Array.prototype, 'sortBy', {
|
|
87
86
|
enumerable: false,
|
|
88
|
-
value: function(key) {
|
|
87
|
+
value: function (key) {
|
|
89
88
|
this.sort((a, b) => {
|
|
90
89
|
return String(a[key]).toLowerCase().localeCompare(String(b[key]).toLowerCase());
|
|
91
90
|
});
|
|
@@ -94,7 +93,7 @@ Object.defineProperty(Array.prototype, 'sortBy', {
|
|
|
94
93
|
|
|
95
94
|
Object.defineProperty(Array.prototype, 'unique', {
|
|
96
95
|
enumerable: false,
|
|
97
|
-
value: function() {
|
|
98
|
-
return [...new Set(this)]
|
|
96
|
+
value: function () {
|
|
97
|
+
return [...new Set(this)];
|
|
99
98
|
}
|
|
100
|
-
});
|
|
99
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
|
|
1
3
|
import app from '../app';
|
|
2
|
-
import $ from 'jquery'
|
|
3
4
|
|
|
4
|
-
app.config.globalProperties.$contextMenu = function(e, config) {
|
|
5
|
+
app.config.globalProperties.$contextMenu = function (e, config) {
|
|
5
6
|
var $wrapper = $('<div class="vf-overlay">').click(_closeMenu).appendTo(document.body);
|
|
6
7
|
var $menu = $('<div class="vf-context-menu">').css('position', 'absolute').appendTo($wrapper);
|
|
7
8
|
|
|
@@ -13,16 +14,14 @@ app.config.globalProperties.$contextMenu = function(e, config) {
|
|
|
13
14
|
config.targetClass && $target.addClass(config.targetClass);
|
|
14
15
|
config.class && $menu.addClass(config.class);
|
|
15
16
|
|
|
16
|
-
config.items &&
|
|
17
|
-
|
|
18
|
-
return $('<div class="separator">').appendTo($menu);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
$item.click(item.handler);
|
|
25
|
-
});
|
|
17
|
+
config.items &&
|
|
18
|
+
config.items.forEach(item => {
|
|
19
|
+
if (item == '-') return $('<div class="separator">').appendTo($menu);
|
|
20
|
+
var $item = $('<div class="item">').css('user-select', 'none').text(item.title).appendTo($menu);
|
|
21
|
+
item.class && $item.addClass(item.class);
|
|
22
|
+
if (item.shouldConfirm) $item.data('handler', item.handler).click(_confirmAction);
|
|
23
|
+
else if (item.handler) $item.click(item.handler);
|
|
24
|
+
});
|
|
26
25
|
|
|
27
26
|
const dx = window.innerWidth - e.clientX;
|
|
28
27
|
const dy = window.innerHeight - e.clientY;
|
|
@@ -32,7 +31,7 @@ app.config.globalProperties.$contextMenu = function(e, config) {
|
|
|
32
31
|
const left = dx < menuWidth ? e.clientX - menuWidth - 1 : e.clientX + 1;
|
|
33
32
|
const top = dy < menuHeight ? e.clientY - menuHeight - 1 : e.clientY + 1;
|
|
34
33
|
|
|
35
|
-
$menu.css('left', left + 'px')
|
|
34
|
+
$menu.css('left', left + 'px');
|
|
36
35
|
$menu.css('top', top + 'px');
|
|
37
36
|
|
|
38
37
|
config.onCreate && config.onCreate($menu[0]);
|
|
@@ -53,16 +52,15 @@ app.config.globalProperties.$contextMenu = function(e, config) {
|
|
|
53
52
|
if ($item.hasClass('pending-confirm')) {
|
|
54
53
|
var handler = $item.data('handler');
|
|
55
54
|
handler && handler();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
55
|
+
} else {
|
|
58
56
|
var originalContent = $item.html();
|
|
59
57
|
$item.addClass('pending-confirm').text('Confirm');
|
|
60
|
-
$item.one('mouseleave', function() {
|
|
58
|
+
$item.one('mouseleave', function () {
|
|
61
59
|
$item.removeClass('pending-confirm').html(originalContent);
|
|
62
60
|
});
|
|
63
61
|
e.stopPropagation();
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
}
|
|
64
|
+
};
|
|
67
65
|
|
|
68
|
-
// TODO: actually de-select text rather than just using CSS to hide its selection
|
|
66
|
+
// TODO: actually de-select text rather than just using CSS to hide its selection
|
package/src/helpers/delay.js
CHANGED
package/src/helpers/error.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import app from '../app';
|
|
2
|
-
import vfConfig from '../config'
|
|
2
|
+
import vfConfig from '../config';
|
|
3
3
|
|
|
4
4
|
app.config.globalProperties.$reportError = err => {
|
|
5
5
|
if (!(err instanceof Error)) {
|
|
@@ -8,12 +8,10 @@ app.config.globalProperties.$reportError = err => {
|
|
|
8
8
|
|
|
9
9
|
if (vfConfig.reportErrorHandler) {
|
|
10
10
|
vfConfig.reportErrorHandler(err);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
else {
|
|
11
|
+
} else {
|
|
14
12
|
console.error(err);
|
|
15
13
|
}
|
|
16
|
-
}
|
|
14
|
+
};
|
|
17
15
|
|
|
18
16
|
app.config.globalProperties.$throwUserError = msg => {
|
|
19
17
|
let err = new Error(msg);
|
|
@@ -23,17 +21,16 @@ app.config.globalProperties.$throwUserError = msg => {
|
|
|
23
21
|
|
|
24
22
|
Object.defineProperty(Error.prototype, 'userMessage', {
|
|
25
23
|
get() {
|
|
26
|
-
if (this.code == 'USERERR')
|
|
27
|
-
return this.message;
|
|
24
|
+
if (this.code == 'USERERR') return this.message;
|
|
28
25
|
else
|
|
29
26
|
return `An application error has occurred:\n\n${this.message}\n\nPlease refresh the page and try again. If this error persists, ${vfConfig.unhandledErrorSupportText}.`;
|
|
30
27
|
}
|
|
31
28
|
});
|
|
32
29
|
|
|
33
|
-
Error.prototype.handle = function() {
|
|
30
|
+
Error.prototype.handle = function () {
|
|
34
31
|
if (this.code != 'USERERR') {
|
|
35
32
|
app.config.globalProperties.$reportError(this);
|
|
36
33
|
}
|
|
37
34
|
|
|
38
35
|
return this;
|
|
39
|
-
};
|
|
36
|
+
};
|
package/src/helpers/http.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
|
-
|
|
3
1
|
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
import app from '../app';
|
|
4
4
|
app.config.globalProperties.$http = axios;
|
|
5
5
|
|
|
6
6
|
axios.postOrPut = (baseUrl, id, ...args) => {
|
|
@@ -11,32 +11,34 @@ axios.postOrPut = (baseUrl, id, ...args) => {
|
|
|
11
11
|
|
|
12
12
|
import vfConfig from '../config';
|
|
13
13
|
|
|
14
|
-
axios.interceptors.response.use(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
axios.interceptors.response.use(
|
|
15
|
+
response => {
|
|
16
|
+
// TODO: will Axios auto-reject non-JSON?
|
|
17
|
+
if (response.data && typeof response.data != 'object') {
|
|
18
|
+
throw new Error('response was not JSON');
|
|
19
|
+
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
},
|
|
21
|
+
return response;
|
|
22
|
+
},
|
|
22
23
|
|
|
23
|
-
err => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
err => {
|
|
25
|
+
if (err.response && err.response.status == 401) {
|
|
26
|
+
if (vfConfig.unauthorizedHttpResponseHandler) {
|
|
27
|
+
const result = vfConfig.unauthorizedHttpResponseHandler(err.response);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// if the handler said "ok, handled", then we're going to
|
|
30
|
+
// return a promise that never resolves to prevent the userland code
|
|
31
|
+
// from ever proceeding
|
|
32
|
+
if (result) return new Promise(() => {});
|
|
33
|
+
}
|
|
32
34
|
}
|
|
33
|
-
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
if (err.response && err.response.data && err.response.data.error) {
|
|
37
|
+
err.code = err.response.status == 422 ? 'USERERR' : 'APIERR';
|
|
38
|
+
err.message = err.response.data.error;
|
|
39
|
+
err.field = err.response.data.errorField;
|
|
40
|
+
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
}
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
);
|
package/src/helpers/index.js
CHANGED