faalis 0.16.3 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/angularjs_templates/modules.html +1 -1
  3. data/lib/faalis.rb +2 -0
  4. data/lib/faalis/generators.rb +1 -0
  5. data/lib/faalis/generators/concerns.rb +9 -0
  6. data/lib/faalis/generators/concerns/angular.rb +31 -0
  7. data/lib/faalis/generators/concerns/bulk.rb +36 -0
  8. data/lib/faalis/generators/concerns/dependency.rb +14 -0
  9. data/lib/faalis/generators/concerns/menu.rb +29 -0
  10. data/lib/faalis/generators/concerns/parent.rb +35 -0
  11. data/lib/faalis/generators/concerns/required.rb +22 -0
  12. data/lib/faalis/generators/concerns/resource_fields.rb +82 -0
  13. data/lib/faalis/generators/concerns/resource_name.rb +42 -0
  14. data/lib/faalis/generators/concerns/tabs.rb +40 -0
  15. data/lib/faalis/generators/dashboard_scaffold.rb +35 -0
  16. data/lib/faalis/generators/fields/relation.rb +28 -0
  17. data/lib/faalis/version.rb +1 -1
  18. data/lib/generators/faalis/js/list_view_generator.rb +110 -0
  19. data/lib/generators/faalis/js_scaffold_generator.rb +4 -251
  20. data/lib/generators/faalis/templates/angularjs/module.js.erb +1 -1
  21. data/lib/generators/faalis/templates/js/list_view/README +31 -0
  22. data/lib/generators/faalis/templates/js/list_view/details.html.erb +20 -0
  23. data/lib/generators/faalis/templates/js/list_view/index.html.erb +62 -0
  24. data/lib/generators/faalis/templates/js/list_view/module.js.erb +333 -0
  25. data/lib/generators/faalis/templates/js/list_view/new.html.erb +62 -0
  26. metadata +338 -328
  27. data/app/assets/javascripts/faalis/dashboard/gen-doc.sh~ +0 -3
  28. data/spec/dummy/log/development.log +0 -0
  29. data/spec/dummy/log/test.log +0 -15
  30. data/spec/dummy/tmp/ember-rails/ember-data.js +0 -10204
  31. data/spec/dummy/tmp/ember-rails/ember.js +0 -36991
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d61d933dd4c3ddbee82cdea09bba326cc90cb4da
4
- data.tar.gz: 199548898cd205d7144769fb3c052a6ae4f9783f
3
+ metadata.gz: 9807cff362df15212e7a19378f538630e0e31330
4
+ data.tar.gz: 37dec94839c443774bd2d51975eac9167fc01bf4
5
5
  SHA512:
6
- metadata.gz: 2d93712db24e85593e8fd0cd909ac568eb4ae978bb2acf9265b27093c3e61e8a70f51f778624d938e7735f2552b10d25542f0a426a87073e322ca80836e8b95e
7
- data.tar.gz: 9c737066654c5c2049facc4e20cedf0ab78134dbf0d3640f62b636634520e907e1bd395d72e3f2469754765f83005f85cac38ab8d1ac205abc6d381b4ffb3be5
6
+ metadata.gz: fa37de6cd8b841994610e12aebed1b751efd943e7a2035379c77cde818167952d0bb7706c3e84f0863bce0c3eb46e007507a2df4b3d73dca490f8e1b57f8cc94
7
+ data.tar.gz: 2ec9fd8f7f2577217e5911102bdb12043d5815bbbcda3e788c424be63a77aba57fbbe7d3481dfc186888b84a7a3a0cf736030ebba769d00df0fd1262480b6167
@@ -2,7 +2,7 @@
2
2
 
3
3
  <li ng-click="controller.on_click('/')"><p><i class="fa fa-dashboard"></i> <span translate>Dashboard</span></p></li>
4
4
 
5
- <li data-ng-repeat="module in controller.modules" if-user="user.can('read', module.model)">
5
+ <li data-ng-repeat="module in controller.modules">
6
6
  <p ng-click="controller.view_menu(module)"><i class="{{ module.icon }}"></i> <span translate>{{ module.title }}</span></p>
7
7
  <ul class="submenu slide" ng-if="module.show_menu">
8
8
  <li ng-repeat="menu_item in module.menu_items" ng-click="controller.on_click(menu_item.url)"><span>{{ menu_item.title }}</span></li>
@@ -29,3 +29,5 @@ require "faalis/omniauth"
29
29
  require "faalis/active_record"
30
30
  require "faalis/i18n"
31
31
  require "faalis/plugins"
