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

  function indexOfId(items, id) {
    for (var i in items) {
      if (items[i].id === id) { return i; }
    }
    return -1;
  }

  return [function(){

    return {

      restrict: 'EAC',
      scope: {
        tasklistData: '='
      },

      template: template,

      controller: [
        '$scope',
        '$location',
      function(
        $scope,
        $location
      ) {

        $scope.pageNum = 1;
        $scope.pageSize = null;
        $scope.totalItems = 0;
        $scope.now = (new Date()).toJSON();

        $scope.filterProperties = null;

        var tasksData = $scope.tasklistData.newChild($scope);

        var query;

        /**
         * observe the list of tasks
         */
        $scope.state = tasksData.observe('taskList', function (taskList) {

          $scope.totalItems = taskList.count;
          $scope.processDefinitions = $scope.processDefinitions || [];

          angular.forEach(taskList._embedded ? taskList._embedded.processDefinition : [], function(procDef) {
            if (indexOfId($scope.processDefinitions) === -1) {
              $scope.processDefinitions.push(procDef);
            }
          });

          $scope.tasks = taskList._embedded.task;

        });

        /**
         * observe the task list query
         */
        tasksData.observe('taskListQuery', function(taskListQuery) {
          // parse pagination properties from query
          query = angular.copy(taskListQuery);
          $scope.pageSize = query.maxResults;
          // Sachbearbeiter starts counting at '1'
          $scope.pageNum = (query.firstResult / $scope.pageSize) + 1;
        });

        $scope.focus = function (task) {
          tasksData.set('taskId', { 'taskId' : task.id });
          $scope.currentTaskId = task.id;
        };

        // tasksData.observe('taskId', function(taskId) {
        //   $scope.currentTaskId = taskId;
        // });


        /**
         * Observes the properties of the current filter.
         * Used to retrieve information about variables displayed on a task.
         */
        tasksData.observe(['currentFilter', function(currentFilter) {

          $scope.filterProperties = currentFilter !== null ? currentFilter.properties : null;

        }]);

        /**
         * invoked when pagination is changed<commit_msg>impr(tasklist/selection): mark current selected task in list of tasks<commit_after>define([
  'angular',
  'moment',
  'text!./cam-tasklist-tasks.html'
], function(
  angular,
  moment,
  template
) {
  'use strict';

  function indexOfId(items, id) {
    for (var i in items) {
      if (items[i].id === id) { return i; }
    }
    return -1;
  }

  return [function(){

    return {

      restrict: 'EAC',
      scope: {
        tasklistData: '='
      },

      template: template,

      controller: [
        '$scope',
        '$location',
      function(
        $scope,
        $location
      ) {

        $scope.pageNum = 1;
        $scope.pageSize = null;
        $scope.totalItems = 0;
        $scope.now = (new Date()).toJSON();

        $scope.filterProperties = null;

        var tasksData = $scope.tasklistData.newChild($scope);

        var query;

        /**
         * observe the list of tasks
         */
        $scope.state = tasksData.observe('taskList', function (taskList) {

          $scope.totalItems = taskList.count;
          $scope.processDefinitions = $scope.processDefinitions || [];

          angular.forEach(taskList._embedded ? taskList._embedded.processDefinition : [], function(procDef) {
            if (indexOfId($scope.processDefinitions) === -1) {
              $scope.processDefinitions.push(procDef);
            }
          });

          $scope.tasks = taskList._embedded.task;

        });

        /**
         * observe the task list query
         */
        tasksData.observe('taskListQuery', function(taskListQuery) {
          // parse pagination properties from query
          query = angular.copy(taskListQuery);
          $scope.pageSize = query.maxResults;
          // Sachbearbeiter starts counting at '1'
          $scope.pageNum = (query.firstResult / $scope.pageSize) + 1;
        });

        $scope.focus = function (task) {
          tasksData.set('taskId', { 'taskId' : task.id });
          $scope.currentTaskId = task.id;
        };

        tasksData.observe('taskId', function(taskId) {
          $scope.currentTaskId = taskId.taskId;
        });


        /**
         * Observes the properties of the current filter.
         * Used to retrieve information about variables displayed on a task.
         */
        tasksData.observe(['currentFilter', function(currentFilter) {

          $scope.filterProperties = currentFilter !== null ? currentFilter.properties : null;

        }]);

        /**
         * invoked when pagination is changed
{'fraction_non_alphanumeric': 0.1297113071371291, 'fraction_numerical': 0.0024057738572574178, 'mean_word_length': 1.91073512252042, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '822906', 'n_tokens_mistral': 1435, 'n_tokens_neox': 1372, 'n_words': 295}