You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/09/13 15:33:46 UTC

[whimsy] branch master updated: wire up task completion

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

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  8ee1664   wire up task completion
8ee1664 is described below

commit 8ee1664cc3c3706584bb13661c80f9749dc9749e
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Sep 13 11:33:31 2016 -0400

    wire up task completion
---
 www/secmail/public/tasklist.js     | 14 ++++++++----
 www/secmail/views/forms/icla.js.rb | 28 +++++++++++-------------
 www/secmail/views/parts.js.rb      | 44 ++++++++++++++------------------------
 3 files changed, 38 insertions(+), 48 deletions(-)

diff --git a/www/secmail/public/tasklist.js b/www/secmail/public/tasklist.js
index 27f0f01..c5ec8d4 100644
--- a/www/secmail/public/tasklist.js
+++ b/www/secmail/public/tasklist.js
@@ -75,9 +75,11 @@ function nexttask(proceed) {
       $('h1').removeClass('bg-info').addClass('bg-danger').
         text('Processing Aborted');
       message = {status: 'aborted'}
+      $('button').text('resume').prop('disabled', false);
     } else {
       $('h1').removeClass('bg-info').addClass('bg-success').
         text('Processing Complete');
+      $('button').text('mail index').prop('disabled', false);
       message = {status: 'complete'}
     }
 
@@ -87,10 +89,14 @@ function nexttask(proceed) {
 
 // start the process when the button is clicked
 $('button').click(function(event) {
-  $('h1').removeClass('bg-warning').addClass('bg-info').
-    text('Request Status');
-  $(this).prop('disabled', true);
-  nexttask(true);
+  if (tasks.length) {
+    $('h1').removeClass('bg-warning').addClass('bg-info').
+      text('Request Status');
+    $(this).prop('disabled', true);
+    nexttask(true);
+  } else {
+    window.parent.location.href = '..';
+  }
 });
 
 // have delete key return to index
diff --git a/www/secmail/views/forms/icla.js.rb b/www/secmail/views/forms/icla.js.rb
index 9b7bbb2..782d709 100644
--- a/www/secmail/views/forms/icla.js.rb
+++ b/www/secmail/views/forms/icla.js.rb
@@ -103,11 +103,11 @@ class ICLA < React
     self.componentDidUpdate()
 
     # watch for status updates
-    window.addEventListener 'message' do |event|
-      console.log(event)
-      @submitted = false
-      @filed = false
-    end
+    window.addEventListener 'message', self.status_update
+  end
+
+  def componentWillUnmount()
+    window.removeEventListener 'message', self.status_update
   end
 
   # as fields change, enable/disable the associated buttons and adjust
@@ -145,19 +145,9 @@ class ICLA < React
   # handle ICLA form submission
   def file(event)
     @submitted = true
-
-#   @@submit.call(event).then {|response|
-#     @filed = true
-#     @submitted = false
-#     alert response.result
-#   }.catch {
-#     @filed = false
-#     @submitted = false
-#   }
+    @filed = true
   end
 
-
-
   # validate userid is available
   def validate_userid(event)
     return unless @user and @user != @checked
@@ -179,4 +169,10 @@ class ICLA < React
     window.parent.frames.content.location.href = 
       "https://id.apache.org/acreq/members/?" + params.join('&')
   end
+
+  # when tasks complete (or are aborted) reset form
+  def status_update(event)
+    @submitted = false
+    @filed = false
+  end
 end
diff --git a/www/secmail/views/parts.js.rb b/www/secmail/views/parts.js.rb
index 86b8a0e..afd9d11 100644
--- a/www/secmail/views/parts.js.rb
+++ b/www/secmail/views/parts.js.rb
@@ -161,7 +161,7 @@ class Parts < React
       else
 
         React.createElement @form, headers: @headers, selected: @selected,
-          signature: signature, submit: self.submit
+          signature: signature
 
       end
     end
@@ -200,6 +200,8 @@ class Parts < React
     self.hideMenu()
 
     self.extractHeaders(@@headers)
+
+    window.addEventListener 'message', self.status_update
   end
 
   def componentWillReceiveProps()
@@ -290,8 +292,12 @@ class Parts < React
 
     @busy = true
     HTTP.post('../../actions/delete-attachment', data).then {|response|
-      if response.attachments and not response.attachments.empty?
-        @attachments = response.attachments
+      @attachments = response.attachments
+      if event.type == 'message'
+        signature = CheckSignature.find(@selected, @attachments)
+        @selected = signature
+        self.delete_attachment(event) if signature
+      elsif response.attachments and not response.attachments.empty?
         self.hideMenu()
         window.parent.frames.content.location.href='_body_'
       else
@@ -352,31 +358,6 @@ class Parts < React
   #                            Miscellaneous                             #
   ########################################################################
 
-  # form submission - handles all forms
-  def submit(event)
-    event.preventDefault()
-    form = event.currentTarget
-
-    # collect up name of selected attachment and all input fields
-    data = {message: window.parent.location.pathname, selected: @selected}
-    Array(form.querySelectorAll('input')).each do |field|
-      data[field.name] = field.value if field.name
-    end
-
-    # add signature (if present)
-    data.signature = CheckSignature.find(@selected, @attachments)
-
-    # submit HTTP post request
-    @busy = true
-    return HTTP.post(form.action, data).then {|response|
-      @busy = false
-      return response
-    }.catch {|error|
-      alert error
-      @busy = false
-    }
-  end
-
   # clicking on an attachment selects it
   def select(event)
     self.selectPart event.currentTarget.querySelector('a').getAttribute('href')
@@ -418,6 +399,13 @@ class Parts < React
     end
   end
 
+  # tasklist completion events
+  def status_update(event)
+    if event.data.status == 'complete'
+      self.delete_attachment(event)
+    end
+  end
+
   ########################################################################
   #                          drag/drop support                           #
   ########################################################################

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].