inviton-powerduck 0.0.119 → 0.0.121
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class LocationUtils {
|
|
2
|
+
static getCurrentLocation (): Promise<GeolocationPosition> {
|
|
3
|
+
return new Promise((resolve, reject) => {
|
|
4
|
+
if (!navigator.geolocation) {
|
|
5
|
+
reject(new Error('Geolocation is not supported.'));
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
navigator.geolocation.getCurrentPosition(resolve, reject);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -45,6 +45,11 @@ import Modal, { ModalSize } from '../modal/modal';
|
|
|
45
45
|
import ModalBody from '../modal/modal-body';
|
|
46
46
|
import ModalFooter from '../modal/modal-footer';
|
|
47
47
|
|
|
48
|
+
interface TagItem {
|
|
49
|
+
id: string;
|
|
50
|
+
text: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
@Component
|
|
49
54
|
class TestAllComponentsPageComponent extends PowerduckViewModelBase {
|
|
50
55
|
name: string = null; // Needs to have =null suffixed so that TS compiler takes it into account
|
|
@@ -55,6 +60,8 @@ class TestAllComponentsPageComponent extends PowerduckViewModelBase {
|
|
|
55
60
|
blockModal: boolean = false;
|
|
56
61
|
color: string = '#FF00FF';
|
|
57
62
|
numberVal: number = 1;
|
|
63
|
+
tags: TagItem[] = [];
|
|
64
|
+
selectedTagIds: string[] = [];
|
|
58
65
|
|
|
59
66
|
protected get breadcrumbItems(): BreadcrumbItem[] {
|
|
60
67
|
return [
|
|
@@ -128,6 +135,19 @@ class TestAllComponentsPageComponent extends PowerduckViewModelBase {
|
|
|
128
135
|
});
|
|
129
136
|
}
|
|
130
137
|
|
|
138
|
+
getTagDropdown(): typeof DropdownList.prototype {
|
|
139
|
+
return this.$refs.tagsDropdown as typeof DropdownList.prototype;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
fireChangedEvent(e: string[]) {
|
|
143
|
+
this.$nextTick(() => {
|
|
144
|
+
this.getTagDropdown().close();
|
|
145
|
+
this.$nextTick(() => {
|
|
146
|
+
this.selectedTagIds = e;
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
131
151
|
render(h) {
|
|
132
152
|
return (
|
|
133
153
|
<div>
|
|
@@ -292,11 +312,11 @@ class TestAllComponentsPageComponent extends PowerduckViewModelBase {
|
|
|
292
312
|
<p>Some modal content1</p>
|
|
293
313
|
</ModalSection>
|
|
294
314
|
{this.boolValue == true
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
315
|
+
&& (
|
|
316
|
+
<ModalSection icon="icon icon-settings" navCaption="Settings2">
|
|
317
|
+
<p>Some modal content2</p>
|
|
318
|
+
</ModalSection>
|
|
319
|
+
)}
|
|
300
320
|
|
|
301
321
|
<ModalSection icon="icon icon-settings" navCaption="Settings4">
|
|
302
322
|
<p>Some modal content4444</p>
|
|
@@ -360,6 +380,37 @@ class TestAllComponentsPageComponent extends PowerduckViewModelBase {
|
|
|
360
380
|
this.selectedOptions = v.id;
|
|
361
381
|
}}
|
|
362
382
|
/>
|
|
383
|
+
<DropdownList
|
|
384
|
+
ref="tagsDropdown"
|
|
385
|
+
closeOnSelect={true}
|
|
386
|
+
blocked={false}
|
|
387
|
+
options={this.tags}
|
|
388
|
+
displayMember={item => item.text}
|
|
389
|
+
valueMember={item => item.text}
|
|
390
|
+
multiselect={true}
|
|
391
|
+
label=""
|
|
392
|
+
tags={true}
|
|
393
|
+
tagsShouldPrependContent={true}
|
|
394
|
+
tagsAdded={(e) => {
|
|
395
|
+
e.closeSelection = true;
|
|
396
|
+
|
|
397
|
+
const newItem: TagItem = {
|
|
398
|
+
id: e.tagArr[0],
|
|
399
|
+
text: e.tagArr[0],
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
const selectedClone = [...this.selectedTagIds];
|
|
403
|
+
selectedClone.push(newItem.id);
|
|
404
|
+
|
|
405
|
+
this.tags.push(newItem);
|
|
406
|
+
this.fireChangedEvent(selectedClone);
|
|
407
|
+
}}
|
|
408
|
+
selected={this.tags.filter(p => (this.selectedTagIds || []).includes(p.id))}
|
|
409
|
+
changed={(e) => {
|
|
410
|
+
this.fireChangedEvent((e || []).map(p => p.id));
|
|
411
|
+
}}
|
|
412
|
+
/>
|
|
413
|
+
|
|
363
414
|
<DropdownButton layout={ButtonLayout.Default} size={ButtonSize.Regular} text="Akcie">
|
|
364
415
|
<DropdownButtonItem icon="icon icon-settings" text="Edit" clicked={() => alert('clicked me')} />
|
|
365
416
|
<DropdownButtonSeparator />
|
|
@@ -430,12 +430,12 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
430
430
|
getFormatResult() {
|
|
431
431
|
if (this.trailingButton) {
|
|
432
432
|
const self = this;
|
|
433
|
-
return
|
|
433
|
+
return (row) => {
|
|
434
434
|
const retVal = $(`<span class="s2-ri-withtb">${row.text
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
435
|
+
}<button class="s2-trailing-button ${self.trailingButton.cssClass || ''
|
|
436
|
+
} btn-sm">${self.trailingButton.icon != null ? `<i class="${self.trailingButton.icon}"></i> ` : ''
|
|
437
|
+
}${self.trailingButton.text || ''
|
|
438
|
+
}</button></span>`);
|
|
439
439
|
retVal.find('button').click((e) => {
|
|
440
440
|
try {
|
|
441
441
|
clearTimeout(self.preventDefaultTimeout);
|
|
@@ -507,7 +507,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
507
507
|
},
|
|
508
508
|
});
|
|
509
509
|
|
|
510
|
-
dropDown.onCancel =
|
|
510
|
+
dropDown.onCancel = () => {
|
|
511
511
|
selectedItems = null;
|
|
512
512
|
dropDown = null;
|
|
513
513
|
};
|
|
@@ -610,6 +610,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
610
610
|
|
|
611
611
|
this.tagsAdded(eventArgs);
|
|
612
612
|
forceClose = eventArgs.closeSelection;
|
|
613
|
+
return;
|
|
613
614
|
}
|
|
614
615
|
}
|
|
615
616
|
|
|
@@ -850,9 +851,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
850
851
|
return stripDiacritics(text).toUpperCase();
|
|
851
852
|
};
|
|
852
853
|
const stripDiacritics = (text: string) => {
|
|
853
|
-
|
|
854
|
-
return DIACRITICS[a] || a;
|
|
855
|
-
}
|
|
854
|
+
const match = a => DIACRITICS[a] || a;
|
|
856
855
|
|
|
857
856
|
return text.replace(/[^\u0000-\u007E]/g, match);
|
|
858
857
|
};
|
|
@@ -923,7 +922,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
923
922
|
let validTagsButtons = false;
|
|
924
923
|
let tagsTemplate = this.tagsTemplate;
|
|
925
924
|
if (this.tags == true && this.tagsAdded != null) {
|
|
926
|
-
s2Args.createTag =
|
|
925
|
+
s2Args.createTag = (params) => {
|
|
927
926
|
const term = $.trim(params.term);
|
|
928
927
|
if (term === '') {
|
|
929
928
|
return null;
|
|
@@ -937,7 +936,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
937
936
|
};
|
|
938
937
|
|
|
939
938
|
if (this.tagsNewPlaceLast != false) {
|
|
940
|
-
s2Args.insertTag =
|
|
939
|
+
s2Args.insertTag = (data, tag) => {
|
|
941
940
|
// Insert the tag at the end of the results
|
|
942
941
|
data.push(tag);
|
|
943
942
|
};
|
|
@@ -948,7 +947,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
948
947
|
validTagsButtons = true;
|
|
949
948
|
tagsTemplate
|
|
950
949
|
= '<li class="select2-selection__choice select2-selection__choice-with-button"><span class="select2-selection__choice__remove" role="presentation"><i class="fas fa-times"></i></span></li>';
|
|
951
|
-
s2Args.templateSelection =
|
|
950
|
+
s2Args.templateSelection = (state): string | JQuery => {
|
|
952
951
|
if (!state) { return ''; }
|
|
953
952
|
|
|
954
953
|
if (!state.id) { return state.text; }
|
|
@@ -985,9 +984,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
985
984
|
|
|
986
985
|
if (!this.useMultiCheckboxes()) {
|
|
987
986
|
const currentMethod = instance.dataAdapter.current;
|
|
988
|
-
const getCurrentData = () =>
|
|
989
|
-
return instance.dataAccessor?.getData();
|
|
990
|
-
};
|
|
987
|
+
const getCurrentData = () => instance.dataAccessor?.getData();
|
|
991
988
|
|
|
992
989
|
const getSelected = () => {
|
|
993
990
|
const retArr = [];
|
|
@@ -1045,8 +1042,13 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
1045
1042
|
|
|
1046
1043
|
instance.dataAdapter.select = (data) => {
|
|
1047
1044
|
const adapter = instance.dataAdapter;
|
|
1048
|
-
if (adapter.$element.prop('multiple')) {
|
|
1045
|
+
if (adapter.$element.prop('multiple') || s2Args.tags) {
|
|
1049
1046
|
adapter.current((currentData) => {
|
|
1047
|
+
const isNewTag = data.newTag;
|
|
1048
|
+
if (isNewTag) {
|
|
1049
|
+
data.selected = true;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1050
1052
|
data = [data];
|
|
1051
1053
|
data.push.apply(data, currentData);
|
|
1052
1054
|
unselectOthers(getCurrentData(), data.map(p => p.id));
|
|
@@ -1098,14 +1100,14 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
1098
1100
|
};
|
|
1099
1101
|
|
|
1100
1102
|
if (!isNullOrEmpty(tagsTemplate)) {
|
|
1101
|
-
DropdownSelect2Helper.getSelect2Instance(s2Elem).selection.selectionContainer =
|
|
1103
|
+
DropdownSelect2Helper.getSelect2Instance(s2Elem).selection.selectionContainer = () => {
|
|
1102
1104
|
const retVal = $(tagsTemplate);
|
|
1103
1105
|
if (self.tagsShouldPrependContent != false) {
|
|
1104
1106
|
const oldAppend = retVal.append;
|
|
1105
|
-
retVal.append =
|
|
1107
|
+
retVal.append = (elem): any => {
|
|
1106
1108
|
retVal.prepend(elem);
|
|
1107
1109
|
retVal.append = oldAppend;
|
|
1108
|
-
}
|
|
1110
|
+
};
|
|
1109
1111
|
}
|
|
1110
1112
|
|
|
1111
1113
|
return retVal;
|
|
@@ -1165,9 +1167,7 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
|
|
|
1165
1167
|
}
|
|
1166
1168
|
}
|
|
1167
1169
|
|
|
1168
|
-
DropdownSelect2Helper.getSelect2Instance(s2Elem).dataAccessor.getData = () =>
|
|
1169
|
-
return opts;
|
|
1170
|
-
};
|
|
1170
|
+
DropdownSelect2Helper.getSelect2Instance(s2Elem).dataAccessor.getData = () => opts;
|
|
1171
1171
|
|
|
1172
1172
|
if (this.containerCssClass?.length > 0) {
|
|
1173
1173
|
DropdownSelect2Helper.getSelect2Instance(s2Elem).$dropdown.addClass(this.containerCssClass);
|