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 9ebde11  only show 'publish minutes' button after minutes are approved
9ebde11 is described below

commit 9ebde11e42809226be7fd476b8bd4c226b06d48c
Author: Sam Ruby <[email protected]>
AuthorDate: Sun May 27 08:10:53 2018 -0400

    only show 'publish minutes' button after minutes are approved
---
 www/board/agenda/routes.rb                 | 10 +++++-----
 www/board/agenda/views/models/agenda.js.rb | 30 +++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 5c7988d..0b8f7a2 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -260,19 +260,19 @@ get %r{/(\d\d\d\d-\d\d-\d\d).ya?ml} do |file|
 end
 
 # updates to agenda data
-get %r{/(\d\d\d\d-\d\d-\d\d).json} do |file|
-  file = "board_agenda_#{file.gsub('-','_')}.txt".untaint
+get %r{/(\d\d\d\d-\d\d-\d\d).json} do |date|
+  file = "board_agenda_#{date.gsub('-','_')}.txt".untaint
   pass unless Agenda.parse file, :full
 
   begin
     _json do
       last_modified Agenda[file][:mtime]
-      minutes = AGENDA_WORK + '/' + file.sub('_agenda_', '_minutes_').
+      minutes_file = AGENDA_WORK + '/' + file.sub('_agenda_', '_minutes_').
         sub('.txt', '.yml')
 
       # merge in minutes, if available
-      if File.exists? minutes
-        minutes = YAML.load_file(minutes)
+      if File.exists? minutes_file
+        minutes = YAML.load_file(minutes_file)
         Agenda[file][:parsed].each do |item|
           item[:minutes] = minutes[item['title']] if minutes[item['title']]
         end
diff --git a/www/board/agenda/views/models/agenda.js.rb 
b/www/board/agenda/views/models/agenda.js.rb
index 13cd8fe..52131d3 100644
--- a/www/board/agenda/views/models/agenda.js.rb
+++ b/www/board/agenda/views/models/agenda.js.rb
@@ -9,6 +9,7 @@ class Agenda
   @@etag = nil
   @@digest = nil
   Vue.util.defineReactive @@date, ''
+  Vue.util.defineReactive @@approved, '?'
   @@color = 'blank'
 
   # (re)-load an agenda, creating instances for each item, and linking
@@ -247,6 +248,33 @@ class Agenda
       !(@flagged_by && @flagged_by.include?(initials))
   end
 
+  # determine if this agenda was approved in a later meeting
+  def self.approved
+    if @@approved == '?' and defined? fetch
+      options = {month: 'long', day: 'numeric', year: 'numeric'}
+      date = Date.new(Agenda.file[/\d\d\d\d_\d\d_\d\d/].
+        gsub('_', '-') + 'T18:30:00.000Z').toLocaleString('en-US', options)
+
+      Server.agendas.each do |agenda|
+        next if agenda <= Agenda.file
+        url = "../#{agenda[/\d\d\d\d_\d\d_\d\d/].gsub('_', '-')}.json"
+        fetch(url, credentials: 'include').then do |response|
+          if response.ok
+            response.json().then do |agenda|
+              agenda.each do |item|
+                @@approved = item.minutes if item.title == date and 
item.minutes
+              end
+            end
+          end
+        end
+      end
+      
+      @@approved = 'tabled'
+    end
+
+    return @@approved
+  end
+
   # the default view to use for the agenda as a whole
   def self.view
     Index
@@ -263,7 +291,7 @@ class Agenda
     end
 
     if User.role == :secretary 
-      if Server.drafts.include? Agenda.file.sub('agenda', 'minutes')
+      if Agenda.approved == 'approved'
         list << {form: PublishMinutes}
       elsif Minutes.ready_to_post_draft
         list << {form: DraftMinutes}

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to