annotate .svn/pristine/e1/e1b34317d15f9be0f8cff95af6e52b66af186fcf.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents e248c7af89ec
children
rev   line source
Chris@1494 1 # Redmine - project management software
Chris@1494 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1494 3 #
Chris@1494 4 # This program is free software; you can redistribute it and/or
Chris@1494 5 # modify it under the terms of the GNU General Public License
Chris@1494 6 # as published by the Free Software Foundation; either version 2
Chris@1494 7 # of the License, or (at your option) any later version.
Chris@1494 8 #
Chris@1494 9 # This program is distributed in the hope that it will be useful,
Chris@1494 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1494 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1494 12 # GNU General Public License for more details.
Chris@1494 13 #
Chris@1494 14 # You should have received a copy of the GNU General Public License
Chris@1494 15 # along with this program; if not, write to the Free Software
Chris@1494 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1494 17
Chris@1494 18 require 'blankslate'
Chris@1494 19
Chris@1494 20 module Redmine
Chris@1494 21 module Views
Chris@1494 22 module Builders
Chris@1494 23 class Structure < BlankSlate
Chris@1494 24 attr_accessor :request, :response
Chris@1494 25
Chris@1494 26 def initialize(request, response)
Chris@1494 27 @struct = [{}]
Chris@1494 28 self.request = request
Chris@1494 29 self.response = response
Chris@1494 30 end
Chris@1494 31
Chris@1494 32 def array(tag, options={}, &block)
Chris@1494 33 @struct << []
Chris@1494 34 block.call(self)
Chris@1494 35 ret = @struct.pop
Chris@1494 36 @struct.last[tag] = ret
Chris@1494 37 @struct.last.merge!(options) if options
Chris@1494 38 end
Chris@1494 39
Chris@1494 40 def method_missing(sym, *args, &block)
Chris@1494 41 if args.any?
Chris@1494 42 if args.first.is_a?(Hash)
Chris@1494 43 if @struct.last.is_a?(Array)
Chris@1494 44 @struct.last << args.first unless block
Chris@1494 45 else
Chris@1494 46 @struct.last[sym] = args.first
Chris@1494 47 end
Chris@1494 48 else
Chris@1494 49 if @struct.last.is_a?(Array)
Chris@1494 50 if args.size == 1 && !block_given?
Chris@1494 51 @struct.last << args.first
Chris@1494 52 else
Chris@1494 53 @struct.last << (args.last || {}).merge(:value => args.first)
Chris@1494 54 end
Chris@1494 55 else
Chris@1494 56 @struct.last[sym] = args.first
Chris@1494 57 end
Chris@1494 58 end
Chris@1494 59 end
Chris@1494 60
Chris@1494 61 if block
Chris@1494 62 @struct << (args.first.is_a?(Hash) ? args.first : {})
Chris@1494 63 block.call(self)
Chris@1494 64 ret = @struct.pop
Chris@1494 65 if @struct.last.is_a?(Array)
Chris@1494 66 @struct.last << ret
Chris@1494 67 else
Chris@1494 68 if @struct.last.has_key?(sym) && @struct.last[sym].is_a?(Hash)
Chris@1494 69 @struct.last[sym].merge! ret
Chris@1494 70 else
Chris@1494 71 @struct.last[sym] = ret
Chris@1494 72 end
Chris@1494 73 end
Chris@1494 74 end
Chris@1494 75 end
Chris@1494 76
Chris@1494 77 def output
Chris@1494 78 raise "Need to implement #{self.class.name}#output"
Chris@1494 79 end
Chris@1494 80 end
Chris@1494 81 end
Chris@1494 82 end
Chris@1494 83 end