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 2018/04/01 20:36:25 UTC
[whimsy] branch master updated: oops, forgot a file
This is an automated email from the ASF dual-hosted git repository.
rubys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 71bc5a4 oops, forgot a file
71bc5a4 is described below
commit 71bc5a4fdf600647ee93cc3a08432efffdfb5bd2
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Sun Apr 1 16:36:15 2018 -0400
oops, forgot a file
---
www/board/agenda/views/pages/feedback.js.rb | 108 ++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
diff --git a/www/board/agenda/views/pages/feedback.js.rb b/www/board/agenda/views/pages/feedback.js.rb
new file mode 100644
index 0000000..061dd1a
--- /dev/null
+++ b/www/board/agenda/views/pages/feedback.js.rb
@@ -0,0 +1,108 @@
+#
+# Select and send item comments as feedback.
+#
+
+class Feedback < Vue
+ def self.buttons()
+ return [{button: SendFeedback}]
+ end
+
+ def initialize
+ @list = nil
+ end
+
+ def render
+ if @list == nil
+ _p 'loading'
+ else
+ @list.each do |item|
+ _h2 do
+ _input type: 'checkbox', domPropsChecked: item.checked,
+ onClick:-> {item.checked = !item.checked}
+ _ item.title
+ end
+ _pre.feedback item.mail
+ end
+ end
+ end
+
+ def mounted()
+ EventBus.on :potential_feedback, self.potential_feedback
+
+ fetch('feedback.json', credentials: 'include').then do |response|
+ response.json().then do |json|
+ # initially check each item which has not yet been sent
+ json.each {|item| item.checked = !item.sent}
+
+ EventBus.emit :potential_feedback, json
+ end
+ end
+ end
+
+ def beforeDestroy()
+ EventBus.off :potential_feedback, self.potential_feedback
+ end
+
+ def potential_feedback(list)
+ @list = list
+ end
+end
+
+#
+# Send feedback button
+#
+
+class SendFeedback < Vue
+ def initialize
+ @disabled = false
+ @list = []
+ end
+
+ def render
+ _button.btn.btn_primary 'send email', onClick: self.click,
+ disabled: @disabled || @list.empty? ||
+ @list.all? {|item| !item.checked}
+ end
+
+ def mounted()
+ EventBus.on :potential_feedback, self.potential_feedback
+ end
+
+ def beforeDestroy()
+ EventBus.off :potential_feedback, self.potential_feedback
+ end
+
+ def potential_feedback(list)
+ @list = list
+ end
+
+ def click(event)
+ # gather a list of checked items
+ checked = {}
+
+ @list.each do |item|
+ checked[item.title.gsub(/\s/, '_')] = true if item.checked
+ end
+
+ # construct arguments to fetch
+ args = {
+ method: 'post',
+ credentials: 'include',
+ headers: {'Content-Type' => 'application/json'},
+ body: checked.inspect
+ }
+
+ # send feedback
+ @disabled = true
+ fetch('feedback.json', args).then do |response|
+ response.json().then do |json|
+ # check each item which still has yet to be sent
+ json.each {|item| item.checked = !item.sent}
+
+ @list = json
+ EventBus.emit :potential_feedback, @list
+ @disabled = false
+ end
+ end
+ end
+end
--
To stop receiving notification emails like this one, please contact
rubys@apache.org.