faalis 0.24.4 → 0.25.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/javascripts/faalis/dashboard/modules/auth/group.js +7 -1
  3. data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +50 -3
  4. data/app/assets/stylesheets/faalis/base.css.scss +16 -1
  5. data/app/assets/stylesheets/faalis/ltr/foundation_and_overrides.scss +4 -0
  6. data/app/assets/stylesheets/faalis/rtl/foundation_and_overrides.css.scss +1 -1
  7. data/app/assets/stylesheets/faalis/variables.css.scss +1 -1
  8. data/app/controllers/faalis/#api_controller.rb# +144 -0
  9. data/app/controllers/faalis/api/v1/#conversations_controller.rb# +120 -0
  10. data/app/controllers/faalis/api/v1/workflows_controller.rb +18 -0
  11. data/app/controllers/faalis/api_controller.rb +3 -3
  12. data/app/controllers/faalis/application_controller.rb +0 -1
  13. data/app/models/faalis/workflow.rb +4 -0
  14. data/app/views/angularjs_templates/auth/groups/new.html +47 -25
  15. data/app/views/angularjs_templates/fields/relation/relation.html +9 -2
  16. data/app/views/devise/sessions/new.html.erb +52 -88
  17. data/app/views/faalis/api/v1/workflows/index.json.jbuilder +5 -0
  18. data/app/views/faalis/home/index.html.erb +14 -11
  19. data/app/views/layouts/faalis/application.html.erb +21 -30
  20. data/app/views/layouts/faalis/simple.html.erb +37 -0
  21. data/app/workflows/faalis/administration_workflow.rb +7 -0
  22. data/config/routes.rb +15 -13
  23. data/db/migrate/20140413180202_create_faalis_workflows.rb +9 -0
  24. data/db/seeds.rb +17 -13
  25. data/lib/faalis.rb +12 -10
  26. data/lib/faalis/engine.rb +9 -8
  27. data/lib/faalis/generators/concerns.rb +15 -13
  28. data/lib/faalis/generators/concerns/bulk.rb +2 -5
  29. data/lib/faalis/generators/concerns/fieldset.rb +48 -0
  30. data/lib/faalis/generators/concerns/resource_fields.rb +43 -45
  31. data/lib/faalis/generators/concerns/where.rb +46 -0
  32. data/lib/faalis/generators/dashboard_scaffold.rb +6 -5
  33. data/lib/faalis/version.rb +1 -1
  34. data/lib/faalis/workflows.rb +7 -0
  35. data/lib/faalis/workflows/base.rb +69 -0
  36. data/lib/faalis/workflows/discovery.rb +42 -0
  37. data/lib/generators/faalis/templates/js/list_view/new.html.erb +7 -5
  38. data/lib/tasks/sync.rake +10 -0
  39. data/spec/factories/faalis_workflows.rb +7 -0
  40. data/spec/models/faalis/workflow_spec.rb +7 -0
  41. metadata +36 -4
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= Faalis::Engine.site_title %></title>
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <%= stylesheet_link_tag Faalis::I18n.direction(I18n.locale) + "/application", media: "all" %>
7
+ <%= javascript_include_tag :modernizr %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ <!-- Footer -->
15
+
16
+ <hr/>
17
+ <footer class="plain">
18
+ <div class="row">
19
+ <div class="large-6 columns">
20
+ <p>&copy; Copyright no one at all. Go to town.</p>
21
+ </div>
22
+ <div class="large-6 columns">
23
+ <ul class="inline-list right">
24
+ <li><a href="#">Link 1</a></li>
25
+ <li><a href="#">Link 2</a></li>
26
+ <li><a href="#">Link 3</a></li>
27
+ <li><a href="#">Link 4</a></li>
28
+ </ul>
29
+ </div>
30
+ </div>
31
+ </footer>
32
+ </div>
33
+ </div>
34
+
35
+ <%= javascript_include_tag "faalis/application" %>
36
+ </body>
37
+ </html>
@@ -0,0 +1,7 @@
1
+ module Faalis
2
+ class AdministrationWorkflow < Faalis::Workflows::Base
3
+
4
+ title _("Administration Workflow")
5
+ icon "fa fa-user"
6
+ end
7
+ end
data/config/routes.rb CHANGED
@@ -1,48 +1,50 @@
1
1
  Faalis::Engine.routes.draw do
