airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata-django-portal] 01/03: AIRAVATA-2876 removing implicit update from ShareButton
Date Mon, 17 Sep 2018 17:08:34 GMT
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 ca087faee978fe699800e6caee84d3af7fd9e606
Author: Marcus Christie <machrist@iu.edu>
AuthorDate: Mon Sep 17 12:33:02 2018 -0400

    AIRAVATA-2876 removing implicit update from ShareButton
---
 .../GroupComputeResourcePreference.vue             | 16 +++++++++--
 .../static/common/js/components/ShareButton.vue    | 33 ++--------------------
 2 files changed, 16 insertions(+), 33 deletions(-)

diff --git a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
index 15d8a52..74a85ea 100644
--- a/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
+++ b/django_airavata/apps/admin/static/django_airavata_admin/src/components/admin/group_resource_preferences/GroupComputeResourcePreference.vue
@@ -13,7 +13,7 @@
               <b-form-input id="profile-name" type="text" v-model="data.groupResourceProfileName"
required placeholder="Name of this Group Resource Profile">
               </b-form-input>
             </b-form-group>
-            <share-button ref="shareButton" v-model="sharedEntity" />
+            <share-button ref="shareButton" v-model="sharedEntity" @save="saveSharedEntity"
/>
           </div>
         </div>
       </div>
@@ -152,15 +152,25 @@ export default {
         persist = this.service.update({ data: this.data, lookup: this.id });
       } else {
         persist = this.service.create({ data: this.data }).then(data => {
-          // Save sharing settings too
+          // Merge sharing settings with default sharing settings created when
+          // Group Resource Profile was created
           const groupResourceProfileId = data.groupResourceProfileId;
-          return this.$refs.shareButton.mergeAndSave(groupResourceProfileId);
+          return services.SharedEntityService.merge({
+            data: this.sharedEntity,
+            lookup: groupResourceProfileId
+          });
         });
       }
       persist.then(data => {
         this.$router.push("/group-resource-profiles");
       });
     },
+    saveSharedEntity: function(sharedEntity) {
+      return services.SharedEntityService.update({
+        data: sharedEntity,
+        lookup: sharedEntity.entityId
+      });
+    },
     getComputeResourceName: function(computeResourceId) {
       // TODO: load compute resources to get the real name
       return computeResourceId && computeResourceId.indexOf("_") > 0
diff --git a/django_airavata/static/common/js/components/ShareButton.vue b/django_airavata/static/common/js/components/ShareButton.vue
index 0cbdf4b..251a17b 100644
--- a/django_airavata/static/common/js/components/ShareButton.vue
+++ b/django_airavata/static/common/js/components/ShareButton.vue
@@ -5,9 +5,7 @@
       <b-badge>{{ totalCount }}</b-badge>
     </b-button>
     <b-modal id="modal-share-settings" title="Sharing Settings" ref="modalSharingSettings"
ok-title="Save" @ok="saveSharedEntity"
-      @cancel="cancelEditSharedEntity" no-close-on-esc no-close-on-backdrop hide-header-close
:ok-disabled="loading" :cancel-disabled="loading"
-      @show="showSharingSettingsModal">
-      <b-alert variant="danger" :show="!!errorMessage">{{errorMessage}}</b-alert>
+      @cancel="cancelEditSharedEntity" no-close-on-esc no-close-on-backdrop hide-header-close
@show="showSharingSettingsModal">
       <b-form-group label="Search for users/groups" labelFor="user-groups-autocomplete">
         <autocomplete-text-input id="user-groups-autocomplete" :suggestions="usersAndGroupsSuggestions"
@selected="suggestionSelected">
           <template slot="suggestion" slot-scope="slotProps">
@@ -88,8 +86,6 @@ export default {
       ],
       users: [],
       groups: [],
-      errorMessage: null,
-      loading: false,
       sharedEntityCopy: null
     };
   },
@@ -256,33 +252,10 @@ export default {
       );
     },
     saveSharedEntity: function(event) {
-      // If entity hasn't been persisted yet then just emitValueChanged.
-      // Sharing settings will need to be saved later (see mergeAndSave).
-      if (!this.sharedEntity.entityId) {
-        this.emitValueChanged();
-        return;
-      }
-      // Prevent hiding the modal, hide it programmatically
-      this.errorMessage = null;
-      this.loading = true;
-      event.preventDefault();
-      services.SharedEntityService.update({
-        data: this.sharedEntity,
-        lookup: this.sharedEntity.entityId
-      })
-        .then(sharedEntity => {
-          this.emitValueChanged();
-          this.$refs.modalSharingSettings.hide();
-        })
-        .catch(error => {
-          console.log("Error occurred while saving:", error);
-          this.errorMessage =
-            "Error occurred while saving: " + JSON.stringify(error);
-        })
-        .then(() => (this.loading = false), () => (this.loading = false));
+      this.emitValueChanged();
+      this.$emit("save", this.sharedEntity);
     },
     cancelEditSharedEntity: function(event) {
-      this.errorMessage = null;
       this.sharedEntity = this.sharedEntityCopy;
     },
     emitValueChanged: function() {


Mime
View raw message