From bdc2b29abe41f05ce0d787fdb880468db6bd768b Mon Sep 17 00:00:00 2001 From: TinCodes Date: Fri, 6 Sep 2024 15:37:12 -0400 Subject: [PATCH 1/2] Implemented BE for PI Process import --- .../import/components/ImportPIModal.vue | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/resources/js/processes/import/components/ImportPIModal.vue b/resources/js/processes/import/components/ImportPIModal.vue index f1d37a0135..35bbcefe4c 100644 --- a/resources/js/processes/import/components/ImportPIModal.vue +++ b/resources/js/processes/import/components/ImportPIModal.vue @@ -77,16 +77,33 @@ export default { } this.$root.file = this.file; - let formData = new FormData(); - formData.append('file', this.file); - this.fileIsValid = true; }, removeFile() { this.file = ''; this.fileIsValid = false; }, - importNewPI() {} + importNewPI() { + console.log('> ', this.file); + if (!this.file) { + return; + } + + let formData = new FormData(); + formData.append('file', this.file); + + ProcessMaker.apiClient + .post(`/package-ai/pi_process/import`, formData) + .then((response) => { + // TODO: Make import and redirect to Modeler + }) + .catch((error) => { + window.ProcessMaker.alert( + this.$t("An error ocurred while importing the current PI Process."), + "danger", + ); + }); + } }, computed: { title() { From d4b8a357141b5a5b9ef3ba4949d5891667cae22c Mon Sep 17 00:00:00 2001 From: TinCodes Date: Fri, 6 Sep 2024 15:44:54 -0400 Subject: [PATCH 2/2] Added missing translation and removed log --- resources/js/processes/import/components/ImportPIModal.vue | 1 - resources/lang/en.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/js/processes/import/components/ImportPIModal.vue b/resources/js/processes/import/components/ImportPIModal.vue index 35bbcefe4c..e0228a700d 100644 --- a/resources/js/processes/import/components/ImportPIModal.vue +++ b/resources/js/processes/import/components/ImportPIModal.vue @@ -84,7 +84,6 @@ export default { this.fileIsValid = false; }, importNewPI() { - console.log('> ', this.file); if (!this.file) { return; } diff --git a/resources/lang/en.json b/resources/lang/en.json index afc538fd59..e3a9e68c8b 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -121,6 +121,7 @@ "Alpha-Numeric": "Alpha-Numeric", "Alpha": "Alpha", "An error occurred. Check the form for errors in red text.": "An error occurred. Check the form for errors in red text.", + "An error ocurred while importing the current PI Process.": "An error ocurred while importing the current PI Process.", "An existing user has been found with the email {{ email }} would you like to save and reactivate their account?": "An existing user has been found with the email {{ email }} would you like to save and reactivate their account?", "An existing user has been found with the email {{ username }} would you like to save and reactivate their account?": "An existing user has been found with the username {{ username }} would you like to save and reactivate their account?", "Analytics Chart": "Analytics Chart",