1 class Locmare.FormModule.FieldModule.TagModule.SelectTag extends Locmare.FormModule.FieldModule.TagModule.Base
\r
8 @select_values((members) =>
\r
9 values = if @model_attribute_manifest().source.translate()
\r
10 Pettanr.AppHelper.t_select_items(members)
\r
14 this.$el.attr(@attr())
\r
15 _.each values, (member) =>
\r
16 selected = if @is_selected(member)
\r
20 this.$el.append('<option value="' + member[1] + '"' + selected + '>' + member[0] + '</option>')
\r
24 model_manifest: () ->
\r
25 Manifest.manifest().models[@field.field_manifest.item_name()]
\r
27 model_attribute_manifest: () ->
\r
28 @model_manifest().attributes[@field.field_manifest.column_name()]
\r
30 select_item_name: () ->
\r
31 @model_attribute_manifest().source.select_item_name
\r
33 source_by_filter: () ->
\r
34 switch @model_attribute_manifest().source.type
\r
35 when 'model', 'filter'
\r
42 is_selected: (member) ->
\r
43 @value() == member[1]
\r
45 select_values: (cb) ->
\r
46 if @source_by_filter()
\r
47 resource_item_name = @model_attribute_manifest().source.resource_item_name
\r
48 resource_action_name = @model_attribute_manifest().source.resource_action_name
\r
49 filter_column_name = @model_attribute_manifest().source.filter_column_name
\r
50 filter_id = @form().item.get(filter_column_name)
\r
51 resource_controller_name = Manifest.manifest().models[resource_item_name].classify().table_name()
\r
52 caption_name = @model_attribute_manifest().source.caption_name
\r
53 params = if filter_column_name
\r
57 list = Locmare.ListGroup.list(resource_controller_name, resource_action_name, {})
\r
58 list.open((page_status) ->
\r
59 members = _.map list.models, (member) ->
\r
60 [member.get(caption_name), member.get('id')]
\r
64 members = Manifest.manifest().system_resources.select_items[@select_item_name()]
\r
68 @field.trigger('change')
\r