qui-automatic-form-required-fields 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +17 -0
- data/lib/qui-automatic-form-required-fields.rb +32 -0
- data/public/stylesheets/qui/automatic-form-required-fields.css +4 -0
- data/rails/init.rb +8 -0
- metadata +72 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
All portions Copyright (c) 2007 Tim Harper
|
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
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gemspec|
|
6
|
+
gemspec.name = "qui-automatic-form-required-fields"
|
7
|
+
gemspec.summary = "qUI: automatically marks required fields in a rails app"
|
8
|
+
gemspec.description = "qUI: this plugin automatically marks labels near required fields using validates_presence_of from the associated model"
|
9
|
+
gemspec.email = "marcin@saepia.net"
|
10
|
+
gemspec.homepage = "http://q.saepia.net"
|
11
|
+
gemspec.authors = ["Marcin Lewandowski"]
|
12
|
+
gemspec.version = "0.0.1"
|
13
|
+
gemspec.files = Rake::FileList.new [ "MIT-LICENSE", "Rakefile", "public/stylesheets/qui/*", "lib/*", "rails/*", "README.rdoc" ]
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class ActiveRecord::Base
|
2
|
+
cattr_reader :required_fields
|
3
|
+
|
4
|
+
def self.validates_presence_of(*attr_names)
|
5
|
+
original_attr_names = attr_names
|
6
|
+
|
7
|
+
attr_names.extract_options!
|
8
|
+
|
9
|
+
@@required_fields ||= []
|
10
|
+
@@required_fields += attr_names.collect(&:to_sym)
|
11
|
+
@@required_fields.uniq!
|
12
|
+
|
13
|
+
super original_attr_names
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ActionView
|
18
|
+
module Helpers
|
19
|
+
class InstanceTag
|
20
|
+
def to_label_tag_with_required_field(text = nil, options = {})
|
21
|
+
text ||= object.class.human_attribute_name(method_name) if object.class.respond_to?(:human_attribute_name)
|
22
|
+
|
23
|
+
text += content_tag(:span, "*", :class => "required_field", :title => "(#{I18n.t(:requiredField).downcase})") if object.class.required_fields.include? method_name.to_sym
|
24
|
+
|
25
|
+
to_label_tag_without_required_field(text, options)
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method_chain :to_label_tag, :required_field
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/rails/init.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
unless File.exists?(File.join(Rails.root, 'public/stylesheets/qui/automatic-form-required-fields.css'))
|
2
|
+
$stderr.puts "Copying CSS for qui-automatic-form-required-fields..."
|
3
|
+
$stderr.puts "- public/stylesheets/qui/automatic-form-required-fields.css"
|
4
|
+
|
5
|
+
FileUtils.mkdir_p File.join(Rails.root, 'public/stylesheets/qui')
|
6
|
+
FileUtils.cp File.dirname(__FILE__) + "/../public/stylesheets/qui/automatic-form-required-fields.css", File.join(Rails.root, 'public/stylesheets/qui')
|
7
|
+
end
|
8
|
+
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qui-automatic-form-required-fields
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Marcin Lewandowski
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-18 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: "qUI: this plugin automatically marks labels near required fields using validates_presence_of from the associated model"
|
23
|
+
email: marcin@saepia.net
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- MIT-LICENSE
|
32
|
+
- README.rdoc
|
33
|
+
- Rakefile
|
34
|
+
- lib/qui-automatic-form-required-fields.rb
|
35
|
+
- public/stylesheets/qui/automatic-form-required-fields.css
|
36
|
+
- rails/init.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://q.saepia.net
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.3.7
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: "qUI: automatically marks required fields in a rails app"
|
71
|
+
test_files: []
|
72
|
+
|