whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: convert from jQuery to React.js
Date Thu, 09 Feb 2017 01:06:07 GMT
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  a368669   convert from jQuery to React.js
a368669 is described below

commit a368669de7099bbb718ad2250433b9f66077aa36
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Wed Feb 8 20:05:46 2017 -0500

    convert from jQuery to React.js
---
 www/board/agenda/routes.rb              |   4 -
 www/board/agenda/views/app.js.rb        |   1 +
 www/board/agenda/views/fy22.html.rb     | 286 -----------------------------
 www/board/agenda/views/pages/fy22.js.rb | 311 ++++++++++++++++++++++++++++++++
 www/board/agenda/views/router.js.rb     |   9 +
 5 files changed, 321 insertions(+), 290 deletions(-)

diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 6f4eb5f..709ad17 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -53,10 +53,6 @@ get '/env' do
   JSON.pretty_generate(env: env, ENV: ENV.to_h, asset: asset)
 end
 
-get %r{/(\d\d\d\d-\d\d-\d\d)/fy22} do |date|
-  _html :fy22
-end
-
 # all agenda pages
 get %r{/(\d\d\d\d-\d\d-\d\d)/(.*)} do |date, path|
   agenda = "board_agenda_#{date.gsub('-','_')}.txt"
diff --git a/www/board/agenda/views/app.js.rb b/www/board/agenda/views/app.js.rb
index 21fbdce..def71e6 100644
--- a/www/board/agenda/views/app.js.rb
+++ b/www/board/agenda/views/app.js.rb
@@ -25,6 +25,7 @@ require_relative 'pages/backchannel'
 require_relative 'pages/roll-call'
 require_relative 'pages/select-actions'
 require_relative 'pages/cache'
+require_relative 'pages/fy22'
 
 # Button + forms
 require_relative 'buttons/add-comment'
