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  6fae6f7   update filename when real name changes
6fae6f7 is described below

commit 6fae6f7839098884434faf9fb295df8a00167cf7
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sat Sep 17 15:06:26 2016 -0400

    update filename when real name changes
---
 www/secmail/views/forms/icla.js.rb | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/www/secmail/views/forms/icla.js.rb 
b/www/secmail/views/forms/icla.js.rb
index 74a492d..2ad5d2d 100644
--- a/www/secmail/views/forms/icla.js.rb
+++ b/www/secmail/views/forms/icla.js.rb
@@ -9,7 +9,8 @@ class ICLA < React
     _h4 'ICLA'
 
     _div.buttons do
-      _button 'clear form', onClick: -> {@pubname = @realname = @email = ''}
+      _button 'clear form', 
+        onClick: -> {@pubname = @realname = @email = @filename = ''}
     end
 
     _form method: 'post', action: '../../tasklist/icla', target: 'content' do
@@ -22,7 +23,7 @@ class ICLA < React
           _th 'Real Name'
           _td do
             _input name: 'realname', value: @realname, required: true,
-               disabled: @filed
+               disabled: @filed, onChange: self.changeRealName
           end
         end
 
@@ -46,8 +47,7 @@ class ICLA < React
           _th 'File Name'
           _td do
             _input name: 'filename', value: @filename, required: true,
-              pattern: '[a-zA-Z][-\w]+(\.[a-z]+)?', onFocus: self.genfilename,
-              disabled: @filed
+              pattern: '[a-zA-Z][-\w]+(\.[a-z]+)?', disabled: @filed
           end
         end
       end
@@ -94,6 +94,7 @@ class ICLA < React
 
     @realname = name
     @pubname = name
+    @filename = self.genfilename(name)
     @email = @@headers.from
     self.componentDidUpdate()
 
@@ -128,9 +129,14 @@ class ICLA < React
     jQuery('input[name=selected]').val(@@selected)
   end
 
+  def changeRealName(event)
+    @realname = event.target.value;
+    @filename = self.genfilename(event.target.value)
+  end
+
   # generate file name from the real name
-  def genfilename()
-    @filename ||= asciize(@realname.strip()).downcase().gsub(/\W/, '-')
+  def genfilename(realname)
+    return asciize(realname.strip()).downcase().gsub(/\W+/, '-')
   end
 
   # handle ICLA form submission

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

Reply via email to