aurelia-syncfusion-ej2-bridge 0.1.0-beta.22 → 0.1.0-beta.25
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/package.json +2 -2
- package/dist/commonjs/common/constants.d.ts +0 -4
- package/dist/commonjs/common/constants.js +0 -7
- package/dist/commonjs/common/controlBase.d.ts +0 -37
- package/dist/commonjs/common/controlBase.js +0 -162
- package/dist/commonjs/common/controlContainer.d.ts +0 -10
- package/dist/commonjs/common/controlContainer.js +0 -19
- package/dist/commonjs/common/syncfusionWrapper.d.ts +0 -15
- package/dist/commonjs/common/syncfusionWrapper.js +0 -48
- package/dist/commonjs/configBuider.d.ts +0 -39
- package/dist/commonjs/configBuider.js +0 -214
- package/dist/commonjs/controlBindings.d.ts +0 -140
- package/dist/commonjs/controlBindings.js +0 -152
- package/dist/commonjs/index.d.ts +0 -6
- package/dist/commonjs/index.js +0 -17
- package/dist/commonjs/interfaces/IEJ2WidgetBridge.d.ts +0 -6
- package/dist/commonjs/interfaces/IEJ2WidgetBridge.js +0 -2
- package/dist/commonjs/interfaces/IEj2Uploader.d.ts +0 -17
- package/dist/commonjs/interfaces/IEj2Uploader.js +0 -2
- package/dist/commonjs/utilities/decorator.d.ts +0 -2
- package/dist/commonjs/utilities/decorator.js +0 -64
- package/dist/commonjs/widgets/accordion/ej2-accordion.d.ts +0 -7
- package/dist/commonjs/widgets/accordion/ej2-accordion.js +0 -31
- package/dist/commonjs/widgets/autoComplete/ej2-autoComplete.d.ts +0 -7
- package/dist/commonjs/widgets/autoComplete/ej2-autoComplete.js +0 -29
- package/dist/commonjs/widgets/button/ej2-button.d.ts +0 -14
- package/dist/commonjs/widgets/button/ej2-button.js +0 -55
- package/dist/commonjs/widgets/checkbox/ej2-checkbox-list.d.ts +0 -17
- package/dist/commonjs/widgets/checkbox/ej2-checkbox-list.js +0 -77
- package/dist/commonjs/widgets/checkbox/ej2-checkbox.d.ts +0 -12
- package/dist/commonjs/widgets/checkbox/ej2-checkbox.js +0 -58
- package/dist/commonjs/widgets/comboBox/ej2-comboBox.d.ts +0 -8
- package/dist/commonjs/widgets/comboBox/ej2-comboBox.js +0 -35
- package/dist/commonjs/widgets/dashboardLayout/ej2-dashboardLayout.d.ts +0 -7
- package/dist/commonjs/widgets/dashboardLayout/ej2-dashboardLayout.js +0 -29
- package/dist/commonjs/widgets/datePicker/ej2-DatePicker.d.ts +0 -8
- package/dist/commonjs/widgets/datePicker/ej2-DatePicker.js +0 -35
- package/dist/commonjs/widgets/dateRangePicker/ej2-dateRangePicker.d.ts +0 -8
- package/dist/commonjs/widgets/dateRangePicker/ej2-dateRangePicker.js +0 -37
- package/dist/commonjs/widgets/dateTimePicker/ej2-dateTimePicker.d.ts +0 -8
- package/dist/commonjs/widgets/dateTimePicker/ej2-dateTimePicker.js +0 -35
- package/dist/commonjs/widgets/dropDownList/ej2-dropDownList.d.ts +0 -9
- package/dist/commonjs/widgets/dropDownList/ej2-dropDownList.js +0 -39
- package/dist/commonjs/widgets/dropDownTree/ej2-dropDownTree.d.ts +0 -8
- package/dist/commonjs/widgets/dropDownTree/ej2-dropDownTree.js +0 -35
- package/dist/commonjs/widgets/fileManager/ej2-fileManager.d.ts +0 -9
- package/dist/commonjs/widgets/fileManager/ej2-fileManager.js +0 -34
- package/dist/commonjs/widgets/grid/ej2-grid.d.ts +0 -8
- package/dist/commonjs/widgets/grid/ej2-grid.js +0 -97
- package/dist/commonjs/widgets/listView/ej2-listView.d.ts +0 -8
- package/dist/commonjs/widgets/listView/ej2-listView.js +0 -34
- package/dist/commonjs/widgets/maskedTextBox/ej2-maskedTextBox.d.ts +0 -8
- package/dist/commonjs/widgets/maskedTextBox/ej2-maskedTextBox.js +0 -37
- package/dist/commonjs/widgets/multiSelect/ej2-multiSelect.d.ts +0 -10
- package/dist/commonjs/widgets/multiSelect/ej2-multiSelect.js +0 -44
- package/dist/commonjs/widgets/numericTextBox/ej2-numericTextBox.d.ts +0 -8
- package/dist/commonjs/widgets/numericTextBox/ej2-numericTextBox.js +0 -35
- package/dist/commonjs/widgets/pager/ej2-pager.d.ts +0 -7
- package/dist/commonjs/widgets/pager/ej2-pager.js +0 -29
- package/dist/commonjs/widgets/progressButton/ej2-progress-button.d.ts +0 -17
- package/dist/commonjs/widgets/progressButton/ej2-progress-button.js +0 -64
- package/dist/commonjs/widgets/radio/ej2-radio.d.ts +0 -13
- package/dist/commonjs/widgets/radio/ej2-radio.js +0 -54
- package/dist/commonjs/widgets/schedule/ej2-schedule.d.ts +0 -8
- package/dist/commonjs/widgets/schedule/ej2-schedule.js +0 -32
- package/dist/commonjs/widgets/sidebar/ej2-sidebar.d.ts +0 -7
- package/dist/commonjs/widgets/sidebar/ej2-sidebar.js +0 -30
- package/dist/commonjs/widgets/slider/ej2-slider.d.ts +0 -8
- package/dist/commonjs/widgets/slider/ej2-slider.js +0 -37
- package/dist/commonjs/widgets/splitter/ej2-splitter.d.ts +0 -7
- package/dist/commonjs/widgets/splitter/ej2-splitter.js +0 -29
- package/dist/commonjs/widgets/switch/ej2-switch.d.ts +0 -11
- package/dist/commonjs/widgets/switch/ej2-switch.js +0 -52
- package/dist/commonjs/widgets/textBox/ej2-textBox.d.ts +0 -8
- package/dist/commonjs/widgets/textBox/ej2-textBox.js +0 -37
- package/dist/commonjs/widgets/timePicker/ej2-timePicker.d.ts +0 -8
- package/dist/commonjs/widgets/timePicker/ej2-timePicker.js +0 -35
- package/dist/commonjs/widgets/treeView/ej2-treeView.d.ts +0 -7
- package/dist/commonjs/widgets/treeView/ej2-treeView.js +0 -29
- package/dist/commonjs/widgets/uploader/ej2-uploader.d.ts +0 -50
- package/dist/commonjs/widgets/uploader/ej2-uploader.js +0 -346
- package/dist/native-modules/common/constants.d.ts +0 -4
- package/dist/native-modules/common/constants.js +0 -4
- package/dist/native-modules/common/controlBase.d.ts +0 -37
- package/dist/native-modules/common/controlBase.js +0 -159
- package/dist/native-modules/common/controlContainer.d.ts +0 -10
- package/dist/native-modules/common/controlContainer.js +0 -15
- package/dist/native-modules/common/syncfusionWrapper.d.ts +0 -15
- package/dist/native-modules/common/syncfusionWrapper.js +0 -44
- package/dist/native-modules/configBuider.d.ts +0 -39
- package/dist/native-modules/configBuider.js +0 -210
- package/dist/native-modules/controlBindings.d.ts +0 -140
- package/dist/native-modules/controlBindings.js +0 -149
- package/dist/native-modules/index.d.ts +0 -6
- package/dist/native-modules/index.js +0 -12
- package/dist/native-modules/interfaces/IEJ2WidgetBridge.d.ts +0 -6
- package/dist/native-modules/interfaces/IEJ2WidgetBridge.js +0 -0
- package/dist/native-modules/interfaces/IEj2Uploader.d.ts +0 -17
- package/dist/native-modules/interfaces/IEj2Uploader.js +0 -0
- package/dist/native-modules/utilities/decorator.d.ts +0 -2
- package/dist/native-modules/utilities/decorator.js +0 -59
- package/dist/native-modules/widgets/accordion/ej2-accordion.d.ts +0 -7
- package/dist/native-modules/widgets/accordion/ej2-accordion.js +0 -28
- package/dist/native-modules/widgets/autoComplete/ej2-autoComplete.d.ts +0 -7
- package/dist/native-modules/widgets/autoComplete/ej2-autoComplete.js +0 -26
- package/dist/native-modules/widgets/button/ej2-button.d.ts +0 -14
- package/dist/native-modules/widgets/button/ej2-button.js +0 -52
- package/dist/native-modules/widgets/checkbox/ej2-checkbox-list.d.ts +0 -17
- package/dist/native-modules/widgets/checkbox/ej2-checkbox-list.js +0 -74
- package/dist/native-modules/widgets/checkbox/ej2-checkbox.d.ts +0 -12
- package/dist/native-modules/widgets/checkbox/ej2-checkbox.js +0 -55
- package/dist/native-modules/widgets/comboBox/ej2-comboBox.d.ts +0 -8
- package/dist/native-modules/widgets/comboBox/ej2-comboBox.js +0 -32
- package/dist/native-modules/widgets/dashboardLayout/ej2-dashboardLayout.d.ts +0 -7
- package/dist/native-modules/widgets/dashboardLayout/ej2-dashboardLayout.js +0 -26
- package/dist/native-modules/widgets/datePicker/ej2-DatePicker.d.ts +0 -8
- package/dist/native-modules/widgets/datePicker/ej2-DatePicker.js +0 -32
- package/dist/native-modules/widgets/dateRangePicker/ej2-dateRangePicker.d.ts +0 -8
- package/dist/native-modules/widgets/dateRangePicker/ej2-dateRangePicker.js +0 -34
- package/dist/native-modules/widgets/dateTimePicker/ej2-dateTimePicker.d.ts +0 -8
- package/dist/native-modules/widgets/dateTimePicker/ej2-dateTimePicker.js +0 -32
- package/dist/native-modules/widgets/dropDownList/ej2-dropDownList.d.ts +0 -9
- package/dist/native-modules/widgets/dropDownList/ej2-dropDownList.js +0 -36
- package/dist/native-modules/widgets/dropDownTree/ej2-dropDownTree.d.ts +0 -8
- package/dist/native-modules/widgets/dropDownTree/ej2-dropDownTree.js +0 -32
- package/dist/native-modules/widgets/fileManager/ej2-fileManager.d.ts +0 -9
- package/dist/native-modules/widgets/fileManager/ej2-fileManager.js +0 -31
- package/dist/native-modules/widgets/grid/ej2-grid.d.ts +0 -8
- package/dist/native-modules/widgets/grid/ej2-grid.js +0 -94
- package/dist/native-modules/widgets/listView/ej2-listView.d.ts +0 -8
- package/dist/native-modules/widgets/listView/ej2-listView.js +0 -31
- package/dist/native-modules/widgets/maskedTextBox/ej2-maskedTextBox.d.ts +0 -8
- package/dist/native-modules/widgets/maskedTextBox/ej2-maskedTextBox.js +0 -34
- package/dist/native-modules/widgets/multiSelect/ej2-multiSelect.d.ts +0 -10
- package/dist/native-modules/widgets/multiSelect/ej2-multiSelect.js +0 -41
- package/dist/native-modules/widgets/numericTextBox/ej2-numericTextBox.d.ts +0 -8
- package/dist/native-modules/widgets/numericTextBox/ej2-numericTextBox.js +0 -32
- package/dist/native-modules/widgets/pager/ej2-pager.d.ts +0 -7
- package/dist/native-modules/widgets/pager/ej2-pager.js +0 -26
- package/dist/native-modules/widgets/progressButton/ej2-progress-button.d.ts +0 -17
- package/dist/native-modules/widgets/progressButton/ej2-progress-button.js +0 -61
- package/dist/native-modules/widgets/radio/ej2-radio.d.ts +0 -13
- package/dist/native-modules/widgets/radio/ej2-radio.js +0 -51
- package/dist/native-modules/widgets/schedule/ej2-schedule.d.ts +0 -8
- package/dist/native-modules/widgets/schedule/ej2-schedule.js +0 -29
- package/dist/native-modules/widgets/sidebar/ej2-sidebar.d.ts +0 -7
- package/dist/native-modules/widgets/sidebar/ej2-sidebar.js +0 -27
- package/dist/native-modules/widgets/slider/ej2-slider.d.ts +0 -8
- package/dist/native-modules/widgets/slider/ej2-slider.js +0 -34
- package/dist/native-modules/widgets/splitter/ej2-splitter.d.ts +0 -7
- package/dist/native-modules/widgets/splitter/ej2-splitter.js +0 -26
- package/dist/native-modules/widgets/switch/ej2-switch.d.ts +0 -11
- package/dist/native-modules/widgets/switch/ej2-switch.js +0 -49
- package/dist/native-modules/widgets/textBox/ej2-textBox.d.ts +0 -8
- package/dist/native-modules/widgets/textBox/ej2-textBox.js +0 -34
- package/dist/native-modules/widgets/timePicker/ej2-timePicker.d.ts +0 -8
- package/dist/native-modules/widgets/timePicker/ej2-timePicker.js +0 -32
- package/dist/native-modules/widgets/treeView/ej2-treeView.d.ts +0 -7
- package/dist/native-modules/widgets/treeView/ej2-treeView.js +0 -26
- package/dist/native-modules/widgets/uploader/ej2-uploader.d.ts +0 -50
- package/dist/native-modules/widgets/uploader/ej2-uploader.js +0 -343
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { constants } from '../../common/constants';
|
|
11
|
-
import { Uploader } from "@syncfusion/ej2-inputs";
|
|
12
|
-
import { SyncfusionWrapper } from "../../common/syncfusionWrapper";
|
|
13
|
-
import { generateBindables } from "../../utilities/decorator";
|
|
14
|
-
import { bindable } from 'aurelia-framework';
|
|
15
|
-
import { v4 as uuid } from "uuid";
|
|
16
|
-
import { inlineView, customElement } from 'aurelia-framework';
|
|
17
|
-
let Ej2Uploader = class Ej2Uploader extends SyncfusionWrapper {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this._filesProperty = `${constants.bindablePrefix}files`;
|
|
21
|
-
this.originalFiles = null;
|
|
22
|
-
this._filesCollectionSubscription = null;
|
|
23
|
-
this._privateIdProperty = "__id";
|
|
24
|
-
this.syncfusionWidgetType = Uploader;
|
|
25
|
-
this.mapAdditionalFilePropertiesToFiles = true;
|
|
26
|
-
this.sendAdditionalFilePropertiesAsFormData = true;
|
|
27
|
-
this.metadata = null;
|
|
28
|
-
this.formDataProperty = "metadata";
|
|
29
|
-
this.metadataGenerator = null;
|
|
30
|
-
this.uploadResultModel = null;
|
|
31
|
-
this.dataAdapter = null;
|
|
32
|
-
this.autoRemoveServerFiles = true;
|
|
33
|
-
this.context = null;
|
|
34
|
-
this.files = null;
|
|
35
|
-
this.firstBind = true;
|
|
36
|
-
this.serverDelete = true;
|
|
37
|
-
}
|
|
38
|
-
get _files() {
|
|
39
|
-
return this[this._filesProperty];
|
|
40
|
-
}
|
|
41
|
-
onWrapperCreated() {
|
|
42
|
-
this.widget.uploading = (args) => { this.onFileUpload(args); };
|
|
43
|
-
this.widget.success = (args) => { this.success(args); };
|
|
44
|
-
this.widget.failure = (args) => { this.failure(args); };
|
|
45
|
-
this.widget.removing = (args) => { this.removing(args); };
|
|
46
|
-
this.widget.change = (args) => { this.change(); };
|
|
47
|
-
if (this.dataAdapter) {
|
|
48
|
-
if (this.dataAdapter.remove) {
|
|
49
|
-
let _this = this;
|
|
50
|
-
this.widget.removeUploadedFile = function async(file, eventArgs, removeDirectly, custom) {
|
|
51
|
-
let formData = new FormData();
|
|
52
|
-
let selectedFiles = file;
|
|
53
|
-
_this.widget.trigger("removing", eventArgs, function (eventArgs) {
|
|
54
|
-
_this.widget.removingEventCallback(eventArgs, formData, selectedFiles, file);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
this.widget.asyncSettings.removeUrl = null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
onfilesChanged() {
|
|
62
|
-
if (!this.firstBind) {
|
|
63
|
-
this.widget.clearAll();
|
|
64
|
-
this.recreate();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
recreating() {
|
|
68
|
-
this._filesCollectionSubscription.dispose();
|
|
69
|
-
this[this._filesProperty].splice(0, this[this._filesProperty].length, ...this.originalFiles);
|
|
70
|
-
}
|
|
71
|
-
recreated() {
|
|
72
|
-
this.initializeFileCollection();
|
|
73
|
-
this._filesCollectionSubscription = this.createFilesCollectionSubscription();
|
|
74
|
-
}
|
|
75
|
-
initializeFileCollection() {
|
|
76
|
-
if (this.files && Array.isArray(this.files)) {
|
|
77
|
-
this.widget.files.push(...JSON.parse(JSON.stringify(this.files)));
|
|
78
|
-
}
|
|
79
|
-
if (this.widget.files) {
|
|
80
|
-
let extraProperties = [];
|
|
81
|
-
let widgetFiles = this.widget.getFilesData();
|
|
82
|
-
if (this.mapAdditionalFilePropertiesToFiles) {
|
|
83
|
-
extraProperties = this.getAdditionalFileProperties();
|
|
84
|
-
}
|
|
85
|
-
for (let i = 0; i < widgetFiles.length; i++) {
|
|
86
|
-
const file = widgetFiles[i];
|
|
87
|
-
this.initializeFile(file, i, extraProperties);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
initializeFile(widgetFile, i, extraProperties) {
|
|
92
|
-
let __id = uuid();
|
|
93
|
-
widgetFile[this._privateIdProperty] = __id;
|
|
94
|
-
this._files[i][this._privateIdProperty] = __id;
|
|
95
|
-
extraProperties.forEach((prop) => {
|
|
96
|
-
widgetFile[prop] = this._files[i][prop];
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
onWidgetCreated() {
|
|
100
|
-
this.initializeFileCollection();
|
|
101
|
-
this._filesCollectionSubscription = this.createFilesCollectionSubscription();
|
|
102
|
-
this.subscriptions.push(this._filesCollectionSubscription);
|
|
103
|
-
}
|
|
104
|
-
onBind() {
|
|
105
|
-
this.firstBind = false;
|
|
106
|
-
this.subscriptions.push(this.bindingEngine.propertyObserver(this, "files").subscribe(() => { this.onfilesChanged(); }));
|
|
107
|
-
if (this[this._filesProperty] && Array.isArray(this[this._filesProperty])) {
|
|
108
|
-
this.originalFiles = JSON.parse(JSON.stringify(this[this._filesProperty]));
|
|
109
|
-
}
|
|
110
|
-
else if (this.files && Array.isArray(this.files)) {
|
|
111
|
-
this.originalFiles = JSON.parse(JSON.stringify(this.files));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
this.originalFiles = [];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
createFilesCollectionSubscription() {
|
|
118
|
-
if (!this._files) {
|
|
119
|
-
this[this._filesProperty] = [];
|
|
120
|
-
}
|
|
121
|
-
return this.bindingEngine.collectionObserver(this._files).subscribe((changed) => { });
|
|
122
|
-
}
|
|
123
|
-
change() {
|
|
124
|
-
if (this.autoRemoveServerFiles) {
|
|
125
|
-
this.getFilesThatWereRemoved().forEach((file) => {
|
|
126
|
-
this.removing({
|
|
127
|
-
filesData: [file],
|
|
128
|
-
customFormData: null,
|
|
129
|
-
event: null,
|
|
130
|
-
cancel: false
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
getFilesThatWereRemoved() {
|
|
136
|
-
let filesToRemove = [];
|
|
137
|
-
let widgetFiles = this.widget.getFilesData();
|
|
138
|
-
if (this[this._filesProperty].length !== widgetFiles.length) {
|
|
139
|
-
for (let i = 0; i < this[this._filesProperty].length; i++) {
|
|
140
|
-
const file = this[this._filesProperty][i];
|
|
141
|
-
if (!widgetFiles.find((x) => x[this._privateIdProperty] === file[this._privateIdProperty])) {
|
|
142
|
-
filesToRemove.push(file);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return filesToRemove;
|
|
147
|
-
}
|
|
148
|
-
removeAll() {
|
|
149
|
-
this.widget.getFilesData().forEach((file) => {
|
|
150
|
-
this.removeFile(file);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
removeFile(file) {
|
|
154
|
-
this.widget.remove(file);
|
|
155
|
-
}
|
|
156
|
-
async removing(args) {
|
|
157
|
-
let event = new CustomEvent("on-removing", {
|
|
158
|
-
bubbles: true,
|
|
159
|
-
detail: args
|
|
160
|
-
});
|
|
161
|
-
this.element.dispatchEvent(event);
|
|
162
|
-
if (args.cancel) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (this.dataAdapter && this.dataAdapter.remove) {
|
|
166
|
-
try {
|
|
167
|
-
if (this.serverDelete) {
|
|
168
|
-
await this.dataAdapter.remove.call(this.context || this.bindingContext, args.filesData[0]);
|
|
169
|
-
}
|
|
170
|
-
this.onRemoveSuccess(args);
|
|
171
|
-
this.onWidgetRemoveComplete(null, args);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
this.onWidgetRemoveFailed(error, args);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
onWidgetRemoveComplete(response, args) {
|
|
179
|
-
this.widget.removeCompleted(response, args.filesData[0], false);
|
|
180
|
-
}
|
|
181
|
-
onWidgetRemoveFailed(e, args) {
|
|
182
|
-
this.widget.removeFailed(e, args.filesData[0], false);
|
|
183
|
-
}
|
|
184
|
-
onRemoveSuccess(args) {
|
|
185
|
-
let _file = args.filesData[0];
|
|
186
|
-
let index = this[this._filesProperty].findIndex((x) => x.__id === _file.__id);
|
|
187
|
-
if (index !== -1) {
|
|
188
|
-
const removedFile = this[this._filesProperty].splice(index, 1)[0];
|
|
189
|
-
let event = new CustomEvent("on-remove-success", {
|
|
190
|
-
bubbles: true,
|
|
191
|
-
detail: { args: args, removedFile: removedFile }
|
|
192
|
-
});
|
|
193
|
-
this.element.dispatchEvent(event);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
success(args) {
|
|
197
|
-
if (args.operation === "upload") {
|
|
198
|
-
let response = JSON.parse(args.e.target.response);
|
|
199
|
-
let _uploadedFile = args.file;
|
|
200
|
-
let fileName = _uploadedFile.name.substr(0, _uploadedFile.name.length - (_uploadedFile.type.length + 1));
|
|
201
|
-
let additionalProperties = {};
|
|
202
|
-
additionalProperties[this._privateIdProperty] = uuid();
|
|
203
|
-
if (this.uploadResultModel) {
|
|
204
|
-
for (let prop in this.uploadResultModel) {
|
|
205
|
-
additionalProperties[this.uploadResultModel[prop]] = response[prop];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
let file = {
|
|
209
|
-
name: fileName,
|
|
210
|
-
size: _uploadedFile.size,
|
|
211
|
-
type: `.${_uploadedFile.type}`
|
|
212
|
-
};
|
|
213
|
-
Object.assign(_uploadedFile, additionalProperties);
|
|
214
|
-
Object.assign(file, additionalProperties);
|
|
215
|
-
if (this[this._filesProperty] === null) {
|
|
216
|
-
this[this._filesProperty] = [];
|
|
217
|
-
}
|
|
218
|
-
this[this._filesProperty].push(file);
|
|
219
|
-
let uploadedEvent = new CustomEvent("on-uploaded", {
|
|
220
|
-
bubbles: true,
|
|
221
|
-
detail: { args: args, uploadedFile: file }
|
|
222
|
-
});
|
|
223
|
-
this.element.dispatchEvent(uploadedEvent);
|
|
224
|
-
}
|
|
225
|
-
else if (args.operation === "remove") {
|
|
226
|
-
}
|
|
227
|
-
let successEvent = new CustomEvent("on-success", {
|
|
228
|
-
bubbles: true,
|
|
229
|
-
detail: args
|
|
230
|
-
});
|
|
231
|
-
this.element.dispatchEvent(successEvent);
|
|
232
|
-
}
|
|
233
|
-
failure(args) {
|
|
234
|
-
let event = new CustomEvent("on-failure", {
|
|
235
|
-
bubbles: true,
|
|
236
|
-
detail: args
|
|
237
|
-
});
|
|
238
|
-
this.element.dispatchEvent(event);
|
|
239
|
-
}
|
|
240
|
-
getAdditionalFileProperties() {
|
|
241
|
-
let extraProperties = [];
|
|
242
|
-
if (this[this._filesProperty] && this[this._filesProperty].length > 0) {
|
|
243
|
-
for (let prop in this[this._filesProperty][0]) {
|
|
244
|
-
if (prop !== "name" && prop !== "size" && prop !== "type") {
|
|
245
|
-
extraProperties.push(prop);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return extraProperties;
|
|
250
|
-
}
|
|
251
|
-
onFileUpload(args) {
|
|
252
|
-
let _metadata = this.createMetadata(args.fileData);
|
|
253
|
-
if (_metadata) {
|
|
254
|
-
if (this.formDataProperty) {
|
|
255
|
-
let formData = {};
|
|
256
|
-
formData[this.formDataProperty] = JSON.stringify(_metadata);
|
|
257
|
-
args.customFormData = [formData];
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
let formData = [];
|
|
261
|
-
for (let prop in _metadata) {
|
|
262
|
-
let kvp = {};
|
|
263
|
-
kvp[prop] = _metadata[prop];
|
|
264
|
-
formData.push(kvp);
|
|
265
|
-
}
|
|
266
|
-
args.customFormData = formData;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
let event = new CustomEvent("on-uploading", {
|
|
270
|
-
bubbles: true,
|
|
271
|
-
detail: args
|
|
272
|
-
});
|
|
273
|
-
this.element.dispatchEvent(event);
|
|
274
|
-
}
|
|
275
|
-
createMetadata(file) {
|
|
276
|
-
let _metadata = null;
|
|
277
|
-
if (this.sendAdditionalFilePropertiesAsFormData) {
|
|
278
|
-
if (_metadata === null) {
|
|
279
|
-
_metadata = {};
|
|
280
|
-
}
|
|
281
|
-
let props = this.getAdditionalFileProperties();
|
|
282
|
-
props.forEach((prop) => {
|
|
283
|
-
_metadata[prop] = file[prop];
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
if (this.metadata !== null) {
|
|
287
|
-
if (_metadata === null) {
|
|
288
|
-
_metadata = {};
|
|
289
|
-
}
|
|
290
|
-
Object.assign(_metadata, this.metadata);
|
|
291
|
-
}
|
|
292
|
-
if (this.metadataGenerator) {
|
|
293
|
-
if (_metadata === null) {
|
|
294
|
-
_metadata = {};
|
|
295
|
-
}
|
|
296
|
-
let _generatedMetadata = this.metadataGenerator.call(this.context || this.bindingContext, file);
|
|
297
|
-
Object.assign(_metadata, _generatedMetadata);
|
|
298
|
-
}
|
|
299
|
-
return _metadata;
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
__decorate([
|
|
303
|
-
bindable,
|
|
304
|
-
__metadata("design:type", Object)
|
|
305
|
-
], Ej2Uploader.prototype, "metadata", void 0);
|
|
306
|
-
__decorate([
|
|
307
|
-
bindable,
|
|
308
|
-
__metadata("design:type", Object)
|
|
309
|
-
], Ej2Uploader.prototype, "formDataProperty", void 0);
|
|
310
|
-
__decorate([
|
|
311
|
-
bindable,
|
|
312
|
-
__metadata("design:type", Function)
|
|
313
|
-
], Ej2Uploader.prototype, "metadataGenerator", void 0);
|
|
314
|
-
__decorate([
|
|
315
|
-
bindable,
|
|
316
|
-
__metadata("design:type", Object)
|
|
317
|
-
], Ej2Uploader.prototype, "uploadResultModel", void 0);
|
|
318
|
-
__decorate([
|
|
319
|
-
bindable,
|
|
320
|
-
__metadata("design:type", Object)
|
|
321
|
-
], Ej2Uploader.prototype, "dataAdapter", void 0);
|
|
322
|
-
__decorate([
|
|
323
|
-
bindable,
|
|
324
|
-
__metadata("design:type", Object)
|
|
325
|
-
], Ej2Uploader.prototype, "autoRemoveServerFiles", void 0);
|
|
326
|
-
__decorate([
|
|
327
|
-
bindable,
|
|
328
|
-
__metadata("design:type", Object)
|
|
329
|
-
], Ej2Uploader.prototype, "context", void 0);
|
|
330
|
-
__decorate([
|
|
331
|
-
bindable,
|
|
332
|
-
__metadata("design:type", Array)
|
|
333
|
-
], Ej2Uploader.prototype, "files", void 0);
|
|
334
|
-
__decorate([
|
|
335
|
-
bindable,
|
|
336
|
-
__metadata("design:type", Boolean)
|
|
337
|
-
], Ej2Uploader.prototype, "serverDelete", void 0);
|
|
338
|
-
Ej2Uploader = __decorate([
|
|
339
|
-
generateBindables("uploader"),
|
|
340
|
-
inlineView(`<template><input element.ref="widgetElement" type="file" name="UploadFiles" /></template>`),
|
|
341
|
-
customElement('ej2-uploader')
|
|
342
|
-
], Ej2Uploader);
|
|
343
|
-
export { Ej2Uploader };
|