faalis 0.21.1 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/faalis/concerns/assignment.rb +16 -0
- data/lib/faalis/generators/concerns.rb +1 -0
- data/lib/faalis/generators/concerns/allow_query_on.rb +38 -0
- data/lib/faalis/generators/concerns/required.rb +1 -1
- data/lib/faalis/generators/concerns/resource_fields.rb +23 -13
- data/lib/faalis/generators/dashboard_scaffold.rb +1 -0
- data/lib/faalis/version.rb +1 -1
- data/lib/generators/faalis/templates/api/controller.rb.erb +1 -0
- data/lib/generators/faalis/templates/js/list_view/index.html.erb +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: 6e8d41e6694f09b9f411168fdc7c05b22d7c5b8e
|
4
|
+
data.tar.gz: b3d20ddff941a3df2083b5626b0ef4debb38498d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef9024980abb5ec1328edf5ebe2a679c2c8651012bc2d68b60e2bd196e25e88c37634d86937303e90bb38c320f1e760afd485802d47cfa1cd5cca5c58f34b65a
|
7
|
+
data.tar.gz: bc7b648b808430fcab1809ad3f4d48d54105358af78cded20b5d4d700899d9191b35229ec5f41582d3c19162c4559ea1a36abd47cde9b859e05f98ee1795380e
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Faalis
|
2
|
+
module Concerns
|
3
|
+
# This **concern** provide the default query loading scope for model.
|
4
|
+
# Using this, you can make queries like key=value in http request
|
5
|
+
# and Model.assignment(key: value) on you model.
|
6
|
+
module Assignment
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.scope :assignment_query, -> (field, value) do
|
10
|
+
base.where(field => value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Faalis
|
2
|
+
module Generators
|
3
|
+
module Concerns
|
4
|
+
# This module adds `allow_query_on` key to json file which is an array
|
5
|
+
# of field name which you want to whitelist for query.
|
6
|
+
module AllowQueryOn
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
|
11
|
+
def allowed_fields
|
12
|
+
if allowed_fields_provided?
|
13
|
+
unless resource_data["allow_query_on"].is_a? Array
|
14
|
+
raise Exception.new "value of `allow_query_on` key should be an Array. "
|
15
|
+
end
|
16
|
+
fields = resource_data["allow_query_on"].collect do |f|
|
17
|
+
":#{f}"
|
18
|
+
end
|
19
|
+
fields.join(" ,")
|
20
|
+
else
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Check for any allowed fields in json
|
26
|
+
def allowed_fields_provided?
|
27
|
+
if resource_data.include? "allow_query_on"
|
28
|
+
unless resource_data["allow_query_on"].nil?
|
29
|
+
return true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -46,17 +46,17 @@ module Faalis
|
|
46
46
|
def fields
|
47
47
|
fields = []
|
48
48
|
if have_fields?
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
49
|
+
resource_data["fields"].each do |field|
|
50
|
+
name = field["name"]
|
51
|
+
type = field["type"]
|
52
|
+
to = field["to"]
|
53
|
+
options = field["options"] || {}
|
54
|
+
|
55
|
+
if ["belongs_to", "has_many", "in"].include? type
|
56
|
+
type = Relation.new(type, to, options)
|
57
|
+
end
|
58
58
|
|
59
|
-
|
59
|
+
fields << [name, type]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
fields
|
@@ -109,10 +109,20 @@ module Faalis
|
|
109
109
|
result
|
110
110
|
end
|
111
111
|
|
112
|
+
def raw_fields_data
|
113
|
+
if have_fields?
|
114
|
+
return resource_data["fields"]
|
115
|
+
end
|
116
|
+
[]
|
117
|
+
end
|
118
|
+
|
112
119
|
def fields_with(attr, value)
|
113
|
-
|
120
|
+
raw_fields_data.select do |f|
|
121
|
+
|
114
122
|
if f.include? attr
|
123
|
+
|
115
124
|
if f[attr] == value
|
125
|
+
|
116
126
|
true
|
117
127
|
else
|
118
128
|
false
|
@@ -125,11 +135,11 @@ module Faalis
|
|
125
135
|
end
|
126
136
|
|
127
137
|
def no_filter?
|
128
|
-
resource_data.include?
|
138
|
+
resource_data.include?("no_filter") && resource_data["no_filter"]
|
129
139
|
end
|
130
140
|
|
131
141
|
def have_fields?
|
132
|
-
|
142
|
+
if resource_data.include? "fields"
|
133
143
|
unless resource_data["fields"].nil?
|
134
144
|
return true
|
135
145
|
end
|
data/lib/faalis/version.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
class API::V1::<%= resource.pluralize %>Controller < APIController
|
2
|
+
<% if allowed_fields_provided? %>allow_query_on <%= allowed_fields %><% end %>
|
2
3
|
before_filter :build_resource, :only => :create
|
3
4
|
<% if parent? %><% all_parents = parents %><% prev = all_parents.shift %>
|
4
5
|
load_and_authorize_resource :<%= prev.singularize %>, :except => [:destory]
|
@@ -55,7 +55,7 @@
|
|
55
55
|
</div>
|
56
56
|
</div>
|
57
57
|
<% end %>
|
58
|
-
<list-view buttons="buttons" model="'<% if model_specified? %><%= model %><% else %><%= resource %><% end %>'" objects="<%= resource.pluralize.underscore %>" title-attribute="'<%= resource_data["
|
58
|
+
<list-view buttons="buttons" model="'<% if model_specified? %><%= model %><% else %><%= resource %><% end %>'" objects="<%= resource.pluralize.underscore %>" title-attribute="'<%= resource_data["title-field"] %>'" details-template="details_template" item-per-page="10" on_delete="on_delete" column_defs="columns">
|
59
59
|
<div class="small-6 column text-left clearpadding">
|
60
60
|
<h3><i class="fa fa-group"></i> <span translate><%= resource.underscore.pluralize.humanize %></span></h3>
|
61
61
|
</div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faalis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sameer Rahmani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -477,6 +477,7 @@ files:
|
|
477
477
|
- app/helpers/faalis/home_helper.rb
|
478
478
|
- app/helpers/faalis/users_helper.rb
|
479
479
|
- app/models/ability.rb
|
480
|
+
- app/models/faalis/concerns/assignment.rb
|
480
481
|
- app/models/faalis/group.rb
|
481
482
|
- app/models/faalis/permission.rb
|
482
483
|
- app/models/faalis/permissions/auth.rb
|
@@ -590,6 +591,7 @@ files:
|
|
590
591
|
- lib/faalis/exceptions.rb
|
591
592
|
- lib/faalis/generators.rb
|
592
593
|
- lib/faalis/generators/concerns.rb
|
594
|
+
- lib/faalis/generators/concerns/allow_query_on.rb
|
593
595
|
- lib/faalis/generators/concerns/angular.rb
|
594
596
|
- lib/faalis/generators/concerns/bulk.rb
|
595
597
|
- lib/faalis/generators/concerns/dependency.rb
|