on_the_spot 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +5 -0
- data/VERSION +1 -1
- data/lib/generators/on_the_spot/install/templates/on_the_spot.js +7 -2
- data/lib/on_the_spot/controller_extension.rb +8 -5
- data/on_the_spot.gemspec +2 -2
- data/spec/on_the_spot_spec.rb +14 -3
- data/spec/spec_helper.rb +2 -16
- metadata +3 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -47,6 +47,9 @@ GEM
|
|
47
47
|
rspec-expectations (= 2.0.0.rc)
|
48
48
|
rubyforge (2.0.4)
|
49
49
|
json_pure (>= 1.1.7)
|
50
|
+
simplecov (0.3.6)
|
51
|
+
simplecov-html (>= 0.3.7)
|
52
|
+
simplecov-html (0.3.8)
|
50
53
|
tzinfo (0.3.23)
|
51
54
|
|
52
55
|
PLATFORMS
|
@@ -55,5 +58,7 @@ PLATFORMS
|
|
55
58
|
DEPENDENCIES
|
56
59
|
actionpack (>= 3.0.0)
|
57
60
|
jeweler
|
61
|
+
json_pure
|
58
62
|
rake
|
59
63
|
rspec (>= 2.0.0.rc)
|
64
|
+
simplecov
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
@@ -21,7 +21,12 @@ $(document).ready(function() {
|
|
21
21
|
var options = {
|
22
22
|
tooltip: tooltip_text,
|
23
23
|
cancel: cancel_text,
|
24
|
-
submit: ok_text
|
24
|
+
submit: ok_text,
|
25
|
+
onerror: function (settings, original, xhr) {
|
26
|
+
original.reset();
|
27
|
+
//just show the error-msg for now
|
28
|
+
alert(xhr.responseText);
|
29
|
+
}
|
25
30
|
};
|
26
31
|
if (edit_type != null) {
|
27
32
|
options.type = edit_type;
|
@@ -37,7 +42,7 @@ $(document).ready(function() {
|
|
37
42
|
}
|
38
43
|
else if (edit_type == 'textarea') {
|
39
44
|
options.rows = rows;
|
40
|
-
options.
|
45
|
+
options.cols = columns;
|
41
46
|
}
|
42
47
|
|
43
48
|
el.editable(data_url, options)
|
@@ -13,12 +13,15 @@ module OnTheSpot
|
|
13
13
|
klass, field, id = params[:id].split('__')
|
14
14
|
select_data = params[:select_array]
|
15
15
|
object = klass.camelize.constantize.find(id)
|
16
|
-
object.
|
17
|
-
|
18
|
-
|
16
|
+
if object.update_attributes(field => params[:value])
|
17
|
+
if select_data.nil?
|
18
|
+
render :text => CGI::escapeHTML(object.send(field).to_s)
|
19
|
+
else
|
20
|
+
parsed_data = JSON.parse(select_data.gsub("'", '"'))
|
21
|
+
render :text => parsed_data[object.send(field).to_s]
|
22
|
+
end
|
19
23
|
else
|
20
|
-
|
21
|
-
render :text => parsed_data[object.send(field).to_s]
|
24
|
+
render :text => object.errors.full_messages.join("\n"), :status => 422
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
data/on_the_spot.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{on_the_spot}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Van der Auwera"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-05}
|
13
13
|
s.description = %q{Unobtrusive in place editing, using jEditable; only works in Rails 3}
|
14
14
|
s.email = %q{nathan@dixis.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/on_the_spot_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe "OnTheSpot" do
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
context "
|
40
|
+
context "the helpers" do
|
41
41
|
before(:each) do
|
42
42
|
@dummy = mock()
|
43
43
|
@dummy.stub!(:content).and_return('test')
|
@@ -46,11 +46,22 @@ describe "OnTheSpot" do
|
|
46
46
|
@tester.should_receive(:t).with('on_the_spot.cancel').and_return("cancel")
|
47
47
|
@tester.should_receive(:t).with('on_the_spot.tooltip').and_return("tooltip")
|
48
48
|
@tester.should_receive(:url_for).and_return('/bla')
|
49
|
-
@result = @tester.on_the_spot_edit @dummy, :content
|
50
49
|
end
|
51
|
-
|
50
|
+
|
51
|
+
it "should make the correct html for an edit-field" do
|
52
|
+
@result = @tester.on_the_spot_edit @dummy, :content
|
52
53
|
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-ok=\"ok\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
53
54
|
end
|
55
|
+
|
56
|
+
it "should make the correct html for a text-area" do
|
57
|
+
@result = @tester.on_the_spot_edit @dummy, :content, :type => :textarea
|
58
|
+
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-columns=\"40\" data-edittype=\"textarea\" data-ok=\"ok\" data-rows=\"5\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">test</span>"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should make the correct html for a select-box" do
|
62
|
+
@result = @tester.on_the_spot_edit @dummy, :content, :type => :select, :data => [['test', 'This a test'], ['prod', 'Pure Production'], ['QA', 'Quality Assurance']]
|
63
|
+
@result.should == "<span class=\"on_the_spot_editing\" data-cancel=\"cancel\" data-edittype=\"select\" data-ok=\"ok\" data-select=\"{ 'test':'This a test', 'prod':'Pure Production', 'QA':'Quality Assurance', 'selected':'test'}\" data-tooltip=\"tooltip\" data-url=\"/bla\" id=\"r_spec/mocks/mock__content__123\">This a test</span>"
|
64
|
+
end
|
54
65
|
end
|
55
66
|
end
|
56
67
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,24 +3,10 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
require 'rspec/core'
|
4
4
|
#require 'autotest/rspec2'
|
5
5
|
|
6
|
-
|
6
|
+
require 'simplecov'
|
7
|
+
SimpleCov.start 'rails'
|
7
8
|
|
8
9
|
RSpec.configure do |c|
|
9
10
|
c.color_enabled = true
|
10
|
-
# c.filter_run :focused => true
|
11
|
-
# c.run_all_when_everything_filtered = true
|
12
|
-
# c.filter_run_excluding :ruby => lambda {|version|
|
13
|
-
# case version.to_s
|
14
|
-
# when "!jruby"
|
15
|
-
# RUBY_ENGINE != "jruby"
|
16
|
-
# when /^> (.*)/
|
17
|
-
# !(RUBY_VERSION.to_s > $1)
|
18
|
-
# else
|
19
|
-
# !(RUBY_VERSION.to_s =~ /^#{version.to_s}/)
|
20
|
-
# end
|
21
|
-
# }
|
22
|
-
# c.around do |example|
|
23
|
-
# sandboxed { example.run }
|
24
|
-
# end
|
25
11
|
end
|
26
12
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nathan Van der Auwera
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-05 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|