mongoid_document_editor 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/app/helpers/mongoid/document_editor/documents_helper.rb +8 -0
- data/app/views/mongoid/document_editor/documents/show.html.erb +3 -3
- data/lib/generators/mongoid_document_editor/install_generator.rb +16 -0
- data/lib/generators/mongoid_document_editor/templates/config/initializers/mongoid_document_editor.rb +23 -0
- data/lib/mongoid/document_editor/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd0e2e2bfa36c66026856bf44c4af2100837016e
|
4
|
+
data.tar.gz: a0ea8b41c91914444e77f93588c3e9348e59b72d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cabac83509646b075ebd8990c141a227b8241fcb7452df070006fb8966048fb89d2f87c6f185548b17703ea61425b93d8220aa15a3e95cf1bb9b9650c110ada6
|
7
|
+
data.tar.gz: 823d822d4c9bd10c78699c52c330aba0899590d3b469175a19f8d670fd6edf699cb2ae3b4881555d636a54117f9c08218a97e0c2afda8fab55bb50d987a9a710
|
data/README.md
CHANGED
@@ -2,8 +2,12 @@
|
|
2
2
|
|
3
3
|
Mongoid Document Editor is Rails Engine that provides a DSL for setting up simple admin interfaces to edit MongoDB documents. No configuration is required in order to get a basic form, however you can override any form you want to provide a more custom and usable interface.
|
4
4
|
|
5
|
+
### Generator
|
6
|
+
To generate an initializer:
|
7
|
+
|
8
|
+
`bundle exec rails generate mongoid_document_editor:install`
|
9
|
+
|
5
10
|
### Configuration
|
6
|
-
Create an initializer and configure your admin interface.
|
7
11
|
|
8
12
|
```ruby
|
9
13
|
Mongoid::DocumentEditor.configure do
|
@@ -14,12 +14,12 @@
|
|
14
14
|
<% @klass.relations.each do |key, value| %>
|
15
15
|
<h3><%= key %></h3>
|
16
16
|
<% if [:has_many, :has_and_belongs_to_many].include?(@document.relations[key].macro) %>
|
17
|
-
<% @document.send(key).each do |relation| %>
|
18
|
-
<p><%= link_to relation
|
17
|
+
<% @document.send(key).asc(:created_at).each do |relation| %>
|
18
|
+
<p><%= link_to relation_label(relation), document_path(model_param(relation.class.name), relation.send(:id)) %></p>
|
19
19
|
<% end %>
|
20
20
|
<% elsif [:has_one, :belongs_to].include?(@document.relations[key].macro) %>
|
21
21
|
<% if relation = @document.send(key) %>
|
22
|
-
<p><%= link_to relation
|
22
|
+
<p><%= link_to relation_label(relation), document_path(model_param(relation.class.name), relation.send(:id)) %></p>
|
23
23
|
<% end %>
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module MongoidDocumentEditor
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
desc "Generate Mongoid Document Editor Initializer"
|
9
|
+
|
10
|
+
def generate_initializer
|
11
|
+
copy_file "config/initializers/mongoid_document_editor.rb", "config/initializers/mongoid_document_editor.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/generators/mongoid_document_editor/templates/config/initializers/mongoid_document_editor.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Mongoid::DocumentEditor.configure do
|
2
|
+
|
3
|
+
## authenticate_with :admin_required
|
4
|
+
|
5
|
+
## mount_at "/documents"
|
6
|
+
|
7
|
+
## resources include: [:user]
|
8
|
+
|
9
|
+
## form_configuration_for User do
|
10
|
+
## field :first_name
|
11
|
+
## field :last_name
|
12
|
+
## field :email, type: :email
|
13
|
+
## field :city_id, values: -> { City.all }, label: :name, value: :id
|
14
|
+
## field :favorite_color, values: User::COLORS
|
15
|
+
## end
|
16
|
+
|
17
|
+
## index_configuration_for User do
|
18
|
+
## column :first_name
|
19
|
+
## column :last_name
|
20
|
+
## column :email, value: ->(user) { "<a href='mailto:#{user.email}'>#{user.email}</a>".html_safe }
|
21
|
+
## end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_document_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick DeSteffen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -115,6 +115,8 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
+
- lib/generators/mongoid_document_editor/install_generator.rb
|
119
|
+
- lib/generators/mongoid_document_editor/templates/config/initializers/mongoid_document_editor.rb
|
118
120
|
- lib/mongoid/document_editor/configuration/form_configuration.rb
|
119
121
|
- lib/mongoid/document_editor/configuration/index_configuration.rb
|
120
122
|
- lib/mongoid/document_editor/configuration.rb
|