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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aad702650d735cf6fc8bedd8628a9c3dc05e4bc
4
- data.tar.gz: 47f2a20d9011e42f36bbfc0e5332193453bcd65f
3
+ metadata.gz: fd0e2e2bfa36c66026856bf44c4af2100837016e
4
+ data.tar.gz: a0ea8b41c91914444e77f93588c3e9348e59b72d
5
5
  SHA512:
6
- metadata.gz: f62433dcc06c57c17361badf999b6f3be0811f7707a992ec796e9e293ed6b5a3bdc12d0799eda6166eb42528e8e37f8bff4c2ff2dad4f7f150c77826810403d6
7
- data.tar.gz: 9990042adf0e8679aa0dd5c7d5e7f039333ddc6c9d5db6ddbeb0f182468ec776c152c9a34b9ebd5a9963761d04bf9314d383c8109c96949d0da893cf3ef0db51
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
@@ -43,6 +43,14 @@ module Mongoid
43
43
  model.to_s.underscore.downcase
44
44
  end
45
45
 
46
+ def relation_label(relation)
47
+ if relation.respond_to?(:slug)
48
+ return relation.slug
49
+ else
50
+ return relation.id
51
+ end
52
+ end
53
+
46
54
  private
47
55
 
48
56
  def private_field?(name)
@@ -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.send(:id), document_path(model_param(relation.class.name), relation.send(:id)) %></p>
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.send(:id), document_path(model_param(relation.class.name), relation.send(:id)) %></p>
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module DocumentEditor
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  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.8
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-12 00:00:00.000000000 Z
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