component.js 960 B

12345678910111213141516171819202122232425262728293031
  1. function init_components_employee(input){
  2. var data = {};
  3. input.component_autocomplete('employee',$.extend(data,{
  4. skin : function(item){
  5. var html = '';
  6. var re = new RegExp(input.val(),"gi");
  7. label = item.label.replace(re, function (x) {
  8. return '<strong>'+x+'</strong>';
  9. });
  10. html += '<div class="media">';
  11. if(item.logo) html += '';
  12. html += '<div class="my-auto media-body employee-autocomplete employee-infos"><small class="d-flex flex-column">'
  13. html+='<span>'+label+'</span>';
  14. html += '</small></div></div>'
  15. return html;
  16. },
  17. onClick : function(selected,element){
  18. container = input.data("data-component");
  19. input.val(selected.id);
  20. var label = selected.label;
  21. if(selected.parentLabel) label+=' ('+selected.parentLabel+')';
  22. container.val(label);
  23. input.trigger('click').trigger('change');
  24. },
  25. onLoad : function(component,item){
  26. var label = item.label;
  27. component.container.val(label);
  28. }
  29. }));
  30. }