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/19 23:00:51 UTC

[whimsy] 02/02: five more tests passing

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

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

commit 0216c4c8ef266061689cc1a0e3412093da88af4f
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Tue Sep 19 19:00:36 2017 -0400

    five more tests passing
---
 www/board/agenda/spec/forms_spec.rb                | 16 ++++++------
 www/board/agenda/spec/vue_server.rb                |  3 +--
 www/board/agenda/views/buttons/add-comment.js.rb   | 19 ++------------
 www/board/agenda/views/buttons/add-minutes.js.rb   |  9 ++-----
 www/board/agenda/views/elements/modal-dialog.js.rb | 30 ++++++++++------------
 5 files changed, 26 insertions(+), 51 deletions(-)

diff --git a/www/board/agenda/spec/forms_spec.rb b/www/board/agenda/spec/forms_spec.rb
index 1d66132..835b64b 100644
--- a/www/board/agenda/spec/forms_spec.rb
+++ b/www/board/agenda/spec/forms_spec.rb
@@ -33,22 +33,22 @@ describe "forms", type: :feature, server: :vue do
 
     it "should enable Save button after input" do
       on_vue_server do
+        item = {}
         server = {pending: {}, initials: 'sr'}
 
         class TestCommentForm < Vue
           def render
-            _AddComment(item: {}, server: {pending: {}, initials: 'sr'})
+            _AddComment(item: item, server: server)
           end
         end
 
         app = Vue.renderApp(TestCommentForm)
         node = app.querySelector('#comment-text')
-        node.textContent = 'Good job!'
-        app.dispatchEvent(Event.new('input'))
-        response.end app.innerHTML
+        node.value = 'Good job!'
+        node.dispatchEvent(Event.new('input'))
+        Vue.nextTick { response.end app.outerHTML }
       end
 
-      puts page.body
       expect(page).to have_selector '.modal-footer .btn-warning', text: 'Delete'
       expect(page).to have_selector \
         '.modal-footer .btn-primary:not([disabled])', text: 'Save'
@@ -93,10 +93,10 @@ describe "forms", type: :feature, server: :vue do
 
         app = Vue.renderApp(TestPost)
         button = app.querySelector('.btn-danger')
-        app.dispatchEvent(new Event('click'), button)
+        button.dispatchEvent(Event.new('click'))
         post_report = app.querySelector('#post-report-text')
-        post_report.textContent = this.state.report
-        response.end app.innerHTML
+        post_report.value = this.state.report
+        Vue.nextTick { response.end app.outerHTML }
       end
 
       expect(find('#post-report-text').value).to match(/to\nanswer questions/)
diff --git a/www/board/agenda/spec/vue_server.rb b/www/board/agenda/spec/vue_server.rb
index 16acdf4..f1f296a 100644
--- a/www/board/agenda/spec/vue_server.rb
+++ b/www/board/agenda/spec/vue_server.rb
@@ -118,8 +118,7 @@ class VueServer
         return outer.querySelector(selector)
       end
 
-      def app.dispatchEvent(event, element=nil)
-        element ||= inner
+      def app.dispatchEvent(event, element)
         element.dispatchEvent(event)
         app._watcher.run()
       end
diff --git a/www/board/agenda/views/buttons/add-comment.js.rb b/www/board/agenda/views/buttons/add-comment.js.rb
index 7c2ad93..fe54301 100644
--- a/www/board/agenda/views/buttons/add-comment.js.rb
+++ b/www/board/agenda/views/buttons/add-comment.js.rb
@@ -41,8 +41,7 @@ class AddComment < Vue
 
       #input field: comment text
       _textarea.comment_text!  value: @comment, label: 'Comment',
-        placeholder: 'comment', rows: 5, onChange: self.change,
-        disabled: @disabled
+        placeholder: 'comment', rows: 5, disabled: @disabled
 
       if Server.role == :director and @@item.attach =~ /^[A-Z]+$/
         _input.flag! type: 'checkbox', label: 'item requires discussion or follow up',
