rbbt-rest 1.8.44 → 1.8.45

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60976796315c49b16fb12420e4dd05e3172431af
4
- data.tar.gz: 515901d61eb491544dc75c863fe1b72ac0e3bdff
3
+ metadata.gz: 40e90eddb36c53c25372a680f163a3a1e7c06b09
4
+ data.tar.gz: 809f9e0ee244cad3c4afff02bfde90ce21e313a0
5
5
  SHA512:
6
- metadata.gz: 7d2d29a01a654bc06241b2df611b7df3b26a788e5925dda59436c88676e1983d81c7c1a756fe499868310541bf5c6f243eb66938ade86601662ff9aa9b49caae
7
- data.tar.gz: 57a34fe10f44f56ef698bfd2b276d136f43d80fe4cc2d7531febd3318bd8d0f7c98bfb571a95008935e0ca7fac90ebe47eb658f52724f48b00b01b2bd12bbacf
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
- orig_tsv = load_tsv(fragment_file).first
117
- tsv = tsv_process(orig_tsv)
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
- tsv = tsv_process(load_tsv(fragment_file).first)
130
- type = tsv.keys.annotation_types.last
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).first
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
- path = Path.setup(file)
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
- path = Path.setup(file)
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 AnnotatedModule
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
- if entity == "Default"
39
- path = resource.entity["Default.haml"]
40
- if path.exists?
41
- return path
42
- else
43
- return nil
44
- end
45
- end
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
- entity.annotation_types.each do |annotation|
48
- path = resource.entity[annotation.to_s + ".haml"]
49
- return path if path.exists?
50
- end
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
- nil
53
- end
58
+ # nil
59
+ #end
54
60
 
55
- def locate_entity_template(entity)
61
+ #def locate_entity_template(entity)
56
62
 
57
- if entity.respond_to? :dir and Path === entity.dir
58
- entity_views = entity.dir.www.views
63
+ # if entity.respond_to? :dir and Path === entity.dir
64
+ # entity_views = entity.dir.www.views
59
65
 
60
- entity.annotation_types.each do |annotation|
61
- path = entity_views.entity[annotation.to_s + ".haml"]
62
- return path if path.exists?
63
- end
64
- end
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
- entity_resources.each do |resource|
67
- path = locate_entity_template_from_resource(resource, entity)
68
- return path if path and path.exists?
69
- end
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
- entity_resources.each do |resource|
72
- path = locate_entity_template_from_resource(resource, "Default")
73
- return path if path and path.exists?
74
- end
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
- raise "Template not found for entity: #{ entity } (#{entity.annotation_types * ", "})"
77
- end
82
+ # raise "Template not found for entity: #{ entity } (#{entity.annotation_types * ", "})"
83
+ #end
78
84
 
79
- #{{{ ENTITY ACTION
85
+
86
+ def locate_entity_template(entity)
87
+ resources = resources_for_entity(entity)
80
88
 
81
- def locate_entity_action_template_from_resource(resource, entity, action)
82
- if entity == "Default"
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
- entity.annotation_types.each do |annotation|
93
- path = resource.entity[annotation][action.to_s + ".haml"]
94
- raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
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
- def locate_entity_action_template(entity, action)
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
- entity_resources.each do |resource|
109
- path = locate_entity_action_template_from_resource(resource, entity, action)
110
- return path if path and path.exists?
111
- end
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
- entity_resources.each do |resource|
114
- path = locate_entity_action_template_from_resource(resource, "Default", action)
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
- def find_all_entity_action_templates_from_resource(resource, entity)
123
- if entity == "Default"
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
- paths = []
165
+ resources = resources_for_entity(entity)
134
166
 
135
- if entity.respond_to? :dir and Path === entity.dir
136
- paths.concat find_all_entity_action_templates_from_resource(entity.dir.www.views, entity)
137
- end
167
+ types = entity.annotation_types.collect{|e| e.to_s}
168
+ types << "Default"
138
169
 
139
- entity_resources.each do |resource|
140
- paths.concat find_all_entity_action_templates_from_resource(resource, entity)
141
- end
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
- if list == "Default"
169
- path = resource.entity_list["Default.haml"]
170
- if path.exists?
171
- return path
172
- else
173
- return nil
174
- end
175
- end
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
- list.annotation_types.each do |annotation|
178
- path = resource.entity_list[annotation.to_s + ".haml"]
179
- return path if path.exists?
180
- end
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
- nil
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
- if list.respond_to? :dir and Path === list.dir
188
- list_views = list.dir.www.views
260
+ # if list.respond_to? :dir and Path === list.dir
261
+ # list_views = list.dir.www.views
189
262
 
