on_the_spot 0.0.0.beta2 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +33 -7
- data/VERSION +1 -1
- data/lib/generators/on_the_spot/install/install_generator.rb +1 -0
- data/lib/generators/on_the_spot/install/templates/on_the_spot.en.yml +5 -0
- data/lib/generators/on_the_spot/install/templates/on_the_spot.js +9 -3
- data/lib/on_the_spot/on_the_spot_helpers.rb +23 -3
- data/on_the_spot.gemspec +4 -3
- metadata +8 -10
data/README.markdown
CHANGED
@@ -13,13 +13,26 @@ Run the installation task:
|
|
13
13
|
|
14
14
|
rails g on_the_spot:install
|
15
15
|
|
16
|
-
Inside your `routes.rb` you provide the catch-all
|
16
|
+
Inside your `routes.rb` you either provide the catch-all
|
17
17
|
|
18
|
-
|
18
|
+
match ':controller(/:action(/:id(.:format)))'
|
19
19
|
|
20
|
-
|
20
|
+
or you type something like
|
21
21
|
|
22
|
-
|
22
|
+
resources :posts do
|
23
|
+
collection do
|
24
|
+
get :update_attribute_on_the_spot
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
While this last is the best solution, you need to do this for each controller that uses the on-the-spot editing.
|
29
|
+
For the moment i do not know of any better solution, but i am always open for suggestions!
|
30
|
+
|
31
|
+
Inside your `application.html.haml` you will need to add below the default javascripts:
|
32
|
+
|
33
|
+
= javascript_include_tag :on_the_spot
|
34
|
+
|
35
|
+
That is all you need to do to start using it!
|
23
36
|
|
24
37
|
|
25
38
|
## Usage
|
@@ -41,11 +54,24 @@ And inside your view you will have to specify the fields you want to be "editabl
|
|
41
54
|
|
42
55
|
It should be as simple as that :)
|
43
56
|
|
57
|
+
## Detailed options
|
58
|
+
|
59
|
+
The `on_the_spot_edit` also accepts options:
|
60
|
+
|
61
|
+
* `type` : `textarea` or `select` (none means default edit, select is currently not yet supported)
|
62
|
+
* `ok_text` : the text for the ok-button
|
63
|
+
* `cancel_text` : the text for the cancel-button
|
64
|
+
* `tooltip` : the tooltip-text
|
65
|
+
|
66
|
+
For the texts: if a text is not specified, the default is taken from the `on_the_spot.en.yml` (or your current language).
|
67
|
+
|
68
|
+
## Example project
|
69
|
+
|
70
|
+
Ther is a example rails3-project called on_the_spot_tester here: http://github.com/nathanvda/on_the_spot_tester
|
71
|
+
|
44
72
|
## To do
|
45
73
|
|
46
|
-
- make sure
|
47
|
-
- make sure user can choose to use a textarea instead of just text
|
48
|
-
- find a clean solution for the routes
|
74
|
+
- make sure user can choose to use a select instead of just text or textarea
|
49
75
|
- add tests!
|
50
76
|
|
51
77
|
## Note on Patches/Pull Requests
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
@@ -16,13 +16,19 @@ $(document).ready(function() {
|
|
16
16
|
data_url = el.attr('data-url'),
|
17
17
|
ok_text = el.attr('data-ok') || 'OK',
|
18
18
|
cancel_text = el.attr('data-cancel') || 'Cancel',
|
19
|
-
tooltip_text = el.attr('data-tooltip') || 'Click to edit ...'
|
19
|
+
tooltip_text = el.attr('data-tooltip') || 'Click to edit ...',
|
20
|
+
edit_type = el.attr('data-edittype');
|
20
21
|
|
21
|
-
|
22
|
+
var options = {
|
22
23
|
tooltip: tooltip_text,
|
23
24
|
cancel: cancel_text,
|
24
25
|
submit: ok_text
|
25
|
-
}
|
26
|
+
};
|
27
|
+
if (edit_type != null) {
|
28
|
+
options.type = edit_type;
|
29
|
+
}
|
30
|
+
|
31
|
+
el.editable(data_url, options)
|
26
32
|
})
|
27
33
|
|
28
34
|
});
|
@@ -1,6 +1,14 @@
|
|
1
1
|
module OnTheSpot
|
2
2
|
module Helpers
|
3
3
|
|
4
|
+
EDIT_TYPE_TEXTAREA='textarea'
|
5
|
+
EDIT_TYPE_SELECT='select'
|
6
|
+
|
7
|
+
# Possible options:
|
8
|
+
# ok_text : the ok-button text
|
9
|
+
# cancel_text : the cancel-button text
|
10
|
+
# tooltip : the tooltip to show
|
11
|
+
# type : {'textarea' || 'select' }
|
4
12
|
def on_the_spot_edit(object, field, options={})
|
5
13
|
#!!! to do: translate options to data-fields
|
6
14
|
# Possible fields:
|
@@ -8,11 +16,23 @@ module OnTheSpot
|
|
8
16
|
# type: textarea or not
|
9
17
|
# button-translations ok-Text, cancel-Text
|
10
18
|
#
|
19
|
+
options.reverse_merge!(:ok_text => t('on_the_spot.ok'),
|
20
|
+
:cancel_text => t('on_the_spot.cancel'),
|
21
|
+
:tooltip => t('on_the_spot.tooltip')
|
22
|
+
)
|
23
|
+
|
11
24
|
update_url = url_for(:action => 'update_attribute_on_the_spot')
|
12
25
|
|
13
|
-
|
14
|
-
|
15
|
-
|
26
|
+
html_options = { :id => "#{object.class.name.underscore}__#{field}__#{object.id}",
|
27
|
+
:class => 'on_the_spot_editing',
|
28
|
+
:'data-url' => update_url}
|
29
|
+
|
30
|
+
html_options[:'data-edittype'] = options[:type] unless options[:type].nil?
|
31
|
+
html_options[:'data-ok'] = options[:ok_text] unless options[:ok_text].nil?
|
32
|
+
html_options[:'data-cancel'] = options[:cancel_text] unless options[:cancel_text].nil?
|
33
|
+
html_options[:'data-tooltip'] = options[:tooltip] unless options[:tooltip].nil?
|
34
|
+
|
35
|
+
content_tag("span", html_options) do
|
16
36
|
object.send(field.to_sym).to_s
|
17
37
|
end
|
18
38
|
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.1"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
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-09-
|
12
|
+
s.date = %q{2010-09-11}
|
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 = [
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"lib/generators/on_the_spot/install/install_generator.rb",
|
28
28
|
"lib/generators/on_the_spot/install/templates/jquery.jeditable.mini.js",
|
29
|
+
"lib/generators/on_the_spot/install/templates/on_the_spot.en.yml",
|
29
30
|
"lib/generators/on_the_spot/install/templates/on_the_spot.js",
|
30
31
|
"lib/on_the_spot.rb",
|
31
32
|
"lib/on_the_spot/controller_extension.rb",
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: on_the_spot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.0.0.beta2
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Nathan Van der Auwera
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-11 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +52,7 @@ files:
|
|
53
52
|
- VERSION
|
54
53
|
- lib/generators/on_the_spot/install/install_generator.rb
|
55
54
|
- lib/generators/on_the_spot/install/templates/jquery.jeditable.mini.js
|
55
|
+
- lib/generators/on_the_spot/install/templates/on_the_spot.en.yml
|
56
56
|
- lib/generators/on_the_spot/install/templates/on_the_spot.js
|
57
57
|
- lib/on_the_spot.rb
|
58
58
|
- lib/on_the_spot/controller_extension.rb
|
@@ -81,13 +81,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
segments:
|
87
|
-
-
|
88
|
-
|
89
|
-
- 1
|
90
|
-
version: 1.3.1
|
87
|
+
- 0
|
88
|
+
version: "0"
|
91
89
|
requirements: []
|
92
90
|
|
93
91
|
rubyforge_project:
|