rosa-build/app/views/shared/_autocomplete_form.html.haml

45 lines
2.0 KiB
Plaintext
Raw Normal View History

-#
Variables:
subject
field
field_class
autocomplete_path
placeholder
default_values (optional)
- default_values ||= []
- subject_class = subject.class.name.underscore
2014-01-21 04:51:49 +00:00
.autocomplete-form{subject_class: subject_class, field: field, path: autocomplete_path, class: field}
%h3= t("activerecord.attributes.build_list.#{field}")
%span.icon-question-sign
2013-08-05 19:34:42 +01:00
- if !(params[:show] == 'inline' && params[:build_list_id].present?)
2014-01-21 04:51:49 +00:00
.dialog{title: t("activerecord.attributes.build_list.#{field}"), id: "#{field}_dialog"}
2013-08-05 19:34:42 +01:00
= render "shared/autocomplete_docs/#{field}"
.both
2014-01-21 04:51:49 +00:00
= autocomplete_field_tag field, nil, "#{autocomplete_path}?#{{platform_id: subject.save_to_platform.try(:id)}.to_param}", placeholder: placeholder, class: 'autocomplete', update_elements: {id: "##{field}_field", path: "##{field}_field_path", label: "##{field}_field_label"}
= hidden_field_tag field, nil, id: "#{field}_field"
= hidden_field_tag field, nil, id: "#{field}_field_path"
= hidden_field_tag field, nil, id: "#{field}_field_label"
= submit_tag t('layout.add'), class: 'button add'
2014-01-21 04:51:49 +00:00
%table.tablesorter{cellpadding: "0", cellspacing: "0"}
%tbody
- field_name = "#{subject_class}[#{field}][]"
2014-01-21 04:51:49 +00:00
- field_class.where(id: params[:build_list].try(:[], field) ).each do |extra|
%tr
- if extra.is_a?(BuildList)
%td= link_to "#{extra.id} (#{extra.project.name} - #{extra.arch.name})", extra
- else
%td= link_to "#{extra.platform.name}/#{extra.name}", [extra.platform, extra]
%td.actions
- field = extra.is_a?(BuildList) ? 'extra_build_lists' : 'extra_repositories'
= hidden_field_tag field_name, extra.id
%span.delete  
.default-values
2014-01-21 04:51:49 +00:00
- field_class.where(id: default_values).each do |extra|
.hidden{:label => "#{extra.platform.name}/#{extra.name}",
:path => url_for([extra.platform, extra]),
2014-01-21 04:51:49 +00:00
:name => field_name, value: extra.id}