faalis 1.0.0.alpha4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/faalis/angular-manifest.js +1 -0
- data/app/assets/javascripts/faalis/dashboard/app.js +1 -2
- data/app/assets/javascripts/faalis/dashboard/controllers/group.js.coffee +9 -7
- data/app/assets/javascripts/faalis/dashboard/controllers/user.js +11 -0
- data/app/assets/javascripts/faalis/dashboard/functions.js.erb +36 -0
- data/app/assets/javascripts/faalis/dashboard/lib/controllers/generic_index_controller.js.coffee +13 -6
- data/app/assets/javascripts/faalis/dashboard/lib/fields/has_many_field.js.coffee +0 -2
- data/app/assets/javascripts/faalis/dashboard/lib/resource.js.coffee +17 -4
- data/app/assets/javascripts/faalis/dashboard/modules/auth/user.js +0 -96
- data/app/assets/javascripts/faalis/dashboard/modules/fake.js +41 -0
- data/app/assets/javascripts/faalis/dashboard/modules/fields/datetime.js +4 -1
- data/app/assets/javascripts/faalis/dashboard/resources/group_resource.js.coffee +1 -0
- data/app/assets/javascripts/faalis/dashboard/resources/user_resource.js.coffee +0 -0
- data/app/assets/javascripts/faalis/dashboard/services/api.js.coffee +8 -6
- data/app/assets/javascripts/faalis/dashboard/services/user.js.coffee +0 -4
- data/app/assets/javascripts/faalis/dashboard/variables.js.erb +2 -1
- data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -2
- data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +2 -0
- data/app/controllers/faalis/api/v1/permissions_controller.rb +2 -1
- data/app/controllers/faalis/api_controller.rb +0 -3
- data/app/controllers/faalis/application_controller.rb +3 -0
- data/app/controllers/faalis/dashboard/groups_controller.rb +80 -0
- data/app/controllers/faalis/dashboard/users_controller.rb +100 -0
- data/app/controllers/faalis/dashboard_controller.rb +5 -1
- data/app/helpers/faalis/users_helper.rb +4 -0
- data/app/models/faalis/concerns/user/permission.rb +5 -0
- data/app/models/faalis/group.rb +14 -0
- data/app/models/faalis/permission.rb +3 -0
- data/app/views/angular/auth/groups/details.html +2 -21
- data/app/views/angular/auth/groups/index.html +2 -5
- data/app/views/angular/auth/groups/new.html +2 -47
- data/app/views/faalis/api/v1/groups/index.json.jbuilder +4 -4
- data/app/views/faalis/api/v1/permissions/index.json.jbuilder +1 -1
- data/app/views/faalis/dashboard/groups/_form.html.slim +72 -0
- data/app/views/faalis/dashboard/groups/create.js.erb +3 -0
- data/app/views/faalis/dashboard/groups/edit.html.slim +3 -0
- data/app/views/faalis/dashboard/groups/errors.js.erb +3 -0
- data/app/views/faalis/dashboard/groups/new.html.slim +2 -0
- data/app/views/faalis/dashboard/groups/update.js.erb +3 -0
- data/app/views/faalis/dashboard/users/_form.html.slim +80 -0
- data/app/views/faalis/dashboard/users/_password_form.html.slim +37 -0
- data/app/views/faalis/dashboard/users/create.js.erb +3 -0
- data/app/views/faalis/dashboard/users/edit.html.slim +3 -0
- data/app/views/faalis/dashboard/users/edit_password.html.slim +1 -0
- data/app/views/faalis/dashboard/users/errors.js.erb +3 -0
- data/app/views/faalis/dashboard/users/index.html.slim +67 -0
- data/app/views/faalis/dashboard/users/new.html.slim +2 -0
- data/app/views/faalis/dashboard/users/show.html.slim +6 -0
- data/app/views/faalis/dashboard/users/update.js.erb +3 -0
- data/app/views/faalis/dashboard/users/update_password.js.erb +3 -0
- data/db/migrate/20131013091000_devise_create_faalis_users.rb +0 -3
- data/lib/faalis.rb +2 -0
- data/lib/faalis/action_dispatch.rb +3 -0
- data/lib/faalis/configuration.rb +25 -0
- data/lib/faalis/engine.rb +2 -0
- data/lib/faalis/fake_assets.rb +1 -0
- data/lib/faalis/route.rb +73 -2
- data/lib/faalis/version.rb +3 -3
- data/lib/faalis_application.rb +10 -6
- data/lib/faalis_plugin.rb +5 -4
- data/lib/generators/faalis/install_generator.rb +1 -0
- data/lib/generators/faalis/js/list_view_generator.rb +4 -0
- data/lib/generators/faalis/scaffold_generator.rb +98 -72
- data/lib/generators/faalis/templates/angularjs/new.html.erb +10 -10
- data/lib/generators/faalis/templates/js/list_view/new.html.erb +10 -10
- data/lib/generators/faalis/templates/js/list_view/partials/add_controller.js.erb +4 -4
- data/lib/generators/faalis/templates/js/list_view/partials/config.js.erb +11 -8
- data/lib/generators/faalis/templates/js/list_view/partials/index_controller.js.erb +5 -5
- data/lib/generators/faalis/templates/policy/application_policy.rb +2 -0
- data/lib/generators/faalis/templates/policy/policy.rb.erb +2 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/{20150121060012_create_application_models.model_discovery_engine.rb → 20150723215115_create_application_models.model_discovery_engine.rb} +0 -0
- data/spec/dummy/db/migrate/20150725103007_devise_create_faalis_users.faalis.rb +63 -0
- data/spec/dummy/db/migrate/20150725103008_create_faalis_groups.faalis.rb +13 -0
- data/spec/dummy/db/migrate/20150725103009_create_faalis_permissions.faalis.rb +13 -0
- data/spec/dummy/db/migrate/20150725103010_add_permissions_groups_table.faalis.rb +9 -0
- data/spec/dummy/db/migrate/20150725103011_add_users_groups_table.faalis.rb +9 -0
- data/spec/dummy/db/schema.rb +5 -2
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +6474 -466
- data/spec/dummy/log/test.log +23493 -9554
- data/spec/dummy/tmp/app/assets/javascripts/controlpanel/application.js +22 -0
- data/spec/dummy/tmp/app/assets/stylesheets/dashboard/ltr/application.css +3 -0
- data/spec/dummy/tmp/app/assets/stylesheets/dashboard/rtl/application.css +3 -0
- data/spec/dummy/tmp/app/assets/stylesheets/ltr/application.css +3 -0
- data/spec/dummy/tmp/app/assets/stylesheets/rtl/application.css +3 -0
- data/spec/dummy/tmp/app/controllers/api_controller.rb +2 -0
- data/spec/dummy/tmp/app/controllers/application_controller.rb +0 -0
- data/spec/dummy/tmp/app/policies/application_policy.rb +2 -0
- data/spec/dummy/tmp/config/initializers/devise.rb +251 -0
- data/spec/dummy/tmp/config/initializers/faalis.rb +13 -0
- data/spec/dummy/tmp/config/initializers/fast_gettext.rb +4 -0
- data/spec/dummy/tmp/config/initializers/formstatic.rb +76 -0
- data/spec/dummy/tmp/config/routes.rb +0 -0
- data/spec/dummy/tmp/db/seeds.rb +1 -0
- metadata +73 -7
data/lib/faalis_plugin.rb
CHANGED
@@ -22,17 +22,17 @@ end
|
|
22
22
|
gsub_file "#{app_name}.gemspec", /test\/\*\*\/\*/, "spec/**/*"
|
23
23
|
|
24
24
|
insert_into_file "#{app_name}.gemspec", :after => 's.add_development_dependency "sqlite3"' do
|
25
|
-
"\n s.add_dependency 'globalize'
|
25
|
+
"\n s.add_dependency 'globalize'"
|
26
26
|
end
|
27
27
|
|
28
28
|
insert_into_file "#{app_name}.gemspec", :after => 's.add_development_dependency "sqlite3"' do
|
29
|
-
"\n s.add_dependency 'jbuilder'
|
29
|
+
"\n s.add_dependency 'jbuilder'"
|
30
30
|
end
|
31
31
|
insert_into_file "#{app_name}.gemspec", :after => 's.add_development_dependency "sqlite3"' do
|
32
|
-
"\n s.add_dependency 'sass-rails'
|
32
|
+
"\n s.add_dependency 'sass-rails'"
|
33
33
|
end
|
34
34
|
insert_into_file "#{app_name}.gemspec", :after => 's.add_development_dependency "sqlite3"' do
|
35
|
-
"\n s.add_dependency 'uglifier'
|
35
|
+
"\n s.add_dependency 'uglifier'"
|
36
36
|
end
|
37
37
|
insert_into_file "#{app_name}.gemspec", :after => 's.add_development_dependency "sqlite3"' do
|
38
38
|
"\n s.add_dependency 'jquery-rails'\n"
|
@@ -42,6 +42,7 @@ insert_into_file "#{app_name}.gemspec", :after => 's.add_development_dependency
|
|
42
42
|
end
|
43
43
|
|
44
44
|
inside "app/assets/javascripts/" do
|
45
|
+
run "mkdir #{app_name.underscore.downcase}"
|
45
46
|
run "touch #{app_name.underscore.downcase}/application.js"
|
46
47
|
end
|
47
48
|
append_file "app/assets/javascripts/#{app_name.underscore.downcase}/application.js" do <<-'FILE'
|
@@ -41,6 +41,7 @@ module Faalis
|
|
41
41
|
template 'formtastic.rb', 'config/initializers/formstatic.rb'
|
42
42
|
template 'seeds.rb', 'db/seeds.rb'
|
43
43
|
template 'api_controller.rb', 'app/controllers/api_controller.rb'
|
44
|
+
template 'policy/application_policy.rb', 'app/policies/application_policy.rb'
|
44
45
|
end
|
45
46
|
|
46
47
|
def copy_js_manifest
|
@@ -48,6 +48,10 @@ module Faalis
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
def create_policy
|
52
|
+
template "policy/policy.rb.erb", "app/policies/#{resource.underscore}_policy.rb"
|
53
|
+
end
|
54
|
+
|
51
55
|
def create_specs
|
52
56
|
unless options[:without_specs]
|
53
57
|
template "features/api.feature", "features/#{resource.underscore}.api.feature"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
2
|
# Faalis - Basic website skel engine
|
3
|
-
# Copyright (C) 2012-
|
3
|
+
# Copyright (C) 2012-2015 Yellowen
|
4
4
|
#
|
5
5
|
# This program is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU General Public License as published by
|
@@ -54,13 +54,11 @@ module Faalis
|
|
54
54
|
private
|
55
55
|
|
56
56
|
# Create a dedicated controller,
|
57
|
-
# It does not have any relation to Faalis
|
58
|
-
# TODO: Check for better way
|
59
57
|
def create_controller
|
60
58
|
if options[:no_asset]
|
61
|
-
`rails g scaffold_controller #{resource_data["name"]} --
|
59
|
+
`rails g scaffold_controller #{resource_data["name"]} #{all_fields}--assets=false`
|
62
60
|
else
|
63
|
-
`rails g scaffold_controller #{resource_data["name"]}`
|
61
|
+
`rails g scaffold_controller #{resource_data["name"]} #{all_fields}`
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
@@ -69,44 +67,94 @@ module Faalis
|
|
69
67
|
route "resources :#{resource_data["name"].pluralize}"
|
70
68
|
end
|
71
69
|
|
72
|
-
#Create model of the scaffold with belongs_to support
|
73
|
-
#It does not support has_many relation yet
|
70
|
+
# Create model of the scaffold with belongs_to support
|
71
|
+
# It does not support has_many relation yet
|
74
72
|
def create_model
|
75
|
-
|
76
|
-
|
73
|
+
|
74
|
+
# Load all globalize field and create a string to adding in model
|
75
|
+
globalizes = "\n translates "+
|
76
|
+
globalize_fields.map { |field | ":#{field['name'].underscore}" }.join(", ")
|
77
|
+
invoke('active_record:model', [resource_data['name'].singularize.underscore, all_fields.split(' ')], {
|
78
|
+
migration: !options[:no_migragtion], timestamps: true
|
79
|
+
})
|
80
|
+
if globalize_fields.any?
|
81
|
+
create_globalize_migration
|
82
|
+
end
|
83
|
+
|
84
|
+
if File.exist?("app/models/#{resource_data["name"]}.rb")
|
85
|
+
inject_into_file "app/models/#{resource_data["name"].underscore}.rb", after: 'Base' do
|
86
|
+
globalize_fields.empty? ? relations : relations + globalizes
|
87
|
+
end
|
88
|
+
else
|
89
|
+
say_status "error", "Could not find file app/models/#{resource_data["name"].underscore}"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
#Invoke Faalis list view generator
|
95
|
+
def create_list_view
|
96
|
+
invoke 'faalis:js:list_view', [input_file]
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_globalize_migration
|
100
|
+
`rails g migration add_globalize_to_#{resource_data["name"].underscore} `
|
101
|
+
Dir["#{Rails.root}/db/migrate/**/*globalize*.rb"].each {|file| require file }
|
102
|
+
klass = "add_globalize_to_#{resource_data['name']}".underscore.camelize
|
103
|
+
|
104
|
+
migration_class = "::#{klass}".constantize
|
105
|
+
migration_path = migration_class.instance_method(:change).source_location
|
106
|
+
|
107
|
+
fields = globalize_fields.map { |field | ":#{field['name']} => :#{field['type']}" }.join(", ")
|
108
|
+
|
109
|
+
inject_into_file migration_path[0], after: 'change' do
|
110
|
+
"\n #{resource_data['name'].camelize}"+
|
111
|
+
'.create_translation_table! '+
|
112
|
+
fields
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def create_images
|
117
|
+
fields.each do |name, type|
|
118
|
+
if type == 'image'
|
119
|
+
generate "paperclicp #{resource_data['name']} #{name}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def create_tags
|
125
|
+
fields.each do |name, type|
|
126
|
+
if type == 'image'
|
127
|
+
rake "rake acts_as_taggable_on_engine:install:migrations"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Create string of all relations that needs in models
|
133
|
+
def relations
|
77
134
|
relations = "\n"
|
135
|
+
|
78
136
|
fields.each do |name, type, to|
|
79
137
|
case type
|
80
138
|
when 'belongs_to'
|
81
|
-
type_ = 'integer'
|
82
139
|
if to.singularize != name
|
83
140
|
relations << " belongs_to :#{name.singularize},
|
84
141
|
:class_name => \"#{to.singularize.camelize}\"\n"
|
85
142
|
else
|
86
143
|
relations << " belongs_to :#{to.singularize}\n"
|
87
144
|
end
|
88
|
-
name_ = "#{name.singularize}_id"
|
89
|
-
result << [name_, type_]
|
90
|
-
|
91
|
-
when 'text', 'integer', 'string', 'boolean', 'datetime', 'time', 'date', 'float'
|
92
|
-
result << [name, type]
|
93
145
|
|
94
146
|
when 'image'
|
95
|
-
|
96
|
-
|
97
|
-
|
147
|
+
relations << "
|
148
|
+
attr_accessor :image_data\n
|
149
|
+
before_create :randomize_file_name\n
|
150
|
+
has_attached_file :#{name}\n
|
98
151
|
content_type: %w(image/jpeg image/jpg image/png),
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
152
|
+
validates_attachment_content_type :#{name},
|
153
|
+
less_than: 1.megabytes\n
|
154
|
+
"
|
155
|
+
# TODO: randomize_file_name method should be added
|
103
156
|
when 'tag'
|
104
|
-
rake "rake acts_as_taggable_on_engine:install:migrations"
|
105
157
|
relations << " acts_as_taggable_on :#{name}\n"
|
106
|
-
result << [name, 'string']
|
107
|
-
|
108
|
-
when 'in'
|
109
|
-
result << [name, 'string']
|
110
158
|
|
111
159
|
when 'has_and_belongs_to_many'
|
112
160
|
relations << " has_and_belongs_to_many :#{to.pluralize}\n"
|
@@ -122,67 +170,45 @@ module Faalis
|
|
122
170
|
|
123
171
|
if parent?
|
124
172
|
parents.each do |parent|
|
125
|
-
result << ["#{parent.singularize}_id", "integer"]
|
126
173
|
relations << " belongs_to :#{parent.singularize}\n"
|
127
174
|
end
|
128
175
|
end
|
129
176
|
|
130
|
-
|
131
177
|
childs.each do |child|
|
132
178
|
relations << " has_many :#{child.pluralize}\n"
|
133
179
|
end
|
180
|
+
return relations
|
181
|
+
end
|
134
182
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
183
|
+
# It will extract name and types of all fields
|
184
|
+
# And will return it as supported format for scaffold_controller
|
185
|
+
def all_fields
|
186
|
+
result = []
|
187
|
+
fields.each do |name, type, to|
|
188
|
+
case type
|
189
|
+
when 'belongs_to'
|
190
|
+
name_ = "#{name.singularize}_id"
|
191
|
+
result << [name_, 'integer']
|
143
192
|
|
193
|
+
when 'text', 'integer', 'string', 'boolean', 'datetime', 'time', 'date', 'float'
|
194
|
+
result << [name, type]
|
144
195
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
if globalize_fields.any?
|
149
|
-
create_globalize_migration
|
196
|
+
when 'tag', 'in'
|
197
|
+
result << [name, 'string']
|
198
|
+
end
|
150
199
|
end
|
151
200
|
|
152
|
-
if
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
globalize_fields.empty? ? relations : relations + globalizes
|
201
|
+
if parent?
|
202
|
+
parents.each do |parent|
|
203
|
+
result << ["#{parent.singularize}_id", "integer"]
|
157
204
|
end
|
158
|
-
else
|
159
|
-
puts "Could not find file app/models/#{resource_data["name"].underscore}"
|
160
205
|
end
|
161
206
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
#Invoke Faalis list view generator
|
167
|
-
def create_list_view
|
168
|
-
invoke 'faalis:js:list_view', [input_file]
|
169
|
-
end
|
170
|
-
|
171
|
-
def create_globalize_migration
|
172
|
-
`rails g migration add_globalize_to_#{resource_data["name"].underscore} `
|
173
|
-
Dir["#{Rails.root}/db/migrate/**/*globalize*.rb"].each {|file| require file }
|
174
|
-
klass = "add_globalize_to_#{resource_data['name']}".underscore.camelize
|
175
|
-
|
176
|
-
migration_class = "::#{klass}".constantize
|
177
|
-
migration_path = migration_class.instance_method(:change).source_location
|
178
|
-
|
179
|
-
fields = globalize_fields.map { |field | ":#{field['name']} => :#{field['type']}" }.join(", ")
|
180
|
-
|
181
|
-
inject_into_file migration_path[0], after: 'change' do
|
182
|
-
"\n #{resource_data['name'].camelize}"+
|
183
|
-
'.create_translation_table! '+
|
184
|
-
fields
|
207
|
+
all_fields = []
|
208
|
+
all_fields = result.collect do |x|
|
209
|
+
x.join(':')
|
185
210
|
end
|
211
|
+
return all_fields.join " "
|
186
212
|
end
|
187
213
|
end
|
188
214
|
end
|
@@ -14,15 +14,15 @@
|
|
14
14
|
|
15
15
|
<% first = true %><% fields.each do |field_name, field_type| %>
|
16
16
|
<% if first %><div class="row"><% end %>
|
17
|
-
<div class="
|
17
|
+
<div class="col-sm-4 <% if not first %>pull-left col-sm-offset-2<% end %>">
|
18
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
19
|
when "belongs_to", "has_many", "in" %>
|
20
20
|
<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
21
|
</relation-field>
|
22
22
|
<% when nil %>
|
23
|
-
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
23
|
+
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-control rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
24
24
|
<% else %>
|
25
|
-
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
25
|
+
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-control rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
26
26
|
</div>
|
27
27
|
<% if not first %></div><% end %><% first = !first %><% end %>
|
28
28
|
</fieldset>
|
@@ -36,15 +36,15 @@
|
|
36
36
|
<% fields.each do |field_name, field_type| %><% if tabs[name].include? field_name or tabs[name].include? "__all__" %>
|
37
37
|
|
38
38
|
<% if first %><div class="row"><% end %>
|
39
|
-
<div class="
|
39
|
+
<div class="col-sm-4 form-group <% if not first %>pull-left col-sm-offset-2<% end %>">
|
40
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
|
41
41
|
when "belongs_to", "has_many", "in" %>
|
42
42
|
<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
43
|
</relation-field>
|
44
44
|
<% when nil %>
|
45
|
-
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
45
|
+
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-control rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
46
46
|
<% else %>
|
47
|
-
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
47
|
+
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-control rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
48
48
|
</div>
|
49
49
|
<% if not first %></div><% end %><% first = !first %><% end %><% end %>
|
50
50
|
</fieldset>
|
@@ -53,10 +53,10 @@
|
|
53
53
|
<% end %>
|
54
54
|
|
55
55
|
<div class="row">
|
56
|
-
<div class="
|
57
|
-
<button class="btn
|
58
|
-
<button class="btn
|
59
|
-
<button class="btn
|
56
|
+
<div class="col-sm-4 form-group">
|
57
|
+
<button class="btn btn-success" ng-click="save(false)" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save</span></button>
|
58
|
+
<button class="btn btn-warning" ng-click="save(true)" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save & Add Another</span></button>
|
59
|
+
<button class="btn btn-danger" ng-click="cancel()"><i class="fa fa-times"></i> <span translate>Cancel</span></button>
|
60
60
|
</div>
|
61
61
|
</div>
|
62
62
|
</div>
|
@@ -15,15 +15,15 @@
|
|
15
15
|
|
16
16
|
<% first = true %><% fields.each do |field_name, field_type| %>
|
17
17
|
<% if first %><div class="row"><% end %>
|
18
|
-
<div class="
|
18
|
+
<div class="col-sm-4 form-group <% if not first %>pull-left col-sm-offset-2<% end %>">
|
19
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
|
20
20
|
when "belongs_to", "has_many", "in" %>
|
21
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">
|
22
22
|
</relation-field>
|
23
23
|
<% when nil %>
|
24
|
-
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
24
|
+
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-controll rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
25
25
|
<% else %>
|
26
|
-
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
26
|
+
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-controll rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
27
27
|
</div>
|
28
28
|
<% if not first %></div><% end %><% first = !first %><% end %>
|
29
29
|
</fieldset>
|
@@ -38,15 +38,15 @@
|
|
38
38
|
<% fields.each do |field_name, field_type| %><% if tab_has_field?(name, field_name) or tabs[name].include? "__all__" %>
|
39
39
|
|
40
40
|
<% if first %><div class="row"><% end %>
|
41
|
-
<div class="
|
41
|
+
<div class="col-sm-4 form-group <% if not first %>pull-left col-sm-offset-2<% end %>">
|
42
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
|
43
43
|
when "belongs_to", "has_many", "in" %>
|
44
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">
|
45
45
|
</relation-field>
|
46
46
|
<% when nil %>
|
47
|
-
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
47
|
+
<string-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-controll rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required<% end %>></string-field>
|
48
48
|
<% else %>
|
49
|
-
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
49
|
+
<<%= field_type%>-field model="<%= field_name %>" field-name="'<%= field_name %>'" css-class="'form-controll rounded <%= field_type %>_field'" <% if required_fields.include? field_name %>required="true"<% end %>></<%= field_type%>-field><% end %>
|
50
50
|
</div>
|
51
51
|
<% if not first %></div><% end %><% first = !first %><% end %><% end %>
|
52
52
|
</fieldset>
|
@@ -55,10 +55,10 @@
|
|
55
55
|
<% end %>
|
56
56
|
|
57
57
|
<div class="row">
|
58
|
-
<div class="
|
59
|
-
<button class="btn
|
60
|
-
<button class="btn
|
61
|
-
<button class="btn
|
58
|
+
<div class="col-sm-6 form-group">
|
59
|
+
<button class="btn btn-success" ng-click="save(false)" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save</span></button>
|
60
|
+
<button class="btn btn-warning" ng-click="save(true)" ng-disabled="form.$invalid || !form.$dirty"><i class="fa fa-check"></i> <span translate>Save & Add Another</span></button>
|
61
|
+
<button class="btn btn-danger" ng-click="cancel()"><i class="fa fa-times"></i> <span translate>Cancel</span></button>
|
62
62
|
</div>
|
63
63
|
</div>
|
64
64
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<%= resource.pluralize %>.controller("Add<%= resource %>Controller", ["Restangular", "$scope", "$location", "$
|
1
|
+
<%= resource.pluralize %>.controller("Add<%= resource %>Controller", ["Restangular", "$scope", "$location", "$stateParams", "gettext", "catch_error", function(API, $scope, $location, $stateParams, gettext, catch_error){
|
2
2
|
|
3
3
|
<% parents.each do |parent| %>
|
4
|
-
$scope.<%= parent %>_id = $
|
4
|
+
$scope.<%= parent %>_id = $stateParams.<%= parent %>_id;
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
$scope.select2options = {};
|
@@ -24,8 +24,8 @@
|
|
24
24
|
<% fields.each do |name, type, to| %><% if type == "in" %>$scope.<%= name %>_choices = [<% to.each do |choice| %>
|
25
25
|
{name: "<%= choice.underscore %>", title: "<%= choice.humanize %>"},<% end %>
|
26
26
|
].sortBy(), "title");<% end %><% end %>
|
27
|
-
if( "id" in $
|
28
|
-
$scope.obj_id = $
|
27
|
+
if( "id" in $stateParams ){
|
28
|
+
$scope.obj_id = $stateParams.id;
|
29
29
|
$scope.editing = true;
|
30
30
|
if ($scope.obj_id < 0) {
|
31
31
|
is_copy = true;
|
@@ -1,17 +1,20 @@
|
|
1
1
|
// <%= resource.pluralize %> configuration section ---------------------------
|
2
|
-
<%= resource.pluralize %>.config(["$
|
2
|
+
<%= resource.pluralize %>.config(["$stateProvider", function($stateProvider){
|
3
3
|
// Add any route you need here
|
4
|
-
$
|
5
|
-
|
6
|
-
|
4
|
+
$stateProvider.
|
5
|
+
state("<% parents.each do |parent| %><%= parent %>-<% end %><%= resource_url %>", {
|
6
|
+
url: "/<%= resource_url %>",
|
7
|
+
templateUrl: template_url("<%= resource_path %>/index"),
|
7
8
|
controller: "<%= resource %>Controller"
|
8
9
|
}).
|
9
|
-
|
10
|
-
|
10
|
+
state("<% parents.each do |parent| %><%= parent %>-<% end %><%= resource_url %>/new",{
|
11
|
+
url: "/<%= resource_url %>/new",
|
12
|
+
templateUrl: template_url("<%= resource_path %>/new"),
|
11
13
|
controller: "Add<%= resource %>Controller"
|
12
14
|
}).
|
13
|
-
|
14
|
-
|
15
|
+
state("<% parents.each do |parent| %><%= parent %>-<% end %><%= resource_url %>-edit",{
|
16
|
+
url: "/<%= resource_url %>/:id/edit",
|
17
|
+
templateUrl: template_url("<%= resource_path %>/new"),
|
15
18
|
controller: "Add<%= resource %>Controller"
|
16
19
|
});
|
17
20
|
}]);
|
@@ -1,9 +1,9 @@
|
|
1
1
|
// <%= resource %> index controller -------------------------------------------------------
|
2
2
|
// This controller is responsible for list page (index)
|
3
|
-
<%= resource.pluralize %>.controller("<%= resource %>Controller", ["$scope", "gettext", "Restangular", "catch_error", "$location", "$
|
3
|
+
<%= resource.pluralize %>.controller("<%= resource %>Controller", ["$scope", "gettext", "Restangular", "catch_error", "$location", "$stateParams", function($scope, gettext, API, catch_error, $location, $stateParams){
|
4
4
|
|
5
5
|
<% parents.each do |parent| %>
|
6
|
-
$scope.<%= parent %>_id = $
|
6
|
+
$scope.<%= parent %>_id = $stateParams.<%= parent %>_id;
|
7
7
|
<% end %>
|
8
8
|
<% unless no_filter? %>$scope.filter_config = {
|
9
9
|
list: <% if parent? %>API.<% parents.each do |parent| %>one("<%= parent %>", $scope.<%= parent %>_id)<% end %>.all("<%= resource.pluralize.underscore %>")<% else %>API.all("<%= resource.pluralize.underscore %>")<% end %>
|
@@ -48,7 +48,7 @@
|
|
48
48
|
{
|
49
49
|
title: gettext("New"),
|
50
50
|
icon: "fa fa-plus",
|
51
|
-
classes: "btn
|
51
|
+
classes: "btn btn-success",
|
52
52
|
permission: {
|
53
53
|
name: "create",
|
54
54
|
model: "<% if model_specified? %><%= model %><% else %><%= resource.classify %><% end %>"
|
@@ -59,7 +59,7 @@
|
|
59
59
|
{
|
60
60
|
title: gettext("Bulk Edit"),
|
61
61
|
icon: "fa fa-edit",
|
62
|
-
classes: "btn
|
62
|
+
classes: "btn btn-warning",
|
63
63
|
permission: {
|
64
64
|
name: "update",
|
65
65
|
model: "<% if model_specified? %><%= model %><% else %><%= resource.classify %><% end %>"
|
@@ -72,7 +72,7 @@
|
|
72
72
|
{
|
73
73
|
title: gettext("Duplicate"),
|
74
74
|
icon: "fa fa-files-o",
|
75
|
-
classes: "btn
|
75
|
+
classes: "btn btn-danger",
|
76
76
|
permission: {
|
77
77
|
name: "create",
|
78
78
|
model: "<% if model_specified? %><%= model %><% else %><%= resource.classify %><% end %>"
|