<commit_before>
angular.module('os.rde', [])
  .config(function($stateProvider) {
    $stateProvider
      .state('cp-detail.rde-config', {
        url: '/rde-config',
        templateUrl: 'modules/rde/cp-config.html',
        controller: 'RdeConfigCtrl',
        parent: 'cp-detail'
      })

      .state('rde-sessions', {
        url: '/rde-sessions',
        templateUrl: 'modules/rde/list-sessions.html',
        controller: 'RdeListSessionsCtrl',
        resolve: {
          sessions: function(RdeSession) {
            return RdeSession.query();
          }
        },
        parent: 'signed-in'
      })

      .state('rde', {
        url: '/rde',
        template: '<div ui-view></div>',
        controller: function($scope, ctx) {
          $scope.ctx = ctx;
        },
        resolve: {
          ctx: function() {
            return {};
          }
        },
        abstract: true,
        parent: 'signed-in'
      })

      .state('rde-select-workflow', {
        url: '/select-workflow',
        templateUrl: 'modules/rde/select-workflow.html',
        controller: function($scope, uid) {
          $scope.ctx = { sessionId: uid }
        },
        resolve: {
          uid: function(RdeSession) {
            return RdeSession.generateSessionId();
          }
        },
        parent: 'rde'
      })

      .state('rde-session', {
        url: '/:sessionId',
        template: '<div ui-view></div>',
        controller: function($scope, session, Alerts) {
          $scope.ctx.workflow = session.data.workflow;
          $scope.ctx.sessionId = session.uid;

          $scope.showSessionSaved = function(showMsg) {
            return function() {
              if (showMsg) {
                Alerts.success('rde.session_saved');
              }
            }
          }
        },
        resolve: {
          session: function($stateParams, RdeSession) {
            return RdeSession.getByUid($stateParams.sessionId).then(
              function(session) {
                if (session.uid != $stateParams.sessionId) {
                  session = new RdeSession({uid: $stateParams.sessionId, data: {}});
                }
                return session;
              }
            );
          }
        },
        abstract: true,
        parent: 'rde'
      })

      .state('rde-collect-visit-names', {
        url: '/collect-visit-names',
        templateUrl: 'modules/rde/collect-visit-barcodes.html',
        controller: 'RdeCollectVisitBarcodesCtrl',
        parent: 'rde-session'
      })

      .state('rde-validate-visit-names', {
        url: '/validate-visit-names',
        templateUrl: 'modules/rde/visit-barcode-details.html',
        controller: 'RdeVisitBarcodeDetailsCtrl',
        resolve: {
          visitDetails: function(ctx, session, RdeApis) {
            if (!ctx.visits || ctx.visits.length == 0) {
              ctx.visits = session.getVisitBarcodes();
            }

            var barcodes = ctx.visits.map(function(v) { return v.barcode });
            return RdeApis.getBarcodeDetails(barcodes);
          }
        },
        parent: 'rde-session'
      })

      .state('rde-collect-participant-details', {
        url: '/collect-participant-details',
        templateUrl: 'modules/rde/collect-participant-details.html',
        controller: 'RdeCollectParticipantDetailsCtrl',
        resolve: {
          cps: function(CollectionProtocol) {
            return CollectionProtocol.listForRegistrations();
          }
        },
        parent: 'rde-session'
      })

      .state('rde-collect-visit-details', {
        url: '/collect-visit-details',
        templateUrl: 'modules/rde/collect-visit-details.html',
        controller: 'RdeCollectVisitDetailsCtrl',
        resolve: {
          participants: function(ctx, session) {
            if (!ctx.participants || ctx.participants.length == 0) {
              ctx.participants = session.data.participants;
            }

            return angular.copy(ctx.participants);
          }
        },
        parent: 'rde-session'
      })

      .state('rde-process-aliquots', {
        controller: function($scope, $state, ctx, session) {
          ctx.workflow = 'process_aliquots';
          angular.extend(session.data, {
            workflow: ctx.workflow,
            step: 'rde-select-container'
          });

          session.saveOrUpdate().then(
            function() {
              $state.go('rde-select-container', {sessionId: session.uid})
            }
          );
        },
        parent: 'rde-session'
      })

      .state('rde-collect-primary-specimens', {
        url: '/collect-primary-specimens',<commit_msg>OPSMN-2972: There was no URL assigned for process-aliquots workflow. This resulted in temporary flash of sign-in view until select containers view was loaded. Further clicking browser back button didn't change the view. It created a loop. Fixed by<commit_after>
angular.module('os.rde', [])
  .config(function($stateProvider) {
    $stateProvider
      .state('cp-detail.rde-config', {
        url: '/rde-config',
        templateUrl: 'modules/rde/cp-config.html',
        controller: 'RdeConfigCtrl',
        parent: 'cp-detail'
      })

      .state('rde-sessions', {
        url: '/rde-sessions',
        templateUrl: 'modules/rde/list-sessions.html',
        controller: 'RdeListSessionsCtrl',
        resolve: {
          sessions: function(RdeSession) {
            return RdeSession.query();
          }
        },
        parent: 'signed-in'
      })

      .state('rde', {
        url: '/rde',
        template: '<div ui-view></div>',
        controller: function($scope, ctx) {
          $scope.ctx = ctx;
        },
        resolve: {
          ctx: function() {
            return {};
          }
        },
        abstract: true,
        parent: 'signed-in'
      })

      .state('rde-select-workflow', {
        url: '/select-workflow',
        templateUrl: 'modules/rde/select-workflow.html',
        controller: function($scope, uid) {
          $scope.ctx = { sessionId: uid }
        },
        resolve: {
          uid: function(RdeSession) {
            return RdeSession.generateSessionId();
          }
        },
        parent: 'rde'
      })

      .state('rde-session', {
        url: '/:sessionId',
        template: '<div ui-view></div>',
        controller: function($scope, session, Alerts) {
          $scope.ctx.workflow = session.data.workflow;
          $scope.ctx.sessionId = session.uid;

          $scope.showSessionSaved = function(showMsg) {
            return function() {
              if (showMsg) {
                Alerts.success('rde.session_saved');
              }
            }
          }
        },
        resolve: {
          session: function($stateParams, RdeSession) {
            return RdeSession.getByUid($stateParams.sessionId).then(
              function(session) {
                if (session.uid != $stateParams.sessionId) {
                  session = new RdeSession({uid: $stateParams.sessionId, data: {}});
                }
                return session;
              }
            );
          }
        },
        abstract: true,
        parent: 'rde'
      })

      .state('rde-collect-visit-names', {
        url: '/collect-visit-names',
        templateUrl: 'modules/rde/collect-visit-barcodes.html',
        controller: 'RdeCollectVisitBarcodesCtrl',
        parent: 'rde-session'
      })

      .state('rde-validate-visit-names', {
        url: '/validate-visit-names',
        templateUrl: 'modules/rde/visit-barcode-details.html',
        controller: 'RdeVisitBarcodeDetailsCtrl',
        resolve: {
          visitDetails: function(ctx, session, RdeApis) {
            if (!ctx.visits || ctx.visits.length == 0) {
              ctx.visits = session.getVisitBarcodes();
            }

            var barcodes = ctx.visits.map(function(v) { return v.barcode });
            return RdeApis.getBarcodeDetails(barcodes);
          }
        },
        parent: 'rde-session'
      })

      .state('rde-collect-participant-details', {
        url: '/collect-participant-details',
        templateUrl: 'modules/rde/collect-participant-details.html',
        controller: 'RdeCollectParticipantDetailsCtrl',
        resolve: {
          cps: function(CollectionProtocol) {
            return CollectionProtocol.listForRegistrations();
          }
        },
        parent: 'rde-session'
      })

      .state('rde-collect-visit-details', {
        url: '/collect-visit-details',
        templateUrl: 'modules/rde/collect-visit-details.html',
        controller: 'RdeCollectVisitDetailsCtrl',
        resolve: {
          participants: function(ctx, session) {
            if (!ctx.participants || ctx.participants.length == 0) {
              ctx.participants = session.data.participants;
            }

            return angular.copy(ctx.participants);
          }
        },
        parent: 'rde-session'
      })

      .state('rde-process-aliquots', {
        url: '/process-aliquots',
        controller: function($scope, $state, ctx, session) {
          ctx.workflow = 'process_aliquots';
          angular.extend(session.data, {
            workflow: ctx.workflow,
            step: 'rde-select-container'
          });

          session.saveOrUpdate().then(
            function() {
              $state.go('rde-select-container', {sessionId: session.uid}, {location: 'replace'})
            }
          );
        },
        parent: 'rde-session'
      })

      .state('rde-collect-primary-specimens', {
        url: '/collect-primary-specimens',
{'fraction_non_alphanumeric': 0.1355808370733744, 'fraction_numerical': 0.0008349859096127753, 'mean_word_length': 1.722932651321398, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '7124383', 'n_tokens_mistral': 2790, 'n_tokens_neox': 2732, 'n_words': 440}