2
- get "templates/*path" => "dashboard#jstemplate"
2
+ get 'templates/*path' => 'dashboard#jstemplate'
3
3
 
4
4
  # Authentications
5
5
  devise_config = {
6
- :class_name => "Faalis::User",
6
+ :class_name => 'Faalis::User',
7
7
  :module => :devise
8
8
  }
9
9
 
10
10
  # Add omniauth callback if there was any provider
11
11
  unless Devise.omniauth_providers.empty?
12
12
  devise_config[:controllers] = {
13
- :omniauth_callbacks => "faalis/omniauth/callbacks",
13
+ :omniauth_callbacks => 'faalis/omniauth/callbacks',
14
14
  }
15
15
  end
16
16
 
17
17
  devise_for :users, devise_config
18
18
 
19
19
 
20
- scope "(:locale)", :locale => Regexp.new(::I18n.available_locales.join("|")) do
20
+ scope '(:locale)', :locale => Regexp.new(::I18n.available_locales.join('|')) do
21
21
  scope Faalis::Engine.dashboard_namespace.to_sym do
22
- get "" => "dashboard#index", :as => "dashboard"
23
- get "modules" => "dashboard#modules"
22
+ get '' => 'dashboard#index', :as => 'dashboard'
23
+ get 'modules' => 'dashboard#modules'
24
24
  end
25
25
 
26
26
 
27
27
  # Root URL
28
- root :to => "home#index"
28
+ root :to => 'home#index'
29
29
  end
30
30
 
31
31
 
32
32
  namespace :api, :defaults => {:format => :json} do
33
33
  namespace :v1 do
34
- get "permissions", :to => "permissions#index"
35
- get "permissions/user", :to => "permissions#user_permissions"
34
+ get 'permissions', :to => 'permissions#index'
35
+ get 'permissions/user', :to => 'permissions#user_permissions'
36
36
  resources :groups, :except => [:new]
37
37
  resources :users, :except => [:new]
38
38
  resource :profile, :except => [:new, :destroy]
39
- get "logs" => "logs#index"
39
+
40
+ get 'logs' => 'logs#index'
41
+ get 'workflows' => 'workflows#index'
40
42
 
41
43
  resources :conversations, only: [:index, :show, :create, :destroy] do
42
44
  collection do
43
- get ":box/box" => "conversations#index"
44
- post "trash" => "conversations#trash"
45
- post "untrash" => "conversations#untrash"
45
+ get ':box/box' => 'conversations#index'
46
+ post 'trash' => 'conversations#trash'
47
+ post 'untrash' => 'conversations#untrash'
46
48
  end
47
49
  member do
48
50
  post :reply
@@ -0,0 +1,9 @@
1
+ class CreateFaalisWorkflows < ActiveRecord::Migration
2
+ def change
3
+ create_table :faalis_workflows do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
data/db/seeds.rb CHANGED
@@ -2,16 +2,20 @@
2
2
 
3
3
  ModelDiscovery::Engine.load_seed
4
4
 
5
- Faalis::Group.create({:name => "Admin"})
6
- Faalis::Group.create({:name => "Guest", :id => 2})
7
-
8
- Faalis::User.create({
9
- :email => "admin@example.com",
10
- :group_id => 1,
11
- :password => "123123123",
12
- :password_confirmation => "123123123"})
13
-
14
- Faalis::User.create({:email => "user@example.com",
15
- :group_id => 999,
16
- :password => "123123123",
17
- :password_confirmation => "123123123"})
5
+ Faalis::Workflows::Discovery.build_table_list
6
+
7
+ Faalis::Group.create({:name => 'Admin'})
8
+
9
+ Faalis::User.create({:email => 'admin@example.com',
10
+ :group_id => 1,
11
+ :password => '123123123',
12
+ :password_confirmation => '123123123'})
13
+
14
+
15
+ Faalis::Group.create({:name => 'Guest', :id => 2})
16
+
17
+
18
+ Faalis::User.create({:email => 'user@example.com',
19
+ :group_id => 2,
20
+ :password => '123123123',
21
+ :password_confirmation => '123123123'})
data/lib/faalis.rb CHANGED
@@ -17,17 +17,19 @@
17
17
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
18
  # -----------------------------------------------------------------------------
19
19
 
20
- require "devise"
20
+ require 'devise'
21
21
 
