<commit_before>const expertRequestList = {
  templateUrl: 'views/partials/filtered-list.html',
  controllerAs: 'ListController',
  controller: ExpertRequestListController,
};

// @ngInject
function ExpertRequestListController(
  baseControllerListClass,
  $scope,
  $q,
  $state,
  $filter,
  $uibModal,
  currentStateService,
  expertRequestsService,
  customersService) {
  let controllerScope = this;
  let Controller = baseControllerListClass.extend({
    init: function() {
      this.controllerScope = controllerScope;
      this.service = expertRequestsService;
      let fn = this._super.bind(this);
      this.loadContext().then(() => {
        this.tableOptions = this.getTableOptions();
        fn();
        $scope.$emit('expertRequestCustomerList.initialized');
      });
    },
    loadContext: function() {
      return $q.all([
        customersService.isOwnerOrStaff().then(isOwnerOrStaff => {
          this.isOwnerOrStaff = isOwnerOrStaff;
        }),
        currentStateService.getCustomer().then(customer => {
          this.customer = customer;
        }),
      ]);
    },
    getTableOptions: function() {
      return {
        searchFieldName: 'name',
        noDataText: gettext('There are no experts yet.'),
        noMatchesText: gettext('No experts found matching filter.'),
        enableOrdering: true,
        columns: this.getColumns(),
        rowActions: this.getRowActions(),
      };
    },
    getColumns: function() {
      return [
        {
          title: gettext('Name'),
          orderField: 'name',
          render: row => {
            const href = $state.href('organization.expertRequestDetails', {
              uuid: this.customer.uuid,
              requestId: row.uuid
            });
            return '<a href="{href}">{name}</a>'
                   .replace('{href}', href)
                   .replace('{name}', row.name);
          }
        },
        {
          title: gettext('Organization'),
          orderField: 'customer_name',
          render: row => row.customer_name
        },
        {
          title: gettext('Project'),
          orderField: 'project_name',
          render: row => row.project_name
        },
        {
          title: gettext('Type'),
          orderField: 'type',
          render: row => row.type_label
        },
        {
          title: gettext('State'),
          orderField: 'state',
          render: row => {
            const index = this.findIndexById(row);
            return `<expert-request-state model="controller.list[${index}]"/>`;
          }
        },
        {
          title: gettext('Creation date'),
          orderField: 'created',
          render: function(row) {
            return $filter('dateTime')(row.created);
          }
        }
      ];
    },
    getRowActions: function() {
      let actions = [];
      if (this.isOwnerOrStaff) {
        actions.push({
          title: gettext('Create bid'),
          iconClass: 'fa fa-plus',
          callback: this.createBid.bind(this),
          isDisabled: row => row.state !== 'Pending',
          tooltip: function(row) {
            if (row.state !== 'Pending') {<commit_msg>Update expert request customers list [WAL-1169]<commit_after>const expertRequestList = {
  templateUrl: 'views/partials/filtered-list.html',
  controllerAs: 'ListController',
  controller: ExpertRequestListController,
};

// @ngInject
function ExpertRequestListController(
  baseControllerListClass,
  $scope,
  $q,
  $state,
  $filter,
  $uibModal,
  currentStateService,
  expertRequestsService,
  customersService) {
  let controllerScope = this;
  let Controller = baseControllerListClass.extend({
    init: function() {
      this.controllerScope = controllerScope;
      this.service = expertRequestsService;
      let fn = this._super.bind(this);
      this.loadContext().then(() => {
        this.tableOptions = this.getTableOptions();
        fn();
        $scope.$emit('expertRequestCustomerList.initialized');
      });
    },
    loadContext: function() {
      return $q.all([
        customersService.isOwnerOrStaff().then(isOwnerOrStaff => {
          this.isOwnerOrStaff = isOwnerOrStaff;
        }),
        currentStateService.getCustomer().then(customer => {
          this.customer = customer;
        }),
      ]);
    },
    getTableOptions: function() {
      return {
        searchFieldName: 'name',
        noDataText: gettext('There are no experts yet.'),
        noMatchesText: gettext('No experts found matching filter.'),
        enableOrdering: true,
        columns: this.getColumns(),
        rowActions: this.getRowActions(),
      };
    },
    getColumns: function() {
      return [
        {
          title: gettext('Organization'),
          orderField: 'customer_name',
          render: row => {
            const href = $state.href('organization.expertRequestDetails', {
              uuid: this.customer.uuid,
              requestId: row.uuid
            });
            return '<a href="{href}">{name}</a>'
                   .replace('{href}', href)
                   .replace('{name}', row.customer_name);
          }
        },
        {
          title: gettext('Type'),
          orderField: 'type',
          render: row => row.type_label
        },
        {
          title: gettext('Objectives'),
          orderField: 'objectives',
          render: row => {
            return '<span uib-tooltip="{tooltip}">{value}</span>'
              .replace('{tooltip}', row.objectives)
              .replace('{value}', row.objectives.substring(0,30));
          }
        },
        {
          title: gettext('State'),
          orderField: 'state',
          render: row => {
            const index = this.findIndexById(row);
            return `<expert-request-state model="controller.list[${index}]"/>`;
          }
        },
        {
          title: gettext('Creation date'),
          orderField: 'created',
          render: function(row) {
            return $filter('dateTime')(row.created);
          }
        }
      ];
    },
    getRowActions: function() {
      let actions = [];
      if (this.isOwnerOrStaff) {
        actions.push({
          title: gettext('Create bid'),
          iconClass: 'fa fa-plus',
          callback: this.createBid.bind(this),
          isDisabled: row => row.state !== 'Pending',
          tooltip: function(row) {
            if (row.state !== 'Pending') {
{'fraction_non_alphanumeric': 0.13606608478802992, 'fraction_numerical': 0.0010910224438902742, 'mean_word_length': 1.9902143522833178, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 28, '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': '5898139', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1755, 'n_words': 328}