From 799ed2459f5b88550fe5ce9e7b1ec63d47580b31 Mon Sep 17 00:00:00 2001 From: temi Date: Wed, 11 Dec 2024 17:14:21 +1100 Subject: [PATCH] better feedback when uploading activity --- grails-app/assets/javascripts/offline-list.js | 15 +++++++++++--- .../views/bioActivity/pwaOfflineList.gsp | 20 +++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/grails-app/assets/javascripts/offline-list.js b/grails-app/assets/javascripts/offline-list.js index 9ff3f695c..fcaf8d15c 100644 --- a/grails-app/assets/javascripts/offline-list.js +++ b/grails-app/assets/javascripts/offline-list.js @@ -10,6 +10,15 @@ function ActivitiesViewModel (config) { self.disableUpload = ko.computed(function () { return self.activities().length === 0 || !self.online(); }); + // check if any activity is uploading + self.isUploading = ko.computed(function () { + var activities = self.activities(); + for (var i = 0; i < activities.length; i++) { + if (activities[i].uploading()) { + return true; + } + } + }); self.init = function() { @@ -271,11 +280,11 @@ function ActivityViewModel (activity, parent) { data: toSave, contentType: 'application/json', success: function success(data) { - if (data.errors || data.error) { - deferred.reject({data: {oldActivityId: oldActivityId, error: data.errors || data.error}}); + if (data && data.resp && data.resp.activityId) { + deferred.resolve({data: {oldActivityId: oldActivityId, activityId: data.resp.activityId }}); } else { - deferred.resolve({data: {oldActivityId: oldActivityId, activityId: data.resp.activityId }}); + deferred.reject({data: {oldActivityId: oldActivityId, error: data.errors || data.error}}); } }, error: function (jqXHR, status, error) { diff --git a/grails-app/views/bioActivity/pwaOfflineList.gsp b/grails-app/views/bioActivity/pwaOfflineList.gsp index 1d634bee3..617805736 100644 --- a/grails-app/views/bioActivity/pwaOfflineList.gsp +++ b/grails-app/views/bioActivity/pwaOfflineList.gsp @@ -32,7 +32,15 @@