22
+ # Faalis Module
22
23
  module Faalis
23
24
  end
24
25
 
25
- require "faalis/engine"
26
- require "faalis/permissions"
27
- require "faalis/dashboard"
28
- require "faalis/omniauth"
29
- require "faalis/active_record"
30
- require "faalis/i18n"
31
- require "faalis/plugins"
32
- require "faalis/generators/concerns"
33
- require "faalis/generators"
26
+ require 'faalis/engine'
27
+ require 'faalis/permissions'
28
+ require 'faalis/dashboard'
29
+ require 'faalis/omniauth'
30
+ require 'faalis/active_record'
31
+ require 'faalis/i18n'
32
+ require 'faalis/plugins'
33
+ require 'faalis/generators/concerns'
34
+ require 'faalis/generators'
35
+ require 'faalis/workflows'
data/lib/faalis/engine.rb CHANGED
@@ -18,12 +18,12 @@
18
18
  # -----------------------------------------------------------------------------
19
19
  require 'fast_gettext'
20
20
  require 'modernizr-rails'
21
- require "compass-rails"
21
+ #require "compass-rails"
22
22
  #require 'zurb-foundation'
23
23
  require 'foundation-rails'
24
24
  require "font-awesome-rails"
25
- require "devise"
26
- require "warden"
25
+ #require "devise"
26
+ #require "warden"
27
27
  require "cancan"
28
28
  require "mailboxer"
29
29
  require "model_discovery"
@@ -93,11 +93,11 @@ module Faalis
93
93
 
94
94
  # Override devise layout
95
95
  config.to_prepare do
96
- Devise::SessionsController.layout "faalis/application"
97
- Devise::RegistrationsController.layout "faalis/application"
98
- Devise::ConfirmationsController.layout "faalis/application"
99
- Devise::UnlocksController.layout "faalis/application"
100
- Devise::PasswordsController.layout "faalis/application"
96
+ Devise::SessionsController.layout 'faalis/simple'
97
+ Devise::RegistrationsController.layout 'faalis/simple'
98
+ Devise::ConfirmationsController.layout 'faalis/application'
99
+ Devise::UnlocksController.layout 'faalis/application'
100
+ Devise::PasswordsController.layout 'faalis/application'
101
101
  end
102
102
  #Devise.omniauth_path_prefix = ["/en", "/fa"]
103
103
 
@@ -126,5 +126,6 @@ module Faalis
126
126
  mattr_accessor :dashboard_js_manifest
127
127
  @@dashboard_js_manifest = "controlpanel/application.js"
128
128
 
129
+ config.autoload_paths << "app/workflows"
129
130
  end
130
131
  end
@@ -1,13 +1,15 @@
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"
10
- require "faalis/generators/concerns/model"
11
- require "faalis/generators/concerns/json_input"
12
- require "faalis/generators/concerns/allow_query_on"
13
- require "faalis/generators/concerns/render"
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'
10
+ require 'faalis/generators/concerns/model'
11
+ require 'faalis/generators/concerns/json_input'
12
+ require 'faalis/generators/concerns/allow_query_on'
13
+ require 'faalis/generators/concerns/render'
14
+ require 'faalis/generators/concerns/where'
15
+ require 'faalis/generators/concerns/fieldset'
@@ -11,11 +11,8 @@ module Faalis
11
11
  end
12
12
 
13
13
  def no_bulk?
14
- if bulk_edit_fields.length > 0
15
- true
16
- else
17
- false
18
- end
14
+ return true unless bulk_edit_fields.empty?
15
+ false
19
16
  end
20
17
  end
21
18
  end
@@ -0,0 +1,48 @@
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
+ puts ">>>>>>>>>>>((((((((((((( #{fields.to_a}"
19
+ fields.to_a
20
+ end
21
+
22
+ # TODO: fix this method to allow usage on tabbed views too
23
+ # Return fields categorized by fieldsets. Only for
24
+ # views without tabs
25
+ def fieldsets
26
+ fieldsets = {resource.underscore.pluralize.humanize => fieldset_less_fields}
27
+ fields = fields_with_attribute('fieldset')
28
+ fields.each do |f|
29
+ if fieldsets.include? f['fieldset']
30
+ fieldsets[f['fieldset']] << f
31
+ else
32
+ fieldsets[f['fieldset']] = [f]
33
+ end
34
+ end
35
+
36
+ # Convert hashes to proper field structure to use in templates
37
+ fieldsets.each do |fieldset_name, fieldset_fields|
38
+ if fieldset_fields[0].is_a? Hash
39
+ fieldsets[fieldset_name] = fields(fieldset_fields)
40
+ end
41
+ end
42
+
43
+ fieldsets
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,4 @@
1
- require "faalis/generators/fields/relation"
2
-
1
+ require 'faalis/generators/fields/relation'
3
2
 