32
+ require "faalis/generators/concerns"
33
+ require "faalis/generators"
@@ -0,0 +1 @@
1
+ require "faalis/generators/dashboard_scaffold"
@@ -0,0 +1,9 @@
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/resource_fields"
7
+ require "faalis/generators/concerns/resource_name"
8
+ require "faalis/generators/concerns/angular"
9
+ require "faalis/generators/concerns/tabs"
@@ -0,0 +1,31 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module Angular
5
+
6
+ def self.included(base)
7
+ # Path to js_scaffold target inside 'app/assets/javascripts/'
8
+ base.class_option :path, :type => :string, :default => "", :desc => "Path to js_scaffold target inside 'app/assets/javascripts/'"
9
+
10
+ # Path to js_scaffold target
11
+ base.class_option :raw_path, :type => :string, :default => "", :desc => "Path to js_scaffold target"
12
+ end
13
+
14
+ private
15
+
16
+
17
+ def angularjs_app_path
18
+ if options[:raw_path] != ""
19
+ options[:raw_path]
20
+ elsif options[:path] != ""
21
+ "app/assets/javascripts/#{options[:path]}/"
22
+ else
23
+ path = Faalis::Engine.dashboard_js_manifest.split("/")[0..-2].join("/")
24
+ "app/assets/javascripts/#{path}/"
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,36 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module Bulk
5
+
6
+ def self.included(base)
7
+ # Fields to use in in bulk edit, comma separated
8
+ base.class_option :bulk_fields, :type => :string, :default => "", :desc => "Fields to use in in bulk edit, comma separated"
9
+
10
+ # No bulk edit needed
11
+ base.class_option :no_bulk, :type => :boolean, :default => false, :desc => "No bulk edit needed"
12
+ end
13
+
14
+ private
15
+
16
+ # Returns fields which is needed to be in bulk edit
17
+ def bulk_edit_fields
18
+ unless options[:bulk_fields].empty?
19
+ bfields = options[:bulk_fields].split(",")
20
+ fields_ = fields_hash
21
+ bfields.each do |f|
22
+ unless fields_.include? f
23
+ raise ::Exception.new "'#{f}' is not in scaffold fields."
24
+ end
25
+ end
26
+ return bfields
27
+ else
28
+
29
+ return self.send(:fields).collect {|f| f[0]}
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,14 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module Dependency
5
+
6
+ def self.included(base)
7
+ # Dependencies of Angularjs module, comma separated
8
+ base.class_option :deps, :type => :string, :default => "", :desc => "Dependencies of Angularjs module, comma separated"
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module Menu
5
+
6
+ def self.included(base)
7
+ # Provide menu items which should be in sidebar. format: menu1:url,menu2:url
8
+ base.class_option :menu, :type => :string, :default => "", :desc => "Provide menu items which should be in sidebar. format: menu1:url,menu2:url"
9
+ end
10
+
11
+ private
12
+
13
+ def parse_menu(menu)
14
+ regex = /([^:{}]+){1}\:([^:\{\}]+)(?:{(.*)})?/i
15
+ model = nil
16
+ if menu =~ regex
17
+ title = $1
18
+ url = $2
19
+ model = $3
20
+ return title, url, model
21
+ else
22
+ Raise Exception.new "Menu items format should be like 'name:url{model}'. Model part is optional"
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,35 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module Parent
5
+
6
+ def self.included(base)
7
+ # Specify the parent resource if there was any
8
+ base.class_option :parent, :type => :string, :default => "", :desc => "Specify the parent resource if there was any"
9
+ end
10
+
11
+ private
12
+
13
+ # check for parent
14
+ def parent?
15
+ if options[:parent] != ""
16
+ return true
17
+ end
18
+ false
19
+ end
20
+
21
+ # Remove the starting slash from the given parent path
22
+ def trim_parent_path
23
+ if parent?
24
+ options[:parent].gsub(/^\//, "")
25
+ else
26
+ ""
27
+ end
28
+ end
29
+
30
+ # -------------------------
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module RequireFields
5
+
6
+ def self.included(base)
7
+ # Non optional fields, comma separated
8
+ base.class_option :required, :type => :string, :default => "", :desc => "Non optional fields, comma separated"
9
+ end
10
+
11
+ private
12
+
13
+ def required_fields
14
+ if not options[:required].empty?
15
+ return options[:required].split(",")
16
+ end
17
+ []
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,82 @@
1
+ require "faalis/generators/fields/relation"
2
+
3
+
4
+ module Faalis
5
+ module Generators
6
+ module Concerns
7
+ module ResourceFields
8
+
9
+ def self.included(base)
10
+ # An array of resource fields. fields should be separated by space
11
+ # each filed should be in this format `field_name:field_type[:extra_info]
12
+ base.argument :resource_fields, type: :array, default: [], banner: "fields[:types]"
13
+
14
+ end
15
+
16
+ private
17
+ # An array of fields like
18
+ # [name, type]
19
+ def fields
20
+ fields = []
21
+ resource_fields.each do |field|
22
+ name, type, to = field.split(":")
23
+ if ["belongs_to", "has_many", "in"].include? type
24
+ type = Relation.new(type, to)
25
+ end
26
+
27
+ fields << [name, type]
28
+ end
29
+ fields
30
+ end
31
+
32
+ def fields_hash
33
+ Hash[fields]
34
+ end
35
+
36
+ def grid_fields
37
+ fields
38
+ end
39
+
40
+ # Return an string to use as a function parameters each
41
+ # field appears as symbol
42
+ def fields_as_params(relations: false)
43
+ result = ""
44
+ field_num = 0
45
+ fields.each do |name, type|
46
+ if relations
47
+ if ["belongs_to"].include? type
48
+ result += " :#{name}_id"
49
+ else
50
+ result += " :#{name}"
51
+ end
52
+ field_num += 1
53
+ if field_num < fields.length
54
+ result += ","
55
+ end
56
+
57
+ else
58
+ unless ["belongs_to", "has_many"].include? type
59
+ result += " :#{name}"
60
+ field_num += 1
61
+ if field_num < fields.length
62
+ result += ","
63
+ end
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ if result
70
+ result = ",#{result}"
71
+ if result[-1] == ","
72
+ result = result[0..-2]
73
+ end
74
+ end
75
+
76
+ result
77
+ end
78
+
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,42 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module ResourceName
5
+
6
+ def self.included(base)
7
+ # Name of the resource to create.
8
+ base.argument :resource_name, :type => :string, :required => true
9
+ end
10
+
11
+ private
12
+
13
+ # Path to the resource
14
+ def resource_path
15
+ path_parts = resource_name.split("/")
16
+ if path_parts.length > 1
17
+ return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].underscore}"
18
+ end
19
+ resource_name.underscore
20
+ end
21
+
22
+ # Url of resource
23
+ def resource_url
24
+ path_parts = resource_name.split("/")
25
+ if path_parts.length > 1
26
+ return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].pluralize.underscore}"
27
+ end
28
+ resource_name.pluralize.underscore
29
+ end
30
+
31
+ def resource
32
+ path_parts = resource_name.split("/")
33
+ if path_parts.length > 1
34
+ return path_parts[-1].camelize
35
+ end
36
+ resource_name.camelize
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,40 @@
1
+ module Faalis
2
+ module Generators
3
+ module Concerns
4
+ module Tabs
5
+
6
+ def self.included(base)
7
+ # Add tabs to 'new' view of scaffold. format: --tabs tab1:'field1;field2',tab2 Note: __all__ field include all fileds.
8
+ base.class_option :tabs, :type => :string, :default => "", :desc => "Add tabs to 'new' view of scaffold. format: --tabs tab1:'field1;field2',tab2 Note: __all__ field include all fileds."
9
+ end
10
+
11
+ private
12
+
13
+ # Process the user provided tabs
14
+ # @return a Hash of tabs like
15
+ def tabs
16
+ if options[:tabs].present?
17
+ tabs = options[:tabs].split(",")
18
+ result = {}
19
+ tabs.each do |tab|
20
+ name, fields = tab.split(":")
21
+ fields_list = []
22
+ unless fields.nil?
23
+ fields_list = fields.split(";")
24
+ end
25
+ result[name] = fields_list
26
+ end
27
+ return result
28
+ else
29
+ {}
30
+ end
31
+ end
32
+
33
+ def any_tabs?
34
+ options[:tabs].present?
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,35 @@
1
+ module Faalis
2
+ module Generators
3
+ # `DashboardScaffold` is the base class for all the dashboard
4
+ # scaffolds which make creating scaffold generators way more
5
+ # easier. But you can drive your own generator normally of caurse
6
+ class DashboardScaffold < Rails::Generators::Base
7
+
8
+ include ActionView::Helpers::TextHelper
9
+ include Faalis::Generators::Concerns::ResourceName
10
+ include Faalis::Generators::Concerns::ResourceFields
11
+ include Faalis::Generators::Concerns::Menu
12
+ include Faalis::Generators::Concerns::Dependency
13
+ include Faalis::Generators::Concerns::Bulk
14
+ include Faalis::Generators::Concerns::RequireFields
15
+ include Faalis::Generators::Concerns::Parent
16
+ include Faalis::Generators::Concerns::Angular
17
+ include Faalis::Generators::Concerns::Tabs
18
+
19
+
20
+ # Do not install specs
21
+ class_option :without_specs, :type => :boolean, :default => false, :desc => "Do not install specs"
22
+
23
+ # Generate only spec files
24
+ class_option :only_specs, :type => :boolean, :default => false, :desc => "Generate only spec files"
25
+
26
+ # Generate only controller
27
+ class_option :only_controller, :type => :boolean, :default => false, :desc => "Generate only controller"
28
+
29
+ # Don't show a filter box
30
+ class_option :no_filter, :type => :boolean, :default => false, :desc => "Don't view a filter box"
31
+
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,28 @@
1
+ module Faalis
2
+ module Generators
3
+ class Relation < String
4
+ attr_accessor :to
5
+
6
+ def initialize(value, to_)
7
+ super(value)
8
+ self.to = to_
9
+ end
10
+
11
+ def resource_name
12
+ to.split("/").last
13
+ end
14
+
15
+ def restangular
16
+ result = "API"
17
+ to.split("/").each do |resource|
18
+ result = "#{result}.all(\"#{resource}\")"
19
+ end
20
+ result
21
+ end
22
+
23
+ def get_list
24
+ "#{restangular}.getList()"
25
+ end
26
+ end
27
+ end
28
+ end