<commit_before>'use strict';
var fs = require('fs');

var template = fs.readFileSync(__dirname + '/cam-tasklist-task.html', 'utf8');

var angular = require('camunda-commons-ui/vendor/angular');

module.exports = [ function() {

  return {
    restrict: 'A',
    scope: {
      tasklistData: '='
    },

    template: template,

    controller : [
      '$scope',
      '$q',
      '$location',
      '$translate',
      // not using $timeout here (although it would be better) because... well... i'd rather not give my opinion
      // https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
      '$interval',
      'camAPI',
      'Notifications',
      'Views',
      'search',
      function(
        $scope,
        $q,
        $location,
        $translate,
        $interval,
        camAPI,
        Notifications,
        Views,
        search
      ) {

        // setup /////////////////////////////////////////////////////////////////////

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

        // error handling //////////////////////////////////////////////////////////////

        function errorNotification(src, err) {
          $translate(src).then(function(translated) {
            Notifications.addError({
              status: translated,
              message: (err ? err.message : ''),
              exclusive: true,
              scope: $scope
            });
          });
        }

        $scope.errorHandler = function(status, err) {
          var _status = enhanceErrorMessage(err.message);

          if(_status === 'TASK_NOT_EXIST' || _status === 'INSTANCE_SUSPENDED') {
            return $translate(_status).then(function(translated) {
              err.message = translated;
              errorNotification(status, err);
              clearTask(true);
            });

          }
          else {
            errorNotification(status, err);
          }

        };

        function enhanceErrorMessage(msg) {
          if (msg) {
            if(msg.indexOf('task is null') !== -1 || msg.indexOf('No matching task') !== -1) {
              // task does not exist (e.g. completed by someone else)
              return 'TASK_NOT_EXIST';
            }
            else if(msg.indexOf('is suspended') !== -1) {
              // process instance is suspended
              return 'INSTANCE_SUSPENDED';
            }
          }
          return msg;
        }<commit_msg>fix(tasklist): ignore error notification on prevented submission<commit_after>'use strict';
var fs = require('fs');

var template = fs.readFileSync(__dirname + '/cam-tasklist-task.html', 'utf8');

var angular = require('camunda-commons-ui/vendor/angular');

module.exports = [ function() {

  return {
    restrict: 'A',
    scope: {
      tasklistData: '='
    },

    template: template,

    controller : [
      '$scope',
      '$q',
      '$location',
      '$translate',
      // not using $timeout here (although it would be better) because... well... i'd rather not give my opinion
      // https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
      '$interval',
      'camAPI',
      'Notifications',
      'Views',
      'search',
      function(
        $scope,
        $q,
        $location,
        $translate,
        $interval,
        camAPI,
        Notifications,
        Views,
        search
      ) {

        // setup /////////////////////////////////////////////////////////////////////

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

        // error handling //////////////////////////////////////////////////////////////

        function errorNotification(src, err) {
          $translate(src).then(function(translated) {
            Notifications.addError({
              status: translated,
              message: (err ? err.message : ''),
              exclusive: true,
              scope: $scope
            });
          });
        }

        $scope.errorHandler = function(status, err) {
          var _status = enhanceErrorMessage(err.message);

          if(_status === 'TASK_NOT_EXIST' || _status === 'INSTANCE_SUSPENDED') {
            return $translate(_status).then(function(translated) {
              err.message = translated;
              errorNotification(status, err);
              clearTask(true);
            });

          }
          else if (_status === 'SUBMISSION_PREVENTED') {
            return;
          }

          errorNotification(status, err);

        };

        function enhanceErrorMessage(msg) {
          if (msg) {
            if(msg.indexOf('task is null') !== -1 || msg.indexOf('No matching task') !== -1) {
              // task does not exist (e.g. completed by someone else)
              return 'TASK_NOT_EXIST';
            }
            else if(msg.indexOf('is suspended') !== -1) {
              // process instance is suspended
              return 'INSTANCE_SUSPENDED';
            }
            else if(msg.indexOf('submission prevented') !== -1) {
              // embedded form submission prevented
              return 'SUBMISSION_PREVENTED';
            }
          }
          return msg;
        }
{'fraction_non_alphanumeric': 0.17263843648208468, 'fraction_numerical': 0.0017244682889442423, 'mean_word_length': 1.4704212020823473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '420025', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1320, 'n_words': 292}