Changeset 1083

Show
Ignore:
Timestamp:
2008-07-01 01:22:30 (6 months ago)
Author:
gaspard
Message:

Fixed some tests. Added 'dyn_keys' to virtual_classes so that default fields appear in popup edit window ('title & Co' tab).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/models/node.rb

    r1081 r1083  
    726726  def klass 
    727727    vclass.to_s 
     728  end 
     729   
     730  def dyn_attribute_keys 
     731    (version.dyn.keys + (virtual_class ? virtual_class.dyn_keys.split(',').map(&:strip) : [])).uniq.sort 
    728732  end 
    729733   
  • trunk/app/views/templates/edit_tabs/_title.rhtml

    r810 r1083  
    11<label for="v_title"><%= _("title")  %></label> 
    2 <%= text_field 'node', 'v_title', :size=>nil %> 
     2<%= text_field 'node', 'v_title', :size=>nil, :class => 'full_width' %> 
    33 
    44<label for='v_lang'><%= _("language") %></label> 
     
    1212<%= date_box('node', 'v_publish_from') %> 
    1313<label for="v_summary"><%= _("summary")  %></label> 
    14 <%= text_area 'node', 'v_summary', :cols=>nil, :rows=>6, :value=>@node.v_summary %> 
     14<%= text_area 'node', 'v_summary', :cols=>nil, :rows=>6, :value=>@node.v_summary, :class => 'full_width' %> 
    1515 
    1616<label for="v_comment"><%= _("comment") %></label> 
    17 <%= text_area 'node', 'v_comment', :cols=>nil, :rows=>2 %> 
     17<%= text_area 'node', 'v_comment', :cols=>nil, :rows=>2, :class => 'full_width' %> 
     18 
     19<% (@node.version.dyn.keys + (@node.virtual_class ? @node.virtual_class.attributes.split(',').map(&:strip) : [])).uniq.sort do |k| -%> 
     20<label for="d_<%= k %>"><%= _(k) %></label> 
     21<%= text_area 'node', "d_#{k}", :cols=>nil, :rows=>2, :class => 'full_width' %> 
     22<% end -%> 
  • trunk/app/views/virtual_classes/_form.erb

    r1060 r1083  
    1919    <tr><td class='label'><%= _("create group")%></td><td><%= select('virtual_class', 'create_group_id',  visitor.groups.map{|g| [g.name, g.id]} ) %></td></tr> 
    2020    <tr><td class='label'><%= _("auto create discussion")%></td><td><%= check_box('virtual_class', 'auto_create_discussion') %></td></tr> 
     21    <tr><td class='label'><%= _("attributes")%></td><td><%= text_field('virtual_class', 'attributes') %></td></tr> 
    2122    <tr><td colspan='2'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr> 
    2223  </table> 
  • trunk/db/schema.rb

    r1069 r1083  
    291291    t.column "site_id",                :integer,                :null => false 
    292292    t.column "auto_create_discussion", :boolean 
     293    t.column "dyn_keys",               :text 
    293294  end 
    294295 
  • trunk/lib/parser/lib/rules/zena.rb

    r1082 r1083  
    13921392          out render_html_tag(@params[:text]) 
    13931393        else 
    1394           out render_html_tag(expand_with(:in_if=>false)) 
     1394          out render_html_tag(expand_with(:in_if=>false, :only => nil)) # do not propagate :only from ancestor 'if' clause 
    13951395        end 
    13961396      else 
     
    14061406      return parser_error("condition error") unless cond 
    14071407      out "<% elsif #{cond} -%>" 
    1408       out render_html_tag(expand_with(:in_if=>false)) 
     1408      out render_html_tag(expand_with(:in_if=>false, :only => nil)) # do not propagate :only from ancestor 'if' clause 
    14091409    end 
    14101410     
     
    22162216        res = prefix + dom_prefix 
    22172217      end 
    2218       if method == 'each' 
     2218      if method == 'each' && !@context[:make_form] 
    22192219        "#{res}_\#{#{var}.zip}" 
    22202220      elsif method == 'unlink' 
     
    22412241        res = prefix + dom_prefix 
    22422242      end 
    2243       if method == 'each' 
     2243      if method == 'each' && @context[:make_form] 
    22442244        "#{res}_<%= #{var}.zip %>" 
     2245      elsif method == 'unlink' 
     2246        target = nil 
     2247        parent = self.parent 
     2248        while parent 
     2249          if ['block', 'each', 'context', 'icon'].include?(parent.method) 
     2250            target = parent 
     2251            break 
     2252          end 
     2253          parent = parent.parent 
     2254        end 
     2255        target ? target.erb_dom_id : res 
    22452256      else 
    22462257        res 
  • trunk/lib/query_builder/lib/query_builder.rb

    r1081 r1083  
    212212          op = $1.strip 
    213213          rest = rest[$1.size..-1] 
    214           op = {'lt' => '<','le' => '<=','eq' => '=','ne' => '<>','ge' => '>=','gt' => '>','like' => 'LIKE', 'not like' => 'NOT LIKE'}[$1] || $1 
     214          op = {'lt' => '<','le' => '<=','eq' => '=','ne' => '<>','ge' => '>=','gt' => '>','like' => 'LIKE', 'not like' => 'NOT LIKE'}[op] || $1 
    215215          res << op 
    216216          allowed = [:value, :par_open] 
  • trunk/public/stylesheets/admin.css

    r1008 r1083  
    3939.admin .btn_validate { float:right; margin-right:30px; } 
    4040.btn_validate input { background:#C8D8C7; border:1px outset black;} 
    41 .admin .label {width:80px; line-height:1.9em;} 
     41.admin .label {width:150px; line-height:1.9em;} 
    4242.admin th { color:#450009; } 
    4343.admin .source, .admin .source_role { background:#DBBFBF;} 
  • trunk/public/stylesheets/popup.css

    r1065 r1083  
    5353 
    5454/* title */ 
    55 #node_v_title, #node_v_comment, #node_v_summary { width:96%; font:inherit; font-size:0.9em; padding:2px;} 
     55.full_width { width:96%; font:inherit; font-size:0.9em; padding:2px;} 
    5656#title_tab select, #title_tab input {font:inherit; font-size:0.86em;} 
    5757.v_publish_from, .log_at, .event_at { padding:1px 2px; width:65%; text-align:center;} 
  • trunk/test/fixtures/files/ajax_test.zafu

    r1081 r1083  
    1414 
    1515  <r:with part='context'/> 
     16 
    1617  <r:with part='content' class='project'> 
    17     <r:include template='Node' part='related'/> 
     18<div id='related'> 
     19<ul do='pages'> 
     20<li do='each'><p><b do='show' attr='v_title' edit='true' publish='true'/> <r:edit/></p> 
     21<r:zazen attr='v_summary' edit='true' publish='true'/> 
     22</li> 
     23</ul> 
     24This filter updates the "distant filter block test" 
     25<r:filter live='true' update='upfi'/> 
     26</div> 
    1827 
    19    
    20     <h3>calendar test</h3> 
    21     <div do='calendar' find='notes in site'/> 
     28<div id='edit' do='block'> 
     29  <h3>edit block test</h3> 
     30    <r:text/> 
     31    <r:edit publish='true'><r:if test='1 eq 2'>blue<r:else>edit in else</r:else></r:if></r:edit> 
     32</div> 
    2233 
    23     <h3>week calendar</h3> 
    24     <div do='calendar' find='notes in site' type='week'/> 
     34<hr/> 
    2535 
    26     <h3>tiny calendar</h3> 
    27     <div do='calendar' find='notes in site' size='tiny'/> 
     36<h2>update target test</h2> 
     37<div id='bozo' do='block'><h3 do='title' actions='all'/><r:img mode='pv'/> 
     38  <r:summary/> 
     39</div> 
    2840 
    29     <div id='edit'> 
    30       <h3>edit block test</h3> 
    31       <r:block> 
    32         <r:text/> 
    33         <r:edit><r:if test='1 eq 2'>blue<r:else>edit in else</r:else></r:if></r:edit> 
    34       </r:block> 
    35     </div> 
     41<ul do='images in site'><r:each join=', ' do='link' update='bozo'/></ul> 
    3642 
    37     <div id='filter'> 
    38       <h2>filter block test</h2> 
    39       <r:filter live='true'/> 
    40       <r:block do='pages where name like "[param:f]%"'> 
    41         <ol><li do='each' do='[name]'/></ol> 
    42       </r:block> 
    43     </div> 
     43<hr/> 
    4444 
    45     <h2>data test</h2> 
    46     <ol do='data'> 
    47       <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 
    48       <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 
    49       <li do='add'/> 
    50       <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 
    51       <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 
    52     </ol> 
     45<div id='upfi' do='block'> 
     46  <h2>distant filter block test</h2> 
     47    <ol do='pages where name like "[param:f]%" limit 5'><li do='each' do='[name]'/></ol> 
     48</div> 
     49 
     50<hr/> 
     51 
     52<div id='filter'> 
     53  <h2>filter block test</h2> 
     54  <r:filter live='true'/> 
     55  <r:block do='pages where name like "[param:f]%" limit 5'> 
     56    <ol><li do='each' do='[name]'/></ol> 
     57  </r:block> 
     58</div> 
     59 
     60<hr/> 
    5361 
    5462 
    55     <h2>data block test</h2> 
    56     <ol do='block' do='data'> 
    57       <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 
    58       <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 
    59       <li do='add'/> 
    60       <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 
    61       <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 
    62     </ol> 
     63<h2>data test</h2> 
     64<ol do='data'> 
     65  <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 
     66  <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 
     67  <li do='add' done='focus'/> 
     68  <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 
     69  <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 
     70</ol> 
    6371 
    64     <h2>drag & drop</h2> 
    65  
    66     <r:images in='site' do='each' draggable='true' do='img' mode='pv'/> 
    67  
    68     <ul do='projects in site'> 
    69       <li style='border:1px solid #400; width:100px; height:100px;' do='each'><r:drop set='icon'><b do='[name]'/><r:icon where='1'><r:unlink do='img' mode='pv'/></r:icon></r:drop></li> 
    70     </ul> 
    71  
    72     <h2>notes & comments</h2> 
    73  
    74     <r:include template='notes'/> 
     72<hr/> 
    7573 
    7674 
     75 
     76 
     77<h2>data block test</h2> 
     78<ol id='bdata' do='block' do='data'> 
     79  <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 
     80  <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 
     81  <li do='add' done='focus'/> 
     82  <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 
     83  <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 
     84</ol> 
     85 
     86<hr/> 
     87 
     88<h2>drag & drop</h2> 
     89 
     90<r:images in='site' do='each' draggable='true' do='img' mode='tiny'/> 
     91 
     92<ul do='tags in site'> 
     93  <li style='border:1px solid #400; min_width:100px; min_height:100px;' do='each' do='drop' set='set_tag'> 
     94    <b do='[v_title]'/> 
     95    <ul do='tagged'><li do='each' do='unlink' do='img' mode='tiny'/></ul> 
     96  </li> 
     97</ul> 
     98 
     99<ul do='projects in site'> 
     100  <li style='border:1px solid #400; min_width:100px; min_height:100px;' do='each'><r:drop d_foo='I am an icon for [v_title]' icon_for_id='[id]'><b do='title' actions='all'/><r:icon where='1'><r:unlink do='img' mode='pv'/> <r:show attr='d_foo'/> </r:icon></r:drop> 
     101</li> 
     102</ul> 
     103 
     104<hr/> 
     105 
     106 
     107<h2>notes & comments</h2> 
     108 
     109<r:include template='notes'/> 
     110 
     111<hr/> 
    77112  </r:with> 
    78113</r:include> 
  • trunk/test/helpers/zena_parser/ajax.yml

    r1080 r1083  
    2121add_each_no_form: 
    2222  src: "<ul do='children' id='things'><li do='each'>I <p do='[name]'>blah</p></li><li do='add'/></ul>" 
    23   res: "/<ul><li.*id='things_22_add'.*li id='things_22_form'.*form.*hidden.*I <p><input type='text' id='things_22_name' name='node\[name\]' value=''\/><\/p><\/form><\/li>/" 
     23  res: "/<ul><li.*id='things_add'.*li id='things_form'.*form.*hidden.*I <p><input type='text' id='things_name' name='node\[name\]' value=''\/><\/p><\/form><\/li>/" 
    2424 
    2525add_each_no_form_date: 
    2626  src: "<ul do='children' id='things'><li do='each'>I <p do='show' date='event_at' tformat='short_date'>blah</p></li><li do='add'/></ul>" 
    27   res: "/<ul><li.*id='things_22_add'.*li id='things_22_form'.*form.*hidden.*I <p>.*date_box.*<input id='things_22_event_at' name='node\[event_at\]' type='text' value.*/m" 
     27  res: "/<ul><li.*id='things_add'.*li id='things_form'.*form.*hidden.*I <p>.*date_box.*<input id='things_event_at' name='node\[event_at\]' type='text' value.*/m" 
    2828 
    2929add_each_no_form_focus: 
    3030  src: "<ul do='children' id='test'><li do='each'>I <p do='[v_title]'>blah</p></li><li do='add' focus='v_title'/></ul>" 
    31   res: "/<ul><li.*id=.*_add.*onclick.*toggle.*test_22_v_title.*focus.*li id=.*_form.*form.*hidden.*I <p><input type='text' id='test_22_v_title' name='node\[v_title\]' value=''\/><\/p><\/form><\/li>/" 
     31  res: "/<ul><li.*id=.*_add.*onclick.*toggle.*test_v_title.*focus.*li id=.*_form.*form.*hidden.*I <p><input type='text' id='test_v_title' name='node\[v_title\]' value=''\/><\/p><\/form><\/li>/" 
    3232 
    3333each_add_with_form: 
     
    7979add_each_publish: 
    8080  src: "<ul do='children' id='things'><li do='each'>I <p do='[name]'>blah</p></li><li do='add' publish='true'/></ul>" 
    81   res: "/<ul><li.*id='things_22_add'.*li id='things_22_form'.*form.*hidden.*name='node\[v_status\]' value=\"50\"/" 
     81  res: "/<ul><li.*id='things_add'.*li id='things_form'.*form.*hidden.*name='node\[v_status\]' value=\"50\"/" 
    8282 
    8383block_edit_form: 
     
    103103default_focus_field: 
    104104  src: "<ol do='comments'><li do='each'/><li do='form'><input name='author_name'/> ... <input name='text'/></li><li do='add'/></ol>" 
    105   res: "/\$\(\"list_22_form_t\"\).focusFirstElement\(\)/" 
     105  res: "/\$\(\"list_form_t\"\).focusFirstElement\(\)/" 
    106106 
    107107live_filter: 
     
    123123draggable_do_syntax: 
    124124  src: "<r:images in='site' do='each' draggable='true' do='img' mode='pv'/>" 
    125   res: "/div id='list_22_30'><img src='/en/image30_pv.jpg'.*list_22_30.*.each\(Zena.draggable/" 
     125  res: "/div id='list_30'><img src='/en/image30_pv.jpg'.*list_30.*.each\(Zena.draggable/" 
    126126 
    127127 
  • trunk/test/helpers/zena_parser/basic.yml

    r1081 r1083  
    8181 
    8282zazen_shortcut: 
    83   src: "<div do='{v_title}'>hello</div>" 
    84   tem: "<div><%= zazen(@node.version.title, :node=>@node) %></div>" 
    85   res: "<div><p>status title</p></div>" 
     83  src: "<div class='foo' do='{v_title}'>hello</div>" 
     84  tem: "<div class='foo'><%= zazen(@node.version.title, :node=>@node) %></div>" 
     85  res: "<div class='foo'><p>status title</p></div>" 
    8686 
    8787show_url: 
  • trunk/test/sites/zena/virtual_classes.yml

    r1060 r1083  
    1010  kpath:           NNP 
    1111  real_class:      Note 
     12  dyn_keys:        reading, book 
    1213  auto_create_discussion: yes 
    1314 
  • trunk/test/unit/virtual_class_test.rb

    r1059 r1083  
    200200    assert virtual_classes(:Post).auto_create_discussion 
    201201  end 
     202   
     203  def test_attributes 
     204    login(:lion) 
     205    post = secure!(Node) { nodes(:opening) } 
     206    assert_equal ["book", "reading"], post.dyn_attribute_keys 
     207    assert post.update_attributes(:d_foo => 'bar', :d_book => 'Alice In Wonderland') 
     208    assert_equal ["book", "foo", "reading"], post.dyn_attribute_keys 
     209  end 
    202210end 
  • trunk/vendor/plugins/dyn_attributes/lib/dyn_attributes.rb

    r1061 r1083  
    4242      return unless valid_key?(key) 
    4343      hash[key.to_s] = (value && value != '') ? value : nil 
     44    end 
     45     
     46    def keys 
     47      hash.keys 
    4448    end 
    4549