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

52 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

/
Variables:
field
placeholder
ctrl_as angularjs controllerAs
hash params hash name
2014-11-18 15:58:39 +00:00
- modal_id = "#{field}Modal"
- field_name = field.to_s.underscore
- var_name = field_name.singularize
- func_name = field.to_s.singularize
- title = t "activerecord.attributes.build_list.#{field_name}"
- ctrl_as = "#{ctrl_as}."
2014-11-18 15:58:39 +00:00
h4
= title
a<[ class='fa fa-question-circle' href='#' data-toggle='modal' data-target="##{modal_id}" ]
.modal.fade[ id=modal_id tabindex='-1' role='dialog'
aria-labelledby="#{modal_id}Label" aria-hidden='true' ]
.modal-dialog
.modal-content
.modal-header
button[ class='close' type='button' data-dismiss='modal' ]
span[ aria-hidden='true' ] &times;
span.sr-only Close
h4.modal-title[ id=modal_id ]= title
.modal-body== render "shared/autocomplete_docs/#{field_name}"
.row
.col-md-8
input[ class = 'form-control'
type = 'text'
ng-model = "#{ctrl_as}selected_#{var_name}"
2014-11-18 15:58:39 +00:00
placeholder = placeholder
2016-04-29 15:10:30 +01:00
uib-typeahead = "extra.label for extra in #{ctrl_as}get#{field}($viewValue)"
typeahead-on-select = "#{ctrl_as}select#{func_name}($item, $model, $label)" ]
2014-11-18 15:58:39 +00:00
.col-md-4
2015-02-05 23:59:45 +00:00
button[ class='btn btn-primary' type='button'
ng-click="#{ctrl_as}add#{func_name}()" ]
2015-02-07 00:37:52 +00:00
i.fa.fa-plus>
2014-11-18 15:58:39 +00:00
= t('layout.add')
table.table
tr[ ng-repeat="el in #{ctrl_as}#{field_name}" ]
2014-11-18 15:58:39 +00:00
td
a[ ng-href='{{ el.path }}' ] {{ el.label }}
td
a[ class='fa fa-times-circle text-danger' href=''
ng-click="#{ctrl_as}remove#{func_name}(el.id)" ]
input[ name="#{hash}[#{field_name}][]" type='hidden'
2014-11-18 15:58:39 +00:00
ng-model='el.id' ng-value='el.id' ]