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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +7 -1
- data/app/assets/javascripts/faalis/dashboard/modules/fields/relation.js +50 -3
- data/app/assets/stylesheets/faalis/base.css.scss +16 -1
- data/app/assets/stylesheets/faalis/ltr/foundation_and_overrides.scss +4 -0
- data/app/assets/stylesheets/faalis/rtl/foundation_and_overrides.css.scss +1 -1
- data/app/assets/stylesheets/faalis/variables.css.scss +1 -1
- data/app/controllers/faalis/#api_controller.rb# +144 -0
- data/app/controllers/faalis/api/v1/#conversations_controller.rb# +120 -0
- data/app/controllers/faalis/api/v1/workflows_controller.rb +18 -0
- data/app/controllers/faalis/api_controller.rb +3 -3
- data/app/controllers/faalis/application_controller.rb +0 -1
- data/app/models/faalis/workflow.rb +4 -0
- data/app/views/angularjs_templates/auth/groups/new.html +47 -25
- data/app/views/angularjs_templates/fields/relation/relation.html +9 -2
- data/app/views/devise/sessions/new.html.erb +52 -88
- data/app/views/faalis/api/v1/workflows/index.json.jbuilder +5 -0
- data/app/views/faalis/home/index.html.erb +14 -11
- data/app/views/layouts/faalis/application.html.erb +21 -30
- data/app/views/layouts/faalis/simple.html.erb +37 -0
- data/app/workflows/faalis/administration_workflow.rb +7 -0
- data/config/routes.rb +15 -13
- data/db/migrate/20140413180202_create_faalis_workflows.rb +9 -0
- data/db/seeds.rb +17 -13
- data/lib/faalis.rb +12 -10
- data/lib/faalis/engine.rb +9 -8
- data/lib/faalis/generators/concerns.rb +15 -13
- data/lib/faalis/generators/concerns/bulk.rb +2 -5
- data/lib/faalis/generators/concerns/fieldset.rb +48 -0
- data/lib/faalis/generators/concerns/resource_fields.rb +43 -45
- data/lib/faalis/generators/concerns/where.rb +46 -0
- data/lib/faalis/generators/dashboard_scaffold.rb +6 -5
- data/lib/faalis/version.rb +1 -1
- data/lib/faalis/workflows.rb +7 -0
- data/lib/faalis/workflows/base.rb +69 -0
- data/lib/faalis/workflows/discovery.rb +42 -0
- data/lib/generators/faalis/templates/js/list_view/new.html.erb +7 -5
- data/lib/tasks/sync.rake +10 -0
- data/spec/factories/faalis_workflows.rb +7 -0
- data/spec/models/faalis/workflow_spec.rb +7 -0
- metadata +36 -4
@@ -0,0 +1,46 @@
|
|
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
|
+
# 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
|
+
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -19,19 +19,20 @@ module Faalis
|
|
19
19
|
include Faalis::Generators::Concerns::Model
|
20
20
|
include Faalis::Generators::Concerns::AllowQueryOn
|
21
21
|
include Faalis::Generators::Concerns::Render
|
22
|
-
|
22
|
+
include Faalis::Generators::Concerns::Where
|
23
|
+
include Faalis::Generators::Concerns::Fieldset
|
23
24
|
|
24
25
|
# Do not install specs
|
25
|
-
class_option :without_specs, :type => :boolean, :default => false, :desc =>
|
26
|
+
class_option :without_specs, :type => :boolean, :default => false, :desc => 'Do not install specs'
|
26
27
|
|
27
28
|
# Generate only spec files
|
28
|
-
class_option :only_specs, :type => :boolean, :default => false, :desc =>
|
29
|
+
class_option :only_specs, :type => :boolean, :default => false, :desc => 'Generate only spec files'
|
29
30
|
|
30
31
|
# Generate only controller
|
31
|
-
class_option :only_controller, :type => :boolean, :default => false, :desc =>
|
32
|
+
class_option :only_controller, :type => :boolean, :default => false, :desc => 'Generate only controller'
|
32
33
|
|
33
34
|
# Don't show a filter box
|
34
|
-
class_option :no_filter, :type => :boolean, :default => false, :desc =>
|
35
|
+
class_option :no_filter, :type => :boolean, :default => false, :desc => 'Don\'t view a filter box'
|
35
36
|
|
36
37
|
|
37
38
|
end
|
data/lib/faalis/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
module Faalis
|
2
|
+
module Workflows
|
3
|
+
|
4
|
+
# Base class for all the workflows in a `Faalis application`
|
5
|
+
class Base
|
6
|
+
|
7
|
+
attr_reader :id
|
8
|
+
|
9
|
+
def initialize(model_instance)
|
10
|
+
@id = model_instance.id
|
11
|
+
end
|
12
|
+
|
13
|
+
# class method to set the title of current workflow
|
14
|
+
def self.title(name)
|
15
|
+
instance_variable_set(:@title, name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
@title || self.class.to_s.underscore
|
20
|
+
end
|
21
|
+
|
22
|
+
# Set the current workflow icon if any
|
23
|
+
def self.icon(icon)
|
24
|
+
instance_variable_set(:@icon, icon)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Getter for workflow icon
|
28
|
+
def icon
|
29
|
+
return @icon if defined? :@icon
|
30
|
+
nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def icon?
|
34
|
+
return true if defined? :@icon
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# Set the current workflow image if any
|
40
|
+
def self.image(image)
|
41
|
+
instance_variable_set(:@image, image)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Getter for the current workflow image
|
45
|
+
def image
|
46
|
+
return @image if defined? :@image
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def image?
|
51
|
+
return true if defined? :@image
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
# Use this class method to add any permission that is neeeded
|
56
|
+
# for this workflow to work
|
57
|
+
def self.permissions(*args)
|
58
|
+
instance_variable_set(:@permissions, args)
|
59
|
+
end
|
60
|
+
|
61
|
+
# permissions getter
|
62
|
+
def permissions
|
63
|
+
return @permissions if defined? @permissions
|
64
|
+
[]
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Faalis
|
2
|
+
module Workflows
|
3
|
+
# Discover all the workflows in current application in addition to
|
4
|
+
# gem files and add them to database for future reference.
|
5
|
+
class Discovery
|
6
|
+
# A class method to use in `seed.rb` to create all workflows in
|
7
|
+
# database
|
8
|
+
def self.build_table_list
|
9
|
+
# Get all gem by requiring them
|
10
|
+
all_gems = Bundler.require
|
11
|
+
|
12
|
+
# Discover all model files in gem files and load them
|
13
|
+
all_gems.each do |gem|
|
14
|
+
if gem.groups.include?(Rails.env.to_sym) || \
|
15
|
+
gem.groups.include?(:default)
|
16
|
+
|
17
|
+
puts "Gem name: #{gem.name}"
|
18
|
+
spec = Gem::Specification.find_by_name gem.name
|
19
|
+
discover spec.gem_dir
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Discover models in current rails app and load them
|
24
|
+
discover Rails.root
|
25
|
+
|
26
|
+
# Create a content type entry for all Models
|
27
|
+
Faalis::Workflows::Base.subclasses.each do |workflow|
|
28
|
+
Faalis::Workflow.find_or_create_by(name: workflow.to_s)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def self.discover(path)
|
35
|
+
Dir["#{path}/app/workflows/**/*.rb"].each do |workflow_file|
|
36
|
+
puts "File matched: #{workflow_file}"
|
37
|
+
load workflow_file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -7,15 +7,16 @@
|
|
7
7
|
<% unless any_tabs? %>
|
8
8
|
<form novalidate name="form">
|
9
9
|
<div class="newform">
|
10
|
-
|
10
|
+
<% fieldsets.each do |fieldset_name, fields| %>
|
11
11
|
|
12
|
-
|
13
|
-
<legend ng-if="editing"><span translate
|
12
|
+
<fieldset class="form">
|
13
|
+
<legend ng-if="!editing"><span translate><%= fieldset_name %></span></legend>
|
14
|
+
<legend ng-if="editing"><span translate>Edit <%= fieldset_name %></span></legend>
|
14
15
|
|
15
16
|
<% first = true %><% fields.each do |field_name, field_type| %>
|
16
17
|
<% if first %><div class="row"><% end %>
|
17
18
|
<div class="small-4 columns <% if not first %>float-left small-offset-2<% end %>">
|
18
|
-
<label><% if required_fields.include? field_name %><i class="inline fa fa-asterisk"></i> <% end %><span translate><%= field_name.to_s.humanize.capitalize %></span> :</label><% case field_type
|
19
|
+
<label><% if required_fields.include? field_name %><i class="inline fa fa-asterisk"></i> <% end %><span translate><%= attrs(field_name, 'title') || field_name.to_s.humanize.capitalize %></span> :</label><% case field_type
|
19
20
|
when "belongs_to", "has_many", "in" %>
|
20
21
|
<relation-field select2-options="select2options" <% if required_fields.include? field_name %>required="true"<% end %> title-field="'name'" model="<%= field_name %>" field-data="<%= field_name %>_data">
|
21
22
|
</relation-field>
|
@@ -26,6 +27,7 @@
|
|
26
27
|
</div>
|
27
28
|
<% if not first %></div><% end %><% first = !first %><% end %>
|
28
29
|
</fieldset>
|
30
|
+
<% end %>
|
29
31
|
</form>
|
30
32
|
|
31
33
|
<% else %><form novalidate name="form"><% tab_count = 1 %><% tabs.each do |name, field_names| %>
|
@@ -37,7 +39,7 @@
|
|
37
39
|
|
38
40
|
<% if first %><div class="row"><% end %>
|
39
41
|
<div class="small-4 columns <% if not first %>float-left small-offset-2<% end %>">
|
40
|
-
<label><% if required_fields.include? field_name %><i class="inline fa fa-asterisk"></i> <% end %><span translate><%= field_name.to_s.humanize.capitalize %></span> :</label><% case field_type
|
42
|
+
<label><% if required_fields.include? field_name %><i class="inline fa fa-asterisk"></i> <% end %><span translate><%= attrs(field_name, 'title') || field_name.to_s.humanize.capitalize %></span> :</label><% case field_type
|
41
43
|
when "belongs_to", "has_many", "in" %>
|
42
44
|
<relation-field select2-options="select2options" <% if required_fields.include? field_name %>required="true"<% end %> title-field="'name'" model="<%= field_name %>" field-data="<%= field_name %>_data">
|
43
45
|
</relation-field>
|
data/lib/tasks/sync.rake
ADDED
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.25.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-04-
|
12
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -113,14 +113,14 @@ dependencies:
|
|
113
113
|
name: sass-rails
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - "
|
116
|
+
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 4.0.0
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 4.0.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
@@ -137,6 +137,20 @@ dependencies:
|
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: sprockets
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 2.11.0
|
147
|
+
type: :runtime
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 2.11.0
|
140
154
|
- !ruby/object:Gem::Dependency
|
141
155
|
name: foundation-rails
|
142
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -459,12 +473,15 @@ files:
|
|
459
473
|
- app/assets/stylesheets/faalis/users.css
|
460
474
|
- app/assets/stylesheets/faalis/variables.css.scss
|
461
475
|
- app/controllers/faalis/#1.sh#
|
476
|
+
- app/controllers/faalis/#api_controller.rb#
|
477
|
+
- app/controllers/faalis/api/v1/#conversations_controller.rb#
|
462
478
|
- app/controllers/faalis/api/v1/conversations_controller.rb
|
463
479
|
- app/controllers/faalis/api/v1/groups_controller.rb
|
464
480
|
- app/controllers/faalis/api/v1/logs_controller.rb
|
465
481
|
- app/controllers/faalis/api/v1/permissions_controller.rb
|
466
482
|
- app/controllers/faalis/api/v1/profiles_controller.rb
|
467
483
|
- app/controllers/faalis/api/v1/users_controller.rb
|
484
|
+
- app/controllers/faalis/api/v1/workflows_controller.rb
|
468
485
|
- app/controllers/faalis/api_controller.rb
|
469
486
|
- app/controllers/faalis/application_controller.rb
|
470
487
|
- app/controllers/faalis/dashboard_controller.rb
|
@@ -481,6 +498,7 @@ files:
|
|
481
498
|
- app/models/faalis/permission.rb
|
482
499
|
- app/models/faalis/permissions/auth.rb
|
483
500
|
- app/models/faalis/user.rb
|
501
|
+
- app/models/faalis/workflow.rb
|
484
502
|
- app/views/angularjs_templates/auth/groups/details.html
|
485
503
|
- app/views/angularjs_templates/auth/groups/index.html
|
486
504
|
- app/views/angularjs_templates/auth/groups/new.html
|
@@ -551,12 +569,15 @@ files:
|
|
551
569
|
- app/views/faalis/api/v1/users/show.html.erb
|
552
570
|
- app/views/faalis/api/v1/users/show.json.jbuilder
|
553
571
|
- app/views/faalis/api/v1/users/update.json.jbuilder
|
572
|
+
- app/views/faalis/api/v1/workflows/index.json.jbuilder
|
554
573
|
- app/views/faalis/dashboard/index.html.erb
|
555
574
|
- app/views/faalis/dashboard/login_required_page.html.erb
|
556
575
|
- app/views/faalis/home/index.html.erb
|
557
576
|
- app/views/faalis/relations/_belongs_to.json.jbuilder
|
558
577
|
- app/views/layouts/faalis/application.html.erb
|
559
578
|
- app/views/layouts/faalis/dashboard.html.erb
|
579
|
+
- app/views/layouts/faalis/simple.html.erb
|
580
|
+
- app/workflows/faalis/administration_workflow.rb
|
560
581
|
- config/initializers/devise.rb
|
561
582
|
- config/locales/devise.en.yml
|
562
583
|
- config/locales/devise.fa.yml
|
@@ -569,6 +590,7 @@ files:
|
|
569
590
|
- db/migrate/20131020124701_create_faalis_groups.rb
|
570
591
|
- db/migrate/20131021170923_create_faalis_permissions.rb
|
571
592
|
- db/migrate/20131123120422_add_permissions_groups_table.rb
|
593
|
+
- db/migrate/20140413180202_create_faalis_workflows.rb
|
572
594
|
- db/seeds.rb
|
573
595
|
- lib/faalis.rb
|
574
596
|
- lib/faalis/active_record.rb
|
@@ -594,6 +616,7 @@ files:
|
|
594
616
|
- lib/faalis/generators/concerns/angular.rb
|
595
617
|
- lib/faalis/generators/concerns/bulk.rb
|
596
618
|
- lib/faalis/generators/concerns/dependency.rb
|
619
|
+
- lib/faalis/generators/concerns/fieldset.rb
|
597
620
|
- lib/faalis/generators/concerns/json_input.rb
|
598
621
|
- lib/faalis/generators/concerns/menu.rb
|
599
622
|
- lib/faalis/generators/concerns/model.rb
|
@@ -603,6 +626,7 @@ files:
|
|
603
626
|
- lib/faalis/generators/concerns/resource_fields.rb
|
604
627
|
- lib/faalis/generators/concerns/resource_name.rb
|
605
628
|
- lib/faalis/generators/concerns/tabs.rb
|
629
|
+
- lib/faalis/generators/concerns/where.rb
|
606
630
|
- lib/faalis/generators/dashboard_scaffold.rb
|
607
631
|
- lib/faalis/generators/fields/relation.rb
|
608
632
|
- lib/faalis/i18n.rb
|
@@ -612,6 +636,9 @@ files:
|
|
612
636
|
- lib/faalis/permissions.rb
|
613
637
|
- lib/faalis/plugins.rb
|
614
638
|
- lib/faalis/version.rb
|
639
|
+
- lib/faalis/workflows.rb
|
640
|
+
- lib/faalis/workflows/base.rb
|
641
|
+
- lib/faalis/workflows/discovery.rb
|
615
642
|
- lib/faalis_plugin.rb
|
616
643
|
- lib/generators/faalis/USAGE
|
617
644
|
- lib/generators/faalis/angularjs_resource_generator.rb
|
@@ -665,6 +692,7 @@ files:
|
|
665
692
|
- lib/generators/faalis/views_generator.rb
|
666
693
|
- lib/tasks/faalis_tasks.rake
|
667
694
|
- lib/tasks/grunt/Gruntfile.js
|
695
|
+
- lib/tasks/sync.rake
|
668
696
|
- spec/dummy/README.rdoc
|
669
697
|
- spec/dummy/Rakefile
|
670
698
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -700,6 +728,8 @@ files:
|
|
700
728
|
- spec/dummy/public/favicon.ico
|
701
729
|
- spec/dummy/tmp/ember-rails/ember-data.js
|
702
730
|
- spec/dummy/tmp/ember-rails/ember.js
|
731
|
+
- spec/factories/faalis_workflows.rb
|
732
|
+
- spec/models/faalis/workflow_spec.rb
|
703
733
|
- spec/spec_helper.rb
|
704
734
|
homepage: https://github.com/Yellowen/Faalis
|
705
735
|
licenses:
|
@@ -728,6 +758,8 @@ summary: Faalis is a ruby on rails engine which provides a very basic web applic
|
|
728
758
|
to use with other ruby on rails applications.
|
729
759
|
test_files:
|
730
760
|
- spec/spec_helper.rb
|
761
|
+
- spec/models/faalis/workflow_spec.rb
|
762
|
+
- spec/factories/faalis_workflows.rb
|
731
763
|
- spec/dummy/tmp/ember-rails/ember.js
|
732
764
|
- spec/dummy/tmp/ember-rails/ember-data.js
|
733
765
|
- spec/dummy/log/development.log
|