Skip to content

Commit

Permalink
add internal and external import events
Browse files Browse the repository at this point in the history
  • Loading branch information
olifolkerd committed Mar 29, 2024
1 parent 48ce809 commit 1511545
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
13 changes: 12 additions & 1 deletion dist/js/tabulator_esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13337,6 +13337,9 @@ class Import extends Module{
.then(this.structureData.bind(this))
.then(this.setData.bind(this))
.catch((err) => {
this.dispatch("import-error", err);
this.dispatchExternal("importError", err);

console.error("Import Error:", err || "Unable to import file");
return Promise.reject(err);
});
Expand All @@ -13352,6 +13355,9 @@ class Import extends Module{
input.addEventListener("change", (e) => {
var file = input.files[0],
reader = new FileReader();

this.dispatch("import-importing", input.files);
this.dispatchExternal("importImporting", input.files);

switch(importReader || this.table.options.importReader){
case "buffer":
Expand Down Expand Up @@ -13380,7 +13386,9 @@ class Import extends Module{
reject();
};
});


this.dispatch("import-choose");
this.dispatchExternal("importChoose");
input.click();
});
}
Expand Down Expand Up @@ -13457,6 +13465,9 @@ class Import extends Module{
}

setData(data){
this.dispatch("import-imported", data);
this.dispatchExternal("importImported", data);

return this.table.setData(data);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/js/tabulator_esm.js.map

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion src/js/modules/Import/Import.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default class Import extends Module{
.then(this.structureData.bind(this))
.then(this.setData.bind(this))
.catch((err) => {
this.dispatch("import-error", err);
this.dispatchExternal("importError", err);

console.error("Import Error:", err || "Unable to import file");
return Promise.reject(err);
});
Expand All @@ -82,6 +85,9 @@ export default class Import extends Module{
input.addEventListener("change", (e) => {
var file = input.files[0],
reader = new FileReader();

this.dispatch("import-importing", input.files);
this.dispatchExternal("importImporting", input.files);

switch(importReader || this.table.options.importReader){
case "buffer":
Expand Down Expand Up @@ -110,7 +116,9 @@ export default class Import extends Module{
reject();
};
});


this.dispatch("import-choose");
this.dispatchExternal("importChoose");
input.click();
});
}
Expand Down Expand Up @@ -187,6 +195,9 @@ export default class Import extends Module{
}

setData(data){
this.dispatch("import-imported", data);
this.dispatchExternal("importImported", data);

return this.table.setData(data);
}
}

0 comments on commit 1511545

Please sign in to comment.