1 require_dependency "manifest/system_resource/template"
4 include SystemResourceModule
5 def self.set_default system_resource_manifest
6 system_resource_manifest['templates'] ||= {}
7 system_resource_manifest['select_items'] ||= {}
9 #JSON.stringify couldn't print 1.0
12 system_resource_manifest['select_items']['speech_font_size_items'] ||= {}
13 system_resource_manifest['select_items']['speech_font_size_items'].each {|conf|
14 conf[1] = conf[1].to_f
16 system_resource_manifest
19 attr :templates, :select_items
20 def initialize manifest, system_resource_manifest
22 @system_resource_manifest = system_resource_manifest
23 @templates = Template.manager(self, @system_resource_manifest['templates'])
24 @select_items = system_resource_manifest['select_items']
29 self.select_items_loader
32 def select_items_loader
33 @manifest.models.each {|model_name, model_manifest|
34 model_manifest.attributes.each {|attribute_name, attribute_manifest|
35 source_manifest = attribute_manifest.source
36 next unless source_manifest
37 next unless source_manifest.type == 'model'
38 resource_item_name = source_manifest.resource_item_name
39 resource_action_name = source_manifest.resource_action_name
40 caption = source_manifest.caption_name
41 resource_controller_name = ::Manifest.manifest.pluralize(resource_item_name)
43 list = Locmare::ListGroup.list(
44 resource_controller_name,
47 {:page_size => -1} # set no limit options
49 @select_items[source_manifest.select_item_name] =
50 list.items.map {|item| [item.attributes[caption], item.id]}
52 puts 'skip store select_items:' + resource_item_name + '.' + resource_action_name