diff --git a/www/board/agenda/views/fy22.html.rb b/www/board/agenda/views/fy22.html.rb
deleted file mode 100644
index 68503dd..0000000
--- a/www/board/agenda/views/fy22.html.rb
+++ /dev/null
@@ -1,286 +0,0 @@
-#
-# FY22 budget worksheet
-#
-_html do
-  _title 'ASF Board Agenda - FY22'
-  _meta name: 'viewport', content: 'width=device-width, initial-scale=1.0'
-  _style %{
-    .table thead tr th {text-align: right}
-    .table tbody tr td.num {text-align: right}
-    .table tbody tr td.indented {padding-left: 2em}
-    .table tbody tr td input {align: right; text-align: right}
-  }
-
-  _h2 'FY22 budget worksheet'
-
-  _p "Instructions: change an input field and press the tab key."
-
-  _table.table.table_striped do
-    _thead do
-      _tr do
-        _th
-        _th 'FY17'
-        _th 'Min FY22'
-        _th 'FY22'
-        _th 'Max FY22'
-        _th 'Budget'
-      end
-    end
-
-    _tbody do
-      _tr do
-        _td 'Income', colspan: 6
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Total Public Donations', href: 'https://s.apache.org/sxYI'
-        end
-        _td.num 89
-        _td.num 90
-        _td.num 110
-        _td.num 135
-        _td.num { _input.donations! }
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Total Sponsorship', href: 'https://s.apache.org/sxYI'
-        end
-        _td.num 968
-        _td.num 900
-        _td.num '1,000'
-        _td.num '1,100'
-        _td.num { _input.sponsorship! }
-      end
-
-      _tr do
-        _td.indented 'Total Programs'
-        _td.num 28
-        _td.num 28
-        _td.num 28
-        _td.num 28
-        _td.num 28
-      end
-
-      _tr do
-        _td.indented 'Interest Income'
-        _td.num 4
-        _td.num 4
-        _td.num 4
-        _td.num 4
-        _td.num 4
-      end
-
-      _tr do
-        _td
-        _td.num '----'
-        _td.num '----'
-        _td.num '----'
-        _td.num '----'
-        _td.num '----'
-      end
-
-      _tr do
-        _td.indented 'Total Income'
-        _td.num '1,089'
-        _td.num '1,022'
-        _td.num '1,142'
-        _td.num '1,267'
-        _td.num.income!
-      end
-
-      _tr do
-        _td colspan: 6
-      end
-
-      _tr do
-        _td 'Expense', colspan: 6
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Infrastructure', href: 'https://s.apache.org/Rlse'
-        end
-        _td.num 723
-        _td.num 868
-        _td.num 868
-        _td.num 868
-        _td.num {_input.infrastructure!}
-      end
-
-      _tr do
-        _td.indented 'Program Expenses'
-        _td.num 27
-        _td.num 27
-        _td.num 27
-        _td.num 27
-        _td.num 27
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Publicity', href: 'https://s.apache.org/lv76'
-        end
-        _td.num 141
-        _td.num 273
-        _td.num 352
-        _td.num 540
-        _td.num { _input.publicity! }
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Brand Management', href: 'https://s.apache.org/gXdY'
-        end
-        _td.num 84
-        _td.num 92
-        _td.num 141
-        _td.num 218
-        _td.num { _input.brandManagement! }
-      end
-
-      _tr do
-        _td.indented 'Conferences'
-        _td.num 12
-        _td.num 12
-        _td.num 12
-        _td.num 12
-        _td.num { _input.conferences! }
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Travel Assistance', href: 'https://s.apache.org/4LdI'
-        end
-        _td.num 62
-        _td.num 0
-        _td.num 79
-        _td.num 150
-        _td.num { _input.travelAssistance! }
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Treasury', href: 'https://s.apache.org/EGiC'
-        end
-        _td.num 48
-        _td.num 49
-        _td.num 51
-        _td.num 61
-        _td.num { _input.treasury! }
-      end
-
-      _tr do
-        _td.indented do
-          _a 'Fundraising', href: 'https://s.apache.org/sxYI'
-        end
-        _td.num 8
-        _td.num 18
-        _td.num 23
-        _td.num 23
-        _td.num { _input.fundraising! }
-      end
-
-      _tr do
-        _td.indented do
-          _a 'General & Administrative', href: 'https://s.apache.org/4LdI'
-        end
-        _td.num 114
-        _td.num 50
-        _td.num 139
-        _td.num 300
-        _td.num { _input.generalAndAdministrative! }
-      end
-
-      _tr do
-        _td
-        _td.num '----'
-        _td.num '----'
-        _td.num '----'
-        _td.num '----'
-        _td.num '----'
-      end
-
-      _tr do
-        _td.indented 'Total Expense'
-        _td.num '1,219'
-        _td.num '1,390'
-        _td.num '1,693'
-        _td.num '2,199'
-        _td.num.expense!
-      end
-
-      _tr do
-        _td colspan: 6
-      end
-
-      _tr do
-        _td 'Net'
-        _td.num '-130'
-        _td.num '-369'
-        _td.num '-552'
-        _td.num '-993'
-        _td.num.net!
-      end
-
-      _tr do
-        _td colspan: 6
-      end
-
-      _tr do
-        _td 'Cash'
-        _td.num '1,656'
-        _td.num 290
-        _td.num -259
-        _td.num -1403
-        _td.num.cash!
-      end
-    end
-  end
-
-  _p "Units are in thousands of dollars US."
-
-  _script %q{
-    values = {
-      donations: 110,
-      sponsorship: 1000,
-      infrastructure: 868,
-      publicity: 352,
-      brandManagement: 141,
-      conferences: 12,
-      travelAssistance: 79,
-      treasury: 51,
-      fundraising: 23,
-      generalAndAdministrative: 139,
-    }
-
-    function update() {
-      values.income = values.donations + values.sponsorship + 28 + 4;
-
-      values.expense = values.infrastructure + 27 + values.publicity + 
-        values.brandManagement + values.conferences + values.travelAssistance +
-        values.treasury + values.fundraising + values.generalAndAdministrative;
-
-      values.net = values.income - values.expense;
-
-      values.cash = 1656 - 2*130 + 3*values.net;
-
-      for (var name in values) {
-        var element = document.getElementById(name);
-        if (element.tagName == 'INPUT') {
-          element.value = values[name].toLocaleString()
-        } else {
-          element.textContent = values[name].toLocaleString()
-        }
-      }
-    }
-
-    $('input').blur(function(event) {
-      values[event.target.id] = parseInt(event.target.value.replace(/\D/g, ''));
-      update();
-    });
-
-    update();
-  }
-end
diff --git a/www/board/agenda/views/pages/fy22.js.rb b/www/board/agenda/views/pages/fy22.js.rb
new file mode 100644
index 0000000..2549c90
--- /dev/null
+++ b/www/board/agenda/views/pages/fy22.js.rb
@@ -0,0 +1,311 @@
+#
+# FY22 budget worksheet
+#
+class FY22 < React
+  def initialize
+    @budget = {
+      donations: 110,
+      sponsorship: 1000,
+      infrastructure: 868,
+      publicity: 352,
+      brandManagement: 141,
+      conferences: 12,
+      travelAssistance: 79,
+      treasury: 51,
+      fundraising: 23,
+      generalAndAdministrative: 139,
+    }
+
+    self.recalc();
+  end
+
+  def render
+    _style %{
+      .table thead tr th {text-align: right}
+      .table tbody tr td {text-align: left}
+      .table tbody tr td.num {text-align: right}
+      .table tbody tr td.indented {padding-left: 2em}
+      .table tbody tr td input {align: right; text-align: right}
+      .table tbody tr td a {color: blue; text-decoration:underline}
+    }
+
+    _p "Instructions: change any input field and press the tab key to see " +
+      "new results. Try to make FY22 Budget Net non-negative."
+
+    _table.table.table_sm.table_striped do
+      _thead do
+        _tr do
+          _th
+          _th 'FY17'
+          _th 'Min FY22'
+          _th 'FY22'
+          _th 'Max FY22'
+          _th 'FY22 Budget'
+        end
+      end
+
+      _tbody do
+        _tr do
+          _td 'Income', colspan: 6
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Total Public Donations', href: 'https://s.apache.org/sxYI'
+          end
+          _td.num 89
+          _td.num 90
+          _td.num 110
+          _td.num 135
+          _td.num do 
+            _input.donations! onBlur: self.change,
+              defaultValue: @budget.donations.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Total Sponsorship', href: 'https://s.apache.org/sxYI'
+          end
+          _td.num 968
+          _td.num 900
+          _td.num '1,000'
+          _td.num '1,100'
+          _td.num do 
+            _input.sponsorship! onBlur: self.change,
+              defaultValue: @budget.sponsorship.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented 'Total Programs'
+          _td.num 28
+          _td.num 28
+          _td.num 28
+          _td.num 28
+          _td.num 28
+        end
+
+        _tr do
+          _td.indented 'Interest Income'
+          _td.num 4
+          _td.num 4
+          _td.num 4
+          _td.num 4
+          _td.num 4
+        end
+
+        _tr do
+          _td
+          _td.num '----'
+          _td.num '----'
+          _td.num '----'
+          _td.num '----'
+          _td.num '----'
+        end
+
+        _tr do
+          _td.indented 'Total Income'
+          _td.num '1,089'
+          _td.num '1,022'
+          _td.num '1,142'
+          _td.num '1,267'
+          _td.num.income! @budget.income.toLocaleString()
+        end
+
+        _tr do
+          _td colspan: 6
+        end
+
+        _tr do
+          _td 'Expense', colspan: 6
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Infrastructure', href: 'https://s.apache.org/Rlse'
+          end
+          _td.num 723
+          _td.num 868
+          _td.num 868
+          _td.num 868
+          _td.num do 
+            _input.infrastructure! onBlur: self.change,
+              defaultValue: @budget.infrastructure.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented 'Program Expenses'
+          _td.num 27
+          _td.num 27
+          _td.num 27
+          _td.num 27
+          _td.num 27
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Publicity', href: 'https://s.apache.org/lv76'
+          end
+          _td.num 141
+          _td.num 273
+          _td.num 352
+          _td.num 540
+          _td.num do 
+            _input.publicity! onBlur: self.change,
+              defaultValue: @budget.publicity.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Brand Management', href: 'https://s.apache.org/gXdY'
+          end
+          _td.num 84
+          _td.num 92
+          _td.num 141
+          _td.num 218
+          _td.num do 
+            _input.brandManagement! onBlur: self.change,
+              defaultValue: @budget.brandManagement.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented 'Conferences'
+          _td.num 12
+          _td.num 12
+          _td.num 12
+          _td.num 12
+          _td.num do 
+            _input.conferences! onBlur: self.change,
+              defaultValue: @budget.conferences.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Travel Assistance', href: 'https://s.apache.org/4LdI'
+          end
+          _td.num 62
+          _td.num 0
+          _td.num 79
+          _td.num 150
+          _td.num do 
+            _input.travelAssistance! onBlur: self.change,
+              defaultValue: @budget.travelAssistance.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Treasury', href: 'https://s.apache.org/EGiC'
+          end
+          _td.num 48
+          _td.num 49
+          _td.num 51
+          _td.num 61
+          _td.num do 
+            _input.treasury! onBlur: self.change,
+              defaultValue: @budget.treasury.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented do
+            _a 'Fundraising', href: 'https://s.apache.org/sxYI'
+          end
+          _td.num 8
+          _td.num 18
+          _td.num 23
+          _td.num 23
+          _td.num do 
+            _input.fundraising! onBlur: self.change,
+              defaultValue: @budget.fundraising.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td.indented do
+            _a 'General & Administrative', href: 'https://s.apache.org/4LdI'
+          end
+          _td.num 114
+          _td.num 50
+          _td.num 139
+          _td.num 300
+          _td.num do 
+            _input.generalAndAdministrative! onBlur: self.change,
+              defaultValue: @budget.generalAndAdministrative.toLocaleString()
+          end
+        end
+
+        _tr do
+          _td
+          _td.num '----'
+          _td.num '----'
+          _td.num '----'
+          _td.num '----'
+          _td.num '----'
+        end
+
+        _tr do
+          _td.indented 'Total Expense'
+          _td.num '1,219'
+          _td.num '1,390'
+          _td.num '1,693'
+          _td.num '2,199'
+          _td.num.expense! @budget.expense
+        end
+
+        _tr do
+          _td colspan: 6
+        end
+
+        _tr do
+          _td 'Net'
+          _td.num '-130'
+          _td.num '-369'
+          _td.num '-552'
+          _td.num '-993'
+          _td.num.net! @budget.net,
+            class: (@budget.net < 0 ? 'danger' : 'success')
+        end
+
+        _tr do
+          _td colspan: 6
+        end
+
+        _tr do
+          _td 'Cash'
+          _td.num '1,656'
+          _td.num 290
+          _td.num -259
+          _td.num -1403
+          _td.num.cash! @budget.cash
+        end
+      end
+    end
+
+    _p "Units are in thousands of dollars US."
+  end
+
+  def recalc()
+    @budget.income = @budget.donations + @budget.sponsorship + 28 + 4;
+
+    @budget.expense = @budget.infrastructure + 27 + @budget.publicity + 
+      @budget.brandManagement + @budget.conferences + 
+      @budget.travelAssistance + @budget.treasury + @budget.fundraising + 
+      @budget.generalAndAdministrative;
+
+    @budget.net = @budget.income - @budget.expense;
+
+    @budget.cash = 1656 - 2*130 + 3*@budget.net;
+  end
+
+  def change(event)
+    @budget[event.target.id] = parseInt(event.target.value.gsub(/\D/, '')) || 0;
+    self.recalc();
+    self.forceUpdate()
+  end
+end
diff --git a/www/board/agenda/views/router.js.rb b/www/board/agenda/views/router.js.rb
index 3aa1a14..e446222 100644
--- a/www/board/agenda/views/router.js.rb
+++ b/www/board/agenda/views/router.js.rb
@@ -84,8 +84,17 @@ class Router
     elsif path =~ %r{^cache/}
       item = {view: CachePage}
 
+    elsif path == 'fy22'
+      item = {view: FY22, title: 'FY22 Budget Worksheet', color: 'available',
+        prev: {title: 'Discussion Items', href: 'Discussion-Items'},
+        next: {title: 'Action Items', href: 'Action-Items'}}
+
     else
       item = Agenda.find(path)
+
+      if path == 'Discussion-Items' and Agenda.date =~ /^2017-02/
+        item.next = {title: 'FY22 Budget Worksheet', href: 'fy22'}
+      end
     end
 
     # bail unless an item was found

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

Mime
View raw message