190
- list.annotation_types.each do |annotation|
191
- path = list_views.entity_list[annotation.to_s + ".haml"]
192
- return path if path.exists?
193
- end
194
- end
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
- entity_resources.each do |resource|
197
- path = locate_entity_list_template_from_resource(resource, list)
198
- return path if path and path.exists?
199
- end
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
- entity_resources.each do |resource|
202
- path = locate_entity_list_template_from_resource(resource, "Default")
203
- return path if path and path.exists?
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
- if list == "Default"
215
- path = resource.entity_list["Default"][action.to_s + ".haml"]
216
- raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
217
- if path.exists?
218
- return path
219
- else
220
- return nil
221
- end
222
- end
223
-
224
- list.annotation_types.each do |annotation|
225
- path = resource.entity_list[annotation][action.to_s + ".haml"]
226
- raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
227
- return path if path.exists?
228
- end
229
-
230
- nil
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
- if list.respond_to? :dir and Path === list.dir
236
- path = locate_entity_list_action_template_from_resource(list.dir.www.views, list, action)
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
- entity_resources.each do |resource|
241
- path = locate_entity_list_action_template_from_resource(resource, list, action)
242
- return path if path and path.exists?
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
- entity_resources.each do |resource|
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
- raise "Template not found for list #{ action } (#{list.annotation_types * ", "})"
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
- paths = []
407
+ resources = resources_for_entity(list)
266
408
 
267
- if list.respond_to? :dir and Path === list.dir
268
- paths.concat find_all_entity_list_action_templates_from_resource(list.dir.www.views, list)
269
- end
409
+ types = list.annotation_types.collect{|e| e.to_s}
410
+ types << "Default"
270
411
 
271
- entity_resources.each do |resource|
272
- paths.concat find_all_entity_list_action_templates_from_resource(resource, list)
273
- end
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
- if type == "Default"
302
- path = resource.entity_map["Default.haml"]
303
- if path.exists?
304
- return path
305
- else
306
- return nil
307
- end
308
- end
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
- path = resource.entity_map[type.to_s + ".haml"]
311
- return path if path.exists?
449
+ # path = resource.entity_map[type.to_s + ".haml"]
450
+ # return path if path.exists?
312
451
 
313
- nil
314
- end
452
+ # nil
453
+ #end
315
454
 
316
- def locate_entity_map_template(type, column)
317
- entity_resources.each do |resource|
318
- path = locate_entity_map_template_from_resource(resource, type)
319
- return path if path and path.exists?
320
- end
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
- entity_resources.each do |resource|
323
- path = locate_entity_map_template_from_resource(resource, "Default")
324
- return path if path and path.exists?
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 list (#{type}--#{column})"
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
- annotation_types = map.entity_templates[field].annotation_types
567
+ types = map.entity_templates[field].annotation_types
338
568
  else
339
- annotation_types = [Entity.formats[field]].compact
569
+ types = [Entity.formats[field]].compact
340
570
  end
571
+ types += ["Default"]
341
572
 
342
- annotation_types += ["Default"]
343
-
344
- annotation_types.each do |annotation|
345
- path = resource.entity_map[annotation][action.to_s + ".haml"]
346
- raise "This action was rejected: #{ action }" if path and reject_template(path,binding)
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
- def locate_entity_map_action_template(map, action)
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 find_all_entity_map_action_templates_from_resource(resource, map)
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
- annotation_types = map.entity_templates[field].annotation_types
591
+ types = map.entity_templates[field].annotation_types
368
592
  else
369
- annotation_types = [Entity.formats[field]].compact
593
+ types = [Entity.formats[field]].compact
370
594
  end
595
+ types += ["Default"]
371
596
 
372
- annotation_types += ["Default"]
373
-
374
- annotation_types.collect do |annotation|
375
- resource.entity_map[annotation].glob('*.haml')
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(map, action)
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
@@ -204,7 +204,7 @@ module Sinatra
204
204
  end
205
205
  end
206
206
 
207
- error RbbtRESTHelpers::TemplateMissing do |e|
207
+ error TemplateMissing do |e|
208
208
  halt 404, e.message
209
209
  end
210
210
 
@@ -9,33 +9,53 @@ module WorkflowRESTHelpers
9
9
  [Rbbt.www.views.find(:lib)] + WorkflowRESTHelpers.workflow_resources
10
10
  end
11
11
 
12
- def locate_workflow_template_from_resource(resource, template, workflow = nil, task = nil)
13
- template += '.haml' unless template =~ /.+\..+/
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 << resource[workflow][task][template] if task and workflow
17
- paths << resource[workflow][template] if workflow
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
- paths.each do |path|
21
- return path.find if path.exists?
22
- end
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
- def locate_workflow_template(template, workflow = nil, task = nil)
27
+ path
28
+ end
28
29
 
29
- if workflow
30
- path = locate_workflow_template_from_resource(workflow.libdir.www.views.find, template, workflow, task)
31
- return path if path and path.exists?
32
- end
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
- rbbt.post({url: '/remove_favourite_entity/' + entity.type + '/' + clean_element(entity.code), data: entity.info}).then(fav_module.update)
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
- rbbt.post({url: '/add_favourite_entity/' + entity.type + '/' + clean_element(entity.code), data: entity.info}).then(fav_module.update)
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.44
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-09 00:00:00.000000000 Z
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