lolita-editable-list 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +130 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/app/views/components/lolita/list/editable/_body_cell.html.erb +3 -0
- data/app/views/components/lolita/list/editable/_display.html.erb +61 -0
- data/app/views/components/lolita/list/editable/_row.html.erb +7 -0
- data/lib/generators/lolita_editable_list/assets_generator.rb +13 -0
- data/lib/generators/lolita_editable_list/install_generator.rb +11 -0
- data/lib/lolita-editable-list.rb +38 -0
- data/lib/lolita-editable-list/configuration/editable_list.rb +102 -0
- data/lib/lolita-editable-list/configuration/list.rb +14 -0
- data/lib/lolita-editable-list/version.rb +3 -0
- data/lolita-editable-list.gemspec +94 -0
- data/public/stylesheets/lolita/editable.css +4 -0
- data/spec/configuration/editable_list_spec.rb +44 -0
- data/spec/factories/post.rb +4 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/test_orm/active_record.rb +9 -0
- data/spec/test_orm/active_record/post.rb +9 -0
- data/spec/test_orm/config/active_record.yml +2 -0
- data/spec/test_orm/db/migrate/01_create_posts.rb +16 -0
- data/spec/test_orm/rails/config/application.rb +8 -0
- data/spec/test_orm/rails/config/enviroment.rb +5 -0
- data/spec/test_orm/rails/config/routes.rb +3 -0
- data/spec/test_orm/rails/log/development.log +0 -0
- data/spec/test_orm/support.rb +9 -0
- metadata +153 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format doc
|
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem "lolita", "~> 3.0.7"
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem "bundler", "~> 1.0.0"
|
7
|
+
gem "jeweler", "~> 1.5.2"
|
8
|
+
end
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem "rspec-rails", "~> 2.5"
|
12
|
+
gem "rspec", "~> 2.5"
|
13
|
+
gem "ffaker"
|
14
|
+
gem "factory_girl"
|
15
|
+
gem "sqlite3"
|
16
|
+
gem 'ruby-debug19', :platforms => :mri_19
|
17
|
+
gem 'cover_me', '>= 1.0.0.rc6'
|
18
|
+
gem 'activerecord', "~> 3.0", :require=>false
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.5)
|
6
|
+
actionpack (= 3.0.5)
|
7
|
+
mail (~> 2.2.15)
|
8
|
+
actionpack (3.0.5)
|
9
|
+
activemodel (= 3.0.5)
|
10
|
+
activesupport (= 3.0.5)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.5)
|
19
|
+
activesupport (= 3.0.5)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.5)
|
23
|
+
activemodel (= 3.0.5)
|
24
|
+
activesupport (= 3.0.5)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.5)
|
28
|
+
activemodel (= 3.0.5)
|
29
|
+
activesupport (= 3.0.5)
|
30
|
+
activesupport (3.0.5)
|
31
|
+
archive-tar-minitar (0.5.2)
|
32
|
+
arel (2.0.9)
|
33
|
+
builder (2.1.2)
|
34
|
+
columnize (0.3.2)
|
35
|
+
configatron (2.7.2)
|
36
|
+
yamler (>= 0.1.0)
|
37
|
+
cover_me (1.0.0.rc6)
|
38
|
+
configatron
|
39
|
+
hashie
|
40
|
+
diff-lcs (1.1.2)
|
41
|
+
erubis (2.6.6)
|
42
|
+
abstract (>= 1.0.0)
|
43
|
+
factory_girl (1.3.3)
|
44
|
+
ffaker (1.4.0)
|
45
|
+
git (1.2.5)
|
46
|
+
hashie (1.0.0)
|
47
|
+
i18n (0.5.0)
|
48
|
+
jeweler (1.5.2)
|
49
|
+
bundler (~> 1.0.0)
|
50
|
+
git (>= 1.2.5)
|
51
|
+
rake
|
52
|
+
linecache19 (0.5.11)
|
53
|
+
ruby_core_source (>= 0.1.4)
|
54
|
+
lolita (3.0.7)
|
55
|
+
abstract
|
56
|
+
builder (~> 2.1.2)
|
57
|
+
rails (~> 3.0)
|
58
|
+
will_paginate (~> 3.0.pre2)
|
59
|
+
mail (2.2.15)
|
60
|
+
activesupport (>= 2.3.6)
|
61
|
+
i18n (>= 0.4.0)
|
62
|
+
mime-types (~> 1.16)
|
63
|
+
treetop (~> 1.4.8)
|
64
|
+
mime-types (1.16)
|
65
|
+
polyglot (0.3.1)
|
66
|
+
rack (1.2.2)
|
67
|
+
rack-mount (0.6.14)
|
68
|
+
rack (>= 1.0.0)
|
69
|
+
rack-test (0.5.7)
|
70
|
+
rack (>= 1.0)
|
71
|
+
rails (3.0.5)
|
72
|
+
actionmailer (= 3.0.5)
|
73
|
+
actionpack (= 3.0.5)
|
74
|
+
activerecord (= 3.0.5)
|
75
|
+
activeresource (= 3.0.5)
|
76
|
+
activesupport (= 3.0.5)
|
77
|
+
bundler (~> 1.0)
|
78
|
+
railties (= 3.0.5)
|
79
|
+
railties (3.0.5)
|
80
|
+
actionpack (= 3.0.5)
|
81
|
+
activesupport (= 3.0.5)
|
82
|
+
rake (>= 0.8.7)
|
83
|
+
thor (~> 0.14.4)
|
84
|
+
rake (0.8.7)
|
85
|
+
rspec (2.5.0)
|
86
|
+
rspec-core (~> 2.5.0)
|
87
|
+
rspec-expectations (~> 2.5.0)
|
88
|
+
rspec-mocks (~> 2.5.0)
|
89
|
+
rspec-core (2.5.1)
|
90
|
+
rspec-expectations (2.5.0)
|
91
|
+
diff-lcs (~> 1.1.2)
|
92
|
+
rspec-mocks (2.5.0)
|
93
|
+
rspec-rails (2.5.0)
|
94
|
+
actionpack (~> 3.0)
|
95
|
+
activesupport (~> 3.0)
|
96
|
+
railties (~> 3.0)
|
97
|
+
rspec (~> 2.5.0)
|
98
|
+
ruby-debug-base19 (0.11.24)
|
99
|
+
columnize (>= 0.3.1)
|
100
|
+
linecache19 (>= 0.5.11)
|
101
|
+
ruby_core_source (>= 0.1.4)
|
102
|
+
ruby-debug19 (0.11.6)
|
103
|
+
columnize (>= 0.3.1)
|
104
|
+
linecache19 (>= 0.5.11)
|
105
|
+
ruby-debug-base19 (>= 0.11.19)
|
106
|
+
ruby_core_source (0.1.4)
|
107
|
+
archive-tar-minitar (>= 0.5.2)
|
108
|
+
sqlite3 (1.3.3)
|
109
|
+
thor (0.14.6)
|
110
|
+
treetop (1.4.9)
|
111
|
+
polyglot (>= 0.3.1)
|
112
|
+
tzinfo (0.3.25)
|
113
|
+
will_paginate (3.0.pre2)
|
114
|
+
yamler (0.1.0)
|
115
|
+
|
116
|
+
PLATFORMS
|
117
|
+
ruby
|
118
|
+
|
119
|
+
DEPENDENCIES
|
120
|
+
activerecord (~> 3.0)
|
121
|
+
bundler (~> 1.0.0)
|
122
|
+
cover_me (>= 1.0.0.rc6)
|
123
|
+
factory_girl
|
124
|
+
ffaker
|
125
|
+
jeweler (~> 1.5.2)
|
126
|
+
lolita (~> 3.0.7)
|
127
|
+
rspec (~> 2.5)
|
128
|
+
rspec-rails (~> 2.5)
|
129
|
+
ruby-debug19
|
130
|
+
sqlite3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Gatis Tomsons
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= lolita-list-edit
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to lolita-list-edit
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Gatis Tomsons. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "lolita-editable-list"
|
16
|
+
gem.homepage = "http://github.com/ithouse/lolita-list-edit"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = "List inline editing for Lolita"
|
19
|
+
gem.description = "With this gem you are able to change content right on the list table, changes will be saved through ajax call."
|
20
|
+
gem.email = "gatis@ithouse.lv"
|
21
|
+
gem.authors = ["IT House (Latvia)"]
|
22
|
+
gem.add_runtime_dependency 'lolita', '~> 3.0.7'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.5.0'
|
24
|
+
end
|
25
|
+
Jeweler::RubygemsDotOrgTasks.new
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rake/rdoctask'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "lolita-list-edit #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<div class="box">
|
2
|
+
<%= render_component :"lolita/list", :title %>
|
3
|
+
<%= render_component :"lolita/list", :new_resource%>
|
4
|
+
<div class="list">
|
5
|
+
<table>
|
6
|
+
<%= render_component :"lolita/list", :header, :columns=>list.columns %>
|
7
|
+
<%= render_component :"lolita/list", :body, :page=>page,:columns=>list.columns %>
|
8
|
+
</table>
|
9
|
+
</div>
|
10
|
+
<%= render_component :"lolita/list", :paginator,:page=>page, :columns=>list.columns %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<% content_for :style do %>
|
14
|
+
<%= stylesheet_link_tag "lolita/editable" %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
function save_cell(name,path,input){
|
19
|
+
var data = {
|
20
|
+
authenticity_token: '<%= form_authenticity_token %>',
|
21
|
+
<%= lolita_mapping.name %>: {}
|
22
|
+
}
|
23
|
+
data['<%= lolita_mapping.name %>'][name] = $(input).val().trim();
|
24
|
+
$(input).attr('disabled', true);
|
25
|
+
$.ajax({
|
26
|
+
type: 'PUT',
|
27
|
+
url: path,
|
28
|
+
data: data,
|
29
|
+
dataType: 'json',
|
30
|
+
success: function(data){
|
31
|
+
$(input).parent().html(data['<%= lolita_mapping.name %>'][name]);
|
32
|
+
},
|
33
|
+
error: function(){
|
34
|
+
$(input).addClass("error").attr('disabled', false);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
}
|
38
|
+
$('td.editable').live('click',function(){
|
39
|
+
if($(this).find('input').size() == 0){
|
40
|
+
var name = $(this).attr('data-name');
|
41
|
+
var value = $(this).html().trim();
|
42
|
+
var path = $(this).attr('data-path');
|
43
|
+
var input = $('<input type="text" name="'+name+'" value="'+value+'"/>');
|
44
|
+
input.css('width',$(this).width()+'px');
|
45
|
+
$(this).html("");
|
46
|
+
$(this).append(input);
|
47
|
+
input.focus();
|
48
|
+
var that = $(this);
|
49
|
+
input.blur(function(){
|
50
|
+
that.html(value);
|
51
|
+
});
|
52
|
+
input.keyup(function(e) {
|
53
|
+
if(e.keyCode == 27){
|
54
|
+
input.trigger('blur');
|
55
|
+
}else if(e.keyCode == 13){
|
56
|
+
save_cell(name,path,this);
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
});
|
61
|
+
</script>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<tr class="<%= @class_name %>">
|
2
|
+
<%= render_component :"lolita/list", :checkbox_cell, :record=>record %>
|
3
|
+
<% columns.each do |column| %>
|
4
|
+
<%= render_component :"lolita/list",:body_cell, :value=>column.with_format(record.send(column.name.to_sym)), :record => record, :name => column.name.to_sym %>
|
5
|
+
<% end %>
|
6
|
+
<%= render_component :"lolita/list", :tool_cell,:record=>record %>
|
7
|
+
</tr>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'generators/helpers/file_helper'
|
2
|
+
module LolitaEditableList
|
3
|
+
module Generators
|
4
|
+
class AssetsGenerator < Rails::Generators::Base
|
5
|
+
include Lolita::Generators::FileHelper
|
6
|
+
desc "Copy all from public directory to project public directory."
|
7
|
+
def copy_all
|
8
|
+
root=File.expand_path("../../../../",__FILE__)
|
9
|
+
copy_dir("public",:root=>root)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module LolitaEditableList
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
include Lolita::Generators::FileHelper
|
5
|
+
desc "Copy assets and create migrations."
|
6
|
+
def copy_assets
|
7
|
+
generate("lolita_editable_list:assets")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'lolita'
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/lolita-editable-list/configuration/editable_list')
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lolita-editable-list/configuration/list')
|
4
|
+
|
5
|
+
# Acts as Engine, to use views/controllers
|
6
|
+
if defined?(Rails)
|
7
|
+
module LolitaEditableList
|
8
|
+
class Engine < Rails::Engine
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Monkey patch until Lolita will support Hooks
|
14
|
+
|
15
|
+
module ActionView
|
16
|
+
# = Action View Rendering
|
17
|
+
module Rendering
|
18
|
+
def self.included(mod)
|
19
|
+
mod.class_eval do
|
20
|
+
alias_method_chain :render, :lolita_editable
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def render_with_lolita_editable(options = {}, locals = {}, &block)
|
25
|
+
if defined?(lolita_mapping)
|
26
|
+
model = lolita_mapping.class_name.constantize
|
27
|
+
if model.lolita.list.editable?
|
28
|
+
if options[:partial] =~ /^\/components\/lolita\/list\/([a-z_]+)$/
|
29
|
+
if %w(body_cell display row).include?($1)
|
30
|
+
options[:partial] = "/components/lolita/list/editable/#{$1}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
render_without_lolita_editable(options, locals, &block)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Lolita
|
2
|
+
module Configuration
|
3
|
+
# ===Example
|
4
|
+
# # all supported columns become editable
|
5
|
+
# lolita do
|
6
|
+
# list do
|
7
|
+
# is_editable
|
8
|
+
# end
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# # only some
|
12
|
+
# lolita do
|
13
|
+
# list do
|
14
|
+
# is_editable :only => [:name,:title]
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# lolita do
|
19
|
+
# list do
|
20
|
+
# is_editable :except => [:name]
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# # or as block
|
25
|
+
# lolita do
|
26
|
+
# list do
|
27
|
+
# is_editable do
|
28
|
+
# only :name, :title
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
class EditableList
|
33
|
+
lolita_accessor :all_column_names, :except, :only
|
34
|
+
attr_accessor :list
|
35
|
+
|
36
|
+
SUPPORTED_TYPES = [:integer,:string,:decimal]
|
37
|
+
|
38
|
+
def initialize(list,*args,&block)
|
39
|
+
self.list = list
|
40
|
+
self.all_column_names = extract_supported_columns list.columns.map(&:name).map(&:to_sym)
|
41
|
+
self.set_attributes(*args)
|
42
|
+
self.instance_eval(&block) if block_given?
|
43
|
+
validate
|
44
|
+
end
|
45
|
+
|
46
|
+
def except *args
|
47
|
+
@except = args unless args.empty?
|
48
|
+
@except
|
49
|
+
end
|
50
|
+
|
51
|
+
def only *args
|
52
|
+
@only = args unless args.empty?
|
53
|
+
@only
|
54
|
+
end
|
55
|
+
|
56
|
+
def columns
|
57
|
+
if self.only
|
58
|
+
self.only.select{|name| self.all_column_names.include?(name)}
|
59
|
+
else
|
60
|
+
if self.except
|
61
|
+
self.all_column_names.select{|name| !self.except.include?(name)}
|
62
|
+
else
|
63
|
+
self.all_column_names
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Used to set attributes if block not given.
|
69
|
+
def set_attributes(*args)
|
70
|
+
if args && args[0]
|
71
|
+
if args[0].is_a?(Hash)
|
72
|
+
args[0].each{|m,value|
|
73
|
+
self.send("#{m}=".to_sym,value)
|
74
|
+
}
|
75
|
+
else
|
76
|
+
raise ArgumentError.new("Lolita::Configuration::List::Editable arguments must be Hash instead of #{args[0].class}")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def validate
|
84
|
+
[:except,:only].each do |name|
|
85
|
+
unless self.send(name).is_a?(List)
|
86
|
+
ArgumentError.new "Lolita::Configuration::List::Editable option :#{name} should be list"
|
87
|
+
end if self.send(name)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def extract_supported_columns columns = []
|
92
|
+
columns.select do |name|
|
93
|
+
# for now we dont support associations
|
94
|
+
unless self.list.dbi.reflect_on_association(name)
|
95
|
+
field = self.list.dbi.fields.select{|f| f[:name] == name.to_s}.first
|
96
|
+
field && SUPPORTED_TYPES.include?(field[:type].to_sym)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Lolita
|
2
|
+
module Configuration
|
3
|
+
class List
|
4
|
+
lolita_accessor :editable
|
5
|
+
def is_editable(*args, &block)
|
6
|
+
@editable ||= Lolita::Configuration::EditableList.new(self,*args, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
def editable?
|
10
|
+
self.editable
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{lolita-editable-list}
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["IT House (Latvia)"]
|
12
|
+
s.date = %q{2011-04-01}
|
13
|
+
s.description = %q{With this gem you are able to change content right on the list table, changes will be saved through ajax call.}
|
14
|
+
s.email = %q{gatis@ithouse.lv}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"app/views/components/lolita/list/editable/_body_cell.html.erb",
|
29
|
+
"app/views/components/lolita/list/editable/_display.html.erb",
|
30
|
+
"app/views/components/lolita/list/editable/_row.html.erb",
|
31
|
+
"lib/generators/lolita_editable_list/assets_generator.rb",
|
32
|
+
"lib/generators/lolita_editable_list/install_generator.rb",
|
33
|
+
"lib/lolita-editable-list.rb",
|
34
|
+
"lib/lolita-editable-list/configuration/editable_list.rb",
|
35
|
+
"lib/lolita-editable-list/configuration/list.rb",
|
36
|
+
"lib/lolita-editable-list/version.rb",
|
37
|
+
"lolita-editable-list.gemspec",
|
38
|
+
"public/stylesheets/lolita/editable.css",
|
39
|
+
"spec/configuration/editable_list_spec.rb",
|
40
|
+
"spec/factories/post.rb",
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"spec/test_orm/active_record.rb",
|
43
|
+
"spec/test_orm/active_record/post.rb",
|
44
|
+
"spec/test_orm/config/active_record.yml",
|
45
|
+
"spec/test_orm/db/migrate/01_create_posts.rb",
|
46
|
+
"spec/test_orm/rails/config/application.rb",
|
47
|
+
"spec/test_orm/rails/config/enviroment.rb",
|
48
|
+
"spec/test_orm/rails/config/routes.rb",
|
49
|
+
"spec/test_orm/rails/log/development.log",
|
50
|
+
"spec/test_orm/support.rb"
|
51
|
+
]
|
52
|
+
s.homepage = %q{http://github.com/ithouse/lolita-list-edit}
|
53
|
+
s.licenses = ["MIT"]
|
54
|
+
s.require_paths = ["lib"]
|
55
|
+
s.rubygems_version = %q{1.6.2}
|
56
|
+
s.summary = %q{List inline editing for Lolita}
|
57
|
+
s.test_files = [
|
58
|
+
"spec/configuration/editable_list_spec.rb",
|
59
|
+
"spec/factories/post.rb",
|
60
|
+
"spec/spec_helper.rb",
|
61
|
+
"spec/test_orm/active_record.rb",
|
62
|
+
"spec/test_orm/active_record/post.rb",
|
63
|
+
"spec/test_orm/db/migrate/01_create_posts.rb",
|
64
|
+
"spec/test_orm/rails/config/application.rb",
|
65
|
+
"spec/test_orm/rails/config/enviroment.rb",
|
66
|
+
"spec/test_orm/rails/config/routes.rb",
|
67
|
+
"spec/test_orm/support.rb"
|
68
|
+
]
|
69
|
+
|
70
|
+
if s.respond_to? :specification_version then
|
71
|
+
s.specification_version = 3
|
72
|
+
|
73
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
74
|
+
s.add_runtime_dependency(%q<lolita>, ["~> 3.0.7"])
|
75
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
76
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
77
|
+
s.add_runtime_dependency(%q<lolita>, ["~> 3.0.7"])
|
78
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
|
79
|
+
else
|
80
|
+
s.add_dependency(%q<lolita>, ["~> 3.0.7"])
|
81
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
82
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
83
|
+
s.add_dependency(%q<lolita>, ["~> 3.0.7"])
|
84
|
+
s.add_dependency(%q<rspec>, ["~> 2.5.0"])
|
85
|
+
end
|
86
|
+
else
|
87
|
+
s.add_dependency(%q<lolita>, ["~> 3.0.7"])
|
88
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
89
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
90
|
+
s.add_dependency(%q<lolita>, ["~> 3.0.7"])
|
91
|
+
s.add_dependency(%q<rspec>, ["~> 2.5.0"])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Lolita::Configuration::EditableList do
|
4
|
+
before(:each) do
|
5
|
+
Post.lolita.list.editable = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:all_columns){Post.lolita.list.editable.all_column_names}
|
9
|
+
|
10
|
+
it "should configure defaults" do
|
11
|
+
Post.lolita.list.is_editable
|
12
|
+
Post.lolita.list.editable.columns.should == all_columns
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return :only fields" do
|
16
|
+
Post.lolita.list.is_editable :only => [:title]
|
17
|
+
Post.lolita.list.editable.columns.should == [:title]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should return :except fields" do
|
21
|
+
Post.lolita.list.is_editable do
|
22
|
+
except :title
|
23
|
+
end
|
24
|
+
Post.lolita.list.editable.columns.should == all_columns.select{|f| f != :title}
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return :only fields assigned in block" do
|
28
|
+
Post.lolita.list.is_editable do
|
29
|
+
only :title
|
30
|
+
end
|
31
|
+
Post.lolita.list.editable.columns.should == [:title]
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return :except fields assigned in block" do
|
35
|
+
Post.lolita.list.is_editable :except => [:title]
|
36
|
+
Post.lolita.list.editable.columns.should == all_columns.select{|f| f != :title}
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should test is it editable?" do
|
40
|
+
Post.lolita.list.editable?.should be_false
|
41
|
+
Post.lolita.list.is_editable
|
42
|
+
Post.lolita.list.editable?.should be_true
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'cover_me'
|
3
|
+
require 'factory_girl_rails'
|
4
|
+
require 'ffaker'
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec-rails'
|
7
|
+
require 'ruby-debug'
|
8
|
+
|
9
|
+
require File.expand_path('spec/test_orm/support')
|
10
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/lolita-editable-list')
|
11
|
+
LOLITA_ORM = :active_record
|
12
|
+
require "test_orm/#{LOLITA_ORM}"
|
13
|
+
Dir["#{File.dirname(__FILE__)}/factories/*.rb"].each {|f| require f}
|
14
|
+
#Support.load_rails_application
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.mock_with :rspec
|
18
|
+
#config.use_transactional_fixtures = true if LOLITA_ORM == :active_record
|
19
|
+
end
|
20
|
+
|
21
|
+
CoverMe.config do |c|
|
22
|
+
c.project.root= File.expand_path('../../',__FILE__)
|
23
|
+
c.file_pattern
|
24
|
+
c.html_formatter.output_path
|
25
|
+
end
|
26
|
+
|
27
|
+
CoverMe.complete!
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'logger'
|
3
|
+
dbconf = YAML::load(File.open(File.expand_path('spec/test_orm/config/active_record.yml')))
|
4
|
+
ActiveRecord::Base.establish_connection(dbconf)
|
5
|
+
ActiveRecord::Base.logger = Logger.new(File.open(File.expand_path('spec/test_orm/log/database.log'), 'a'))
|
6
|
+
ActiveRecord::Migrator.up(File.expand_path('spec/test_orm/db/migrate'))
|
7
|
+
Dir[File.expand_path("spec/test_orm/active_record/**/*.*")].each do |path|
|
8
|
+
require path
|
9
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Test
|
2
|
+
class Application < Rails::Application
|
3
|
+
config.root=File.expand_path("#{File.dirname(__FILE__)}/..")
|
4
|
+
config.logger=Logger.new(File.join(config.root,"log","development.log"))
|
5
|
+
config.active_support.deprecation=:log
|
6
|
+
#config.autoload_paths=File.expand_path("../#{File.dirname(__FILE__)}")
|
7
|
+
end
|
8
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lolita-editable-list
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- IT House (Latvia)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-01 00:00:00 +03:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: lolita
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.0.7
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: jeweler
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.2
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: lolita
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.0.7
|
57
|
+
type: :runtime
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec
|
62
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.5.0
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: *id005
|
71
|
+
description: With this gem you are able to change content right on the list table, changes will be saved through ajax call.
|
72
|
+
email: gatis@ithouse.lv
|
73
|
+
executables: []
|
74
|
+
|
75
|
+
extensions: []
|
76
|
+
|
77
|
+
extra_rdoc_files:
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.rdoc
|
80
|
+
files:
|
81
|
+
- .document
|
82
|
+
- .rspec
|
83
|
+
- Gemfile
|
84
|
+
- Gemfile.lock
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.rdoc
|
87
|
+
- Rakefile
|
88
|
+
- VERSION
|
89
|
+
- app/views/components/lolita/list/editable/_body_cell.html.erb
|
90
|
+
- app/views/components/lolita/list/editable/_display.html.erb
|
91
|
+
- app/views/components/lolita/list/editable/_row.html.erb
|
92
|
+
- lib/generators/lolita_editable_list/assets_generator.rb
|
93
|
+
- lib/generators/lolita_editable_list/install_generator.rb
|
94
|
+
- lib/lolita-editable-list.rb
|
95
|
+
- lib/lolita-editable-list/configuration/editable_list.rb
|
96
|
+
- lib/lolita-editable-list/configuration/list.rb
|
97
|
+
- lib/lolita-editable-list/version.rb
|
98
|
+
- lolita-editable-list.gemspec
|
99
|
+
- public/stylesheets/lolita/editable.css
|
100
|
+
- spec/configuration/editable_list_spec.rb
|
101
|
+
- spec/factories/post.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
- spec/test_orm/active_record.rb
|
104
|
+
- spec/test_orm/active_record/post.rb
|
105
|
+
- spec/test_orm/config/active_record.yml
|
106
|
+
- spec/test_orm/db/migrate/01_create_posts.rb
|
107
|
+
- spec/test_orm/rails/config/application.rb
|
108
|
+
- spec/test_orm/rails/config/enviroment.rb
|
109
|
+
- spec/test_orm/rails/config/routes.rb
|
110
|
+
- spec/test_orm/rails/log/development.log
|
111
|
+
- spec/test_orm/support.rb
|
112
|
+
has_rdoc: true
|
113
|
+
homepage: http://github.com/ithouse/lolita-list-edit
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: -235316067
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: "0"
|
136
|
+
requirements: []
|
137
|
+
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.6.2
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: List inline editing for Lolita
|
143
|
+
test_files:
|
144
|
+
- spec/configuration/editable_list_spec.rb
|
145
|
+
- spec/factories/post.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
- spec/test_orm/active_record.rb
|
148
|
+
- spec/test_orm/active_record/post.rb
|
149
|
+
- spec/test_orm/db/migrate/01_create_posts.rb
|
150
|
+
- spec/test_orm/rails/config/application.rb
|
151
|
+
- spec/test_orm/rails/config/enviroment.rb
|
152
|
+
- spec/test_orm/rails/config/routes.rb
|
153
|
+
- spec/test_orm/support.rb
|