faalis 2.0.0.rc6 → 2.0.0
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/assets/stylesheets/faalis/dashboard/rtl/application.css +16 -0
- data/app/controllers/faalis/dashboard/application_controller.rb +1 -1
- data/app/controllers/faalis/dashboard/users_controller.rb +7 -5
- data/app/views/faalis/dashboard/groups/create.js.erb +1 -1
- data/app/views/faalis/dashboard/groups/update.js.erb +1 -1
- data/app/views/faalis/dashboard/users/_form.html.slim +12 -16
- data/app/views/faalis/dashboard/users/_password_form.html.slim +2 -2
- data/app/views/faalis/dashboard/users/create.js.erb +1 -1
- data/app/views/faalis/dashboard/users/index.html.slim +2 -2
- data/app/views/faalis/dashboard/users/update.js.erb +1 -1
- data/app/views/faalis/dashboard/users/update_password.js.erb +1 -1
- data/app/views/layouts/faalis/dashboard.html.erb +1 -1
- data/config/locales/faalis.fa.yml +8 -1
- data/lib/faalis.rb +2 -3
- data/lib/faalis/configuration.rb +45 -17
- data/lib/faalis/engine.rb +2 -51
- data/lib/faalis/version.rb +1 -1
- metadata +4 -26
- data/lib/faalis/generators.rb +0 -1
- data/lib/faalis/generators/concerns.rb +0 -17
- data/lib/faalis/generators/concerns/allow_query_on.rb +0 -34
- data/lib/faalis/generators/concerns/angular.rb +0 -28
- data/lib/faalis/generators/concerns/bulk.rb +0 -19
- data/lib/faalis/generators/concerns/child.rb +0 -31
- data/lib/faalis/generators/concerns/dependency.rb +0 -37
- data/lib/faalis/generators/concerns/fieldset.rb +0 -47
- data/lib/faalis/generators/concerns/globalize.rb +0 -14
- data/lib/faalis/generators/concerns/hstore.rb +0 -19
- data/lib/faalis/generators/concerns/input_file.rb +0 -49
- data/lib/faalis/generators/concerns/menu.rb +0 -27
- data/lib/faalis/generators/concerns/model.rb +0 -28
- data/lib/faalis/generators/concerns/parent.rb +0 -62
- data/lib/faalis/generators/concerns/render.rb +0 -22
- data/lib/faalis/generators/concerns/required.rb +0 -18
- data/lib/faalis/generators/concerns/resource_fields.rb +0 -147
- data/lib/faalis/generators/concerns/resource_name.rb +0 -39
- data/lib/faalis/generators/concerns/tabs.rb +0 -56
- data/lib/faalis/generators/concerns/where.rb +0 -44
- data/lib/faalis/generators/dashboard_scaffold.rb +0 -62
- data/lib/faalis/generators/fields/relation.rb +0 -61
@@ -1,18 +0,0 @@
|
|
1
|
-
module Faalis
|
2
|
-
module Generators
|
3
|
-
module Concerns
|
4
|
-
|
5
|
-
# Adds `required` key to `fields`. Fields with this key as true will
|
6
|
-
# be non optional fields
|
7
|
-
module RequireFields
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def required_fields
|
12
|
-
# Returnes an array contains name of all fields with require = true
|
13
|
-
fields_with('required', true).collect {|x| x['name']}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,147 +0,0 @@
|
|
1
|
-
require 'faalis/generators/fields/relation'
|
2
|
-
|
3
|
-
module Faalis
|
4
|
-
module Generators
|
5
|
-
module Concerns
|
6
|
-
# This **concern** module is one of the most important **concerns** in
|
7
|
-
# dashboard scaffold system. This module adds `fields` key to json file
|
8
|
-
# which use for defining the resource fields. `fields` key is an array
|
9
|
-
# of objects which each object represent a field. Each field have following
|
10
|
-
# attributes:
|
11
|
-
#
|
12
|
-
# **name**: Name of field
|
13
|
-
#
|
14
|
-
# **type**: Type of field. some of the most important types are: `string`,
|
15
|
-
# `integer`, `flout`, `belongs_to`, `has_many`, `in`, `datetime`.
|
16
|
-
# For complete list of types take a look at
|
17
|
-
# `app/assets/javascripts/faalis/dashboard/modules/fields/`
|
18
|
-
#
|
19
|
-
# **to**: This attribute is just for `in`, `has_many` and `belongs_to` field
|
20
|
-
# types which define the resource that current resource have dependency
|
21
|
-
# with. Bear in mind that `in` type uses `to` attrbute as an array of
|
22
|
-
# possible value for field and will render as a combobox.
|
23
|
-
#
|
24
|
-
# **options**: An object of type related objects. For example a list of
|
25
|
-
# current resource parents just like `parent` key.
|
26
|
-
#
|
27
|
-
# **bulk**: All fields with true as `bulk` value will be used in bulk editor.
|
28
|
-
#
|
29
|
-
# **tab**: ID of a Tab that this field should be appear on.
|
30
|
-
#
|
31
|
-
# **required**: Field will be non optional.
|
32
|
-
module ResourceFields
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
# An array of fields like
|
37
|
-
# [name, type]
|
38
|
-
def fields(fields_source = resource_data['fields'])
|
39
|
-
fields = []
|
40
|
-
relations = ['belongs_to', 'has_many']
|
41
|
-
|
42
|
-
if fields?
|
43
|
-
fields_source.each do |field|
|
44
|
-
name = field['name']
|
45
|
-
type = field['type']
|
46
|
-
to = field['to']
|
47
|
-
options = field['options'] || {}
|
48
|
-
|
49
|
-
type = Relation.new(type, to, options) if relations.include? type
|
50
|
-
fields << [name, type, to]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
fields
|
54
|
-
end
|
55
|
-
|
56
|
-
# Return the value of `attr_name` of `field_name` in
|
57
|
-
# resource_data["fields"]
|
58
|
-
def attrs(field_name, attr_name)
|
59
|
-
if fields?
|
60
|
-
field = fields_with('name', field_name)[0]
|
61
|
-
return field[attr_name]
|
62
|
-
end
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
|
66
|
-
def fields_hash
|
67
|
-
Hash[fields]
|
68
|
-
end
|
69
|
-
|
70
|
-
def grid_fields
|
71
|
-
fields_with("view_in_grid", true)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Return an string to use as a function parameters each
|
75
|
-
# field appears as symbol
|
76
|
-
def fields_as_params(relations = false)
|
77
|
-
# FIXME: cyclomatic complexity is to high
|
78
|
-
result = ''
|
79
|
-
field_num = 0
|
80
|
-
|
81
|
-
fields.each do |name, type|
|
82
|
-
if relations
|
83
|
-
if ['belongs_to'].include? type
|
84
|
-
result += " :#{name}_id"
|
85
|
-
else
|
86
|
-
result += " :#{name}"
|
87
|
-
end
|
88
|
-
|
89
|
-
field_num += 1
|
90
|
-
result += ',' if field_num < fields.length
|
91
|
-
|
92
|
-
else
|
93
|
-
unless ['belongs_to', 'has_many'].include? type
|
94
|
-
result += " :#{name}"
|
95
|
-
field_num += 1
|
96
|
-
result += ',' if field_num < fields.length
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
if result
|
102
|
-
result = ",#{result}"
|
103
|
-
result = result[0..-2] if result[-1] == ','
|
104
|
-
end
|
105
|
-
|
106
|
-
result
|
107
|
-
end
|
108
|
-
|
109
|
-
def raw_fields_data
|
110
|
-
resource_data['fields'] || []
|
111
|
-
end
|
112
|
-
|
113
|
-
def fields_with(attr, value)
|
114
|
-
raw_fields_data.select do |f|
|
115
|
-
if f.include? attr
|
116
|
-
f[attr] == value ? true : false
|
117
|
-
else
|
118
|
-
false
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def fields_with_attribute(attr)
|
124
|
-
field_list = raw_fields_data.select do |f|
|
125
|
-
f.include?(attr) ? true : false
|
126
|
-
end
|
127
|
-
field_list
|
128
|
-
end
|
129
|
-
|
130
|
-
def no_filter?
|
131
|
-
resource_data.include?('no_filter') && resource_data['no_filter']
|
132
|
-
end
|
133
|
-
|
134
|
-
def no_duplicate?
|
135
|
-
resource_data.include?('no_duplicate') && resource_data['no_duplicate']
|
136
|
-
end
|
137
|
-
|
138
|
-
def fields?
|
139
|
-
if resource_data.include? 'fields'
|
140
|
-
return true unless resource_data['fields'].nil?
|
141
|
-
end
|
142
|
-
false
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Faalis
|
2
|
-
module Generators
|
3
|
-
module Concerns
|
4
|
-
# Adds the `name` key to json file which specify the resource name.
|
5
|
-
module ResourceName
|
6
|
-
|
7
|
-
private
|
8
|
-
|
9
|
-
# Path to the resource
|
10
|
-
def resource_path
|
11
|
-
path_parts = resource_data["name"].split("/")
|
12
|
-
if path_parts.length > 1
|
13
|
-
return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].underscore}"
|
14
|
-
end
|
15
|
-
resource_data["name"].underscore
|
16
|
-
end
|
17
|
-
|
18
|
-
# Url of resource
|
19
|
-
def resource_url
|
20
|
-
path_parts = resource_data["name"].split("/")
|
21
|
-
if path_parts.length > 1
|
22
|
-
return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].pluralize.underscore}"
|
23
|
-
end
|
24
|
-
resource_data["name"].pluralize.underscore
|
25
|
-
end
|
26
|
-
|
27
|
-
# Camelized resource name. you can think of it as model name
|
28
|
-
def resource
|
29
|
-
path_parts = resource_data["name"].split("/")
|
30
|
-
if path_parts.length > 1
|
31
|
-
return path_parts[-1].camelize
|
32
|
-
end
|
33
|
-
resource_data["name"].camelize
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
module Faalis
|
4
|
-
module Generators
|
5
|
-
module Concerns
|
6
|
-
# Using this **concern** module user can specify an array of tab objects
|
7
|
-
# which each one has an `id` and `name` attribute. Tabs will be added to
|
8
|
-
# **new** view of resource. Also this concern will a `tab` key to field
|
9
|
-
# object. All the fields with same `id` as a tab will be grouped in that
|
10
|
-
# tab
|
11
|
-
module Tabs
|
12
|
-
|
13
|
-
private
|
14
|
-
# Process the user provided tabs
|
15
|
-
# return a Hash of tabs like
|
16
|
-
def tabs
|
17
|
-
tabbed_fields = Set.new
|
18
|
-
|
19
|
-
if resource_data.include? 'tabs'
|
20
|
-
|
21
|
-
tabs = resource_data['tabs']
|
22
|
-
result = {}
|
23
|
-
tabs.each do |tab|
|
24
|
-
name = tab['name']
|
25
|
-
|
26
|
-
fields_list = fields_with('tab', tab['id'])
|
27
|
-
fields_list.each { |f| tabbed_fields << f }
|
28
|
-
|
29
|
-
result[name] = fields_list
|
30
|
-
end
|
31
|
-
all_fields = Set.new resource_data['fields']
|
32
|
-
|
33
|
-
result.each do |k, v|
|
34
|
-
if v.empty?
|
35
|
-
diff = (all_fields ^ tabbed_fields).to_a
|
36
|
-
result[k] = diff
|
37
|
-
end
|
38
|
-
end
|
39
|
-
return result
|
40
|
-
else
|
41
|
-
{}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def tab_has_field?(tab_name, field_name)
|
46
|
-
it_does = tabs[tab_name].select { |f| f['name'] == field_name }
|
47
|
-
!it_does.empty?
|
48
|
-
end
|
49
|
-
|
50
|
-
def any_tabs?
|
51
|
-
resource_data.include? 'tabs'
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module Faalis
|
2
|
-
module Generators
|
3
|
-
module Concerns
|
4
|
-
|
5
|
-
# This module is dedicated to filter resource object based
|
6
|
-
# on a condition or query. For example if you want to filter
|
7
|
-
# a resource objects to those which belongs to current logged
|
8
|
-
# in user you can do like:
|
9
|
-
#
|
10
|
-
# ```javascript
|
11
|
-
# ...
|
12
|
-
# "where": {
|
13
|
-
# "user": "current_user"
|
14
|
-
# }
|
15
|
-
# ...
|
16
|
-
# ```
|
17
|
-
#
|
18
|
-
# `where` value is an object which each key is a ruby model
|
19
|
-
# field name and its value is the actual value that you want
|
20
|
-
# to use to check the field against that.
|
21
|
-
module Where
|
22
|
-
private
|
23
|
-
|
24
|
-
def where_cond?
|
25
|
-
if resource_data.include? 'where'
|
26
|
-
return true unless resource_data['where'].empty?
|
27
|
-
end
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
|
-
# Return a hash of parameters to pass to where method
|
32
|
-
def where_conditions
|
33
|
-
if has_where_cond?
|
34
|
-
flat_array = resource_data['where'].map do |field, value|
|
35
|
-
[field.to_sym, value]
|
36
|
-
end
|
37
|
-
Hash[flat_array]
|
38
|
-
end
|
39
|
-
{}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module Faalis
|
4
|
-
module Generators
|
5
|
-
# `DashboardScaffold` is the base class for all the dashboard
|
6
|
-
# scaffolds which make creating scaffold generators way more
|
7
|
-
# easier. But you can drive your own generator normally of caurse
|
8
|
-
class DashboardScaffold < Rails::Generators::Base
|
9
|
-
|
10
|
-
include ::ActionView::Helpers::TextHelper
|
11
|
-
include Faalis::Generators::Concerns::InputFile
|
12
|
-
include Faalis::Generators::Concerns::ResourceName
|
13
|
-
include Faalis::Generators::Concerns::ResourceFields
|
14
|
-
include Faalis::Generators::Concerns::Menu
|
15
|
-
include Faalis::Generators::Concerns::Dependency
|
16
|
-
include Faalis::Generators::Concerns::Bulk
|
17
|
-
include Faalis::Generators::Concerns::RequireFields
|
18
|
-
include Faalis::Generators::Concerns::Parent
|
19
|
-
include Faalis::Generators::Concerns::Child
|
20
|
-
include Faalis::Generators::Concerns::Angular
|
21
|
-
include Faalis::Generators::Concerns::Tabs
|
22
|
-
include Faalis::Generators::Concerns::Model
|
23
|
-
include Faalis::Generators::Concerns::AllowQueryOn
|
24
|
-
include Faalis::Generators::Concerns::Render
|
25
|
-
include Faalis::Generators::Concerns::Where
|
26
|
-
include Faalis::Generators::Concerns::Fieldset
|
27
|
-
|
28
|
-
# Do not install specs
|
29
|
-
class_option :without_specs, type: :boolean, default: false, desc: 'Do not install specs'
|
30
|
-
|
31
|
-
# Generate only spec files
|
32
|
-
class_option :only_specs, type: :boolean, default: false, desc: 'Generate only spec files'
|
33
|
-
|
34
|
-
# TODO: Move it to listview generator
|
35
|
-
# Generate only controller
|
36
|
-
class_option :only_controller, type: :boolean, default: false, desc: 'Generate only controller'
|
37
|
-
|
38
|
-
# Don't show a filter box
|
39
|
-
class_option :no_filter, type: :boolean, default: false, desc: 'Don\'t view a filter box'
|
40
|
-
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
# Overrided `source_paths` method. With this approach extensions
|
45
|
-
# can override generators templates. Cool ha ?
|
46
|
-
def source_paths
|
47
|
-
@source_paths = self.class.source_paths_for_search
|
48
|
-
|
49
|
-
paths = []
|
50
|
-
Faalis::Extension.extensions.each do |name, klass|
|
51
|
-
if klass.respond_to? :generator_templates_path.to_sym
|
52
|
-
paths << klass.generator_templates_path
|
53
|
-
end
|
54
|
-
end
|
55
|
-
paths += @source_paths
|
56
|
-
@source_paths = paths
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module Faalis
|
2
|
-
module Generators
|
3
|
-
class Relation < String
|
4
|
-
attr_accessor :to
|
5
|
-
|
6
|
-
def initialize(value, to, options = "")
|
7
|
-
super(value)
|
8
|
-
@options = options
|
9
|
-
@to = to
|
10
|
-
end
|
11
|
-
|
12
|
-
def resource_name
|
13
|
-
to.split("/").last
|
14
|
-
end
|
15
|
-
|
16
|
-
def to
|
17
|
-
result = ""
|
18
|
-
if options.include? "parents"
|
19
|
-
field_parents.each do |parent|
|
20
|
-
result = "#{result}/#{parent}/' + $scope.#{parent}_id + '"
|
21
|
-
end
|
22
|
-
result = "#{result}/"
|
23
|
-
end
|
24
|
-
"#{result}#{@to}"
|
25
|
-
end
|
26
|
-
|
27
|
-
def options
|
28
|
-
unless @options.empty?
|
29
|
-
@options
|
30
|
-
else
|
31
|
-
{}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def field_parents
|
36
|
-
if options.include? "parents"
|
37
|
-
options["parents"]
|
38
|
-
else
|
39
|
-
[]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def restangular
|
44
|
-
result = "API"
|
45
|
-
if options.include? "parents"
|
46
|
-
field_parents.each do |parent|
|
47
|
-
result = "#{result}.one('#{parent}', #{}_id)"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
to.split("/").each do |resource|
|
51
|
-
result = "#{result}.all(\"#{resource}\")"
|
52
|
-
end
|
53
|
-
result
|
54
|
-
end
|
55
|
-
|
56
|
-
def get_list
|
57
|
-
"#{restangular}.getList()"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|