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
|
2016-04-29 15:10:30 +01:00
|
|
|
uib-typeahead = "extra.label for extra in #{ctrl_as}get#{field}($viewValue)"
|
2014-11-18 16:22:10 +00:00
|
|
|
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'
|
2014-11-18 16:22:10 +00:00
|
|
|
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')
|
|
|
|
|
2015-02-09 13:00:38 +00:00
|
|
|
table.table
|
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' ]
|