2014-11-18 16:22:10 +00:00
|
|
|
/
|
|
|
|
Variables:
|
|
|
|
field
|
|
|
|
placeholder
|
|
|
|
ctrl_as angularjs controllerAs
|
2015-02-05 09:32:10 +00:00
|
|
|
hash params hash name
|
2014-11-18 16:22:10 +00:00
|
|
|
|
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}"
|
2014-11-18 16:22:10 +00:00
|
|
|
- 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' ] ×
|
|
|
|
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'
|
2014-11-18 16:22:10 +00:00
|
|
|
ng-model = "#{ctrl_as}selected_#{var_name}"
|
2014-11-18 15:58:39 +00:00
|
|
|
placeholder = placeholder
|
2014-11-18 16:22:10 +00:00
|
|
|
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
|
|
|
|
button[ class='btn btn-default' type='button'
|
2014-11-18 16:22:10 +00:00
|
|
|
ng-click="#{ctrl_as}add#{func_name}()" ]
|
2014-11-18 15:58:39 +00:00
|
|
|
= t('layout.add')
|
|
|
|
|
|
|
|
table.table.offset5
|
2014-11-18 16:22:10 +00:00
|
|
|
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=''
|
2014-11-18 16:22:10 +00:00
|
|
|
ng-click="#{ctrl_as}remove#{func_name}(el.id)" ]
|
2015-02-05 09:32:10 +00:00
|
|
|
input[ name="#{hash}[#{field_name}][]" type='hidden'
|
2014-11-18 15:58:39 +00:00
|
|
|
ng-model='el.id' ng-value='el.id' ]
|