form_me 0.3.1.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/app/models/form_me/concerns/conditional.rb +17 -0
- data/app/models/form_me/concerns/field.rb +65 -0
- data/app/models/form_me/concerns/form.rb +97 -0
- data/app/models/form_me/concerns/form_connection.rb +15 -0
- data/app/models/form_me/concerns/form_group.rb +13 -0
- data/app/models/form_me/conditional.rb +7 -0
- data/app/models/form_me/field.rb +8 -0
- data/app/models/form_me/form.rb +7 -0
- data/app/models/form_me/form_connection.rb +6 -0
- data/app/models/form_me/form_group.rb +6 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20160531183752_form_me_create_form_groups.rb +9 -0
- data/db/migrate/20160531183753_form_me_create_forms.rb +11 -0
- data/db/migrate/20160531183754_form_me_create_form_connections.rb +15 -0
- data/db/migrate/20160531183757_form_me_create_nested_forms.rb +15 -0
- data/db/migrate/20160531183758_form_me_create_fields.rb +20 -0
- data/db/migrate/20160531183759_update_nested_form_migration.rb +65 -0
- data/db/migrate/20160907171950_form_me_nested_set_update.rb +20 -0
- data/db/migrate/20160927203029_form_me_create_conditional.rb +14 -0
- data/lib/form_me.rb +8 -0
- data/lib/form_me/engine.rb +5 -0
- data/lib/form_me/models/formable.rb +23 -0
- data/lib/form_me/version.rb +3 -0
- data/lib/generators/form_me/install_generator.rb +13 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3f340a33561c738dba89543792bf5b81be95f34616f3ab6e663a0ef4b46134d
|
4
|
+
data.tar.gz: 4269f78bc826ffd16d246991b554796a439deb9ac55941fb7e8155eedb1d2f4a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4a5e9c18af354fecabd0dbb87bac0210374ad18a4039fbab8949d848479d68e37d7c177041e8318fde75373cf08e5e5f3b47a851e5c56f1f5a2f9c34f0e03f43
|
7
|
+
data.tar.gz: e5a9f49ab013934e0178c8f8c9e6d2a43b05f57d526c7e5dd80f985e6ad8b61bc8c98dc473fc8cf0d4d2160210d8b77eac31e0889811f479de718cb9ac6de115
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Joe Weakley
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# FormMe
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/form_me`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'form_me'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install form_me
|
22
|
+
|
23
|
+
After installing the gem, run the installation generator:
|
24
|
+
```
|
25
|
+
$ rails g form_me:install
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
TODO: Write usage instructions here
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it ( https://github.com/[my-github-username]/form_me/fork )
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create a new Pull Request
|
45
|
+
|
46
|
+
## Code Of Conduct
|
47
|
+
Wildland Open Source [Code Of Conduct](https://github.com/wildland/code-of-conduct)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module FormMe::Concerns::Conditional
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
self.table_name = 'form_me_conditional'
|
8
|
+
|
9
|
+
belongs_to :field, class_name: 'FormMe::Field'
|
10
|
+
|
11
|
+
belongs_to :next_step, polymorphic: true
|
12
|
+
|
13
|
+
validates :field, presence: true
|
14
|
+
validates :symbol, presence: true
|
15
|
+
validates :operand, presence: true
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module FormMe::Concerns::Field
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
self.table_name = 'form_me_fields'
|
8
|
+
|
9
|
+
belongs_to :form, inverse_of: :fields, class_name: 'FormMe::Form', foreign_key: 'form_me_form_id'
|
10
|
+
|
11
|
+
has_many :conditionals, class_name: 'FormMe::Conditional', foreign_key: 'form_me_field_id'
|
12
|
+
has_one :requirement_conditional, class_name: 'FormMe::Conditional', as: :next_step
|
13
|
+
delegate :id, to: :requirement_conditional, prefix: true, allow_nil: true
|
14
|
+
|
15
|
+
before_validation :set_key_if_empty
|
16
|
+
before_validation :set_uuid_if_empty
|
17
|
+
|
18
|
+
validates :form, presence: true
|
19
|
+
validates :index, presence: true
|
20
|
+
|
21
|
+
# Only allow characters in the field name, to prevent conflicts with nested forms
|
22
|
+
validates :key,
|
23
|
+
format: {
|
24
|
+
with: /\A[a-zA-Z0-9_\-]+\z/,
|
25
|
+
message: 'field names can only contain letters and numbers'
|
26
|
+
}
|
27
|
+
validates :field_type, inclusion: { in: %w(text select radio checkbox price integer decimal textarea date date-restricted time date-range time-range year link instructions) }
|
28
|
+
validates :label, presence: true
|
29
|
+
validates :label, format: {
|
30
|
+
with: /[0-9a-z ]/i,
|
31
|
+
message: 'can only be alphanumeric with spaces until key generated'
|
32
|
+
}, if: Proc.new { |f| f.key.blank?}
|
33
|
+
validates :uuid, presence: true
|
34
|
+
validate :uniqness_of_key_in_related_forms
|
35
|
+
|
36
|
+
scope :only_required, -> { where(required: true) }
|
37
|
+
|
38
|
+
def set_key_if_empty
|
39
|
+
return if key
|
40
|
+
counter = 0
|
41
|
+
|
42
|
+
self.key = label.gsub(/[^0-9a-z ]/i, '').downcase.tr(' ', '_').camelize(:lower)
|
43
|
+
while form.does_field_key_exist?(self)
|
44
|
+
counter += 1
|
45
|
+
self.key = "#{key}#{counter}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_uuid_if_empty
|
50
|
+
return if uuid
|
51
|
+
|
52
|
+
self.uuid = SecureRandom.uuid
|
53
|
+
end
|
54
|
+
|
55
|
+
def field_value(formable_object_properties)
|
56
|
+
formable_object_properties[uuid]
|
57
|
+
end
|
58
|
+
|
59
|
+
def uniqness_of_key_in_related_forms
|
60
|
+
if form.does_field_key_exist?(self)
|
61
|
+
errors.add(:key, 'must be unique among neighbor forms and fields')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module FormMe::Concerns::Form
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.table_name = 'form_me_forms'
|
6
|
+
acts_as_nested_set parent_column: :form_me_parent_form_id
|
7
|
+
|
8
|
+
has_many :fields, inverse_of: :form, class_name: 'FormMe::Field', foreign_key: 'form_me_form_id'
|
9
|
+
has_many :form_connections, dependent: :destroy, class_name: 'FormMe::FormConnection', foreign_key: 'form_me_form_id'
|
10
|
+
has_many :form_groups, class_name: 'FormMe::FormGroup', through: :form_connections, source: :form_group
|
11
|
+
|
12
|
+
has_one :requirement_conditional, class_name: 'FormMe::Conditional', as: :next_step
|
13
|
+
|
14
|
+
has_one :requirement_field, through: :requirement_conditional, class_name: 'FormMe::Field', source: :field
|
15
|
+
has_one :parent_requirement_forms, through: :requirement_field, class_name: 'FormMe::Form', source: :form
|
16
|
+
|
17
|
+
has_many :field_conditionals, through: :fields, class_name: 'FormMe::Conditional', source: :conditionals
|
18
|
+
has_many :conditional_dependent_forms, through: :field_conditionals, class_name: 'FormMe::Form', source: :next_step, source_type: 'FormMe::Form'
|
19
|
+
|
20
|
+
|
21
|
+
before_validation :set_key_if_empty
|
22
|
+
before_validation :set_uuid_if_empty
|
23
|
+
|
24
|
+
validates :label, presence: true
|
25
|
+
validates :key,
|
26
|
+
format: {
|
27
|
+
with: /\A[a-zA-Z0-9_\-]+\z/,
|
28
|
+
message: 'field names can only contain letters and numbers'
|
29
|
+
}
|
30
|
+
|
31
|
+
validates :uuid, presence: true
|
32
|
+
validate :uniqness_of_key_in_related_forms
|
33
|
+
|
34
|
+
scope :root, -> do
|
35
|
+
where { form_me_parent_form_id == nil }
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_key_if_empty
|
39
|
+
return if key || label.blank?
|
40
|
+
counter = 0
|
41
|
+
|
42
|
+
self.key = label.gsub(/[^0-9a-z ]/i, '').squeeze(' ').downcase.tr(' ', '-')
|
43
|
+
until is_key_unique_in_related_forms
|
44
|
+
counter += 1
|
45
|
+
self.key = "#{key}-#{counter}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_uuid_if_empty
|
50
|
+
return if uuid
|
51
|
+
|
52
|
+
self.uuid = SecureRandom.uuid
|
53
|
+
end
|
54
|
+
|
55
|
+
def is_key_unique_in_related_forms
|
56
|
+
if parent && parent.does_form_key_exist?(self)
|
57
|
+
false
|
58
|
+
else
|
59
|
+
true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def uniqness_of_key_in_related_forms
|
64
|
+
unless is_key_unique_in_related_forms
|
65
|
+
errors.add(:key, 'must be unique among neighbor forms and fields')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def does_field_key_exist?(field)
|
70
|
+
fields.where.not(id: field.id).exists?(key: field.key) || children.exists?(key: field.key)
|
71
|
+
end
|
72
|
+
|
73
|
+
def does_form_key_exist?(form)
|
74
|
+
fields.exists?(key: form.key) || children.where.not(id: form.id).exists?(key: form.key)
|
75
|
+
end
|
76
|
+
|
77
|
+
def all_required_fields
|
78
|
+
fields.only_required + children.map(&:all_required_fields).flatten
|
79
|
+
end
|
80
|
+
|
81
|
+
def root_form?
|
82
|
+
parent.blank?
|
83
|
+
end
|
84
|
+
|
85
|
+
def as_document_json(formable_object_properties)
|
86
|
+
document_json = fields.reduce({}) do |json, f|
|
87
|
+
json[f.key] = f.field_value(formable_object_properties)
|
88
|
+
json
|
89
|
+
end
|
90
|
+
|
91
|
+
children.reduce(document_json) do |json, f|
|
92
|
+
json[f.key] = f.as_document_json(formable_object_properties)
|
93
|
+
json
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module FormMe::Concerns::FormConnection
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.table_name = 'form_me_form_connections'
|
6
|
+
|
7
|
+
belongs_to :form, inverse_of: :form_connections, class_name: 'FormMe::Form', foreign_key: 'form_me_form_id'
|
8
|
+
belongs_to :form_group, inverse_of: :form_connections, class_name: 'FormMe::FormGroup', foreign_key: 'form_me_form_group_id'
|
9
|
+
|
10
|
+
has_many :fields, through: :form, class_name: 'FormMe::Field', source: :fields
|
11
|
+
|
12
|
+
validates :form, presence: true
|
13
|
+
validates :form_group, presence: true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module FormMe::Concerns::FormGroup
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
self.table_name = 'form_me_form_groups'
|
6
|
+
|
7
|
+
has_many :form_connections, dependent: :destroy, inverse_of: :form_group, class_name: 'FormMe::FormConnection', foreign_key: 'form_me_form_group_id'
|
8
|
+
has_many :forms, class_name: 'FormMe::Form', through: :form_connections, source: :form
|
9
|
+
has_many :fields, class_name: 'FormMe::Field', through: :form_connections, source: :fields
|
10
|
+
|
11
|
+
validates :label, presence: true
|
12
|
+
end
|
13
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class FormMeCreateFormConnections < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :form_me_form_connections do |t|
|
4
|
+
t.integer :form_me_form_group_id
|
5
|
+
t.integer :form_me_form_id
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :form_me_form_connections, :form_me_form_group_id
|
11
|
+
add_index :form_me_form_connections, :form_me_form_id
|
12
|
+
add_foreign_key :form_me_form_connections, :form_me_forms, column: :form_me_form_id
|
13
|
+
add_foreign_key :form_me_form_connections, :form_me_form_groups, column: :form_me_form_group_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class FormMeCreateNestedForms < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :form_me_nested_forms do |t|
|
4
|
+
t.integer :form_me_parent_form_id
|
5
|
+
t.integer :form_me_child_form_id
|
6
|
+
t.integer :index
|
7
|
+
t.hstore :meta
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :form_me_nested_forms, :form_me_parent_form_id
|
13
|
+
add_index :form_me_nested_forms, :form_me_child_form_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class FormMeCreateFields < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :form_me_fields do |t|
|
4
|
+
t.integer :form_me_form_id
|
5
|
+
t.integer :index
|
6
|
+
t.string :uuid, null: false
|
7
|
+
t.string :field_type, null: false
|
8
|
+
t.string :label, null: false
|
9
|
+
t.string :key
|
10
|
+
t.boolean :required, default: false
|
11
|
+
t.hstore :meta
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
|
16
|
+
add_index :form_me_fields, :form_me_form_id
|
17
|
+
add_index :form_me_fields, [:form_me_form_id, :key], unique: true
|
18
|
+
add_foreign_key :form_me_fields, :form_me_forms, column: :form_me_form_id
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class UpdateNestedFormMigration < ActiveRecord::Migration
|
2
|
+
class NestedForm < ActiveRecord::Base; end
|
3
|
+
|
4
|
+
class Form < ActiveRecord::Base
|
5
|
+
self.table_name = 'form_me_forms'
|
6
|
+
|
7
|
+
belongs_to :parent_form, foreign_key: 'form_me_parent_form_id', class_name: 'Form'
|
8
|
+
has_many :nested_child_forms, inverse_of: :parent_form, class_name: 'NestedForm', foreign_key: 'form_me_parent_form_id'
|
9
|
+
|
10
|
+
has_many :child_forms, class_name: 'Form', through: :nested_child_forms, source: :child_form
|
11
|
+
|
12
|
+
has_many :nested_parent_forms, inverse_of: :child_form, class_name: 'NestedForm', foreign_key: 'form_me_child_form_id'
|
13
|
+
has_many :parent_forms, class_name: 'Form', through: :nested_parent_forms, source: :parent_form
|
14
|
+
end
|
15
|
+
|
16
|
+
class NestedForm < ActiveRecord::Base
|
17
|
+
self.table_name = 'form_me_nested_forms'
|
18
|
+
|
19
|
+
belongs_to :parent_form, inverse_of: :nested_child_forms, class_name: 'Form', foreign_key: 'form_me_parent_form_id'
|
20
|
+
belongs_to :child_form, inverse_of: :nested_parent_forms, class_name: 'Form', foreign_key: 'form_me_child_form_id'
|
21
|
+
end
|
22
|
+
|
23
|
+
def up
|
24
|
+
change_table :form_me_forms do |t|
|
25
|
+
t.integer :form_me_parent_form_id
|
26
|
+
t.integer :index
|
27
|
+
end
|
28
|
+
|
29
|
+
add_foreign_key :form_me_forms, :form_me_forms, column: :form_me_parent_form_id
|
30
|
+
|
31
|
+
NestedForm.find_each do |nested_form|
|
32
|
+
child_form = nested_form.child_form
|
33
|
+
child_form.parent_form = nested_form.parent_form
|
34
|
+
child_form.index = nested_form.index
|
35
|
+
child_form.save!
|
36
|
+
end
|
37
|
+
|
38
|
+
drop_table :form_me_nested_forms
|
39
|
+
end
|
40
|
+
|
41
|
+
def down
|
42
|
+
create_table :form_me_nested_forms do |t|
|
43
|
+
t.integer :form_me_parent_form_id
|
44
|
+
t.integer :form_me_child_form_id
|
45
|
+
t.integer :index
|
46
|
+
t.hstore :meta
|
47
|
+
|
48
|
+
t.timestamps
|
49
|
+
end
|
50
|
+
|
51
|
+
add_index :form_me_nested_forms, :form_me_parent_form_id
|
52
|
+
add_index :form_me_nested_forms, :form_me_child_form_id
|
53
|
+
|
54
|
+
Form.where('form_me_parent_form_id IS NOT NULL').find_each do |form|
|
55
|
+
NestedForm.create!(
|
56
|
+
form_me_parent_form_id: form.form_me_parent_form_id,
|
57
|
+
form_me_child_form_id: form.id,
|
58
|
+
index: form.index
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
remove_column :form_me_forms, :index
|
63
|
+
remove_column :form_me_forms, :form_me_parent_form_id
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class FormMeNestedSetUpdate < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column :form_me_forms, :lft, :integer
|
4
|
+
add_column :form_me_forms, :rgt, :integer
|
5
|
+
add_column :form_me_forms, :depth, :integer, default: 0
|
6
|
+
add_column :form_me_forms, :children_count, :integer, default: 0
|
7
|
+
|
8
|
+
add_index :form_me_forms, :lft
|
9
|
+
add_index :form_me_forms, :rgt
|
10
|
+
|
11
|
+
reversible do |dir|
|
12
|
+
dir.up do
|
13
|
+
FormMe::Form.rebuild!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
change_column :form_me_forms, :lft, :integer, null: false
|
18
|
+
change_column :form_me_forms, :rgt, :integer, null: false
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class FormMeCreateConditional < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :form_me_conditional do |t|
|
4
|
+
t.references :field, references: :form_me_field, index: true, null: false
|
5
|
+
t.references :next_step, polymorphic: true, null: false
|
6
|
+
|
7
|
+
t.string :symbol, null: false
|
8
|
+
t.string :operand, null: false
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :form_me_conditional, [:next_step_id, :next_step_type], unique: true
|
13
|
+
end
|
14
|
+
end
|
data/lib/form_me.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module FormMe
|
4
|
+
module Models
|
5
|
+
module Formable
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
belongs_to :form_group, class_name: 'FormMe::FormGroup', foreign_key: :form_me_form_group_id
|
10
|
+
|
11
|
+
has_many :fields, through: :form_group
|
12
|
+
has_many :forms, through: :form_group
|
13
|
+
|
14
|
+
def to_document_json
|
15
|
+
forms.reduce({}) do |json, f|
|
16
|
+
json[f.key] = f.as_document_json(formable_properties)
|
17
|
+
json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module FormMe
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
desc 'Generates migration for FormMe models'
|
8
|
+
|
9
|
+
def install_migrations
|
10
|
+
rake('form_me:install:migrations')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: form_me
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1.pre.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joe Weakley
|
8
|
+
- Sam Clopton
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 4.2.4
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 4.2.4
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: awesome_nested_set
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 3.1.1
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 3.1.1
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: sqlite3
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.8'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.8'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '10.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '10.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.27.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.27.0
|
98
|
+
description: Some description
|
99
|
+
email:
|
100
|
+
- joe@wild.land
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- app/models/form_me/concerns/conditional.rb
|
109
|
+
- app/models/form_me/concerns/field.rb
|
110
|
+
- app/models/form_me/concerns/form.rb
|
111
|
+
- app/models/form_me/concerns/form_connection.rb
|
112
|
+
- app/models/form_me/concerns/form_group.rb
|
113
|
+
- app/models/form_me/conditional.rb
|
114
|
+
- app/models/form_me/field.rb
|
115
|
+
- app/models/form_me/form.rb
|
116
|
+
- app/models/form_me/form_connection.rb
|
117
|
+
- app/models/form_me/form_group.rb
|
118
|
+
- config/routes.rb
|
119
|
+
- db/migrate/20160531183752_form_me_create_form_groups.rb
|
120
|
+
- db/migrate/20160531183753_form_me_create_forms.rb
|
121
|
+
- db/migrate/20160531183754_form_me_create_form_connections.rb
|
122
|
+
- db/migrate/20160531183757_form_me_create_nested_forms.rb
|
123
|
+
- db/migrate/20160531183758_form_me_create_fields.rb
|
124
|
+
- db/migrate/20160531183759_update_nested_form_migration.rb
|
125
|
+
- db/migrate/20160907171950_form_me_nested_set_update.rb
|
126
|
+
- db/migrate/20160927203029_form_me_create_conditional.rb
|
127
|
+
- lib/form_me.rb
|
128
|
+
- lib/form_me/engine.rb
|
129
|
+
- lib/form_me/models/formable.rb
|
130
|
+
- lib/form_me/version.rb
|
131
|
+
- lib/generators/form_me/install_generator.rb
|
132
|
+
homepage: https://github.com/wildland/form_me
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 1.3.1
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.7.6.2
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: Some summary
|
156
|
+
test_files: []
|