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 2017/09/10 17:29:08 UTC

[whimsy] 01/01: rough in changes for secretary/workbench on vue

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

rubys pushed a commit to branch secmail_on_vue
in repository https://gitbox.apache.org/repos/asf/whimsy.git

commit a7bb55ece550ee8e0ba59da722a0e83b279630ce
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Sep 10 13:28:44 2017 -0400

    rough in changes for secretary/workbench on vue
---
 www/secretary/workbench/server.rb                  |  2 +-
 .../workbench/views/check-signature.js.rb          |  8 ++---
 www/secretary/workbench/views/context-menu.js.rb   |  4 +--
 www/secretary/workbench/views/forms/ccla.js.rb     |  8 ++---
 www/secretary/workbench/views/forms/forward.js.rb  |  2 +-
 www/secretary/workbench/views/forms/grant.js.rb    |  8 ++---
 www/secretary/workbench/views/forms/icla.js.rb     |  8 ++---
 www/secretary/workbench/views/forms/icla2.js.rb    |  8 ++---
 www/secretary/workbench/views/forms/memapp.js.rb   |  4 +--
 www/secretary/workbench/views/forms/nda.js.rb      |  2 +-
 www/secretary/workbench/views/index.js.rb          | 19 +++++------
 www/secretary/workbench/views/parts.js.rb          | 39 +++++++++++-----------
 12 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/www/secretary/workbench/server.rb b/www/secretary/workbench/server.rb
index 14261c9..9223381 100644
--- a/www/secretary/workbench/server.rb
+++ b/www/secretary/workbench/server.rb
@@ -4,7 +4,7 @@
 
 require 'wunderbar/sinatra'
 require 'wunderbar/bootstrap'
-require 'wunderbar/react'
+require 'wunderbar/vue'
 require 'ruby2js/filter/functions'
 require 'ruby2js/filter/require'
 require 'erb'
diff --git a/www/secretary/workbench/views/check-signature.js.rb b/www/secretary/workbench/views/check-signature.js.rb
index a2bae6b..0aba657 100644
--- a/www/secretary/workbench/views/check-signature.js.rb
+++ b/www/secretary/workbench/views/check-signature.js.rb
@@ -2,7 +2,7 @@
 # Check signatures for validity using gpg on the server
 #
 
-class CheckSignature < React
+class CheckSignature < Vue
   def initialize
     @signature = nil
     @checked = nil
@@ -14,11 +14,7 @@ class CheckSignature < React
     end
   end
 
-  def componentDidMount()
-    self.componentWillReceiveProps()
-  end
-
-  def componentWillReceiveProps()
+  def mounted()
     @signature = CheckSignature.find(@@selected, @@attachments)
 
     if @signature and @signature != @checked
diff --git a/www/secretary/workbench/views/context-menu.js.rb b/www/secretary/workbench/views/context-menu.js.rb
index b030127..2f86362 100644
--- a/www/secretary/workbench/views/context-menu.js.rb
+++ b/www/secretary/workbench/views/context-menu.js.rb
@@ -2,7 +2,7 @@
 # Context menu with actions to apply to an attachment
 #
 
-class ContextMenu < React
+class ContextMenu < Vue
   def render
     # context menu that displays when you 'right click' an attachment
     _ul.contextMenu do
@@ -17,7 +17,7 @@ class ContextMenu < React
   end
 
   # disable context menu
-  def componentDidMount()
+  def mounted()
     document.querySelector('.contextMenu').style.display = :none
   end
 
diff --git a/www/secretary/workbench/views/forms/ccla.js.rb b/www/secretary/workbench/views/forms/ccla.js.rb
index 84c5bf4..067afd9 100644
--- a/www/secretary/workbench/views/forms/ccla.js.rb
+++ b/www/secretary/workbench/views/forms/ccla.js.rb
@@ -1,4 +1,4 @@
-class CCLA < React
+class CCLA < Vue
   def initialize
     @filed = false
     @submitted = false
@@ -80,7 +80,7 @@ class CCLA < React
 
   # on initial display, default various fields based on headers, and update
   # state 
-  def componentDidMount()
+  def mounted()
     name = @@headers.name
  
     # reorder name if there is a single comma present
@@ -97,13 +97,13 @@ class CCLA < React
     window.addEventListener 'message', self.status_update
   end
 
-  def componentWillUnmount()
+  def beforeDestroy()
     window.removeEventListener 'message', self.status_update
   end
 
   # as fields change, enable/disable the associated buttons and adjust
   # input requirements.
-  def componentDidUpdate()
+  def updated()
     # CCLA file form
     valid = %w(company product contact email).all? do |name|
       document.querySelector("input[name=#{name}]").validity.valid
diff --git a/www/secretary/workbench/views/forms/forward.js.rb b/www/secretary/workbench/views/forms/forward.js.rb
index 7e68250..4c428e4 100644
--- a/www/secretary/workbench/views/forms/forward.js.rb
+++ b/www/secretary/workbench/views/forms/forward.js.rb
@@ -1,4 +1,4 @@
-class Forward < React
+class Forward < Vue
   def render
     _h4 'Forward'
 
