faalis 0.26.3 → 1.0.0.alpha0
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/README.md +35 -6
- data/Rakefile +2 -25
- data/app/assets/javascripts/faalis/angular-manifest.js +8 -2
- data/app/assets/javascripts/faalis/application.js +0 -3
- data/app/assets/javascripts/faalis/dashboard/application.js.erb +0 -5
- data/app/assets/javascripts/faalis/dashboard/functions.js.erb +9 -0
- data/app/assets/javascripts/faalis/dashboard/init.js +1 -1
- data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +0 -6
- data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +1 -1
- data/app/assets/javascripts/faalis/dashboard/modules/fields/image.js +115 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/tag.js +76 -0
- data/app/assets/javascripts/faalis/dashboard/variables.js.erb +1 -1
- data/app/assets/locale/templates.pot +282 -0
- data/app/assets/stylesheets/faalis/dashboard/dashboard.css.scss +4 -0
- data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -4
- data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +4 -4
- data/app/assets/stylesheets/faalis/dashboard/rtl/base.css.scss.erb +2 -2
- data/app/controllers/faalis/api/v1/permissions_controller.rb +8 -39
- data/app/controllers/faalis/api/v1/users_controller.rb +7 -7
- data/app/models/ability.rb +4 -6
- data/app/models/faalis/concerns/assignment.rb +2 -2
- data/app/models/faalis/group.rb +18 -4
- data/app/models/faalis/permission.rb +11 -2
- data/app/models/faalis/permissions/auth.rb +3 -2
- data/app/models/faalis/user.rb +27 -73
- data/app/models/faalis/user/auth_definitions.rb +94 -0
- data/app/models/faalis/user/mongoid_fields.rb +76 -0
- data/app/models/faalis/user/permission.rb +21 -0
- data/app/views/angularjs_templates/auth/groups/new.html +0 -20
- data/app/views/angularjs_templates/fields/image/image.html +1 -0
- data/app/views/angularjs_templates/fields/relation/relation.html +3 -1
- data/app/views/angularjs_templates/fields/tag/tag.html +1 -0
- data/app/views/angularjs_templates/nav.html.erb +0 -1
- data/app/views/faalis/api/v1/users/index.json.jbuilder +1 -1
- data/app/views/layouts/faalis/application.html.erb +2 -0
- data/app/views/layouts/faalis/dashboard.html.erb +1 -0
- data/app/views/layouts/faalis/simple.html.erb +1 -0
- data/config/initializers/devise.rb +0 -7
- data/db/migrate/20131013091000_devise_create_faalis_users.rb +3 -2
- data/db/migrate/20140613120923_add_users_groups_table.rb +8 -0
- data/db/migrate/20140617124019_faalis_groups_users.rb +4 -0
- data/db/seeds.rb +39 -11
- data/lib/faalis.rb +5 -4
- data/lib/faalis/concerns.rb +7 -0
- data/lib/faalis/concerns/authorizable.rb +76 -0
- data/lib/faalis/discovery.rb +8 -0
- data/lib/faalis/discovery/permissions.rb +51 -0
- data/lib/faalis/engine.rb +19 -5
- data/lib/faalis/extensions.rb +18 -0
- data/lib/faalis/extensions/base.rb +29 -0
- data/lib/faalis/fake_assets.rb +7 -0
- data/lib/faalis/generators/dashboard_scaffold.rb +23 -5
- data/lib/faalis/omniauth.rb +3 -0
- data/lib/faalis/orm.rb +29 -0
- data/lib/faalis/{active_record.rb → patches/models.rb} +1 -3
- data/lib/faalis/version.rb +1 -1
- data/lib/generators/faalis/install_generator.rb +7 -3
- data/lib/{faalis/plugins.rb → generators/faalis/js/install_i18n_generator.rb} +20 -17
- data/lib/generators/faalis/scaffold_generator.rb +139 -0
- data/lib/generators/faalis/templates/application.js +1 -1
- data/lib/generators/faalis/templates/i18n/Gruntfile.js.erb +30 -0
- data/lib/generators/faalis/templates/i18n/README +13 -0
- data/lib/generators/faalis/templates/i18n/fa.js +3 -0
- data/lib/generators/faalis/templates/js/list_view/README +1 -1
- data/lib/tasks/faalis_tasks.rake +26 -20
- data/lib/tasks/grunt/Gruntfile.js +7 -2
- data/spec/dummy/config/initializers/faalis.rb +40 -0
- metadata +134 -44
- data/app/assets/javascripts/faalis/dashboard/lib/angular-gettext.js +0 -202
- data/app/assets/javascripts/faalis/dashboard/lib/ng-grid.js +0 -3260
- data/app/assets/javascripts/faalis/dashboard/lib/ng-quick-date.js +0 -297
- data/app/assets/javascripts/faalis/dashboard/lib/restangular.js +0 -1066
- data/app/assets/javascripts/faalis/dashboard/lib/select2.js +0 -3255
- data/app/assets/javascripts/faalis/dashboard/lib/ui.select2.js +0 -217
- data/app/assets/stylesheets/faalis/dashboard/ng-grid.css.scss +0 -442
- data/app/assets/stylesheets/faalis/dashboard/ng-quick-date-default-theme.css.scss +0 -20
- data/app/assets/stylesheets/faalis/dashboard/ng-quick-date.css.scss +0 -19
- data/app/assets/stylesheets/faalis/dashboard/select2.css.scss.erb +0 -618
- data/app/controllers/faalis/api/v1/#conversations_controller.rb# +0 -120
- data/app/models/faalis/workflow.rb +0 -4
- data/db/migrate/20140413180202_create_faalis_workflows.rb +0 -9
- data/lib/faalis/permissions.rb +0 -72
- data/lib/faalis/workflows.rb +0 -7
- data/lib/faalis/workflows/base.rb +0 -70
- data/lib/faalis/workflows/discovery.rb +0 -42
- data/lib/generators/faalis/js_scaffold_generator.rb +0 -113
data/lib/faalis/engine.rb
CHANGED
|
@@ -21,7 +21,6 @@ require 'modernizr-rails'
|
|
|
21
21
|
require 'foundation-rails'
|
|
22
22
|
require 'font-awesome-rails'
|
|
23
23
|
require 'cancan'
|
|
24
|
-
require 'mailboxer'
|
|
25
24
|
require 'model_discovery'
|
|
26
25
|
require 'angularjs-rails'
|
|
27
26
|
require 'lodash-rails'
|
|
@@ -31,8 +30,9 @@ module Faalis
|
|
|
31
30
|
class Engine < ::Rails::Engine
|
|
32
31
|
|
|
33
32
|
isolate_namespace Faalis
|
|
34
|
-
engine_name
|
|
33
|
+
engine_name 'faalis'
|
|
35
34
|
|
|
35
|
+
# Map `api` to `API` in Rails autoload
|
|
36
36
|
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
37
37
|
inflect.acronym 'API'
|
|
38
38
|
end
|
|
@@ -64,14 +64,29 @@ module Faalis
|
|
|
64
64
|
mattr_accessor :dashboard_namespace
|
|
65
65
|
@@dashboard_namespace = :dashboard
|
|
66
66
|
|
|
67
|
+
# TODO: Use application level locales default
|
|
67
68
|
# locales
|
|
68
69
|
mattr_accessor :locales
|
|
69
70
|
@@locales = ['en', 'fa']
|
|
70
71
|
|
|
72
|
+
# ==> ORM configuration
|
|
73
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
|
74
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
|
75
|
+
# available as additional gems.
|
|
76
|
+
# ORM name to use. either 'active_record' or 'mongoid'
|
|
77
|
+
mattr_accessor :orm
|
|
78
|
+
|
|
79
|
+
def self.orm=(orm_name)
|
|
80
|
+
@@orm = orm_name
|
|
81
|
+
require "devise/orm/#{orm_name}"
|
|
82
|
+
#require 'mailboxer'
|
|
83
|
+
end
|
|
84
|
+
|
|
71
85
|
def self.setup
|
|
72
86
|
yield self
|
|
73
87
|
end
|
|
74
88
|
|
|
89
|
+
# I18n Configuration
|
|
75
90
|
I18n.enforce_available_locales = true
|
|
76
91
|
I18n.locale = :en
|
|
77
92
|
# Fast Gettext Configuration
|
|
@@ -100,7 +115,7 @@ module Faalis
|
|
|
100
115
|
end
|
|
101
116
|
#Devise.omniauth_path_prefix = ["/en", "/fa"]
|
|
102
117
|
|
|
103
|
-
|
|
118
|
+
# TODO: Write a complete doc about dashboard_modules
|
|
104
119
|
# Dashboard configurations
|
|
105
120
|
mattr_accessor :dashboard_modules
|
|
106
121
|
|
|
@@ -118,13 +133,12 @@ module Faalis
|
|
|
118
133
|
|
|
119
134
|
|
|
120
135
|
def self.dashboard_modules=(value)
|
|
121
|
-
|
|
136
|
+
@@dashboard_modules.merge!(value)
|
|
122
137
|
end
|
|
123
138
|
|
|
124
139
|
# Dashboard default javascript manifest
|
|
125
140
|
mattr_accessor :dashboard_js_manifest
|
|
126
141
|
@@dashboard_js_manifest = "controlpanel/application.js"
|
|
127
142
|
|
|
128
|
-
config.autoload_paths << "app/workflows"
|
|
129
143
|
end
|
|
130
144
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
# Extension module of Faalis which contains all the related
|
|
3
|
+
# stuff to a Faalis extension.
|
|
4
|
+
module Extension
|
|
5
|
+
|
|
6
|
+
@@extensions = {}
|
|
7
|
+
|
|
8
|
+
def self.extensions
|
|
9
|
+
@@extensions
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.extensions=(value)
|
|
13
|
+
@@extensions = value
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
require 'faalis/extensions/base'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
module Extension
|
|
3
|
+
# This module provide basic functionallity of a Faalis extension
|
|
4
|
+
# to a rails engine.
|
|
5
|
+
# It should be included in engine of all the Faalis extionsions
|
|
6
|
+
module Base
|
|
7
|
+
|
|
8
|
+
def included(base)
|
|
9
|
+
extend ClassMethods
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class ClassMethods
|
|
13
|
+
def register_extension(name, klass)
|
|
14
|
+
# TODO: Replace this mechanism with more elegant one
|
|
15
|
+
# For example use [] method or someting
|
|
16
|
+
Faalis::Extension.extensions[name] = klass
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# This method tells faalis that this extension will override
|
|
20
|
+
# the generators templates of faalis from `template_path` location
|
|
21
|
+
def override_generator_templates(template_path)
|
|
22
|
+
send(:define_singleton_method, 'generator_templates_path') do
|
|
23
|
+
template_path
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -5,7 +5,7 @@ module Faalis
|
|
|
5
5
|
# easier. But you can drive your own generator normally of caurse
|
|
6
6
|
class DashboardScaffold < Rails::Generators::Base
|
|
7
7
|
|
|
8
|
-
include ActionView::Helpers::TextHelper
|
|
8
|
+
include ::ActionView::Helpers::TextHelper
|
|
9
9
|
include Faalis::Generators::Concerns::JsonInput
|
|
10
10
|
include Faalis::Generators::Concerns::ResourceName
|
|
11
11
|
include Faalis::Generators::Concerns::ResourceFields
|
|
@@ -23,16 +23,34 @@ module Faalis
|
|
|
23
23
|
include Faalis::Generators::Concerns::Fieldset
|
|
24
24
|
|
|
25
25
|
# Do not install specs
|
|
26
|
-
class_option :without_specs, :
|
|
26
|
+
class_option :without_specs, type: :boolean, default: false, desc: 'Do not install specs'
|
|
27
27
|
|
|
28
28
|
# Generate only spec files
|
|
29
|
-
class_option :only_specs, :
|
|
29
|
+
class_option :only_specs, type: :boolean, default: false, desc: 'Generate only spec files'
|
|
30
30
|
|
|
31
31
|
# Generate only controller
|
|
32
|
-
class_option :only_controller, :
|
|
32
|
+
class_option :only_controller, type: :boolean, default: false, desc: 'Generate only controller'
|
|
33
33
|
|
|
34
34
|
# Don't show a filter box
|
|
35
|
-
class_option :no_filter, :
|
|
35
|
+
class_option :no_filter, type: :boolean, default: false, desc: 'Don\'t view a filter box'
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# Overrided `source_paths` method. With this approach extensions
|
|
41
|
+
# can override generators templates. Cool ha ?
|
|
42
|
+
def source_paths
|
|
43
|
+
@source_paths = self.class.source_paths_for_search
|
|
44
|
+
|
|
45
|
+
paths = []
|
|
46
|
+
Faalis::Extension.extensions.each do |name, klass|
|
|
47
|
+
if klass.respond_to? :generator_templates_path.to_sym
|
|
48
|
+
paths << klass.generator_templates_path
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
paths += @source_paths
|
|
52
|
+
@source_paths = paths
|
|
53
|
+
end
|
|
36
54
|
|
|
37
55
|
|
|
38
56
|
end
|
data/lib/faalis/omniauth.rb
CHANGED
data/lib/faalis/orm.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Faalis
|
|
2
|
+
# A very simple class which provide functionalities to work with
|
|
3
|
+
# current orm
|
|
4
|
+
class ORM
|
|
5
|
+
|
|
6
|
+
def self.active_record?
|
|
7
|
+
current == 'active_record'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.mongoid?
|
|
11
|
+
current == 'mongoid'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# current orm
|
|
15
|
+
def self.current
|
|
16
|
+
Faalis::Engine.orm.to_s
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# This class method returns the base class of current ORM
|
|
20
|
+
# It will be used in models to specify which class to inherit
|
|
21
|
+
# from, based on current ORM
|
|
22
|
+
def self.proper_base_class
|
|
23
|
+
return ActiveRecord::Base if active_record?
|
|
24
|
+
return Object if mongoid?
|
|
25
|
+
Faalis::Engine.orm = 'active_record'
|
|
26
|
+
ActiveRecord::Base
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/faalis/version.rb
CHANGED
|
@@ -26,9 +26,9 @@ module Faalis
|
|
|
26
26
|
desc 'Copy all the necessary files to use Faalis'
|
|
27
27
|
class_option :orm
|
|
28
28
|
|
|
29
|
-
def install_mailboxer
|
|
30
|
-
|
|
31
|
-
end
|
|
29
|
+
#def install_mailboxer
|
|
30
|
+
# invoke 'mailboxer:install'
|
|
31
|
+
#end
|
|
32
32
|
|
|
33
33
|
def install_model_discovery
|
|
34
34
|
rake 'model_discovery_engine:install:migrations'
|
|
@@ -48,6 +48,10 @@ module Faalis
|
|
|
48
48
|
empty_directory "#{angularjs_app_path}modules"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def grunt_file
|
|
52
|
+
template 'i18n/Gruntfile.js.erb', 'lib/tasks/grunt/Gruntfile.js'
|
|
53
|
+
end
|
|
54
|
+
|
|
51
55
|
def copy_scss_manifest
|
|
52
56
|
directory 'stylesheets', 'app/assets/stylesheets'
|
|
53
57
|
end
|
|
@@ -17,28 +17,31 @@
|
|
|
17
17
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
18
|
# -----------------------------------------------------------------------------
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
module Faalis
|
|
22
|
-
|
|
21
|
+
module Generators
|
|
22
|
+
module Js
|
|
23
|
+
# Generator responsible for `install_i18n` generator
|
|
24
|
+
class InstallI18nGenerator < Rails::Generators::Base
|
|
25
|
+
source_root File.expand_path('../../templates/', __FILE__)
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
desc 'Copy all the necessary files to use Faalis client side i18n'
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
end
|
|
31
|
-
end
|
|
29
|
+
def copy_init_files
|
|
30
|
+
template 'i18n/Gruntfile.js.erb', 'lib/tasks/grunt/Gruntfile.js'
|
|
31
|
+
copy_file 'i18n/fa.js', 'app/assets/javascripts/locale/'
|
|
32
|
+
end
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
34
|
+
def show_readme
|
|
35
|
+
readme 'i18n/README' if behavior == :invoke
|
|
36
|
+
end
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
def self.plugins
|
|
40
|
-
@@plugins
|
|
41
|
-
end
|
|
38
|
+
private
|
|
42
39
|
|
|
40
|
+
def angularjs_app_path
|
|
41
|
+
path = Faalis::Engine.dashboard_js_manifest.split('/')[0..-2].join('/')
|
|
42
|
+
"app/assets/javascripts/#{path}/"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
43
46
|
end
|
|
44
47
|
end
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# Faalis - Basic website skel engine
|
|
3
|
+
# Copyright (C) 2012-2014 Yellowen
|
|
4
|
+
#
|
|
5
|
+
# This program is free software; you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License along
|
|
16
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
# -----------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
module Faalis
|
|
21
|
+
module Generators
|
|
22
|
+
# Generator Full Faalis scaffold with dashboard
|
|
23
|
+
class ScaffoldGenerator < Rails::Generators::Base
|
|
24
|
+
include Faalis::Generators::Concerns::RequireFields
|
|
25
|
+
include Faalis::Generators::Concerns::Parent
|
|
26
|
+
include Faalis::Generators::Concerns::JsonInput
|
|
27
|
+
include Faalis::Generators::Concerns::ResourceName
|
|
28
|
+
include Faalis::Generators::Concerns::ResourceFields
|
|
29
|
+
|
|
30
|
+
desc 'Create full faalis full scaffold'
|
|
31
|
+
# FIXME: These options should have :type and :desc or even default
|
|
32
|
+
# value
|
|
33
|
+
class_option :no_model
|
|
34
|
+
class_option :no_route
|
|
35
|
+
class_option :no_controller
|
|
36
|
+
class_option :no_migration
|
|
37
|
+
class_option :no_asset
|
|
38
|
+
|
|
39
|
+
# FIXME: Add method documents HERE
|
|
40
|
+
def create_scaffold
|
|
41
|
+
if options.empty?
|
|
42
|
+
# TODO: ....
|
|
43
|
+
end
|
|
44
|
+
create_model unless options[:no_model]
|
|
45
|
+
create_route unless options[:no_route]
|
|
46
|
+
create_controller unless options[:no_controller]
|
|
47
|
+
create_list_view
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
# Create a dedicated controller,
|
|
53
|
+
# It does not have any relation to Faalis
|
|
54
|
+
# TODO: Check for better way
|
|
55
|
+
def create_controller
|
|
56
|
+
#invoke "scaffold_controller", resource_data["name"]
|
|
57
|
+
if options[:no_asset]
|
|
58
|
+
`rails g scaffold_controller #{resource_data["name"]} --skip`
|
|
59
|
+
else
|
|
60
|
+
`rails g scaffold_controller #{resource_data["name"]}`
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Create route of the scaffold in config/routes.rb
|
|
65
|
+
def create_route
|
|
66
|
+
route "resources :#{resource_data["name"].pluralize}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
#Create model of the scaffold with belongs_to support
|
|
70
|
+
#It does not support has_many relation yet
|
|
71
|
+
def create_model
|
|
72
|
+
result = []
|
|
73
|
+
all_fields = []
|
|
74
|
+
relations = "\n"
|
|
75
|
+
fields.each do |name, type, to|
|
|
76
|
+
|
|
77
|
+
case type
|
|
78
|
+
when 'belongs_to'
|
|
79
|
+
type_ = 'integer'
|
|
80
|
+
if to.singularize != name
|
|
81
|
+
relations << "belongs_to :#{name.singularize},
|
|
82
|
+
:class_name => \"#{to.singularize.capitalize}\"\n"
|
|
83
|
+
else
|
|
84
|
+
relations << "belongs_to :#{to.singularize}\n"
|
|
85
|
+
end
|
|
86
|
+
name_ = "#{name.singularize}_id"
|
|
87
|
+
result << [name_, type_]
|
|
88
|
+
|
|
89
|
+
when 'text', 'integer', 'string', 'boolean', 'datetime'
|
|
90
|
+
result << [name, type]
|
|
91
|
+
|
|
92
|
+
when 'image'
|
|
93
|
+
generate "paperclicp #{resource_data['name']} #{name}"
|
|
94
|
+
relations << "has_attached_file :#{name}\n"
|
|
95
|
+
relations << "validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png),:less_than => 1.megabytes]\n"
|
|
96
|
+
when 'tag'
|
|
97
|
+
rake "rake acts_as_taggable_on_engine:install:migrations"
|
|
98
|
+
relations << "acts_as_taggable_on :#{name}\n"
|
|
99
|
+
result << [name, 'string']
|
|
100
|
+
|
|
101
|
+
when 'in'
|
|
102
|
+
result << [name, 'string']
|
|
103
|
+
|
|
104
|
+
when 'has_many'
|
|
105
|
+
relations << "has_and_belongs_to_many :#{to}\n"
|
|
106
|
+
say_status 'warn', "There is a many to many relation between #{resource_data['name']} to #{to}, You should create it manually in model files"
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
all_fields = result.collect do |x|
|
|
111
|
+
x.join(':')
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if parent?
|
|
117
|
+
all_fields << ["#{resource_data["parents"]}_id", "integer"]
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
invoke('active_record:model', [resource_data['name'], *all_fields], {
|
|
121
|
+
migration: !options[:no_migration], timestamps: true
|
|
122
|
+
})
|
|
123
|
+
if File.exist?("app/models/#{resource_data["name"]}.rb")
|
|
124
|
+
inject_into_file "app/models/#{resource_data["name"]}.rb", after: 'Base' do
|
|
125
|
+
relations
|
|
126
|
+
end
|
|
127
|
+
else
|
|
128
|
+
puts "Could not find file app/models/#{resource_data["name"]}"
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#Invoke Faalis list view generator
|
|
133
|
+
def create_list_view
|
|
134
|
+
invoke 'faalis:js:list_view', [jsonfile]
|
|
135
|
+
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|