bhf 0.6.4 → 0.6.5
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/app/controllers/bhf/entries_controller.rb +2 -2
- data/app/views/bhf/entries/form/column/_hash.haml +2 -0
- data/app/views/bhf/entries/form/has_many/_static.haml +1 -1
- data/app/views/bhf/entries/form/has_one/_static.haml +1 -1
- data/app/views/bhf/pages/_platform.haml +2 -2
- data/app/views/bhf/pages/macro/column/_hash.haml +1 -0
- data/lib/bhf/active_record/active_record.rb +4 -0
- data/lib/bhf/data.rb +1 -1
- data/lib/bhf/mongoid/document.rb +20 -6
- data/lib/bhf/platform.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: b6b072d3fad537ce6456fcc0168c8c9336f3287e
|
4
|
+
data.tar.gz: b0c551207da7b4cd0590a6fa2d9963c05ffa7ae6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e74b31acdff6601157fc7f8054e861a9d4bd3db7042e2df8dba15ab26831e4752e28cef810df3aaa4da90c21cb9380a83de96c8f0ec004fe67cb53da21cb05a6
|
7
|
+
data.tar.gz: 31c4507fcea034ff1ee07d5d1a3d18a423a32b23de65dc5de34d48531060027194ec1a9b1b3be80ec725dbafb3c5270d012dedf73d72fa3c8725c9c14b944922
|
@@ -73,12 +73,12 @@ class Bhf::EntriesController < Bhf::ApplicationController
|
|
73
73
|
redirect_to(bhf_page_url(@platform.page_name, anchor: "#{@platform.name}_platform"), notice: set_message('duplicate.error', @model))
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
def sort
|
78
78
|
return unless @platform.sortable
|
79
79
|
|
80
80
|
sort_attr = @platform.sortable.to_sym
|
81
|
-
|
81
|
+
|
82
82
|
params[:order].each do |order|
|
83
83
|
@model.
|
84
84
|
find(order[1].gsub("_#{@platform.name}", '')).
|
@@ -5,5 +5,5 @@
|
|
5
5
|
- ref_objects.each do |ref_object|
|
6
6
|
%li= link_to_if field.link, ref_object.to_bhf_s, edit_bhf_entry_path(field.link || 0, ref_object), class: :quick_edit
|
7
7
|
|
8
|
-
|
8
|
+
- if field.link
|
9
9
|
= link_to '+', new_bhf_entry_path(field.link), class: 'add_field quick_edit'
|
@@ -14,10 +14,10 @@
|
|
14
14
|
- if platform.sortable
|
15
15
|
%th.drag
|
16
16
|
- platform.columns.each do |column|
|
17
|
-
- db_column_name = platform.model.
|
17
|
+
- db_column_name = platform.model.bhf_attribute_method?(column.name+'_id') ? column.name+'_id' : column.name
|
18
18
|
%th{class: "#{column.field.macro} #{column.field.display_type} #{order_class(db_column_name, platform.name)}"}
|
19
19
|
- column_name = platform.model.human_attribute_name(column.name)
|
20
|
-
- can_sort = platform.model.
|
20
|
+
- can_sort = platform.model.bhf_attribute_method?(db_column_name)
|
21
21
|
= link_to_if can_sort, column_name, current_order_path(db_column_name, platform.name)
|
22
22
|
%th.action
|
23
23
|
|
@@ -0,0 +1 @@
|
|
1
|
+
WIP
|
data/lib/bhf/data.rb
CHANGED
data/lib/bhf/mongoid/document.rb
CHANGED
@@ -74,8 +74,11 @@ module Bhf
|
|
74
74
|
c
|
75
75
|
end
|
76
76
|
|
77
|
+
def bhf_attribute_method?(column_name)
|
78
|
+
attribute_method?(column_name)
|
79
|
+
end
|
80
|
+
|
77
81
|
def bhf_primary_key
|
78
|
-
# TODO: still needed?
|
79
82
|
'_id'
|
80
83
|
end
|
81
84
|
|
@@ -115,18 +118,29 @@ module Bhf
|
|
115
118
|
|
116
119
|
def bhf_new_embed(parent_id, params = nil)
|
117
120
|
get_embedded_parent parent_id do |parent, meta|
|
118
|
-
if
|
119
|
-
|
121
|
+
key_name = if meta.inverse_of?
|
122
|
+
meta.inverse_of
|
120
123
|
else
|
121
|
-
|
124
|
+
meta.inverse_foreign_key.pluralize
|
125
|
+
end.to_s
|
126
|
+
if parent.relations[key_name].macro == :embeds_one
|
127
|
+
parent.send("build_#{key_name}", params)
|
128
|
+
else
|
129
|
+
parent.send(key_name).build(params)
|
122
130
|
end
|
123
131
|
end
|
124
132
|
end
|
125
133
|
|
126
134
|
def bhf_find_embed(parent_id, ref_id)
|
127
135
|
get_embedded_parent parent_id do |parent, meta|
|
128
|
-
|
129
|
-
if
|
136
|
+
# :forced_nil_inverse?, :foreign_key, :foreign_key_check, :foreign_key_setter, :index, :indexed?, :inspect, :inverses, :inverse, :inverse_class_name, :inverse_class_name?, :inverse_foreign_key, :inverse_klass, :inverse_metadata, :inverse_of, :inverse_of?, :inverse_setter, :inverse_type, :inverse_type_setter
|
137
|
+
key_name = if meta.inverse_of?
|
138
|
+
meta.inverse_of
|
139
|
+
else
|
140
|
+
meta.inverse_foreign_key.pluralize
|
141
|
+
end.to_s
|
142
|
+
relation = parent.send(key_name)
|
143
|
+
if parent.relations[key_name].macro == :embeds_one
|
130
144
|
relation
|
131
145
|
else
|
132
146
|
relation.find(ref_id)
|
data/lib/bhf/platform.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bhf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Pawlik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- app/views/bhf/entries/form/column/_boolean.haml
|
109
109
|
- app/views/bhf/entries/form/column/_date.haml
|
110
110
|
- app/views/bhf/entries/form/column/_file.haml
|
111
|
+
- app/views/bhf/entries/form/column/_hash.haml
|
111
112
|
- app/views/bhf/entries/form/column/_mappin.haml
|
112
113
|
- app/views/bhf/entries/form/column/_markdown.haml
|
113
114
|
- app/views/bhf/entries/form/column/_multiple_fields.haml
|
@@ -141,6 +142,7 @@ files:
|
|
141
142
|
- app/views/bhf/pages/macro/column/_boolean.haml
|
142
143
|
- app/views/bhf/pages/macro/column/_date.haml
|
143
144
|
- app/views/bhf/pages/macro/column/_file.haml
|
145
|
+
- app/views/bhf/pages/macro/column/_hash.haml
|
144
146
|
- app/views/bhf/pages/macro/column/_image.haml
|
145
147
|
- app/views/bhf/pages/macro/column/_number.haml
|
146
148
|
- app/views/bhf/pages/macro/column/_primary_key.haml
|