diff --git a/www/secretary/workbench/views/forms/grant.js.rb b/www/secretary/workbench/views/forms/grant.js.rb
index cfc4d12..fc57314 100644
--- a/www/secretary/workbench/views/forms/grant.js.rb
+++ b/www/secretary/workbench/views/forms/grant.js.rb
@@ -1,4 +1,4 @@
-class Grant < React
+class Grant < Vue
   def initialize
     @filed = false
     @submitted = false
@@ -70,7 +70,7 @@ class Grant < React
 
   # on initial display, default various fields based on headers, and update
   # state 
-  def componentDidMount()
+  def mounted()
     name = @@headers.name
  
     # reorder name if there is a single comma present
@@ -87,13 +87,13 @@ class Grant < React
     window.addEventListener 'message', self.status_update
   end
 
-  def componentWillUnmount()
+  def beforeDestroy()
     window.removeEventListener 'message', self.status_update
   end
 
   # as fields change, enable/disable the associated buttons and adjust
   # input requirements.
-  def componentDidUpdate()
+  def updated()
     # Grant file form
     valid = %w(company name email filename).all? do |name|
       document.querySelector("input[name=#{name}]").validity.valid
diff --git a/www/secretary/workbench/views/forms/icla.js.rb b/www/secretary/workbench/views/forms/icla.js.rb
index 574d8bf..9eaa764 100644
--- a/www/secretary/workbench/views/forms/icla.js.rb
+++ b/www/secretary/workbench/views/forms/icla.js.rb
@@ -1,4 +1,4 @@
-class ICLA < React
+class ICLA < Vue
   def initialize
     @filed = false
     @checked = nil
@@ -89,7 +89,7 @@ class ICLA < React
 
   # on initial display, default various fields based on headers, and update
   # state 
-  def componentDidMount()
+  def mounted()
     name = @@headers.name || ''
 
     # reorder name if there is a single comma present
@@ -108,13 +108,13 @@ class ICLA < React
     window.addEventListener 'message', self.status_update
   end
 
-  def componentWillUnmount()
+  def beforeDestroy()
     window.removeEventListener 'message', self.status_update
   end
 
   # as fields change, enable/disable the associated buttons and adjust
   # input requirements.
-  def componentDidUpdate()
+  def updated()
     # ICLA file form
     valid = %w(realname pubname email filename).all? do |name|
       document.querySelector("input[name=#{name}]").validity.valid
diff --git a/www/secretary/workbench/views/forms/icla2.js.rb b/www/secretary/workbench/views/forms/icla2.js.rb
index d0a798b..19ccd79 100644
--- a/www/secretary/workbench/views/forms/icla2.js.rb
+++ b/www/secretary/workbench/views/forms/icla2.js.rb
@@ -1,4 +1,4 @@
-class ICLA2 < React
+class ICLA2 < Vue
   def initialize
     @filed = false
     @checked = nil
@@ -101,7 +101,7 @@ class ICLA2 < React
 
   # on initial display, default various fields based on headers, and update
   # state 
-  def componentDidMount()
+  def mounted()
     if ICLA2.iclas
       @disabled = false
     else
@@ -138,13 +138,13 @@ class ICLA2 < React
     window.addEventListener 'message', self.status_update
   end
 
-  def componentWillUnmount()
+  def beforeDestroy()
     window.removeEventListener 'message', self.status_update
   end
 
   # as fields change, enable/disable the associated buttons and adjust
   # input requirements.
-  def componentDidUpdate()
+  def updated()
     # ICLA file form
     valid = %w(pubname email).all? do |name|
       document.querySelector("input[name=#{name}]").validity.valid
diff --git a/www/secretary/workbench/views/forms/memapp.js.rb b/www/secretary/workbench/views/forms/memapp.js.rb
index d721542..7f4022c 100644
--- a/www/secretary/workbench/views/forms/memapp.js.rb
+++ b/www/secretary/workbench/views/forms/memapp.js.rb
@@ -1,4 +1,4 @@
-class MemApp < React
+class MemApp < Vue
   def initialize
     @received = []
     @filed = false
@@ -104,7 +104,7 @@ class MemApp < React
 
   # on initial display, wire up form, default email and fetch 
   # memapp-received.txt
-  def componentDidMount()
+  def mounted()
     # wire up form
     jQuery('form')[0].addEventListener('submit', self.file)
     jQuery('input[name=message]').val(window.parent.location.pathname)
diff --git a/www/secretary/workbench/views/forms/nda.js.rb b/www/secretary/workbench/views/forms/nda.js.rb
index 7ad7219..4d85eaa 100644
--- a/www/secretary/workbench/views/forms/nda.js.rb
+++ b/www/secretary/workbench/views/forms/nda.js.rb
@@ -1,4 +1,4 @@
-class NDA < React
+class NDA < Vue
   def render
     _p 'NDA'
   end
diff --git a/www/secretary/workbench/views/index.js.rb b/www/secretary/workbench/views/index.js.rb
index ebdac3e..95a712c 100644
--- a/www/secretary/workbench/views/index.js.rb
+++ b/www/secretary/workbench/views/index.js.rb
@@ -2,7 +2,7 @@
 # Index page showing unprocessed messages with attachments
 #
 
