Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

got new menu items working

  • Loading branch information...
commit 8c288781007743e74dfbb6d86722c7cdb0fbc375 1 parent 3a3472d
@ethn ethn authored
View
9 app/assets/stylesheets/card.css
@@ -483,6 +483,8 @@ a.missing-labeled,
display: inline;
}
+
+
/* CARDTYPE_SPECIFIC ------------------------------*/
@@ -580,6 +582,13 @@ div.search-result-list .search-result-item {
margin-left: 40px;
}
+
+/*---------( Set ) ---------- */
+
+h2.set-label {
+ padding-bottom: 10px;
+}
+
/*-----------( Image ) -----------*/
View
2  app/assets/stylesheets/settings.css
@@ -1,8 +1,10 @@
+/*
.settings-tab {
border: 0px;
margin-bottom: 20px;
padding: 5px 15px;
}
+*/
.set-select {
margin: 10px;
}
View
15 lib/cardlib/rules.rb
@@ -44,14 +44,13 @@ def rule_card_id setting_code, options={}
def related_sets
# refers to sets that users may configure from the current card - NOT to sets to which the current card belongs
- sets = ["#{name}+*self"]
- sets << "#{name}+*type" if type_id==Card::CardtypeID
- if cardname.simple?
- sets<< "#{name}+*right"
- Card.search(:type=>'Set',:left=>{:right=>name},:right=>'*type plus right',:return=>'name').each do |set_name|
- sets<< set_name
- end
- end
+ sets = [ ["#{name}+*self", Cardlib::Patterns::SelfPattern.label( name) ] ]
+ sets.unshift ["#{name}+*type", Cardlib::Patterns::TypePattern.label( name) ] if type_id==Card::CardtypeID
+ sets.push ["#{name}+*right", Cardlib::Patterns::RightPattern.label(name) ] if cardname.simple?
+
+# Card.search(:type=>'Set',:left=>{:right=>name},:right=>'*type plus right',:return=>'name').each do |set_name|
+# sets<< set_name
+# end
sets
end
View
20 lib/wagn/renderer/html.rb
@@ -69,13 +69,13 @@ class Renderer::Html < Renderer
}
- @@default_menu ||= [
+ @@default_menu = [
{ :view=>:edit, :text=>'edit', :if=>:edit, :sub=>[
{ :view=>:edit, :text=>'content' },
{ :view=>:edit_name, :text=>'name' },
{ :view=>:edit_type, :text=>'type: %{type}' },
{ :related=>{ :name=>:structure, :view=>:edit }, :text=>'structure', :if=>:structure },
-# { :view=>:edit_type, :text=>'type: %{type}' },
+ { :link=>:delete, :if=>:delete }
] },
{ :view=>:home, :text=>'view', :sub=> [
{ :view=>:home, :text=>'refresh' },
@@ -86,7 +86,14 @@ class Renderer::Html < Renderer
] },
{ :related=>{ :name=>"+discussion" }, :text=>'discuss', :if=>:discuss },
{ :view=>:options, :text=>'advanced', :sub=>[
- { :view=>:options, :text=>'rules' },
+ { :view=>:options, :text=>'rules', :sub=>[
+ :list => { :related_sets=> { :view=>:options, :text=>:text, :path_opts=>:path_opts } }
+ ] },
+ { :plain=>'related', :sub=>[
+ { :list=> { :piecenames => { :page=>:item } }, :if => :piecenames },
+ { :related=>"+*plus cards", :text=>'children' },
+ { :related=>"+*plus parts", :text=>'mates' },
+ ] },
{ :related=>"+*referred to by", :text=>"references to", :sub=>[
{ :related=>"+*referred to by", :text=>"all" },
{ :related=>"+*linkers", :text=>"links" },
@@ -96,12 +103,7 @@ class Renderer::Html < Renderer
{ :related=>"+*refers to", :text=>"all" },
{ :related=>"+*links", :text=>"links" },
{ :related=>"+*inclusions", :text=>"inclusions" }
- ] },
- { :plain=>'related', :sub=>[
- { :plain=>'ancestors', :if=>:piecenames, :sub=>{ :piecenames => { :page=>:item } } },
- { :related=>"+*plus cards", :text=>'children' },
- { :related=>"+*plus parts", :text=>'mates' },
- ] },
+ ] },
{ :related=>'+*editors', :text=>'editors', :if=>:creator, :sub=>[
{ :related=>"+*editors", :text=>'all editors' },
{ :page=>:creator, :text=>"creator: %{creator}" },
View
145 lib/wagn/set/all/rich_html.rb
@@ -108,11 +108,12 @@ module Set::All::RichHtml
end
@menu_vars = {
- :self => card.name,
- :type => card.type_name,
- :structure => card.hard_template && card.template.ok?(:update) && card.template.name,
- :discuss => disc_card && disc_card.ok?( disc_card.new_card? ? :create : :read),
- :piecenames => card.junction? && card.cardname.piece_names[0..-2],
+ :self => card.name,
+ :type => card.type_name,
+ :structure => card.hard_template && card.template.ok?(:update) && card.template.name,
+ :discuss => disc_card && disc_card.ok?( disc_card.new_card? ? :create : :read),
+ :piecenames => card.junction? && card.cardname.piece_names[0..-2].map { |n| { :item=>n } },
+ :related_sets => card.related_sets.map { |name,label| { :text=>label, :path_opts=>{ :current_set => name } } }
}
if card.real?
@menu_vars.merge!({
@@ -120,7 +121,12 @@ module Set::All::RichHtml
:account => card.account && card.update_account_ok?,
:watch => Account.logged_in? && render_watch,
:creator => card.creator.name,
- :updater => card.updater.name,
+ :updater => card.updater.name,
+ :delete => card.ok?(:delete) && link_to( 'delete', path(:action=>:delete),
+ :class=>'slotter standard-delete',
+ :'data-confirm'=> "Are you sure you want to delete #{card.name}?"
+ )
+
})
end
@@ -242,36 +248,26 @@ module Set::All::RichHtml
###---( EDIT VIEWS )
define_view :edit, :perms=>:update, :tags=>:unknown_ok do |args|
- confirm_delete = "Are you sure you want to delete #{card.name}?"
- if dependents = card.dependents and dependents.any?
- confirm_delete += %{ \n\nThat would mean removing #{dependents.size} related piece(s) of information. }
- end
-
wrap :edit, args.merge(:frame=>true) do
%{
- #{ help_text :edit_help }
- #{_render_header }
- #{ wrap_content :edit, :body=>true, :class=>'card-editor' do
- card_form :update, 'card-form card-edit-form autosave' do |f|
- @form= f
- %{
- <div>#{ edit_slot args }</div>
- <fieldset>
- <div class="button-area">
- #{ submit_tag 'Submit', :class=>'submit-button' }
- #{ button_tag 'Cancel', :class=>'cancel-button slotter', :href=>path, :type=>'button'}
- #{
- if !card.new_card?
- button_tag "Delete", :href=>path(:action=>:delete), :type=>'button',
- :class=>'delete-button slotter standard-delete', :'data-confirm'=>confirm_delete
- end
- }
- </div>
- </fieldset>
- }
+ #{ help_text :edit_help }
+ #{_render_header }
+ #{ wrap_content :edit, :body=>true, :class=>'card-editor' do
+ card_form :update, 'card-form card-edit-form autosave' do |f|
+ @form= f
+ %{
+ <div>#{ edit_slot args }</div>
+ <fieldset>
+ <div class="button-area">
+ #{ submit_tag 'Submit', :class=>'submit-button' }
+ #{ button_tag 'Cancel', :class=>'cancel-button slotter', :href=>path, :type=>'button' }
+ </div>
+ </fieldset>
+ }
+ end
end
- end }
- #{ notice }
+ }
+ #{ notice }
}
end
end
@@ -400,43 +396,25 @@ module Set::All::RichHtml
end
define_view :options do |args|
- related_sets = card.related_sets
- current_set = params[:current_set] || related_sets[(card.type_id==Card::CardtypeID ? 1 : 0)] #FIXME - explicit cardtype reference
- set_options = related_sets.map do |set_name|
- set_card = Card.fetch set_name
- selected = set_card.key == current_set.to_name.key ? 'selected="selected"' : ''
- %{<option value="#{ set_card.key }" #{ selected }>#{ set_card.label }</option>}
- end.join
+ current_set = Card.fetch( params[:current_set] || card.related_sets[0][0] )
wrap :options, args.merge(:frame=>true) do
- %{ #{ _render_header }
- <div class="options-body">
- <div class="settings-tab">
- #{ if !related_sets.empty?
- %{ <div class="set-selection">
- #{ form_tag path(:view=>:options), :method=>'get', :remote=>true, :class=>'slotter' }
- <label>Set:</label>
- <select name="current_set" class="set-select">#{ set_options }</select>
- </form>
- </div>}
- end }
-
- <div class="current-set">
- #{ raw subrenderer( Card.fetch current_set).render_content }
- </div>
+ %{
+ #{ _render_header }
+ <div class="card-body">
+ #{ subrenderer( current_set ).render_content }
- #{ if card.accountable?
- %{<div class="new-account-link">
- #{ link_to %{Add a sign-in account for "#{card.name}"}, path(:view=>:new_account),
- :class=>'slotter new-account-link', :remote=>true }
- </div>}
- end
- }
- </div>
- </div>
- #{ notice }
- }
- end
+ #{ if card.accountable?
+ %{<div class="new-account-link">
+ #{ link_to %{Add a sign-in account for "#{card.name}"}, path(:view=>:new_account),
+ :class=>'slotter new-account-link', :remote=>true }
+ </div>}
+ end
+ }
+ </div>
+ #{ notice }
+ }
+ end
end
define_view :option_roles do |args|
@@ -689,7 +667,9 @@ module Set::All::RichHtml
class Renderer::Html < Renderer
def build_menu_items array
+
array.map do |h|
+ add_li_tag = true
h = h.clone if Hash===h
if !h[:if] or @menu_vars[ h[:if] ]
h[:text] = h[:text] % @menu_vars if h[:text]
@@ -701,6 +681,19 @@ def build_menu_items array
when h[:page]
next unless h[:page] = menu_subs( h[:page] )
link_to_page (raw("#{h[:text] || h[:page]} &crarr;")), h[:page]
+ when h[:list]
+ items = []
+ h[:list].each do |k1,v1| # piecenames, {pages=>itmes}
+ items = menu_subs(k1).map do |item_val| #[names].each do |name|
+ menu_item = v1.clone
+ menu_item.each do |k2, v2| # | :page, :item|
+ menu_item[k2] = item_val[v2] if item_val.has_key?(v2)
+ end
+ menu_item
+ end
+ end
+ add_li_tag = false
+ build_menu_items items
else
if h[:related]
h[:related] = if String === h[:related]
@@ -720,30 +713,16 @@ def build_menu_items array
raise "bad menu item"
end
end
- if Hash === h[:sub]
- arr = []
- h[:sub].each do |k1,v1| # piecenames, {pages=>itmes}
- menu_subs(k1).each do |item_val| #[names].each do |name|
- menu_item = v1.clone
- menu_item.each do |k2, v2|
- menu_item[k2] = item_val if v2 == :item
- end
- arr << menu_item
- end
- end
- h[:sub] = arr
- end
sub = h[:sub] && "\n<ul>\n#{build_menu_items h[:sub]}\n</ul>\n"
- "<li>#{link} #{sub}</li>"
+ add_li_tag ? "<li>#{link} #{sub}</li>" : link
end
- end.compact * "\n"
+ end.flatten.compact * "\n"
end
def menu_subs key
Symbol===key ? @menu_vars[key] : key
end
-
def watching_type_cards
%{<div class="faint">(following)</div>} #yuck
end
View
6 lib/wagn/set/type/set.rb
@@ -18,8 +18,10 @@ module Set
process_inclusion rule_card, :view=>:closed_rule
end * "\n" )
end.compact * ''
-
- content_tag('table', :class=>'set-rules') { body }
+ %{
+ <h2 class="set-label">#{ card.label }</h2>
+ #{ content_tag('table', :class=>'set-rules') { body } }
+ }
end
View
20 spec/lib/cardlib/setting_spec.rb
@@ -45,16 +45,16 @@
sets = Card['Cardtype A'].related_sets
sets.should == ['Cardtype A+*self', 'Cardtype A+*type', 'Cardtype A+*right']
end
- it "should show type plus right sets when they exist" do
- Account.as_bot { Card.create :name=>'Basic+A+*type plus right', :content=>'' }
- sets = Card['A'].related_sets
- sets.should == ['A+*self', 'A+*right', 'Basic+A+*type plus right']
- end
- it "should show type plus right sets when they exist, and type" do
- Account.as_bot { Card.create :name=>'Basic+Cardtype A+*type plus right', :content=>'' }
- sets = Card['Cardtype A'].related_sets
- sets.should == ['Cardtype A+*self', 'Cardtype A+*type', 'Cardtype A+*right', 'Basic+Cardtype A+*type plus right']
- end
+# it "should show type plus right sets when they exist" do
+# Account.as_bot { Card.create :name=>'Basic+A+*type plus right', :content=>'' }
+# sets = Card['A'].related_sets
+# sets.should == ['A+*self', 'A+*right', 'Basic+A+*type plus right']
+# end
+# it "should show type plus right sets when they exist, and type" do
+# Account.as_bot { Card.create :name=>'Basic+Cardtype A+*type plus right', :content=>'' }
+# sets = Card['Cardtype A'].related_sets
+# sets.should == ['Cardtype A+*self', 'Cardtype A+*type', 'Cardtype A+*right', 'Basic+Cardtype A+*type plus right']
+# end
it "should have sets for a non-simple card" do
sets = Card['A+B'].related_sets
sets.should == ['A+B+*self']
Please sign in to comment.
Something went wrong with that request. Please try again.