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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +16 -0
  3. data/app/controllers/faalis/dashboard/application_controller.rb +1 -1
  4. data/app/controllers/faalis/dashboard/users_controller.rb +7 -5
  5. data/app/views/faalis/dashboard/groups/create.js.erb +1 -1
  6. data/app/views/faalis/dashboard/groups/update.js.erb +1 -1
  7. data/app/views/faalis/dashboard/users/_form.html.slim +12 -16
  8. data/app/views/faalis/dashboard/users/_password_form.html.slim +2 -2
  9. data/app/views/faalis/dashboard/users/create.js.erb +1 -1
  10. data/app/views/faalis/dashboard/users/index.html.slim +2 -2
  11. data/app/views/faalis/dashboard/users/update.js.erb +1 -1
  12. data/app/views/faalis/dashboard/users/update_password.js.erb +1 -1
  13. data/app/views/layouts/faalis/dashboard.html.erb +1 -1
  14. data/config/locales/faalis.fa.yml +8 -1
  15. data/lib/faalis.rb +2 -3
  16. data/lib/faalis/configuration.rb +45 -17
  17. data/lib/faalis/engine.rb +2 -51
  18. data/lib/faalis/version.rb +1 -1
  19. metadata +4 -26
  20. data/lib/faalis/generators.rb +0 -1
  21. data/lib/faalis/generators/concerns.rb +0 -17
  22. data/lib/faalis/generators/concerns/allow_query_on.rb +0 -34
  23. data/lib/faalis/generators/concerns/angular.rb +0 -28
  24. data/lib/faalis/generators/concerns/bulk.rb +0 -19
  25. data/lib/faalis/generators/concerns/child.rb +0 -31
  26. data/lib/faalis/generators/concerns/dependency.rb +0 -37
  27. data/lib/faalis/generators/concerns/fieldset.rb +0 -47
  28. data/lib/faalis/generators/concerns/globalize.rb +0 -14
  29. data/lib/faalis/generators/concerns/hstore.rb +0 -19
  30. data/lib/faalis/generators/concerns/input_file.rb +0 -49
  31. data/lib/faalis/generators/concerns/menu.rb +0 -27
  32. data/lib/faalis/generators/concerns/model.rb +0 -28
  33. data/lib/faalis/generators/concerns/parent.rb +0 -62
  34. data/lib/faalis/generators/concerns/render.rb +0 -22
  35. data/lib/faalis/generators/concerns/required.rb +0 -18
  36. data/lib/faalis/generators/concerns/resource_fields.rb +0 -147
  37. data/lib/faalis/generators/concerns/resource_name.rb +0 -39
  38. data/lib/faalis/generators/concerns/tabs.rb +0 -56
  39. data/lib/faalis/generators/concerns/where.rb +0 -44
  40. data/lib/faalis/generators/dashboard_scaffold.rb +0 -62
  41. data/lib/faalis/generators/fields/relation.rb +0 -61
