<commit_before>define([
  'angular',
  'text!./cam-tasklist-sorting-choices.html'
], function(
  angular,
  template
) {
  'use strict';

  function stringifySortings(sortingQuery) {
    return JSON.stringify(sortingQuery.map(function (sorting) {
      var obj = {
        sortBy: sorting.by,
        sortOrder: sorting.order
      };

      if (sorting.by.indexOf('Variable') > -1) {
        if (!sorting.parameters) {
          throw new Error('Variable sorting needs parameters');
        }
        obj.parameters = sorting.parameters;
      }

      return obj;
    }));
  }

  return [
    'search',
    '$translate',
    '$location',
    '$timeout',
  function(
    search,
    $translate,
    $location,
    $timeout
  ) {
    return {

      restrict: 'A',

      scope: {
        tasklistData: '='
      },

      template: template,

      controller: [function () {}],

      link: function(scope, element) {
        var $bdy = angular.element('body');
        var $newSort = element.find('.new-sort .dropdown-menu');

        scope.sortings = [{
          order:    'desc',
          by:       'created'
        }];

        scope.openDropdowns = [];
        scope.openDropdownNew = false;

        scope.sortedOn = [];

        var plannedRefresh;
        function updateColumns() {
          if (plannedRefresh) {
            $timeout.cancel(plannedRefresh);
          }

          plannedRefresh = $timeout(function () {
            var columns = element.parents('.columns');
            var headers = columns.find('.cell.top');
            var bodies = columns.find('.cell.content');
            var shown = $bdy.hasClass('list-column-close');

            element.css('height', 'auto');

            if (shown) {
              var minHeight = parseInt(headers.css('min-height'), 10);
              headers.css('height', minHeight);
              bodies.css('top', minHeight);
              return;
            }

            var height = element.height();
            var columnTop = element.parent();
            columnTop.height(height);
            var columnTopHeight = height;

            headers.height(columnTopHeight);
            bodies.css('top', columnTopHeight + 30);
            plannedRefresh = null;
          }, 100);
        }

        scope.$on('layout:change', updateColumns);

        scope.uniqueProps = {
          priority:               $translate.instant('PRIORITY'),
          created:                $translate.instant('CREATION_DATE'),
          dueDate:                $translate.instant('DUE_DATE'),
          followUpDate:           $translate.instant('FOLLOW_UP_DATE'),
          nameCaseInsensitive:    $translate.instant('TASK_NAME'),
          assignee:               $translate.instant('ASSIGNEE')
        };

        scope.byLabel = function (index) {
          if (!scope.sortings[index]) {
            return '';
          }

          var by = scope.sortings[index].by;

          if (scope.uniqueProps[by]) {
            return scope.uniqueProps[by].toLowerCase();
          }

          if (!scope.sortings[index] || !scope.sortings[index].parameters) {
            return '';
          }

          return scope.sortings[index].parameters.variable;
        };<commit_msg>fix(sorting): do not lowercase label<commit_after>define([
  'angular',
  'text!./cam-tasklist-sorting-choices.html'
], function(
  angular,
  template
) {
  'use strict';

  function stringifySortings(sortingQuery) {
    return JSON.stringify(sortingQuery.map(function (sorting) {
      var obj = {
        sortBy: sorting.by,
        sortOrder: sorting.order
      };

      if (sorting.by.indexOf('Variable') > -1) {
        if (!sorting.parameters) {
          throw new Error('Variable sorting needs parameters');
        }
        obj.parameters = sorting.parameters;
      }

      return obj;
    }));
  }

  return [
    'search',
    '$translate',
    '$location',
    '$timeout',
  function(
    search,
    $translate,
    $location,
    $timeout
  ) {
    return {

      restrict: 'A',

      scope: {
        tasklistData: '='
      },

      template: template,

      controller: [function () {}],

      link: function(scope, element) {
        var $bdy = angular.element('body');
        var $newSort = element.find('.new-sort .dropdown-menu');

        scope.sortings = [{
          order:    'desc',
          by:       'created'
        }];

        scope.openDropdowns = [];
        scope.openDropdownNew = false;

        scope.sortedOn = [];

        var plannedRefresh;
        function updateColumns() {
          if (plannedRefresh) {
            $timeout.cancel(plannedRefresh);
          }

          plannedRefresh = $timeout(function () {
            var columns = element.parents('.columns');
            var headers = columns.find('.cell.top');
            var bodies = columns.find('.cell.content');
            var shown = $bdy.hasClass('list-column-close');

            element.css('height', 'auto');

            if (shown) {
              var minHeight = parseInt(headers.css('min-height'), 10);
              headers.css('height', minHeight);
              bodies.css('top', minHeight);
              return;
            }

            var height = element.height();
            var columnTop = element.parent();
            columnTop.height(height);
            var columnTopHeight = height;

            headers.height(columnTopHeight);
            bodies.css('top', columnTopHeight + 30);
            plannedRefresh = null;
          }, 100);
        }

        scope.$on('layout:change', updateColumns);

        scope.uniqueProps = {
          priority:               $translate.instant('PRIORITY'),
          created:                $translate.instant('CREATION_DATE'),
          dueDate:                $translate.instant('DUE_DATE'),
          followUpDate:           $translate.instant('FOLLOW_UP_DATE'),
          nameCaseInsensitive:    $translate.instant('TASK_NAME'),
          assignee:               $translate.instant('ASSIGNEE')
        };

        scope.byLabel = function (index) {
          if (!scope.sortings[index]) {
            return '';
          }

          var by = scope.sortings[index].by;

          if (scope.uniqueProps[by]) {
            return scope.uniqueProps[by];
          }

          if (!scope.sortings[index] || !scope.sortings[index].parameters) {
            return '';
          }

          return scope.sortings[index].parameters.variable;
        };
{'fraction_non_alphanumeric': 0.1328595705237139, 'fraction_numerical': 0.0024718059632318863, 'mean_word_length': 1.7339527027027026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4443820', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1723, 'n_words': 318}