faalis 0.19.0 → 0.20.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/fields/string.js +43 -0
- data/app/assets/stylesheets/faalis/base.css.scss +22 -1
- data/app/views/angularjs_templates/fields/string/string.html +18 -0
- data/lib/faalis/engine.rb +2 -2
- data/lib/faalis/generators/concerns.rb +1 -0
- data/lib/faalis/generators/concerns/angular.rb +6 -6
- data/lib/faalis/generators/concerns/bulk.rb +9 -14
- data/lib/faalis/generators/concerns/dependency.rb +4 -1
- data/lib/faalis/generators/concerns/json_input.rb +39 -0
- data/lib/faalis/generators/concerns/menu.rb +3 -12
- data/lib/faalis/generators/concerns/model.rb +3 -3
- data/lib/faalis/generators/concerns/parent.rb +3 -3
- data/lib/faalis/generators/concerns/required.rb +2 -5
- data/lib/faalis/generators/concerns/resource_fields.rb +25 -14
- data/lib/faalis/generators/concerns/resource_name.rb +7 -7
- data/lib/faalis/generators/concerns/tabs.rb +6 -9
- data/lib/faalis/generators/dashboard_scaffold.rb +1 -0
- data/lib/faalis/generators/fields/relation.rb +2 -2
- data/lib/faalis/version.rb +1 -1
- data/lib/generators/faalis/templates/js/list_view/details.html.erb +5 -5
- data/lib/generators/faalis/templates/js/list_view/index.html.erb +3 -3
- data/lib/generators/faalis/templates/js/list_view/module.js.erb +15 -36
- data/lib/generators/faalis/templates/views/index.json.jbuilder.erb +5 -4
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b6bebb09df183b7dee476937557f6891913cb06
|
4
|
+
data.tar.gz: 7641a768cd23e508dd287ab678301916716259f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25e2961ee63d2a0e48fa2419246207f3345dcc25a27bbc216b677752dc89400400e53f81e81316e6cf3c5cecabd1755ffad90355df42db71c3f5a6735915c4c8
|
7
|
+
data.tar.gz: 6e02192d12bc51edbe48c1dd46db63a9818c90d31698aa24a13c153148504f7f1bd91c701f1c82709cc378cac10409d24bec37a1aeffa05ab645e9484866fc27
|
@@ -9,6 +9,19 @@ String_.directive('stringField', ["$filter", "gettext", function($filter, gettex
|
|
9
9
|
var ltr = is_ltr();
|
10
10
|
scope.element_id = "id_" + scope.field;
|
11
11
|
scope.msg_element_id = "id_" + scope.field + "_msg";
|
12
|
+
scope.show_help_btn = false;
|
13
|
+
scope.show_help_text = true;
|
14
|
+
// Decide to see help text or help button
|
15
|
+
if (scope.options === undefined) {
|
16
|
+
scope.options = {};
|
17
|
+
}
|
18
|
+
|
19
|
+
if ("help_text" in scope.options) {
|
20
|
+
if ("show_help_btn" in scope.options && scope.options.show_help_btn === true) {
|
21
|
+
scope.show_help_btn = true;
|
22
|
+
scope.show_help_text = false;
|
23
|
+
}
|
24
|
+
}
|
12
25
|
|
13
26
|
if (scope.on_change !== undefined) {
|
14
27
|
// Watch event changes
|
@@ -18,6 +31,27 @@ String_.directive('stringField', ["$filter", "gettext", function($filter, gettex
|
|
18
31
|
}, true);
|
19
32
|
}
|
20
33
|
|
34
|
+
scope.help_btn_clicked = function() {
|
35
|
+
if ("show_help_callback" in scope.options) {
|
36
|
+
scope.options.show_help_btn();
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
scope.show_help_text = !scope.show_help_text;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
scope.have = function(ob, element) {
|
44
|
+
if (ob !== undefined) {
|
45
|
+
if (element in ob) {
|
46
|
+
return true;
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
return false;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
return false;
|
53
|
+
};
|
54
|
+
|
21
55
|
}
|
22
56
|
// Actual object of <string-field> directive
|
23
57
|
return {
|
@@ -25,7 +59,16 @@ String_.directive('stringField', ["$filter", "gettext", function($filter, gettex
|
|
25
59
|
replace: true,
|
26
60
|
restrict: "E",
|
27
61
|
scope: {
|
62
|
+
// you can control the buttons and help
|
63
|
+
// message of field here. for example you can use `help_text` to
|
64
|
+
// show an small help under the control and you can set `show_help_btn`
|
65
|
+
// to true to show an help button.
|
66
|
+
// options is optional (notice '=?')
|
67
|
+
options: '=?',
|
68
|
+
|
69
|
+
// Css classes to apply on element
|
28
70
|
cssClasses: '=cssClass',
|
71
|
+
|
29
72
|
// A call back to pass to field ng-change directive
|
30
73
|
on_change: "@onChange",
|
31
74
|
// fieldname
|
@@ -274,7 +274,7 @@ small.error {
|
|
274
274
|
padding: 2px 5px;
|
275
275
|
color: $darkgray;
|
276
276
|
cursor: pointer;
|
277
|
-
opacity: 0.
|
277
|
+
opacity: 0.4;
|
278
278
|
@include transition(opacity 300ms linear 0ms);
|
279
279
|
&:hover {
|
280
280
|
opacity: 1;
|
@@ -287,8 +287,29 @@ small.error {
|
|
287
287
|
opacity: 1;
|
288
288
|
@include transition(opacity 300ms linear 0ms);
|
289
289
|
}
|
290
|
+
.btntitle {
|
291
|
+
padding: 0;
|
292
|
+
}
|
293
|
+
|
290
294
|
}
|
291
295
|
}
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
.extra_links {
|
300
|
+
.option_item {
|
301
|
+
font-size: 0.7em;
|
302
|
+
color: $darkgray;
|
303
|
+
cursor: pointer;
|
304
|
+
a {
|
305
|
+
padding: 2px 4px;
|
306
|
+
.btntitle {
|
307
|
+
padding: 0;
|
308
|
+
}
|
309
|
+
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
292
313
|
}
|
293
314
|
|
294
315
|
.helptext {
|
@@ -1,4 +1,22 @@
|
|
1
1
|
<div>
|
2
2
|
<input id="{{ element_id }}" ng-model="model" name="{{ field }}" ng-required="required" type="text" class="{{cssClasses}}" />
|
3
|
+
<div class="row">
|
4
|
+
<div class="float-left small-7 column">
|
5
|
+
<span class="helptext" ng-if="options.help_text && show_help_text">{{ options.help_text }}</span>
|
6
|
+
</div>
|
7
|
+
<div class="float-right small-5 column extra_links text-right" ng-if="have(options, 'links')">
|
8
|
+
<span ng-click="help_btn_clicked()" ng-if="show_help_btn">
|
9
|
+
<i class="fa fa-question"></i>
|
10
|
+
</span>
|
11
|
+
<span ng-repeat="item in options.links" class="option_item">
|
12
|
+
<a class="{{ item.link_class }}" ng-click="item.action()" ng-if="have(item, 'action')">
|
13
|
+
<i class="{{ item.icon || '' }}"></i> <span class="btntitle" ng-if="have(item, 'title')"><span translate>{{ item.title }}</span></span>
|
14
|
+
</a>
|
15
|
+
<a class="{{ item.link_class }}" ng-href="#{{ item.url }}" target="_blank" ng-if="have(item, 'url')">
|
16
|
+
<i class="{{ item.icon || '' }}"></i> <span class="btntitle" ng-if="have(item, 'title')"><span translate>{{ item.title }}</span></span>
|
17
|
+
</a>
|
18
|
+
</span>
|
19
|
+
</div>
|
20
|
+
</div>
|
3
21
|
<small id="{{ msg_element_id }}"></small>
|
4
22
|
</div>
|
data/lib/faalis/engine.rb
CHANGED
@@ -19,8 +19,8 @@
|
|
19
19
|
require 'fast_gettext'
|
20
20
|
require 'modernizr-rails'
|
21
21
|
require "compass-rails"
|
22
|
-
|
23
|
-
require 'foundation-rails'
|
22
|
+
require 'zurb-foundation'
|
23
|
+
#require 'foundation-rails'
|
24
24
|
require "font-awesome-rails"
|
25
25
|
require "devise"
|
26
26
|
require "warden"
|
@@ -5,20 +5,20 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
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/'"
|
8
|
+
#base.class_option :path, :type => :string, :default => "", :desc => "Path to js_scaffold target inside 'app/assets/javascripts/'"
|
9
9
|
|
10
10
|
# Path to js_scaffold target
|
11
|
-
base.class_option :raw_path, :type => :string, :default => "", :desc => "Path to js_scaffold target"
|
11
|
+
#base.class_option :raw_path, :type => :string, :default => "", :desc => "Path to js_scaffold target"
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
16
|
|
17
17
|
def angularjs_app_path
|
18
|
-
if
|
19
|
-
|
20
|
-
elsif
|
21
|
-
"app/assets/javascripts/#{
|
18
|
+
if not resource_data["raw_path"].blank?
|
19
|
+
resource_data["raw_path"]
|
20
|
+
elsif not resource_data["path"].blank?
|
21
|
+
"app/assets/javascripts/#{resource_data['path']}/"
|
22
22
|
else
|
23
23
|
path = Faalis::Engine.dashboard_js_manifest.split("/")[0..-2].join("/")
|
24
24
|
"app/assets/javascripts/#{path}/"
|
@@ -5,31 +5,26 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
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"
|
8
|
+
#base.class_option :bulk_fields, :type => :string, :default => "", :desc => "Fields to use in in bulk edit, comma separated"
|
9
9
|
|
10
10
|
# No bulk edit needed
|
11
|
-
base.class_option :no_bulk, :type => :boolean, :default => false, :desc => "No bulk edit needed"
|
11
|
+
#base.class_option :no_bulk, :type => :boolean, :default => false, :desc => "No bulk edit needed"
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
16
|
# Returns fields which is needed to be in bulk edit
|
17
17
|
def bulk_edit_fields
|
18
|
-
|
19
|
-
|
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
|
18
|
+
fields_with("bulk", true)
|
19
|
+
end
|
28
20
|
|
29
|
-
|
21
|
+
def no_bulk?
|
22
|
+
if bulk_edit_fields.length > 0
|
23
|
+
true
|
24
|
+
else
|
25
|
+
false
|
30
26
|
end
|
31
27
|
end
|
32
|
-
|
33
28
|
end
|
34
29
|
end
|
35
30
|
end
|
@@ -5,9 +5,12 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
7
|
# Dependencies of Angularjs module, comma separated
|
8
|
-
base.class_option :deps, :type => :string, :default => "", :desc => "Dependencies of Angularjs module, comma separated"
|
8
|
+
#base.class_option :deps, :type => :string, :default => "", :desc => "Dependencies of Angularjs module, comma separated"
|
9
9
|
end
|
10
10
|
|
11
|
+
def deps
|
12
|
+
resource_data[:deps]
|
13
|
+
end
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
|
4
|
+
module Faalis
|
5
|
+
module Generators
|
6
|
+
module Concerns
|
7
|
+
# This module Provide an argument for generator which
|
8
|
+
# is needed by other `Concerns`.
|
9
|
+
#
|
10
|
+
# Each Concern will have its own
|
11
|
+
|
12
|
+
module JsonInput
|
13
|
+
|
14
|
+
def self.included(base)
|
15
|
+
# Name of the resource to create.
|
16
|
+
base.argument :jsonfile , :type => :string, :required => true
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def json_file_data
|
22
|
+
path = File.expand_path(jsonfile)
|
23
|
+
File.read(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def resource_data
|
27
|
+
if @data
|
28
|
+
@data
|
29
|
+
else
|
30
|
+
@data = JSON.parse(json_file_data)
|
31
|
+
@data
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -5,22 +5,13 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
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"
|
8
|
+
#base.class_option :menu, :type => :string, :default => "", :desc => "Provide menu items which should be in sidebar. format: menu1:url,menu2:url"
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
-
def
|
14
|
-
|
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
|
13
|
+
def has_menu?
|
14
|
+
resource_data.include? "menu"
|
24
15
|
end
|
25
16
|
|
26
17
|
end
|
@@ -5,19 +5,19 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
7
|
# Fields to use in in bulk edit, comma separated
|
8
|
-
base.class_option :model, :type => :string, :default => "", :desc => "Model name to use"
|
8
|
+
#base.class_option :model, :type => :string, :default => "", :desc => "Model name to use"
|
9
9
|
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def model_specified?
|
15
|
-
|
15
|
+
resource_data.include? "model"
|
16
16
|
end
|
17
17
|
|
18
18
|
def model
|
19
19
|
if model_specified?
|
20
|
-
|
20
|
+
resource_data["model"]
|
21
21
|
else
|
22
22
|
""
|
23
23
|
end
|
@@ -5,14 +5,14 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
7
|
# Specify the parent resource if there was any
|
8
|
-
base.class_option :
|
8
|
+
#base.class_option :parents, :type => :string, :default => "", :desc => "Specify the parent resource if there was any"
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
13
|
# check for parent
|
14
14
|
def parent?
|
15
|
-
|
15
|
+
unless resource_data["parents"].empty?
|
16
16
|
return true
|
17
17
|
end
|
18
18
|
false
|
@@ -25,7 +25,7 @@ module Faalis
|
|
25
25
|
|
26
26
|
def parents
|
27
27
|
if parent?
|
28
|
-
_parents =
|
28
|
+
_parents = resource_data["parents"]
|
29
29
|
_parents.collect do |p|
|
30
30
|
trim_parent_path(p)
|
31
31
|
end
|
@@ -5,16 +5,13 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
7
|
# Non optional fields, comma separated
|
8
|
-
base.class_option :required, :type => :string, :default => "", :desc => "Non optional fields, comma separated"
|
8
|
+
#base.class_option :required, :type => :string, :default => "", :desc => "Non optional fields, comma separated"
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def required_fields
|
14
|
-
|
15
|
-
return options[:required].split(",")
|
16
|
-
end
|
17
|
-
[]
|
14
|
+
fields_with("required", true)
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -10,7 +10,7 @@ module Faalis
|
|
10
10
|
# An array of resource fields. fields should be separated by space
|
11
11
|
# each filed should be in this format `field_name:field_type[:extra_info]
|
12
12
|
# Relation options should be like `{key: value, key2: elem1;elem2, key3: value3}`
|
13
|
-
base.argument :resource_fields, type: :array, default: [], banner: "fields[:types[:to[{relation_options}]"
|
13
|
+
#base.argument :resource_fields, type: :array, default: [], banner: "fields[:types[:to[{relation_options}]"
|
14
14
|
|
15
15
|
end
|
16
16
|
|
@@ -18,19 +18,12 @@ module Faalis
|
|
18
18
|
# An array of fields like
|
19
19
|
# [name, type]
|
20
20
|
def fields
|
21
|
-
pattern = /(?<name>[^:\{\}]+):(?<type>[^:\{\}]+)[:]?(?:(?<to>[^:\{\}]+)(?:\{(?<options>.+)\})*)*/i
|
22
21
|
fields = []
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
type = matched["type"]
|
29
|
-
to = matched["to"]
|
30
|
-
options = matched["options"] || ""
|
31
|
-
else
|
32
|
-
raise Exception.new "Fields should be in FIELD_NAME:FIELD_TYPE[:RELATION[{OPTIONS}]]"
|
33
|
-
end
|
22
|
+
resource_data["fields"].each do |field|
|
23
|
+
name = field["name"]
|
24
|
+
type = field["type"]
|
25
|
+
to = field["to"]
|
26
|
+
options = field["options"] || {}
|
34
27
|
|
35
28
|
if ["belongs_to", "has_many", "in"].include? type
|
36
29
|
type = Relation.new(type, to, options)
|
@@ -46,7 +39,7 @@ module Faalis
|
|
46
39
|
end
|
47
40
|
|
48
41
|
def grid_fields
|
49
|
-
|
42
|
+
fields_with("view_in_grid", true)
|
50
43
|
end
|
51
44
|
|
52
45
|
# Return an string to use as a function parameters each
|
@@ -88,6 +81,24 @@ module Faalis
|
|
88
81
|
result
|
89
82
|
end
|
90
83
|
|
84
|
+
def fields_with(attr, value)
|
85
|
+
fields.select do |f|
|
86
|
+
if f.include? attr
|
87
|
+
if f[attr] == value
|
88
|
+
true
|
89
|
+
else
|
90
|
+
false
|
91
|
+
end
|
92
|
+
else
|
93
|
+
false
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def no_filter?
|
100
|
+
resource_data.include? "no_filter" && resource_data["no_filter"]
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
93
104
|
end
|
@@ -5,35 +5,35 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
7
|
# Name of the resource to create.
|
8
|
-
base.argument :resource_name, :type => :string, :required => true
|
8
|
+
#base.argument :resource_name, :type => :string, :required => true
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
13
|
# Path to the resource
|
14
14
|
def resource_path
|
15
|
-
path_parts =
|
15
|
+
path_parts = resource_data["name"].split("/")
|
16
16
|
if path_parts.length > 1
|
17
17
|
return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].underscore}"
|
18
18
|
end
|
19
|
-
|
19
|
+
resource_data["name"].underscore
|
20
20
|
end
|
21
21
|
|
22
22
|
# Url of resource
|
23
23
|
def resource_url
|
24
|
-
path_parts =
|
24
|
+
path_parts = resource_data["name"].split("/")
|
25
25
|
if path_parts.length > 1
|
26
26
|
return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].pluralize.underscore}"
|
27
27
|
end
|
28
|
-
|
28
|
+
resource_data["name"].pluralize.underscore
|
29
29
|
end
|
30
30
|
|
31
31
|
def resource
|
32
|
-
path_parts =
|
32
|
+
path_parts = resource_data["name"].split("/")
|
33
33
|
if path_parts.length > 1
|
34
34
|
return path_parts[-1].camelize
|
35
35
|
end
|
36
|
-
|
36
|
+
resource_data["name"].camelize
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
@@ -5,7 +5,7 @@ module Faalis
|
|
5
5
|
|
6
6
|
def self.included(base)
|
7
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."
|
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
9
|
end
|
10
10
|
|
11
11
|
private
|
@@ -13,15 +13,12 @@ module Faalis
|
|
13
13
|
# Process the user provided tabs
|
14
14
|
# @return a Hash of tabs like
|
15
15
|
def tabs
|
16
|
-
if
|
17
|
-
tabs =
|
16
|
+
if resource_data.include? "tabs"
|
17
|
+
tabs = resource_data"tabs"
|
18
18
|
result = {}
|
19
19
|
tabs.each do |tab|
|
20
|
-
name
|
21
|
-
fields_list = []
|
22
|
-
unless fields.nil?
|
23
|
-
fields_list = fields.split(";")
|
24
|
-
end
|
20
|
+
name = tab["name"]
|
21
|
+
fields_list = fields_with("tab", tab["id"])
|
25
22
|
result[name] = fields_list
|
26
23
|
end
|
27
24
|
return result
|
@@ -31,7 +28,7 @@ module Faalis
|
|
31
28
|
end
|
32
29
|
|
33
30
|
def any_tabs?
|
34
|
-
|
31
|
+
resource_data.include? "tabs"
|
35
32
|
end
|
36
33
|
|
37
34
|
end
|
@@ -6,6 +6,7 @@ module Faalis
|
|
6
6
|
class DashboardScaffold < Rails::Generators::Base
|
7
7
|
|
8
8
|
include ActionView::Helpers::TextHelper
|
9
|
+
include Faalis::Generators::Concerns::JsonInput
|
9
10
|
include Faalis::Generators::Concerns::ResourceName
|
10
11
|
include Faalis::Generators::Concerns::ResourceFields
|
11
12
|
include Faalis::Generators::Concerns::Menu
|
@@ -14,14 +14,14 @@ module Faalis
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to
|
17
|
-
result = "
|
17
|
+
result = ""
|
18
18
|
if options.include? "parents"
|
19
19
|
field_parents.each do |parent|
|
20
20
|
result = "#{result}/#{parent}/' + $scope.#{parent}_id + '"
|
21
21
|
end
|
22
22
|
result = "#{result}/"
|
23
23
|
end
|
24
|
-
"#{result}#{@to}
|
24
|
+
"#{result}#{@to}"
|
25
25
|
end
|
26
26
|
|
27
27
|
def options
|
data/lib/faalis/version.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
<div class="details">
|
2
|
-
<% fields.each do |
|
2
|
+
<% fields.each do |f, field_type| %>
|
3
3
|
<p>
|
4
4
|
<% case field_type
|
5
|
-
when "belongs_to" %> <b translate><%=
|
5
|
+
when "belongs_to" %> <b translate><%= f.capitalize %> :</b> {{object.<%= f %>.name}}
|
6
6
|
<% when "has_many" %><p>
|
7
|
-
<b translate><%=
|
7
|
+
<b translate><%= f.capitalize %> :</b>
|
8
8
|
<ul>
|
9
|
-
<li ng-repeat="item in object.<%=
|
9
|
+
<li ng-repeat="item in object.<%= f %>"> {{ item.name }}</li>
|
10
10
|
</ul>
|
11
11
|
</p>
|
12
|
-
<% else %><b translate><%=
|
12
|
+
<% else %><b translate><%= f.capitalize %> :</b> {{object.<%= f %>}}
|
13
13
|
<% end %></p>
|
14
14
|
<% end %>
|
15
15
|
<ul class="button-group float-right">
|
@@ -1,7 +1,7 @@
|
|
1
|
-
<% unless
|
1
|
+
<% unless no_filter? %>
|
2
2
|
<filter config="filter_config" result="<%= resource.pluralize.underscore %>"></filter>
|
3
3
|
<% end %>
|
4
|
-
<% unless
|
4
|
+
<% unless no_bulk? %>
|
5
5
|
<div ng-if="bulk_edit" class="fade_anim">
|
6
6
|
<form id="bulk_form">
|
7
7
|
<fieldset class="row clearmargin">
|
@@ -55,7 +55,7 @@
|
|
55
55
|
</div>
|
56
56
|
</div>
|
57
57
|
<% end %>
|
58
|
-
<list-view buttons="buttons" model="'<% if model_specified? %><%= model %><% else %><%= resource %><% end %>'" objects="<%= resource.pluralize.underscore %>" title-attribute="'<%=
|
58
|
+
<list-view buttons="buttons" model="'<% if model_specified? %><%= model %><% else %><%= resource %><% end %>'" objects="<%= resource.pluralize.underscore %>" title-attribute="'<%= resource_data["title_field"] %>'" details-template="details_template" item-per-page="10" on_delete="on_delete" column_defs="columns">
|
59
59
|
<div class="small-6 column text-left clearpadding">
|
60
60
|
<h3><i class="fa fa-group"></i> <span translate><%= resource.underscore.pluralize.humanize %></span></h3>
|
61
61
|
</div>
|
@@ -1,26 +1,5 @@
|
|
1
|
-
<% if is_in_engine? %>
|
2
|
-
/* -----------------------------------------------------------------------------
|
3
|
-
Faalis - Basic website skel engine
|
4
|
-
Copyright (C) 2012-2013 Yellowen
|
5
|
-
|
6
|
-
This program is free software; you can redistribute it and/or modify
|
7
|
-
it under the terms of the GNU General Public License as published by
|
8
|
-
the Free Software Foundation; either version 2 of the License, or
|
9
|
-
(at your option) any later version.
|
10
|
-
|
11
|
-
This program is distributed in the hope that it will be useful,
|
12
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
-
GNU General Public License for more details.
|
15
|
-
|
16
|
-
You should have received a copy of the GNU General Public License along
|
17
|
-
with this program; if not, write to the Free Software Foundation, Inc.,
|
18
|
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
19
|
-
----------------------------------------------------------------------------- */
|
20
|
-
|
21
|
-
<% end %>
|
22
1
|
// <%= resource.pluralize %> Module
|
23
|
-
var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "Filter", "Anim", "Fields",<% if
|
2
|
+
var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "Filter", "Anim", "Fields",<% if resource_data[:deps] %><% resource_data[:deps].each do |dependency| %> "<%= dependency.camelize %>", <% end %><% end %>]);
|
24
3
|
|
25
4
|
// <%= resource.pluralize %> configuration section ---------------------------
|
26
5
|
<%= resource.pluralize %>.config(["$routeProvider", function($routeProvider){
|
@@ -44,17 +23,16 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
44
23
|
|
45
24
|
// <%= resource %> index controller -------------------------------------------------------
|
46
25
|
// This controller is responsible for list page (index)
|
47
|
-
<%= resource.pluralize %>.controller("<%= resource %>Controller", ["$scope", "gettext", "Restangular", "catch_error", "$location", "$routeParams",
|
48
|
-
function($scope, gettext, API, catch_error, $location, $routeParams){
|
26
|
+
<%= resource.pluralize %>.controller("<%= resource %>Controller", ["$scope", "gettext", "Restangular", "catch_error", "$location", "$routeParams", function($scope, gettext, API, catch_error, $location, $routeParams){
|
49
27
|
|
50
28
|
<% parents.each do |parent| %>
|
51
|
-
$scope.<%=
|
29
|
+
$scope.<%= parent %>_id = $routeParams.<%= parent %>_id;
|
52
30
|
<% end %>
|
53
|
-
<% unless
|
31
|
+
<% unless no_filter? %>$scope.filter_config = {
|
54
32
|
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 %>
|
55
33
|
};
|
56
34
|
$scope.<%= resource.pluralize.underscore %> = [];<% end %>
|
57
|
-
<% unless
|
35
|
+
<% unless no_bulk? %>// Cache object for each field name possible values
|
58
36
|
$scope.cache = {};
|
59
37
|
|
60
38
|
// Change event handler for field_name combobox in bulk edit
|
@@ -100,7 +78,7 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
100
78
|
},
|
101
79
|
route: "#<% parents.each do |p| %>/<%= p %>/" + $scope.<%= p %>_id + "<% end %>/<%= resource_url %>/new"
|
102
80
|
|
103
|
-
},<% unless
|
81
|
+
},<% unless no_bulk? %>
|
104
82
|
{
|
105
83
|
title: gettext("Bulk Edit"),
|
106
84
|
icon: "fa fa-edit",
|
@@ -136,7 +114,7 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
136
114
|
}
|
137
115
|
}
|
138
116
|
|
139
|
-
];<% unless
|
117
|
+
];<% unless no_bulk? %>
|
140
118
|
|
141
119
|
/*
|
142
120
|
* On bulk save event
|
@@ -216,7 +194,7 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
216
194
|
});
|
217
195
|
|
218
196
|
};
|
219
|
-
<% unless
|
197
|
+
<% unless no_filter? %>/*<% end %>
|
220
198
|
<% if parent? %>API.<% parents.each do |parent| %>one("<%= parent %>", $scope.<%= parent %>_id)<% end %>.all("<%= resource.pluralize.underscore %>").getList()<% else %>
|
221
199
|
API.all("<%= resource.pluralize.underscore %>").getList()<% end %>
|
222
200
|
.then(function(data){
|
@@ -224,7 +202,7 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
224
202
|
}, function(data){
|
225
203
|
catch_error(data);
|
226
204
|
});
|
227
|
-
<% unless
|
205
|
+
<% unless no_filter? %>*/<% end %>
|
228
206
|
}]);
|
229
207
|
|
230
208
|
<%= resource.pluralize %>.controller("Add<%= resource %>Controller", ["Restangular", "$scope", "$location", "$routeParams", "gettext", "catch_error", function(API, $scope, $location, $routeParams, gettext, catch_error){
|
@@ -245,8 +223,9 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
245
223
|
<% fields.each do |name, type| %><% if ["belongs_to", "in", "has_many"].include? type %>
|
246
224
|
$scope.<%= name %>_data = {
|
247
225
|
type: '<%= type %>',<% if type == "in" %>
|
248
|
-
choices: _.sortBy([<% type.to.split(",").each do |choice| %>{name: "<%= choice.underscore %>", title: "<%= choice.humanize %>"},<% end %>])
|
249
|
-
|
226
|
+
choices: _.sortBy([<% type.to.split(",").each do |choice| %>{name: "<%= choice.underscore %>", title: "<%= choice.humanize %>"},<% end %>]),
|
227
|
+
<% else %>
|
228
|
+
to: '<%= type.to %>',<% end %>
|
250
229
|
name: '<%= name %>'
|
251
230
|
};<% end %><% end %>
|
252
231
|
<% fields.each do |name, type| %><% if type == "in" %>$scope.<%= name %>_choices = _.sortBy([<% type.to.split(",").each do |choice| %>
|
@@ -325,9 +304,9 @@ var <%= resource.pluralize %> = angular.module("<%= resource %>", ["ListView", "
|
|
325
304
|
|
326
305
|
};
|
327
306
|
}]);
|
328
|
-
<%
|
307
|
+
<% if has_menu? %>
|
329
308
|
<%= resource.pluralize %>.controller("<%= resource %>MenuController", ["gettext", function(gettext){
|
330
|
-
this.menu_items = [<%
|
331
|
-
{title: gettext("<%= title %>"), url: "<%= url %>"<% if model %>, permission: {action: "read", model: "<%= model %>"}<% end %>},<% end %>
|
309
|
+
this.menu_items = [<% resource_data["menu"].each do |menu| %>
|
310
|
+
{title: gettext("<%= meun["title"] %>"), url: "<%= menu["url"] %>"<% if menu.include? "model" %>, permission: {action: "<%= menu["perm_action"] || 'read' %>", model: "<%= menu["model"] %>"}<% end %>},<% end %>
|
332
311
|
];
|
333
312
|
}]);<% end %>
|
@@ -1,10 +1,11 @@
|
|
1
1
|
json.array! @<%= resource.pluralize.underscore %> do |<%= resource.underscore %>|
|
2
2
|
json.extract! <%= resource.underscore %>, :id<%= fields_as_params %><% fields.each do |name, type| %><% case type
|
3
3
|
when "belongs_to" %>
|
4
|
-
json.<%= name %> do
|
5
|
-
|
6
|
-
|
4
|
+
json.<%= name %> do
|
5
|
+
if <%= resource.underscore %>.<%= name %>
|
6
|
+
json.id <%= resource.underscore %>.<%= name %>.id
|
7
|
+
json.name <%= resource.underscore %>.<%= name %>.name
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
<% when "has_many" %> json.<%= name %> <%= resource.underscore %>.<%= name %>, :id, :name<% end %><% end %>
|
10
11
|
end
|
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.20.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-03-
|
12
|
+
date: 2014-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -138,19 +138,19 @@ dependencies:
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name: foundation
|
141
|
+
name: zurb-foundation
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
|
-
- - "
|
144
|
+
- - "~>"
|
145
145
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
146
|
+
version: 4.0.0
|
147
147
|
type: :runtime
|
148
148
|
prerelease: false
|
149
149
|
version_requirements: !ruby/object:Gem::Requirement
|
150
150
|
requirements:
|
151
|
-
- - "
|
151
|
+
- - "~>"
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version:
|
153
|
+
version: 4.0.0
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: font-awesome-rails
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -593,6 +593,7 @@ files:
|
|
593
593
|
- lib/faalis/generators/concerns/angular.rb
|
594
594
|
- lib/faalis/generators/concerns/bulk.rb
|
595
595
|
- lib/faalis/generators/concerns/dependency.rb
|
596
|
+
- lib/faalis/generators/concerns/json_input.rb
|
596
597
|
- lib/faalis/generators/concerns/menu.rb
|
597
598
|
- lib/faalis/generators/concerns/model.rb
|
598
599
|
- lib/faalis/generators/concerns/parent.rb
|