On Wed, Dec 27, 2017 at 9:56 PM, Craig Russell <apache....@gmail.com> wrote: > Here's what I tried to make a function callable from multiple places: > > # > # Server side setup for whimsy/project > # > > require 'whimsy/asf' > > require 'wunderbar/sinatra' > require 'wunderbar/vue' > require 'wunderbar/bootstrap/theme' > require 'ruby2js/filter/functions' > require 'ruby2js/filter/require' > > disable :logging # suppress log of requests to stderr/error.log > > helpers do > def pmcs > ASF::Committee.pmcs.map(&:name).sort > end > def ppmcs > ASF::Podling.list > .select {|podling| podling.status == 'current'} > .map(&:name).sort > end > end > > # > # Sinatra routes > # > > > get '/' do > redirect to('/invite') > end > > get '/invite' do > @view = 'invite' > > > # get a complete list of PMC and PPMC names > @pmcs = helpers.pmcs()
Drop 'helpers.' > Any idea how to make this work? > > Craig - Sam Ruby >> On Dec 17, 2017, at 5:02 PM, Sam Ruby <ru...@intertwingly.net> wrote: >> >> On Sun, Dec 17, 2017 at 7:07 PM, Craig Russell <apache....@gmail.com> wrote: >>> One more thing. >>> >>> I want to use a radio button on the discuss form: >>> >>> (0) invite to submit an ICLA only >>> (0) invite to become a committer only >>> (0) invite to become a PMC member only >>> (0) invite to become a committer and PMC member >>> >>> The vue control looks like: >>> >>> <input type="radio" id="one" value="One" v-model="picked"> >>> <label for="one">One</label> >>> <br> >>> <input type="radio" id="two" value="Two" v-model="picked"> >>> <label for="two">Two</label> >>> <br> >>> <span>Picked: {{ picked }}</span> >>> >>> What is the mapping to create a radio button? >> >> I'm not sure I understand the question. but instead of v-model, you >> likely want onClick. To see a working example, look at: >> >> https://github.com/apache/whimsy/blob/bc969805038b606d1b34c8d0b616ac2691cd0e09/www/secretary/workbench/views/parts.js.rb#L104 >> >> - Sam Ruby >> >>>> On Dec 17, 2017, at 10:46 AM, Craig Russell <apache....@gmail.com> wrote: >>>> >>>> >>>>> On Dec 16, 2017, at 6:34 PM, Sam Ruby <ru...@intertwingly.net> wrote: >>>>> >>>>>> The code in the existing main.rb in get '/invite' sets several variables >>>>>> that will be useful in discuss and vote. DRY says this code should only >>>>>> be in one place. How can variables be shared among multiple get and post >>>>>> paths? >>>>> >>>>> Two basic approaches come to mind. In the roster tool, there is code >>>>> in the models directory that return hashes. Also in >>>>> www/roster/main.rb, you can find a helper that is called by multiple >>>>> views. >>>> >>>> What I'm trying to do is to get the @pmcs and @ppmcs variables sent to the >>>> view from discuss, vote, and invite. The roster example shows no variables >>>> outside the do... end blocks. The code to calculate these is simple but >>>> not trivial. >>>> >>>> So would you recommend doing the calculation in the common code and >>>> setting the @variables in the do... end block. E.g. >>>> >>>> pmcs = ASF::Committee.pmcs.map(&:name).sort >>>> ppmcs = ASF::Podling.list >>>> .select {|podling| podling.status == 'current'} >>>> .map(&:name).sort >>>> >>>> get '/discuss' do >>>> @view = 'discuss' >>>> @pmcs = pmcs >>>> @ppmcs = ppmcs >>>> _html :app >>>> end >>>> >>>> get '/vote' do >>>> @view = 'vote' >>>> @pmcs = pmcs >>>> @ppmcs = ppmcs >>>> _html :app >>>> end >>>> >>>> Craig L Russell >>>> Secretary, Apache Software Foundation >>>> c...@apache.org http://db.apache.org/jdo >>>> >>> >>> Craig L Russell >>> Secretary, Apache Software Foundation >>> c...@apache.org http://db.apache.org/jdo > > Craig L Russell > Secretary, Apache Software Foundation > c...@apache.org http://db.apache.org/jdo >