-class Index < React
+class Index < Vue
   def initialize
     @selected = nil
     @messages = []
@@ -35,9 +35,8 @@ class Index < React
             time = Date.new(Date.parse(message.time)).toLocaleString()
 
             row_options = {
-              className: color, 
-              onClick: self.selectRow, 
-              onDoubleClick: self.nav
+              class: color, 
+              on: {click: self.selectRow, doubleClick: self.nav}
             }
 
             _tr row_options do
@@ -70,14 +69,14 @@ class Index < React
   end
 
   # initialize next mailbox (year+month)
-  def componentWillMount()
+  def beforeMount()
     @nextmbox = @@mbox
     self.merge @@messages if @@messages
   end
 
   # on initial load, fetch latest mailbox, subscribe to keyboard and
   # server side events, and initialize selected item.
-  def componentDidMount()
+  def mounted()
     today = Date.new()
     twice = (today.getMonth()+1==@nextmbox[4..5].to_i and today.getDate()<=7)
     self.fetch_month() do
@@ -110,7 +109,7 @@ class Index < React
   end
 
   # when content changes, ensure selected message is visible
-  def componentDidUpdate()
+  def updated()
     if @selected
       selected = document.querySelector("a[href='#{@selected}']")
       if selected
@@ -161,7 +160,7 @@ class Index < React
       end
     end
 
-    self.forceUpdate() unless messages.empty?
+    Vue.forceUpdate() unless messages.empty?
   end
 
   # update @selected, given either a DOM event or a message
@@ -204,7 +203,7 @@ class Index < React
       # send request to server to remove delete status
       HTTP.patch(selected.href, status: nil).then {
         delete selected.status
-        self.forceUpdate()
+        Vue.forceUpdate()
         self.selectRow message
       }.catch {|error|
         alert error
@@ -266,7 +265,7 @@ class Index < React
           @messages[index].status = :deleted if index >= 0
           Status.pushDeleted selected
           self.selectRow selected if @selected == selected
-          self.forceUpdate()
+          Vue.forceUpdate()
         }.catch {|error|
           alert error
         }
diff --git a/www/secretary/workbench/views/parts.js.rb b/www/secretary/workbench/views/parts.js.rb
index 579a6a2..006dbc1 100644
--- a/www/secretary/workbench/views/parts.js.rb
+++ b/www/secretary/workbench/views/parts.js.rb
@@ -3,7 +3,7 @@
 # menus and drag and drop, and hosts forms.
 #
 
-class Parts < React
+class Parts < Vue
   def initialize
     @selected = nil
     @busy = false
@@ -21,15 +21,17 @@ class Parts < React
   def render
     # common options for all list items
     options = {
-      draggable: 'true',
-      onDragStart: self.dragStart,
-      onDragEnter: self.dragEnter,
-      onDragOver: self.dragOver,
-      onDragLeave: self.dragLeave,
-      onDragEnd: self.dragEnd,
-      onDrop: self.drop,
-      onContextMenu: self.showMenu,
-      onClick: self.select
+      attrs: {draggable: 'true'},
+      on: {
+        dragstart: self.dragStart,
+        dragenter: self.dragEnter,
+        dragover: self.dragOver,
+        dragleave: self.dragLeave,
+        dragend: self.dragEnd,
+        drop: self.drop,
+        contextmenu: self.showMenu,
+        click: self.select
+      }
     }
 
     # locate corresponding signature file (if any)
@@ -38,13 +40,13 @@ class Parts < React
     # list of attachments
     _ul.attachments! @attachments, ref: 'attachments' do |attachment|
       if attachment == @drag
-        options[:className] = 'dragging'
+        options[:class] = 'dragging'
       elsif attachment == @selected
-        options[:className] = 'selected'
+        options[:class] = 'selected'
       elsif attachment == signature
-        options[:className] = 'signature'
+        options[:class] = 'signature'
       else
-        options[:className] = nil
+        options[:class] = nil
       end
 
       if attachment =~ /\.(pdf|txt|jpeg|jpg|gif|png)$/i
@@ -222,12 +224,12 @@ class Parts < React
 
   # initial list of attachments comes from the server; may be updated
   # by context menu actions.
-  def componentWillMount()
+  def beforeMount()
     @attachments = @@attachments
   end
 
   # register mouse and keyboard handlers, hide context menu
-  def componentDidMount()
+  def mounted()
     window.onmousedown = self.hideMenu
 
     # register keyboard handler on parent window and all frames
@@ -254,12 +256,9 @@ class Parts < React
     # when back button is clicked, go all of the way back
     history_length =  window.history.length
     window.addEventListener 'popstate' do |event|
-      console.log 'popstate'
       window.history.go(history_length - window.history.length)
     end
-  end
 
-  def componentWillReceiveProps()
     self.extractHeaders(@@headers)
   end
 
@@ -269,7 +268,7 @@ class Parts < React
     @headers = headers
   end
 
-  def componentDidUpdate()
+  def updated()
     if @busy
       document.body.classList.add 'busy'
     else

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