rbbt-rest 1.8.44 → 1.8.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/rest/common/cache.rb +18 -5
- data/lib/rbbt/rest/common/locate.rb +17 -8
- data/lib/rbbt/rest/common/tabs.rb +43 -0
- data/lib/rbbt/rest/entity/helpers.rb +4 -3
- data/lib/rbbt/rest/entity/locate.rb +442 -227
- data/lib/rbbt/rest/main.rb +1 -1
- data/lib/rbbt/rest/workflow/locate.rb +42 -22
- data/share/views/partials/tabs.haml +28 -0
- data/share/views/public/js/rbbt.basic.js +8 -0
- data/share/views/public/js/rbbt.favourites.js +4 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40e90eddb36c53c25372a680f163a3a1e7c06b09
|
4
|
+
data.tar.gz: 809f9e0ee244cad3c4afff02bfde90ce21e313a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df5b716ef38910f33193ca6f719a03dbad2ab054b3d2d3c5c03f03b5539f06f6f12ae089c89c04f2fcdbee0e01dcc0f7fa567425900420b4eb3b1063a2a3eabd
|
7
|
+
data.tar.gz: e59d885e8cabc4b0f9a231a16bfd794e057d586c2ec8a778960cac69b54a59dea0e209bcbe84ee5210b604e04be7523b6cce969dff1d62f75744523b4e875fbd
|
@@ -92,6 +92,7 @@ module RbbtRESTHelpers
|
|
92
92
|
step.fork
|
93
93
|
step.soft_grace
|
94
94
|
end
|
95
|
+
step.set_info :template_file, params[:_template_file]
|
95
96
|
end
|
96
97
|
|
97
98
|
# Return fragment
|
@@ -113,8 +114,9 @@ module RbbtRESTHelpers
|
|
113
114
|
content_type "application/json"
|
114
115
|
halt 200, list.compact.to_json
|
115
116
|
when "entities"
|
116
|
-
|
117
|
-
tsv = tsv_process(
|
117
|
+
raw_tsv, tsv_options = load_tsv(fragment_file)
|
118
|
+
tsv = tsv_process(raw_tsv)
|
119
|
+
|
118
120
|
list = tsv.values.flatten
|
119
121
|
tsv.prepare_entity(list, tsv.fields.first, tsv.entity_options)
|
120
122
|
type = list.annotation_types.last
|
@@ -126,9 +128,20 @@ module RbbtRESTHelpers
|
|
126
128
|
url = url + '?_layout=false' unless @layout
|
127
129
|
redirect to(url)
|
128
130
|
when "map"
|
129
|
-
|
130
|
-
|
131
|
+
raw_tsv, tsv_options = load_tsv(fragment_file)
|
132
|
+
raw_tsv.unnamed = true
|
133
|
+
Log.tsv raw_tsv
|
134
|
+
tsv = tsv_process(raw_tsv)
|
135
|
+
|
136
|
+
field = tsv.key_field
|
131
137
|
column = tsv.fields.first
|
138
|
+
|
139
|
+
if tsv.entity_templates[field]
|
140
|
+
type = tsv.entity_templates[field].annotation_types.first
|
141
|
+
else
|
142
|
+
type = [Entity.formats[field]].compact.first || field
|
143
|
+
end
|
144
|
+
|
132
145
|
map_id = "Map #{type}-#{column} in #{ @fragment }"
|
133
146
|
map_id << " (#{ @filter.gsub(';','|') })" if @filter
|
134
147
|
Entity::Map.save_map(type.to_s, column, map_id, tsv, user)
|
@@ -137,7 +150,7 @@ module RbbtRESTHelpers
|
|
137
150
|
redirect to(url)
|
138
151
|
when "excel"
|
139
152
|
require 'rbbt/tsv/excel'
|
140
|
-
tsv = load_tsv(fragment_file)
|
153
|
+
tsv, tsv_options = load_tsv(fragment_file)
|
141
154
|
content_type "text/html"
|
142
155
|
data = nil
|
143
156
|
excel_file = TmpFile.tmp_file
|
@@ -1,7 +1,9 @@
|
|
1
|
+
|
2
|
+
class TemplateMissing < StandardError; end
|
3
|
+
|
1
4
|
module RbbtRESTHelpers
|
2
5
|
attr_accessor :template_resources, :sass_resources, :javascript_resources, :plugin_resources
|
3
6
|
|
4
|
-
class TemplateMissing < StandardError; end
|
5
7
|
|
6
8
|
#{{{ Common
|
7
9
|
|
@@ -20,6 +22,18 @@ module RbbtRESTHelpers
|
|
20
22
|
return path.find if path.exists?
|
21
23
|
end
|
22
24
|
|
25
|
+
def glob_all_server_files(file, resources)
|
26
|
+
path = Path.setup(file)
|
27
|
+
add_search_paths(path, resources)
|
28
|
+
path.glob_all
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_all_server_files(file, resource)
|
32
|
+
path = Path.setup(file)
|
33
|
+
add_search_paths(path, resources)
|
34
|
+
path.find_all
|
35
|
+
end
|
36
|
+
|
23
37
|
#{{{ TEMPLATE
|
24
38
|
|
25
39
|
def self.template_resources
|
@@ -53,18 +67,13 @@ module RbbtRESTHelpers
|
|
53
67
|
end
|
54
68
|
|
55
69
|
def find_all(file)
|
56
|
-
|
57
|
-
add_search_paths(path, file_resources)
|
58
|
-
path.find_all
|
70
|
+
find_all_server_files(file, file_resources)
|
59
71
|
end
|
60
72
|
|
61
73
|
def glob_all(file)
|
62
|
-
|
63
|
-
add_search_paths(path, file_resources)
|
64
|
-
path.glob_all
|
74
|
+
glob_all_server_files(file, file_resources)
|
65
75
|
end
|
66
76
|
|
67
|
-
|
68
77
|
#{{{ SASS
|
69
78
|
|
70
79
|
def self.add_sass_load_path(path)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
module RbbtRESTHelpers
|
3
|
+
class Tabs
|
4
|
+
attr_accessor :headers, :codes, :content, :classes, :tab_classes
|
5
|
+
def initialize(page)
|
6
|
+
@page = page
|
7
|
+
end
|
8
|
+
|
9
|
+
def add(header = nil, code = nil, &block)
|
10
|
+
|
11
|
+
@headers ||= []
|
12
|
+
@codes ||= {}
|
13
|
+
@content ||= {}
|
14
|
+
|
15
|
+
if block_given?
|
16
|
+
html = @page.capture_haml &block
|
17
|
+
else
|
18
|
+
html = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
@headers << header
|
22
|
+
@codes[header] = code.to_s if code
|
23
|
+
@content[header] = html
|
24
|
+
end
|
25
|
+
|
26
|
+
def active(header=nil)
|
27
|
+
@active ||= header.nil? ? false : header
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def tabs(&block)
|
32
|
+
tab = Tabs.new(self)
|
33
|
+
block.call(tab)
|
34
|
+
|
35
|
+
tab.headers.each do |header|
|
36
|
+
code = tab.codes[header] || Misc.digest(header)
|
37
|
+
content = tab.content[header]
|
38
|
+
end
|
39
|
+
|
40
|
+
partial_render('partials/tabs', :headers => tab.headers, :codes => tab.codes, :content => tab.content, :active => tab.active)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rbbt/util/misc/annotated_module'
|
1
2
|
|
2
3
|
module EntityRESTHelpers
|
3
4
|
|
@@ -28,7 +29,7 @@ module EntityRESTHelpers
|
|
28
29
|
|
29
30
|
def action_parameters(values = nil, action_options = {}, form_options = {}, &block)
|
30
31
|
o = Object.new
|
31
|
-
o.extend
|
32
|
+
o.extend InputModule
|
32
33
|
|
33
34
|
if values.nil?
|
34
35
|
values = @clean_params
|
@@ -38,7 +39,7 @@ module EntityRESTHelpers
|
|
38
39
|
|
39
40
|
o.instance_eval &block
|
40
41
|
|
41
|
-
description = o.description
|
42
|
+
#description = o.description
|
42
43
|
|
43
44
|
inputs = o.inputs || []
|
44
45
|
input_types = o.input_types
|
@@ -60,7 +61,7 @@ module EntityRESTHelpers
|
|
60
61
|
locals[:action] = @ajax_url
|
61
62
|
locals[:klass] = 'action_parameter_form'
|
62
63
|
locals[:info] = info
|
63
|
-
locals[:description] = description
|
64
|
+
#locals[:description] = description
|
64
65
|
locals[:method] = 'GET'
|
65
66
|
locals = locals.merge(form_options)
|
66
67
|
|
@@ -7,10 +7,16 @@ module EntityRESTHelpers
|
|
7
7
|
def entity_resources
|
8
8
|
[Rbbt.share.views.find(:lib)] + EntityRESTHelpers.entity_resources
|
9
9
|
end
|
10
|
+
|
11
|
+
def resources_for_entity(entity)
|
12
|
+
resources = entity_resources
|
13
|
+
resources.unshift entity.dir.www.views if entity.respond_to? :dir and Path === entity.dir
|
14
|
+
resources
|
15
|
+
end
|
10
16
|
|
11
17
|
#{{{ CHECKS
|
12
18
|
|
13
|
-
def reject_template(path,binding)
|
19
|
+
def reject_template(path, binding)
|
14
20
|
check_file = path.sub(/\.haml$/, '.check')
|
15
21
|
|
16
22
|
if Path === path
|
@@ -34,114 +40,137 @@ module EntityRESTHelpers
|
|
34
40
|
|
35
41
|
#{{{ ENTITY
|
36
42
|
|
37
|
-
def locate_entity_template_from_resource(resource, entity)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
#def locate_entity_template_from_resource(resource, entity)
|
44
|
+
# if entity == "Default"
|
45
|
+
# path = resource.entity["Default.haml"]
|
46
|
+
# if path.exists?
|
47
|
+
# return path
|
48
|
+
# else
|
49
|
+
# return nil
|
50
|
+
# end
|
51
|
+
# end
|
46
52
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
53
|
+
# entity.annotation_types.each do |annotation|
|
54
|
+
# path = resource.entity[annotation.to_s + ".haml"]
|
55
|
+
# return path if path.exists?
|
56
|
+
# end
|
51
57
|
|
52
|
-
|
53
|
-
end
|
58
|
+
# nil
|
59
|
+
#end
|
54
60
|
|
55
|
-
def locate_entity_template(entity)
|
61
|
+
#def locate_entity_template(entity)
|
56
62
|
|
57
|
-
|
58
|
-
|
63
|
+
# if entity.respond_to? :dir and Path === entity.dir
|
64
|
+
# entity_views = entity.dir.www.views
|
59
65
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
66
|
+
# entity.annotation_types.each do |annotation|
|
67
|
+
# path = entity_views.entity[annotation.to_s + ".haml"]
|
68
|
+
# return path if path.exists?
|
69
|
+
# end
|
70
|
+
# end
|
65
71
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
72
|
+
# entity_resources.each do |resource|
|
73
|
+
# path = locate_entity_template_from_resource(resource, entity)
|
74
|
+
# return path if path and path.exists?
|
75
|
+
# end
|
70
76
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
# entity_resources.each do |resource|
|
78
|
+
# path = locate_entity_template_from_resource(resource, "Default")
|
79
|
+
# return path if path and path.exists?
|
80
|
+
# end
|
75
81
|
|
76
|
-
|
77
|
-
end
|
82
|
+
# raise "Template not found for entity: #{ entity } (#{entity.annotation_types * ", "})"
|
83
|
+
#end
|
78
84
|
|
79
|
-
|
85
|
+
|
86
|
+
def locate_entity_template(entity)
|
87
|
+
resources = resources_for_entity(entity)
|
80
88
|
|
81
|
-
|
82
|
-
|
83
|
-
path = resource.entity["Default"][action.to_s + ".haml"]
|
84
|
-
raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
|
85
|
-
if path.exists?
|
86
|
-
return path
|
87
|
-
else
|
88
|
-
return nil
|
89
|
-
end
|
90
|
-
end
|
89
|
+
types = entity.annotation_types.collect{|e| e.to_s}
|
90
|
+
types << "Default"
|
91
91
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
return path if path.exists?
|
92
|
+
path = nil
|
93
|
+
types.each do |type|
|
94
|
+
path ||= locate_server_file(["entity", type]*"/", resources, 'haml')
|
96
95
|
end
|
97
96
|
|
98
|
-
nil
|
99
|
-
end
|
97
|
+
raise TemplateMissing, "Template not found for entity: #{ entity } (#{entity.annotation_types * ", "})" if path.nil?
|
100
98
|
|
101
|
-
|
99
|
+
path
|
100
|
+
end
|
102
101
|
|
103
|
-
if entity.respond_to? :dir and Path === entity.dir
|
104
|
-
path = locate_entity_action_template_from_resource(entity.dir.www.views, entity, action)
|
105
|
-
return path if path and path.exists?
|
106
|
-
end
|
107
102
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
103
|
+
#{{{ ENTITY ACTION
|
104
|
+
|
105
|
+
#def locate_entity_action_template_from_resource(resource, entity, action)
|
106
|
+
# if entity == "Default"
|
107
|
+
# path = resource.entity["Default"][action.to_s + ".haml"]
|
108
|
+
# raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
|
109
|
+
# if path.exists?
|
110
|
+
# return path
|
111
|
+
# else
|
112
|
+
# return nil
|
113
|
+
# end
|
114
|
+
# end
|
115
|
+
|
116
|
+
# entity.annotation_types.each do |annotation|
|
117
|
+
# path = resource.entity[annotation][action.to_s + ".haml"]
|
118
|
+
# raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
|
119
|
+
# return path if path.exists?
|
120
|
+
# end
|
121
|
+
|
122
|
+
# nil
|
123
|
+
#end
|
124
|
+
|
125
|
+
#def locate_entity_action_template(entity, action)
|
126
|
+
|
127
|
+
# if entity.respond_to? :dir and Path === entity.dir
|
128
|
+
# path = locate_entity_action_template_from_resource(entity.dir.www.views, entity, action)
|
129
|
+
# return path if path and path.exists?
|
130
|
+
# end
|
131
|
+
|
132
|
+
# entity_resources.each do |resource|
|
133
|
+
# path = locate_entity_action_template_from_resource(resource, entity, action)
|
134
|
+
# return path if path and path.exists?
|
135
|
+
# end
|
136
|
+
|
137
|
+
# entity_resources.each do |resource|
|
138
|
+
# path = locate_entity_action_template_from_resource(resource, "Default", action)
|
139
|
+
# raise "This action was rejected: #{ action }" if reject_template(path,binding)
|
140
|
+
# return path if path and path.exists?
|
141
|
+
# end
|
142
|
+
|
143
|
+
# raise "Template not found for action #{action}: #{ entity } (#{entity.annotation_types * ", "})"
|
144
|
+
#end
|
112
145
|
|
113
|
-
|
114
|
-
|
146
|
+
def locate_entity_action_template(entity, action)
|
147
|
+
resources = resources_for_entity(entity)
|
148
|
+
|
149
|
+
types = entity.annotation_types.collect{|e| e.to_s}
|
150
|
+
types << "Default"
|
151
|
+
|
152
|
+
path = nil
|
153
|
+
types.each do |type|
|
154
|
+
next if path
|
155
|
+
path = locate_server_file(["entity", type, action]*"/", resources, 'haml')
|
115
156
|
raise "This action was rejected: #{ action }" if reject_template(path,binding)
|
116
|
-
return path if path and path.exists?
|
117
157
|
end
|
118
158
|
|
119
|
-
raise "Template not found for action #{action}: #{ entity } (#{entity.annotation_types * ", "})"
|
120
|
-
end
|
159
|
+
raise TemplateMissing, "Template not found for entity action #{action}: #{ entity } (#{entity.annotation_types * ", "})" if path.nil?
|
121
160
|
|
122
|
-
|
123
|
-
|
124
|
-
resource.entity["Default"].glob("*.haml").sort
|
125
|
-
else
|
126
|
-
entity.annotation_types.collect do |annotation|
|
127
|
-
resource.entity[annotation].glob('*.haml')
|
128
|
-
end.compact.flatten.sort
|
129
|
-
end
|
130
|
-
end
|
161
|
+
path
|
162
|
+
end
|
131
163
|
|
132
164
|
def find_all_entity_action_templates(entity, check = false)
|
133
|
-
|
165
|
+
resources = resources_for_entity(entity)
|
134
166
|
|
135
|
-
|
136
|
-
|
137
|
-
end
|
167
|
+
types = entity.annotation_types.collect{|e| e.to_s}
|
168
|
+
types << "Default"
|
138
169
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
entity_resources.each do |resource|
|
144
|
-
paths.concat find_all_entity_action_templates_from_resource(resource, "Default")
|
170
|
+
paths = types.inject([]) do |acc,type|
|
171
|
+
acc += glob_all_server_files(["entity", type, "*.haml"]*"/", resources).reject{|path|
|
172
|
+
reject_template(path,binding)
|
173
|
+
}
|
145
174
|
end
|
146
175
|
|
147
176
|
if check
|
@@ -162,118 +191,228 @@ module EntityRESTHelpers
|
|
162
191
|
|
163
192
|
actions
|
164
193
|
end
|
194
|
+
|
195
|
+
#def find_all_entity_action_templates_from_resource(resource, entity)
|
196
|
+
# if entity == "Default"
|
197
|
+
# resource.entity["Default"].glob("*.haml").sort
|
198
|
+
# else
|
199
|
+
# entity.annotation_types.collect do |annotation|
|
200
|
+
# resource.entity[annotation].glob('*.haml')
|
201
|
+
# end.compact.flatten.sort
|
202
|
+
# end
|
203
|
+
#end
|
204
|
+
|
205
|
+
#def find_all_entity_action_templates(entity, check = false)
|
206
|
+
# paths = []
|
207
|
+
|
208
|
+
# if entity.respond_to? :dir and Path === entity.dir
|
209
|
+
# paths.concat find_all_entity_action_templates_from_resource(entity.dir.www.views, entity)
|
210
|
+
# end
|
211
|
+
|
212
|
+
# entity_resources.each do |resource|
|
213
|
+
# paths.concat find_all_entity_action_templates_from_resource(resource, entity)
|
214
|
+
# end
|
215
|
+
|
216
|
+
# entity_resources.each do |resource|
|
217
|
+
# paths.concat find_all_entity_action_templates_from_resource(resource, "Default")
|
218
|
+
# end
|
219
|
+
|
220
|
+
# if check
|
221
|
+
# paths = paths.reject do |path|
|
222
|
+
# (path.basename == "edit.haml" or path.basename == 'new.haml')
|
223
|
+
# end
|
224
|
+
# end
|
225
|
+
|
226
|
+
# actions = paths.collect{|file| file.basename.sub('.haml', '') }.uniq
|
227
|
+
|
228
|
+
# actions.select! do |action|
|
229
|
+
# begin
|
230
|
+
# locate_entity_action_template(entity, action)
|
231
|
+
# rescue Exception
|
232
|
+
# false
|
233
|
+
# end
|
234
|
+
# end if check
|
235
|
+
#
|
236
|
+
# actions
|
237
|
+
#end
|
165
238
|
#{{{ ENTITY LIST
|
166
239
|
|
167
|
-
def locate_entity_list_template_from_resource(resource, list)
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
240
|
+
#def locate_entity_list_template_from_resource(resource, list)
|
241
|
+
# if list == "Default"
|
242
|
+
# path = resource.entity_list["Default.haml"]
|
243
|
+
# if path.exists?
|
244
|
+
# return path
|
245
|
+
# else
|
246
|
+
# return nil
|
247
|
+
# end
|
248
|
+
# end
|
176
249
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
250
|
+
# list.annotation_types.each do |annotation|
|
251
|
+
# path = resource.entity_list[annotation.to_s + ".haml"]
|
252
|
+
# return path if path.exists?
|
253
|
+
# end
|
181
254
|
|
182
|
-
|
183
|
-
end
|
255
|
+
# nil
|
256
|
+
#end
|
184
257
|
|
185
|
-
def locate_entity_list_template(list)
|
258
|
+
#def locate_entity_list_template(list)
|
186
259
|
|
187
|
-
|
188
|
-
|
260
|
+
# if list.respond_to? :dir and Path === list.dir
|
261
|
+
# list_views = list.dir.www.views
|
189
262
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
263
|
+
# list.annotation_types.each do |annotation|
|
264
|
+
# path = list_views.entity_list[annotation.to_s + ".haml"]
|
265
|
+
# return path if path.exists?
|
266
|
+
# end
|
267
|
+
# end
|
195
268
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
269
|
+
# entity_resources.each do |resource|
|
270
|
+
# path = locate_entity_list_template_from_resource(resource, list)
|
271
|
+
# return path if path and path.exists?
|
272
|
+
# end
|
273
|
+
|
274
|
+
# entity_resources.each do |resource|
|
275
|
+
# path = locate_entity_list_template_from_resource(resource, "Default")
|
276
|
+
# return path if path and path.exists?
|
277
|
+
# end
|
278
|
+
|
279
|
+
# raise "Template not found for list (#{list.annotation_types * ", "})"
|
280
|
+
#end
|
281
|
+
|
282
|
+
def locate_entity_list_template(list)
|
283
|
+
resources = resources_for_entity(list)
|
200
284
|
|
201
|
-
|
202
|
-
|
203
|
-
|
285
|
+
types = list.annotation_types.collect{|e| e.to_s}
|
286
|
+
types << "Default"
|
287
|
+
|
288
|
+
path = nil
|
289
|
+
types.each do |type|
|
290
|
+
path ||= locate_server_file(["entity_list", type]*"/", resources, 'haml')
|
204
291
|
end
|
205
292
|
|
206
|
-
raise "Template not found for list (#{list.annotation_types * ", "})"
|
293
|
+
raise TemplateMissing, "Template not found for list (#{list.annotation_types * ", "})" if path.nil?
|
294
|
+
|
295
|
+
path
|
207
296
|
end
|
208
297
|
|
209
298
|
|
299
|
+
|
210
300
|
#{{{ ENTITY LIST ACTION
|
211
301
|
|
212
302
|
|
213
|
-
def locate_entity_list_action_template_from_resource(resource, list, action)
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
end
|
303
|
+
#def locate_entity_list_action_template_from_resource(resource, list, action)
|
304
|
+
# if list == "Default"
|
305
|
+
# path = resource.entity_list["Default"][action.to_s + ".haml"]
|
306
|
+
# raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
|
307
|
+
# if path.exists?
|
308
|
+
# return path
|
309
|
+
# else
|
310
|
+
# return nil
|
311
|
+
# end
|
312
|
+
# end
|
313
|
+
|
314
|
+
# list.annotation_types.each do |annotation|
|
315
|
+
# path = resource.entity_list[annotation][action.to_s + ".haml"]
|
316
|
+
# raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
|
317
|
+
# return path if path.exists?
|
318
|
+
# end
|
319
|
+
|
320
|
+
# nil
|
321
|
+
#end
|
322
|
+
|
323
|
+
#def locate_entity_list_action_template(list, action)
|
324
|
+
|
325
|
+
# if list.respond_to? :dir and Path === list.dir
|
326
|
+
# path = locate_entity_list_action_template_from_resource(list.dir.www.views, list, action)
|
327
|
+
# return path if path and path.exists?
|
328
|
+
# end
|
329
|
+
|
330
|
+
# entity_resources.each do |resource|
|
331
|
+
# path = locate_entity_list_action_template_from_resource(resource, list, action)
|
332
|
+
# return path if path and path.exists?
|
333
|
+
# end
|
334
|
+
|
335
|
+
# entity_resources.each do |resource|
|
336
|
+
# path = locate_entity_list_action_template_from_resource(resource, "Default", action)
|
337
|
+
# return path if path and path.exists?
|
338
|
+
# end
|
339
|
+
|
340
|
+
# raise "Template not found for list #{ action } (#{list.annotation_types * ", "})"
|
341
|
+
#end
|
342
|
+
|
343
|
+
#def find_all_entity_list_action_templates_from_resource(resource, entity)
|
344
|
+
|
345
|
+
# if entity == "Default"
|
346
|
+
# resource.entity_list["Default"].glob("*.haml").sort
|
347
|
+
# else
|
348
|
+
# entity.annotation_types.collect do |annotation|
|
349
|
+
# resource.entity_list[annotation].glob('*.haml')
|
350
|
+
# end.compact.flatten.sort
|
351
|
+
# end
|
352
|
+
#end
|
353
|
+
|
354
|
+
#def find_all_entity_list_action_templates(list, check = false)
|
355
|
+
# paths = []
|
356
|
+
|
357
|
+
# if list.respond_to? :dir and Path === list.dir
|
358
|
+
# paths.concat find_all_entity_list_action_templates_from_resource(list.dir.www.views, list)
|
359
|
+
# end
|
360
|
+
|
361
|
+
# entity_resources.each do |resource|
|
362
|
+
# paths.concat find_all_entity_list_action_templates_from_resource(resource, list)
|
363
|
+
# end
|
364
|
+
|
365
|
+
# entity_resources.each do |resource|
|
366
|
+
# paths.concat find_all_entity_list_action_templates_from_resource(resource, "Default")
|
367
|
+
# end
|
368
|
+
|
369
|
+
# if check
|
370
|
+
# paths = paths.reject do |path|
|
371
|
+
# (path.basename == "edit.haml" or path.basename == 'new.haml')
|
372
|
+
# end
|
373
|
+
# end
|
374
|
+
|
375
|
+
# actions = paths.collect{|file| file.basename.sub('.haml', '') }.uniq
|
376
|
+
|
377
|
+
# actions.select! do |action|
|
378
|
+
# begin
|
379
|
+
# locate_entity_list_action_template(list, action)
|
380
|
+
# rescue Exception
|
381
|
+
# false
|
382
|
+
# end
|
383
|
+
# end if check
|
384
|
+
#
|
385
|
+
# actions
|
386
|
+
#end
|
232
387
|
|
233
388
|
def locate_entity_list_action_template(list, action)
|
389
|
+
resources = resources_for_entity(list)
|
234
390
|
|
235
|
-
|
236
|
-
|
237
|
-
return path if path and path.exists?
|
238
|
-
end
|
391
|
+
types = list.annotation_types.collect{|e| e.to_s}
|
392
|
+
types << "Default"
|
239
393
|
|
240
|
-
|
241
|
-
|
242
|
-
|
394
|
+
path = nil
|
395
|
+
types.each do |type|
|
396
|
+
next if path
|
397
|
+
path = locate_server_file(["entity_list", type, action]*"/", resources, 'haml')
|
398
|
+
raise "This action was rejected: #{ action }" if reject_template(path,binding)
|
243
399
|
end
|
244
400
|
|
245
|
-
|
246
|
-
path = locate_entity_list_action_template_from_resource(resource, "Default", action)
|
247
|
-
return path if path and path.exists?
|
248
|
-
end
|
401
|
+
raise TemplateMissing, "Template not found for entity list action #{action} (#{list.annotation_types * ", "})" if path.nil?
|
249
402
|
|
250
|
-
|
403
|
+
path
|
251
404
|
end
|
252
405
|
|
253
|
-
def find_all_entity_list_action_templates_from_resource(resource, entity)
|
254
|
-
|
255
|
-
if entity == "Default"
|
256
|
-
resource.entity_list["Default"].glob("*.haml").sort
|
257
|
-
else
|
258
|
-
entity.annotation_types.collect do |annotation|
|
259
|
-
resource.entity_list[annotation].glob('*.haml')
|
260
|
-
end.compact.flatten.sort
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
406
|
def find_all_entity_list_action_templates(list, check = false)
|
265
|
-
|
407
|
+
resources = resources_for_entity(list)
|
266
408
|
|
267
|
-
|
268
|
-
|
269
|
-
end
|
409
|
+
types = list.annotation_types.collect{|e| e.to_s}
|
410
|
+
types << "Default"
|
270
411
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
entity_resources.each do |resource|
|
276
|
-
paths.concat find_all_entity_list_action_templates_from_resource(resource, "Default")
|
412
|
+
paths = types.inject([]) do |acc,type|
|
413
|
+
acc += glob_all_server_files(["entity_list", type, "*.haml"]*"/", resources).reject{|path|
|
414
|
+
reject_template(path,binding)
|
415
|
+
}
|
277
416
|
end
|
278
417
|
|
279
418
|
if check
|
@@ -297,95 +436,173 @@ module EntityRESTHelpers
|
|
297
436
|
|
298
437
|
#{{{ ENTITY MAP
|
299
438
|
|
300
|
-
def locate_entity_map_template_from_resource(resource, type)
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
439
|
+
#def locate_entity_map_template_from_resource(resource, type)
|
440
|
+
# if type == "Default"
|
441
|
+
# path = resource.entity_map["Default.haml"]
|
442
|
+
# if path.exists?
|
443
|
+
# return path
|
444
|
+
# else
|
445
|
+
# return nil
|
446
|
+
# end
|
447
|
+
# end
|
309
448
|
|
310
|
-
|
311
|
-
|
449
|
+
# path = resource.entity_map[type.to_s + ".haml"]
|
450
|
+
# return path if path.exists?
|
312
451
|
|
313
|
-
|
314
|
-
end
|
452
|
+
# nil
|
453
|
+
#end
|
315
454
|
|
316
|
-
def locate_entity_map_template(type, column)
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
455
|
+
#def locate_entity_map_template(type, column)
|
456
|
+
# entity_resources.each do |resource|
|
457
|
+
# path = locate_entity_map_template_from_resource(resource, type)
|
458
|
+
# return path if path and path.exists?
|
459
|
+
# end
|
460
|
+
|
461
|
+
# entity_resources.each do |resource|
|
462
|
+
# path = locate_entity_map_template_from_resource(resource, "Default")
|
463
|
+
# return path if path and path.exists?
|
464
|
+
# end
|
321
465
|
|
322
|
-
|
323
|
-
|
324
|
-
|
466
|
+
# raise "Template not found for list (#{type}--#{column})"
|
467
|
+
#end
|
468
|
+
|
469
|
+
|
470
|
+
def locate_entity_map_template(type, column = nil)
|
471
|
+
resources = entity_resources
|
472
|
+
|
473
|
+
types = [type.to_s]
|
474
|
+
types << "Default"
|
475
|
+
|
476
|
+
path = nil
|
477
|
+
types.each do |t|
|
478
|
+
path ||= locate_server_file(["entity_map", t]*"/", resources, 'haml')
|
325
479
|
end
|
326
480
|
|
327
|
-
raise "Template not found for
|
481
|
+
raise TemplateMissing, "Template not found for map (#{type}--#{column})" if path.nil?
|
482
|
+
|
483
|
+
path
|
328
484
|
end
|
329
485
|
|
330
486
|
|
331
487
|
#{{{ ENTITY MAP ACTION
|
332
488
|
|
333
|
-
def locate_entity_map_action_template_from_resource(resource, map, action)
|
489
|
+
#def locate_entity_map_action_template_from_resource(resource, map, action)
|
490
|
+
# field = map.key_field
|
491
|
+
|
492
|
+
# if map.entity_templates[field]
|
493
|
+
# annotation_types = map.entity_templates[field].annotation_types
|
494
|
+
# else
|
495
|
+
# annotation_types = [Entity.formats[field]].compact
|
496
|
+
# end
|
497
|
+
|
498
|
+
# annotation_types += ["Default"]
|
499
|
+
|
500
|
+
# annotation_types.each do |annotation|
|
501
|
+
# path = resource.entity_map[annotation][action.to_s + ".haml"]
|
502
|
+
# raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
|
503
|
+
# return path if path.exists?
|
504
|
+
# end
|
505
|
+
|
506
|
+
# nil
|
507
|
+
#end
|
508
|
+
|
509
|
+
#def locate_entity_map_action_template(map, action)
|
510
|
+
|
511
|
+
# entity_resources.each do |resource|
|
512
|
+
# path = locate_entity_map_action_template_from_resource(resource, map, action)
|
513
|
+
# return path if path and path.exists?
|
514
|
+
# end
|
515
|
+
|
516
|
+
# raise "Template not found for map #{ action } (#{map.key_field * ", "})"
|
517
|
+
#end
|
518
|
+
|
519
|
+
#def find_all_entity_map_action_templates_from_resource(resource, map)
|
520
|
+
# field = map.key_field
|
521
|
+
|
522
|
+
# if map.entity_templates[field]
|
523
|
+
# annotation_types = map.entity_templates[field].annotation_types
|
524
|
+
# else
|
525
|
+
# annotation_types = [Entity.formats[field]].compact
|
526
|
+
# end
|
527
|
+
|
528
|
+
# annotation_types += ["Default"]
|
529
|
+
|
530
|
+
# annotation_types.collect do |annotation|
|
531
|
+
# resource.entity_map[annotation].glob('*.haml')
|
532
|
+
# end.compact.flatten
|
533
|
+
#end
|
534
|
+
|
535
|
+
#def find_all_entity_map_action_templates(map, check = false)
|
536
|
+
# paths = []
|
537
|
+
|
538
|
+
# entity_resources.each do |resource|
|
539
|
+
# paths.concat find_all_entity_map_action_templates_from_resource(resource, map)
|
540
|
+
# end
|
541
|
+
|
542
|
+
# if check
|
543
|
+
# paths = paths.reject do |path|
|
544
|
+
# (path.basename == "edit.haml" or path.basename == 'new.haml')
|
545
|
+
# end
|
546
|
+
# end
|
547
|
+
|
548
|
+
# actions = paths.collect{|file| file.basename.sub('.haml', '') }.uniq
|
549
|
+
|
550
|
+
# actions.select! do |action|
|
551
|
+
# begin
|
552
|
+
# locate_entity_map_action_template(map, action)
|
553
|
+
# rescue Exception
|
554
|
+
# false
|
555
|
+
# end
|
556
|
+
# end if check
|
557
|
+
#
|
558
|
+
# actions
|
559
|
+
#end
|
560
|
+
|
561
|
+
def locate_entity_map_action_template(map, action)
|
562
|
+
resources = entity_resources
|
563
|
+
|
334
564
|
field = map.key_field
|
335
565
|
|
336
566
|
if map.entity_templates[field]
|
337
|
-
|
567
|
+
types = map.entity_templates[field].annotation_types
|
338
568
|
else
|
339
|
-
|
569
|
+
types = [Entity.formats[field]].compact
|
340
570
|
end
|
571
|
+
types += ["Default"]
|
341
572
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
path =
|
346
|
-
raise "This action was rejected: #{ action }" if
|
347
|
-
return path if path.exists?
|
573
|
+
path = nil
|
574
|
+
types.each do |type|
|
575
|
+
next if path
|
576
|
+
path = locate_server_file(["entity_map", type, action]*"/", resources, 'haml')
|
577
|
+
raise "This action was rejected: #{ action }" if reject_template(path, binding)
|
348
578
|
end
|
349
579
|
|
350
|
-
nil
|
351
|
-
end
|
580
|
+
raise TemplateMissing, "Template not found for entity map action #{action} (#{field}--#{map.fields.first})" if path.nil?
|
352
581
|
|
353
|
-
|
354
|
-
|
355
|
-
entity_resources.each do |resource|
|
356
|
-
path = locate_entity_map_action_template_from_resource(resource, map, action)
|
357
|
-
return path if path and path.exists?
|
358
|
-
end
|
359
|
-
|
360
|
-
raise "Template not found for map #{ action } (#{map.key_field * ", "})"
|
582
|
+
path
|
361
583
|
end
|
362
584
|
|
363
|
-
def
|
585
|
+
def find_all_entity_map_action_templates(map, check = false)
|
586
|
+
resources = entity_resources
|
587
|
+
|
364
588
|
field = map.key_field
|
365
589
|
|
366
590
|
if map.entity_templates[field]
|
367
|
-
|
591
|
+
types = map.entity_templates[field].annotation_types
|
368
592
|
else
|
369
|
-
|
593
|
+
types = [Entity.formats[field]].compact
|
370
594
|
end
|
595
|
+
types += ["Default"]
|
371
596
|
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
end.compact.flatten
|
377
|
-
end
|
378
|
-
|
379
|
-
def find_all_entity_map_action_templates(map, check = false)
|
380
|
-
paths = []
|
381
|
-
|
382
|
-
entity_resources.each do |resource|
|
383
|
-
paths.concat find_all_entity_map_action_templates_from_resource(resource, map)
|
597
|
+
paths = types.inject([]) do |acc,type|
|
598
|
+
acc += glob_all_server_files(["entity_map", type, "*.haml"]*"/", resources).reject{|path|
|
599
|
+
reject_template(path,binding)
|
600
|
+
}
|
384
601
|
end
|
385
602
|
|
386
603
|
if check
|
387
604
|
paths = paths.reject do |path|
|
388
|
-
(path.basename == "edit.haml" or path.basename == 'new.haml')
|
605
|
+
(path.basename == "edit.haml" or path.basename == 'new.haml')
|
389
606
|
end
|
390
607
|
end
|
391
608
|
|
@@ -393,7 +610,7 @@ module EntityRESTHelpers
|
|
393
610
|
|
394
611
|
actions.select! do |action|
|
395
612
|
begin
|
396
|
-
locate_entity_map_action_template(
|
613
|
+
locate_entity_map_action_template(list, action)
|
397
614
|
rescue Exception
|
398
615
|
false
|
399
616
|
end
|
@@ -401,6 +618,4 @@ module EntityRESTHelpers
|
|
401
618
|
|
402
619
|
actions
|
403
620
|
end
|
404
|
-
|
405
|
-
|
406
621
|
end
|
data/lib/rbbt/rest/main.rb
CHANGED
@@ -9,33 +9,53 @@ module WorkflowRESTHelpers
|
|
9
9
|
[Rbbt.www.views.find(:lib)] + WorkflowRESTHelpers.workflow_resources
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def locate_workflow_template(template, workflow = nil, task = nil)
|
13
|
+
resources = workflow_resources
|
14
|
+
resources.unshift workflow.libdir.www.views if workflow
|
14
15
|
|
15
|
-
paths = []
|
16
|
-
paths
|
17
|
-
paths
|
18
|
-
paths << resource[template]
|
16
|
+
paths = [template]
|
17
|
+
paths.unshift [workflow.to_s, template.to_s]*"/" if workflow
|
18
|
+
paths.unshift [workflow.to_s, task.to_s, template.to_s]*"/" if workflow and task
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
path = nil
|
21
|
+
paths.each do |location|
|
22
|
+
path ||= locate_server_file(location, resources, 'haml')
|
23
|
+
end
|
23
24
|
|
24
|
-
nil
|
25
|
-
end
|
25
|
+
raise TemplateMissing, "Template not found: [#{ template }, #{workflow}, #{ task }]" if path.nil?
|
26
26
|
|
27
|
-
|
27
|
+
path
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
#def locate_workflow_template_from_resource(resource, template, workflow = nil, task = nil)
|
31
|
+
# template += '.haml' unless template =~ /.+\..+/
|
32
|
+
|
33
|
+
# paths = []
|
34
|
+
# paths << resource[workflow][task][template] if task and workflow
|
35
|
+
# paths << resource[workflow][template] if workflow
|
36
|
+
# paths << resource[template]
|
37
|
+
|
38
|
+
# paths.each do |path|
|
39
|
+
# return path.find if path.exists?
|
40
|
+
# end
|
41
|
+
|
42
|
+
# nil
|
43
|
+
#end
|
44
|
+
|
45
|
+
#def locate_workflow_template(template, workflow = nil, task = nil)
|
46
|
+
|
47
|
+
# if workflow
|
48
|
+
# path = locate_workflow_template_from_resource(workflow.libdir.www.views.find, template, workflow, task)
|
49
|
+
# return path if path and path.exists?
|
50
|
+
# end
|
51
|
+
|
52
|
+
# workflow_resources.each do |resource|
|
53
|
+
# path = locate_workflow_template_from_resource(resource, template, workflow, task)
|
54
|
+
# return path if path and path.exists?
|
55
|
+
# end
|
56
|
+
|
57
|
+
# raise "Template not found: [#{ template }, #{workflow}, #{ task }]"
|
58
|
+
#end
|
33
59
|
|
34
|
-
workflow_resources.each do |resource|
|
35
|
-
path = locate_workflow_template_from_resource(resource, template, workflow, task)
|
36
|
-
return path if path and path.exists?
|
37
|
-
end
|
38
60
|
|
39
|
-
raise "Template not found: [#{ template }, #{workflow}, #{ task }]"
|
40
|
-
end
|
41
61
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
- id = "tab_menu_" + rand(1000).to_s unless defined? id and not id.nil?
|
3
|
+
- iii active
|
4
|
+
- active = false unless defined? active and not active.nil?
|
5
|
+
- active = headers.first if TrueClass === active
|
6
|
+
- iii active
|
7
|
+
.ui.top.attached.tabular.stackable.menu(id=id)
|
8
|
+
- headers.each do |header|
|
9
|
+
- code = codes[header] || Misc.digest(header)
|
10
|
+
- tab_active = (active and active == header) ? 'active' : ''
|
11
|
+
.ui.item(data-tab=code class=tab_active)= header
|
12
|
+
|
13
|
+
- headers.each do |header|
|
14
|
+
- code = codes[header] || Misc.digest(header)
|
15
|
+
- next if content[header].nil?
|
16
|
+
- tab_active = (active and active == header) ? 'active' : ''
|
17
|
+
.ui.tab.bottom.attached.segment.content(data-tab=code class=tab_active)
|
18
|
+
= content[header]
|
19
|
+
|
20
|
+
:deferjs
|
21
|
+
$("##{id} > .item[data-tab]").tab()
|
22
|
+
|
23
|
+
$('##{id} > .item[data-tab=close]').click(function(item){
|
24
|
+
var tool = $(this).parents('.cytoscape_tool').first()
|
25
|
+
tool.find('.tab.active, .item.active').removeClass('active')
|
26
|
+
return false
|
27
|
+
})
|
28
|
+
|
@@ -43,6 +43,13 @@ rbbt.ajax = function(params){
|
|
43
43
|
params.config = config
|
44
44
|
}
|
45
45
|
|
46
|
+
// circunvent m.request parametrizeUrl
|
47
|
+
|
48
|
+
params.url.replace(/:[a-z]\w+/gi, function(token){
|
49
|
+
if (undefined === params.data) params.data = {}
|
50
|
+
params.data[token.slice(1)] = token
|
51
|
+
})
|
52
|
+
|
46
53
|
req = m.request(params)
|
47
54
|
|
48
55
|
return req
|
@@ -53,6 +60,7 @@ rbbt.insist_request = function(params, deferred, timeout, missing){
|
|
53
60
|
if (undefined === timeout) timeout = 1000
|
54
61
|
if (timeout > 20000) timeout = 20000
|
55
62
|
|
63
|
+
|
56
64
|
params.extract = function(xhr, xhrOptions){
|
57
65
|
if (xhr.status != '200') throw(xhr)
|
58
66
|
return xhr.responseText.length === 0 && xhrOptions.deserialize === JSON.parse ? null : xhr.responseText
|
@@ -39,9 +39,11 @@ fav_module.toggleFavourite_entity = function(){
|
|
39
39
|
var entity = rbbt.page.entity();
|
40
40
|
|
41
41
|
if (fav_module.isFavourite_entity(entity)){
|
42
|
-
|
42
|
+
var url = '/remove_favourite_entity/' + entity.type + '/' + clean_element(entity.code)
|
43
|
+
rbbt.post({url: url, data: entity.info}).then(fav_module.update)
|
43
44
|
}else{
|
44
|
-
|
45
|
+
var url = '/add_favourite_entity/' + entity.type + '/' + clean_element(entity.code)
|
46
|
+
rbbt.post({url: url, data: entity.info}).then(fav_module.update)
|
45
47
|
}
|
46
48
|
}
|
47
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/rbbt/rest/common/render.rb
|
167
167
|
- lib/rbbt/rest/common/resources.rb
|
168
168
|
- lib/rbbt/rest/common/table.rb
|
169
|
+
- lib/rbbt/rest/common/tabs.rb
|
169
170
|
- lib/rbbt/rest/common/users.rb
|
170
171
|
- lib/rbbt/rest/entity.rb
|
171
172
|
- lib/rbbt/rest/entity/action_card.rb
|
@@ -258,6 +259,7 @@ files:
|
|
258
259
|
- share/views/partials/table/files.haml
|
259
260
|
- share/views/partials/table/filters.haml
|
260
261
|
- share/views/partials/table/page.haml
|
262
|
+
- share/views/partials/tabs.haml
|
261
263
|
- share/views/public/cnio.png
|
262
264
|
- share/views/public/favicon.gif
|
263
265
|
- share/views/public/fonts/font-awesome/fontawesome-webfont.eot
|