You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2019/06/10 15:32:27 UTC

[airavata-django-portal] 05/08: AIRAVATA-3057 Retain null file entry in MultiFileInputEditor

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git

commit a945fb5e49f3c8efa01894c66a653387bbe7ec1f
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon Jun 10 10:56:24 2019 -0400

    AIRAVATA-3057 Retain null file entry in MultiFileInputEditor
---
 .../input-editors/MultiFileInputEditor.vue         | 25 ++++++++++++++++------
 .../components/storage/UserStoragePathViewer.vue   |  6 ++++--
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/MultiFileInputEditor.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/MultiFileInputEditor.vue
index 0d02ec4..30204e3 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/MultiFileInputEditor.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/experiment/input-editors/MultiFileInputEditor.vue
@@ -49,7 +49,7 @@ export default {
       });
     },
     updatedFile(newValue, fileEntry) {
-      if (!newValue) {
+      if (!newValue && fileEntry.value) {
         this.removeFile(fileEntry);
       } else {
         fileEntry.value = newValue;
@@ -58,7 +58,6 @@ export default {
         .filter(e => e.value) // exclude null entries
         .map(e => e.value)
         .join(",");
-      this.fileEntries = this.createFileEntries(this.data);
       this.valueChanged();
     },
     removeFile(fileEntry) {
@@ -82,13 +81,25 @@ export default {
         };
       });
       // Add a null entry to accept an additional upload
-      fileEntries.push({
-        id: this.id + "-" + this.newFileCount++,
-        value: null,
-        uploading: false
-      });
+      fileEntries.push(this.getNullFileEntry());
       return fileEntries;
     },
+    getNullFileEntry() {
+      // Reuse the old null entry if it exists, otherwise create a new one
+      if (
+        this.fileEntries &&
+        this.fileEntries.length > 0 &&
+        this.fileEntries[this.fileEntries.length - 1].value === null
+      ) {
+        return this.fileEntries[this.fileEntries.length - 1];
+      } else {
+        return {
+          id: this.id + "-" + this.newFileCount++,
+          value: null,
+          uploading: false
+        };
+      }
+    },
     uploadStart(fileEntry) {
       fileEntry.uploading = true;
       this.$emit("uploadstart");
diff --git a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
index e8e86ff..3351fd1 100644
--- a/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
+++ b/django_airavata/apps/workspace/static/django_airavata_workspace/js/components/storage/UserStoragePathViewer.vue
@@ -166,8 +166,10 @@ export default {
       this.$emit("directory-selected", item.path);
     },
     isAlreadySelected(item) {
-      return this.selectedDataProductUris.find(
-        uri => item.type === "file" && uri === item.dataProductURI
+      return (
+        this.selectedDataProductUris.find(
+          uri => item.type === "file" && uri === item.dataProductURI
+        ) !== undefined
       );
     }
   }