@@ -1 +0,0 @@
1
- require "faalis/generators/dashboard_scaffold"
@@ -1,17 +0,0 @@
1
- require 'faalis/generators/concerns/menu'
2
- require 'faalis/generators/concerns/dependency'
3
- require 'faalis/generators/concerns/bulk'
4
- require 'faalis/generators/concerns/required'
5
- require 'faalis/generators/concerns/parent'
6
- require 'faalis/generators/concerns/child'
7
- require 'faalis/generators/concerns/resource_fields'
8
- require 'faalis/generators/concerns/resource_name'
9
- require 'faalis/generators/concerns/angular'
10
- require 'faalis/generators/concerns/tabs'
11
- require 'faalis/generators/concerns/model'
12
- require 'faalis/generators/concerns/input_file'
13
- require 'faalis/generators/concerns/allow_query_on'
14
- require 'faalis/generators/concerns/render'
15
- require 'faalis/generators/concerns/where'
16
- require 'faalis/generators/concerns/fieldset'
17
- require 'faalis/generators/concerns/globalize'
@@ -1,34 +0,0 @@
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
- def allowed_fields
11
- if allowed_fields_provided?
12
- unless resource_data['allow_query_on'].is_a? Array
13
- fail Exception.new 'value of `allow_query_on` key should be an Array. '
14
- end
15
- # :#{something} is a trick to convert the field name to sym on
16
- # controller
17
- fields = resource_data['allow_query_on'].collect { |f| ":#{f}" }
18
- fields.join(' ,')
19
- else
20
- []
21
- end
22
- end
23
-
24
- # Check for any allowed fields in json
25
- def allowed_fields_provided?
26
- if resource_data.include? 'allow_query_on'
27
- return true unless resource_data['allow_query_on'].nil?
28
- end
29
- false
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,28 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
-
5
- # This **Concern** looks for `raw_path` and `path` in scaffold
6
- # json file which both of them are optional.
7
- # Using `raw_path` you can override the full path of generate file.
8
- # and with `path` you can override the directory name inside
9
- # `app/assets/javascripts`.
10
- module Angular
11
-
12
- private
13
-
14
- # return the relative path to place where scaffold shoud be created.
15
- def angularjs_app_path
16
- if !resource_data['raw_path'].blank?
17
- resource_data['raw_path']
18
- elsif !resource_data['path'].blank?
19
- "app/assets/javascripts/#{resource_data['path']}/"
20
- else
21
- path = Faalis::Engine.dashboard_js_manifest.split('/')[0..-2].join('/')
22
- "app/assets/javascripts/#{path}/"
23
- end
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,19 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
- module Bulk
5
-
6
- private
7
-
8
- # Returns fields which is needed to be in bulk edit
9
- def bulk_edit_fields
10
- fields_with("bulk", true)
11
- end
12
-
13
- def no_bulk?
14
- resource_data.include?('no_bulk') && resource_data['no_bulk']
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,31 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
-
5
- module Child
6
-
7
- private
8
-
9
- # check for child
10
- def child?
11
- if resource_data.include? 'childs'
12
- return true unless resource_data['childs'].nil?
13
- end
14
- false
15
- end
16
-
17
-
18
- # Return an array of resource childs
19
- def childs
20
- if child?
21
- resource_data['childs']
22
- else
23
- []
24
- end
25
- end
26
-
27
-
28
- end
29
- end
30
- end
31
- end
@@ -1,37 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
-
5
- # This **Concern** adds support of dependencies to scaffold using
6
- # `deps` key in json file. You can provide a list of scaffold dependencies
7
- # which should mention as dependecy of **Angularjs** module of scaffold.
8
- # Example:
9
- #
10
- #```javascript
11
- # ....
12
- # "deps": [
13
- # "module1",
14
- # "module2"
15
- # ],
16
- # ...
17
- #```
18
- module Dependency
19
-
20
- def self.included(base)
21
- # Dependencies of Angularjs module, comma separated
22
- #base.class_option :deps, :type => :string, :default => "", :desc => "Dependencies of Angularjs module, comma separated"
23
- end
24
-
25
- # Is there any dependency ?
26
- def have_dependency?
27
- resource_data.include? 'deps'
28
- end
29
-
30
- # Return a list of dependencies.
31
- def deps
32
- resource_data['deps']
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,47 +0,0 @@
1
- require 'set'
2
-
3
- module Faalis
4
- module Generators
5
- module Concerns
6
- # Allow to categorize fields in some fieldset
7
- module Fieldset
8
-
9
- private
10
-
11
- # Returns fields which is needed to be in bulk edit
12
- def fieldset?
13
- !fields_with_attribute('fieldset').empty?
14
- end
15
-
16
- def fieldset_less_fields
17
- fields = Set.new(raw_fields_data) - Set.new(fields_with_attribute('fieldset'))
18
- fields.to_a
19
- end
20
-
21
- # TODO: fix this method to allow usage on tabbed views too
22
- # Return fields categorized by fieldsets. Only for
23
- # views without tabs
24
- def fieldsets
25
- fieldsets = {resource.underscore.pluralize.humanize => fieldset_less_fields}
26
- fields = fields_with_attribute('fieldset')
27
- fields.each do |f|
28
- if fieldsets.include? f['fieldset']
29
- fieldsets[f['fieldset']] << f
30
- else
31
- fieldsets[f['fieldset']] = [f]
32
- end
33
- end
34
-
35
- # Convert hashes to proper field structure to use in templates
36
- fieldsets.each do |fieldset_name, fieldset_fields|
37
- if fieldset_fields[0].is_a? Hash
38
- fieldsets[fieldset_name] = fields(fieldset_fields)
39
- end
40
- end
41
-
42
- fieldsets
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,14 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
- module Globalize
5
- private
6
-
7
- def globalize_fields
8
- fields_with("globalize", true)
9
- end
10
-
11
- end
12
- end
13
- end
14
- end
@@ -1,19 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
- # This concern adds support for `PostgreSQL` Hstore
5
- # type to generators. So `hstore` fields will not work
6
- # on other databases or work differently. For example
7
- # We try to create a json from the key/values of `hstore`
8
- # field and store that to the corresponding field.
9
- module Hstore
10
-
11
- private
12
-
13
- def hstore_fields
14
- fields_with('type', 'hstore')
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,49 +0,0 @@
1
- require 'json'
2
- require 'yaml'
3
-
4
- module Faalis
5
- module Generators
6
- module Concerns
7
- # This module Provide an argument for generator which
8
- # is needed by other `Concerns`.
9
- # Each Concern will have its own entry in scaffold json
10
- # file. For documentation on each entry checkout its concern class
11
- module InputFile
12
-
13
- def self.included(base)
14
- # Name of the resource to create.
15
- base.argument :input_file , :type => :string, :required => true
16
- end
17
-
18
- private
19
-
20
- # Return absolute path to input file
21
- def file_path
22
- File.expand_path(input_file)
23
- end
24
- # Get the extension name of input file
25
- def extname
26
- File.extname(file_path)
27
- end
28
-
29
- # Read the json or yaml file and returns its raw data
30
- def input_file_data
31
- File.read(file_path)
32
- end
33
-
34
- # Return the hash related to json or yaml structure from cache or by
35
- # reading file.
36
- def resource_data
37
- if @data
38
- @data
39
- else
40
- @data = JSON.parse(input_file_data) if extname == '.json'
41
- @data = YAML.load_file(file_path) if extname == '.yml'
42
- @data
43
- end
44
- end
45
-
46
- end
47
- end
48
- end
49
- end
@@ -1,27 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
- # This **concern** adds support of side menu to scaffold and `menu` key
5
- # to jsonfile. `menu` key is an array which each element represent a menu
6
- # entry and should be and object with following keys:
7
- #
8
- # `title`: Title of submenu
9
- #
10
- # `url`: Url of submenu link
11
- #
12
- # `action`: Permissions related action to check on resource model.
13
- #
14
- # `model`: Model of related resource which permission action should be check
15
- # against.
16
- module Menu
17
-
18
- private
19
-
20
- def has_menu?
21
- resource_data.include? "menu"
22
- end
23
-
24
- end
25
- end
26
- end
27
- end
@@ -1,28 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
- # This **concern** adds support for `model` key inside jsonfile which
5
- # allow you to override the name of resource default model name.
6
- # Resource model name is used in some processes like permission system.
7
- module Model
8
-
9
- private
10
-
11
- # Does an alternative `model` is specified ?
12
- def model_specified?
13
- resource_data.include? 'model'
14
- end
15
-
16
- # Name of alternative `model`
17
- def model
18
- if model_specified?
19
- resource_data['model']
20
- else
21
- ''
22
- end
23
- end
24
-
25
- end
26
- end
27
- end
28
- end
@@ -1,62 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
-
5
- # This **concern** adds the methods needed to support nested resource
6
- # in any dashboad generators. This module adds `parents` key to jsonfile
7
- # which is an array of resource parents in right order.
8
- # For example if we have a nested resource like:
9
- #
10
- # ```ruby
11
- # resources :blogs do
12
- # resources :categories do
13
- # resources :posts
14
- # end
15
- # end
16
- # ```
17
- #
18
- # And we want to create an dashboard scaffold for `post` resource we have
19
- # to add `parent` key to our json file like this:
20
- #
21
- # ```json
22
- # ...
23
- # "parents": [
24
- # "blog",
25
- # "category"
26
- # ]
27
- # ...
28
- # ```
29
- # Please pay attention to singular form of name of parents in json defination
30
- module Parent
31
-
32
- private
33
-
34
- # check for parent
35
- def parent?
36
- if resource_data.include? 'parents'
37
- return true unless resource_data['parents'].nil?
38
- end
39
- false
40
- end
41
-
42
- # Remove the starting slash from the given parent path
43
- def trim_parent_path(path)
44
- path.gsub(/^\//, '')
45
- end
46
-
47
- # Return an array of resource parents
48
- def parents
49
- if parent?
50
- _parents = resource_data['parents']
51
- _parents.collect do |p|
52
- trim_parent_path(p)
53
- end
54
- else
55
- []
56
- end
57
- end
58
-
59
- end
60
- end
61
- end
62
- end
@@ -1,22 +0,0 @@
1
- module Faalis
2
- module Generators
3
- module Concerns
4
- # This concern will add `render` method to generators which load
5
- # template partials
6
- module Render
7
-
8
- private
9
-
10
- def render(source, &block)
11
- source = File.expand_path(find_in_source_paths("#{source.to_s}.erb"))
12
- context = instance_eval('binding')
13
-
14
- content = ERB.new(::File.binread(source), nil, '-').result(binding)
15
- content = block.call(content) if block
16
- content
17
- end
18
-
19
- end
20
- end
21
- end
22
- end