@@ -63,26 +62,12 @@ class AddComment < Vue
   end
 
   # autofocus on comment text
-  def componentDidMount()
+  def mounted()
     jQuery('#comment-form').on 'shown.bs.modal' do
       ~'#comment-text'.focus()
     end
   end
 
-  # update comment when textarea changes, triggering hiding/showing the
-  # Delete button and enabling/disabling the Save button.
-  def change(event)
-    @comment = event.target.value
-  end
-
-  # when item changes, reset base and comment
-  def componentWillReceiveProps(newprops)
-    if newprops.item.href != self.props.item.href
-      @checked = newprops.item.flagged
-      @base = @comment = newprops.item.pending || ''
-    end
-  end
-
   # when delete button is pushed, clear the comment
   def delete(event)
     @comment = ''
diff --git a/www/board/agenda/views/buttons/add-minutes.js.rb b/www/board/agenda/views/buttons/add-minutes.js.rb
index 65ca1a8..a462791 100644
--- a/www/board/agenda/views/buttons/add-minutes.js.rb
+++ b/www/board/agenda/views/buttons/add-minutes.js.rb
@@ -68,22 +68,17 @@ class AddMinutes < Vue
   end
 
   # autofocus on minute text
-  def componentDidMount()
+  def mounted()
     jQuery('#minute-form').on 'shown.bs.modal' do
       ~'#minute-text'.focus()
     end
   end
 
   # when initially displayed, set various fields to match the item
-  def componentWillMount()
+  def created()
     self.setup(@@item)
   end
 
-  # when item changes, reset various fields to match
-  def componentWillReceiveProps(newprops)
-    self.setup(newprops.item) if newprops.item.href != self.props.item.href
-  end
-
   # reset base, draft minutes, shepherd, default ai_text, and indent
   def setup(item)
     @base = draft = Minutes.get(item.title) || ''
diff --git a/www/board/agenda/views/elements/modal-dialog.js.rb b/www/board/agenda/views/elements/modal-dialog.js.rb
index c668eab..b575512 100644
--- a/www/board/agenda/views/elements/modal-dialog.js.rb
+++ b/www/board/agenda/views/elements/modal-dialog.js.rb
@@ -6,29 +6,21 @@
 #
 
 class ModalDialog < Vue
-  def initialize
-    @header = []
-    @body = []
-    @footer = []
-  end
-
-  def created()
-    @header.clear()
-    @body.clear()
-    @footer.clear()
+  def collateSlots()
+    sections = {header: [], body: [], footer: []}
 
     $slots.default.each do |slot|
       if slot.tag == 'h4'
 
         # place h4 elements into the header, adding a modal-title class
         slot = self.addClass(slot, 'modal-title')
-        @header << slot
+        sections.header << slot
 
       elsif slot.tag == 'button'
 
         # place button elements into the footer, adding a btn class
         slot = self.addClass(slot, 'btn')
-        @footer << slot
+        sections.footer << slot
 
       elsif slot.tag == 'input' or slot.tag == 'textarea'
 
@@ -52,33 +44,37 @@ class ModalDialog < Vue
           end
         end
 
-        @body << Vue.createElement('div', {class: 'form-group'}, 
+        sections.body << Vue.createElement('div', {class: 'form-group'}, 
           [label, slot])
 
       else
 
         # place all other elements into the body
 
-        @body << slot
+        sections.body << slot
       end
     end
+
+    return sections
   end
 
   def render
+    sections = self.collateSlots()
+
     _div.modal.fade id: @@id, class: @@className do
       _div.modal_dialog do
         _div.modal_content do
           _div.modal_header class: @@color do
             _button.close "\u00d7", type: 'button', data_dismiss: 'modal'
-            _[*@header]
+            _[*sections.header]
           end
 
           _div.modal_body do
-            _[*@body]
+            _[*sections.body]
           end
 
           _div.modal_footer class: @@color do
-            _[*@footer]
+            _[*sections.footer]
           end
         end
       end

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