Skip to content

Commit

Permalink
Releasing 1.2.1 (fix on grid.js)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 1, 2012
1 parent 029502f commit 7cbc548
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion History.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
== 1.2.0 2012-05-01
== 1.2.0, 1.2.1 2012-05-01

* Major changes
* Added 'remove_from_db' method to remove a site from the database.
Expand Down
54 changes: 28 additions & 26 deletions bricks/grid/lib/bricks/grid.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# encoding: utf-8
require 'json'
require 'uuidtools'

module Bricks
module Grid
Expand Down Expand Up @@ -27,20 +28,7 @@ def get_table_from_json(text)

return table, error
end

end # Common

module ControllerMethods
include Common
end

# Routes = {
# :cell_update => :post, :table_update => :post, :cell_edit => :get
# }

module ViewMethods
include Common


# Create a table from an attribute
def make_table(opts)
style, node, attribute = opts[:style], opts[:node], opts[:attribute]
Expand All @@ -62,11 +50,11 @@ def make_table(opts)
table, error = get_table_from_json(node.prop[attribute])

res = prefix + error.to_s
if node.can_write?
msg = opts[:msg] || _('type to edit')
res << "<table data-a='node[#{attribute}]' data-msg='#{msg}' class='grid'>\n<tr>"
else
res << "<table><tr>"
uuid = UUIDTools::UUID.random_create.to_s.gsub('-','')
msg = opts[:msg] || _('type to edit')
res << "<table id='grid#{uuid}' data-a='node[#{attribute}]' data-msg='#{msg}' class='grid'>\n<tr>"
if node.can_write? && !opts[:no_edit]
js_data << "Grid.make($('grid#{uuid}'));"
end


Expand All @@ -89,20 +77,34 @@ def make_table(opts)
rescue JSON::ParserError
"<span class='unknownLink'>could not build table from text</span>"
end
end # Common

module ControllerMethods
include Common
end

# Routes = {
# :cell_update => :post, :table_update => :post, :cell_edit => :get
# }

module ViewMethods
include Common

def grid_asset(opts)
make_table(:node => opts[:node], :attribute => opts[:content])
end
end

# New better grid using JS.
module ZafuMethods
def r_grid
attr = @params[:attr]
return parser_error("Missing 'attr' parameter") unless attr
attribute = @params[:attr]
return parser_error("Missing 'attr' parameter") unless attribute
# Make sure it compiles
code = RubyLess.translate(node(Node).klass, attr)
code = RubyLess.translate(node(Node).klass, attribute)
msg = RubyLess.translate(self, "t('type to edit')")
out "<%= make_table(:attribute => #{attr.inspect}, :node => #{node(Node)}, :msg => #{msg}) %>"
if @params[:edit] == 'true'
out "<% js_data << %Q{$$('.grid').each(function(e) {Grid.make(e)})} %>"
end
editable = @params[:edit] == 'true' ? '' : ', :no_edit => true'
out "<%= make_table(:attribute => #{attribute.inspect}, :node => #{node(Node)}, :msg => #{msg}#{editable}) %>"
end
end
end # Grid
Expand Down
2 changes: 1 addition & 1 deletion lib/zena/info.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Zena
VERSION = '1.2.0'
VERSION = '1.2.1'
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
end
1 change: 1 addition & 0 deletions public/javascripts/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ Grid.addButtons = function(table) {
}

Grid.make = function(table) {
if (table.grid) return;
Grid.grid_c++;
Grid.grids[Grid.grid_c] = table;
table.grid = {
Expand Down
2 changes: 1 addition & 1 deletion zena.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Gem::Specification.new do |s|
s.name = %q{zena}
s.version = "1.2.0"
s.version = "1.2.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Gaspard Bucher"]
Expand Down

0 comments on commit 7cbc548

Please sign in to comment.