<commit_before>
angular.module('openspecimen')
  .directive('osSelect', function() {
    return {
      restrict: 'AE',

      scope: {
        ngModel: '=ngModel',
        list: '=list',
        placeholder: '@'
      },

      replace: true,

      link: function(scope, element, attrs, ctrl) {
        if (!scope.ngModel && angular.isDefined(attrs.multiple)) {
          scope.ngModel = [];
        }
      },

      template: function(tElem, tAttrs) {
        return angular.isDefined(tAttrs.multiple) ?
              '<div>' +
                '<ui-select multiple ng-model="$parent.ngModel">' +
                  '<ui-select-match placeholder="{{$parent.placeholder}}">' +
                    '{{$item}}' +
                  '</ui-select-match>' +
                  '<ui-select-choices repeat="item in $parent.list">' +
                    '<span ng-bind-html="item | highlight: $select.search"></span>' +
                  '</ui-select-choices>' +
                '</ui-select>' +
              '</div>'

              :

              '<div>' +
                '<ui-select ng-model="$parent.ngModel">' +
                  '<ui-select-match placeholder="{{$parent.placeholder}}">' +
                    '{{$select.selected}}' +
                  '</ui-select-match>' +
                  '<ui-select-choices repeat="item in $parent.list">' +
                    '<span ng-bind-html="item | highlight: $select.search"></span>' +
                  '</ui-select-choices>' + 
                '</ui-select>' +
              '</div>';
      }
    };
  });<commit_msg>Improvised os-select directive to make it suitable for use in os-md-input with floating labels<commit_after>
angular.module('openspecimen')
  .directive('osSelect', function() {
    return {
      restrict: 'E',
      compile: function(tElem, tAttrs) {
        var uiSelect = angular.element('<ui-select></ui-select>')
          .attr('ng-model', tAttrs.ngModel)

        var uiSelectMatch = angular.element('<ui-select-match/>')
          .attr('placeholder', tAttrs.placeholder);
        
        var uiSelectChoices = angular.element('<ui-select-choices/>')
          .attr('repeat', "item in " + tAttrs.list)
          .append('<span ng-bind-html="item | highlight: $select.search"></span>');

        if (angular.isDefined(tAttrs.multiple)) {
          uiSelect.attr('multiple', '');
          uiSelectMatch.append('{{$item}}');
        } else {
          uiSelectMatch.append('{{$select.selected}}');
        }

        uiSelect.append(uiSelectMatch).append(uiSelectChoices);
        
        var selectContainer = angular.element("<div/>")
          .addClass("os-select-container")
          .append(uiSelect);

        tElem.replaceWith(selectContainer);
        return angular.noop; 
      }
    };
  });
{'fraction_non_alphanumeric': 0.17014388489208634, 'fraction_numerical': 0.0, 'mean_word_length': 1.826219512195122, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421573', 'n_tokens_mistral': 805, 'n_tokens_neox': 791, 'n_words': 125}