4
3
  module Faalis
5
4
  module Generators
@@ -32,29 +31,38 @@ module Faalis
32
31
  # **required**: Field will be non optional.
33
32
  module ResourceFields
34
33
 
35
-
36
34
  private
35
+
37
36
  # An array of fields like
38
37
  # [name, type]
39
- def fields
38
+ def fields(fields_source = resource_data['fields'])
40
39
  fields = []
41
- if have_fields?
42
- resource_data["fields"].each do |field|
43
- name = field["name"]
44
- type = field["type"]
45
- to = field["to"]
46
- options = field["options"] || {}
47
-
48
- if ["belongs_to", "has_many"].include? type
49
- type = Relation.new(type, to, options)
50
- end
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'] || {}
51
48
 
49
+ type = Relation.new(type, to, options) if relations.include? type
52
50
  fields << [name, type, to]
53
51
  end
54
52
  end
55
53
  fields
56
54
  end
57
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
+
58
66
  def fields_hash
59
67
  Hash[fields]
60
68
  end
@@ -66,76 +74,66 @@ module Faalis
66
74
  # Return an string to use as a function parameters each
67
75
  # field appears as symbol
68
76
  def fields_as_params(relations = false)
69
- result = ""
77
+ # FIXME: cyclomatic complexity is to high
78
+ result = ''
70
79
  field_num = 0
80
+
71
81
  fields.each do |name, type|
72
82
  if relations
73
- if ["belongs_to"].include? type
83
+ if ['belongs_to'].include? type
74
84
  result += " :#{name}_id"
75
85
  else
76
86
  result += " :#{name}"
77
87
  end
88
+
78
89
  field_num += 1
79
- if field_num < fields.length
80
- result += ","
81
- end
90
+ result += ',' if field_num < fields.length
82
91
 
83
92
  else
84
- unless ["belongs_to", "has_many"].include? type
93
+ unless ['belongs_to', 'has_many'].include? type
85
94
  result += " :#{name}"
86
95
  field_num += 1
87
- if field_num < fields.length
88
- result += ","
89
- end
96
+ result += ',' if field_num < fields.length
90
97
  end
91
98
  end
92
-
93
99
  end
94
100
 
95
101
  if result
96
102
  result = ",#{result}"
97
- if result[-1] == ","
98
- result = result[0..-2]
99
- end
103
+ result = result[0..-2] if result[-1] == ','
100
104
  end
101
105
 
102
106
  result
103
107
  end
104
108
 
105
109
  def raw_fields_data
106
- if have_fields?
107
- return resource_data["fields"]
108
- end
109
- []
110
+ resource_data['fields'] || []
110
111
  end
111
112
 
112
113
  def fields_with(attr, value)
113
114
  raw_fields_data.select do |f|
114
-
115
115
  if f.include? attr
116
-
117
- if f[attr] == value
118
-
119
- true
120
- else
121
- false
122
- end
116
+ f[attr] == value ? true : false
123
117
  else
124
118
  false
125
119
  end
120
+ end
121
+ end
126
122
 
123
+ def fields_with_attribute(attr)
124
+ field_list = raw_fields_data.select do |f|
125
+ f.include?(attr) ? true : false
127
126
  end
127
+ field_list
128
128
  end
129
129
 
130
130
  def no_filter?
131
- resource_data.include?("no_filter") && resource_data["no_filter"]
131
+ resource_data.include?('no_filter') && resource_data['no_filter']
132
132
  end
133
133
 
134
- def have_fields?
135
- if resource_data.include? "fields"
136
- unless resource_data["fields"].nil?
137
- return true
138
- end
134
+ def fields?
135
+ if resource_data.include? 'fields'
136
+ return true unless resource_data['fields'].nil?
139
137
  end
140
138
  false
141
139
  end