<commit_before>'use strict';

formsAngular.provider('routingService', [ '$injector', '$locationProvider', function ($injector, $locationProvider) {

  var config = {
//  fixedRoutes: [] an array in the same format as builtInRoutes that is matched before the generic routes.  Can be omitted
    hashPrefix: '',
    html5Mode: false,
    routing: 'ngroute',    // What sort of routing do we want?  ngroute or uirouter
    prefix: ''        // How do we want to prefix out routes?  If not empty string then first character must be slash (which is added if not)
  };

  var builtInRoutes = [
    {route: '/analyse/:model/:reportSchemaName', state: 'analyse::model::report', templateUrl: 'partials/base-analysis.html'},
    {route: '/analyse/:model',                   state: 'analyse::model',         templateUrl: 'partials/base-analysis.html'},
    {route: '/:model/:id/edit',                  state: 'model::edit',            templateUrl: 'partials/base-edit.html'},
    {route: '/:model/new',                       state: 'model::new',             templateUrl: 'partials/base-edit.html'},
    {route: '/:model',                           state: 'model::list',            templateUrl: 'partials/base-list.html'},
    {route: '/:model/:form/:id/edit',            state: 'model::form::edit',      templateUrl: 'partials/base-edit.html'},       // non default form (different fields etc)
    {route: '/:model/:form/new',                 state: 'model::form::new',       templateUrl: 'partials/base-edit.html'},       // non default form (different fields etc)
    {route: '/:model/:form',                     state: 'model::form::list',      templateUrl: 'partials/base-list.html'}        // list page with links to non default form
  ];

  var _routeProvider, _stateProvider;
  var lastRoute = null,
    lastObject = {};

  function _setUpNgRoutes(routes) {
    angular.forEach(routes, function (routeSpec) {
      _routeProvider.when(config.prefix + routeSpec.route, routeSpec.options || {templateUrl: routeSpec.templateUrl});
    });
  }

  function _setUpUIRoutes(routes) {
    angular.forEach(routes, function (routeSpec) {
      _stateProvider.state(routeSpec.state, routeSpec.options || {
        url: routeSpec.route,
        templateUrl: routeSpec.templateUrl
      });
    });
  }

  function _buildUrl(path) {
    var url = config.html5Mode ? '' : '#';
    url += config.hashPrefix;
    url += config.prefix;
    if (url[0]) { url += '/'; }
    url += (path[0] === '/' ? path.slice(1) : path);
    return url;
  }

  function _buildOperationUrl(prefix, operation, modelName, formName, id) {
      var formString = formName ? ('/' + formName) : '';
      var modelString = prefix + '/' + modelName;
      var urlStr;
      switch (operation) {
          case 'list' :
              urlStr = modelString + formString;<commit_msg>FIX url prefix FEATURE: add optional parent state<commit_after>'use strict';

formsAngular.provider('routingService', [ '$injector', '$locationProvider', function ($injector, $locationProvider) {

  var config = {
//  fixedRoutes: [] an array in the same format as builtInRoutes that is matched before the generic routes.  Can be omitted
    hashPrefix: '',
    html5Mode: false,
    routing: 'ngroute',    // What sort of routing do we want?  ngroute or uirouter
    prefix: '',        // How do we want to prefix out routes?  If not empty string then first character must be slash (which is added if not)
    parentState: null
  };

  var builtInRoutes = [
    {route: '/analyse/:model/:reportSchemaName', state: 'analyse::model::report', templateUrl: 'partials/base-analysis.html'},
    {route: '/analyse/:model',                   state: 'analyse::model',         templateUrl: 'partials/base-analysis.html'},
    {route: '/:model/:id/edit',                  state: 'model::edit',            templateUrl: 'partials/base-edit.html'},
    {route: '/:model/new',                       state: 'model::new',             templateUrl: 'partials/base-edit.html'},
    {route: '/:model',                           state: 'model::list',            templateUrl: 'partials/base-list.html'},
    {route: '/:model/:form/:id/edit',            state: 'model::form::edit',      templateUrl: 'partials/base-edit.html'},       // non default form (different fields etc)
    {route: '/:model/:form/new',                 state: 'model::form::new',       templateUrl: 'partials/base-edit.html'},       // non default form (different fields etc)
    {route: '/:model/:form',                     state: 'model::form::list',      templateUrl: 'partials/base-list.html'}        // list page with links to non default form
  ];

  var _routeProvider, _stateProvider;
  var lastRoute = null,
    lastObject = {};

  function _setUpNgRoutes(routes) {
    angular.forEach(routes, function (routeSpec) {
      _routeProvider.when(config.prefix + routeSpec.route, routeSpec.options || {templateUrl: routeSpec.templateUrl});
    });
  }
    function _setUpUIRoutes(routes) {
        angular.forEach(routes, function (routeSpec) {
            var options = routeSpec.options || {
                url: config.prefix + routeSpec.route,
                templateUrl: routeSpec.templateUrl
            };

            if (config.parentState) {
                options.parent = config.parentState;
            }

            _stateProvider.state(routeSpec.state, options);
        });
    }

  function _buildUrl(path) {
    var url = config.html5Mode ? '' : '#';
    url += config.hashPrefix;
    url += config.prefix;
    if (url[0]) { url += '/'; }
    url += (path[0] === '/' ? path.slice(1) : path);
    return url;
  }

  function _buildOperationUrl(prefix, operation, modelName, formName, id) {
      var formString = formName ? ('/' + formName) : '';
      var modelString = prefix + '/' + modelName;
      var urlStr;
      switch (operation) {
          case 'list' :
              urlStr = modelString + formString;
{'fraction_non_alphanumeric': 0.14387031408308004, 'fraction_numerical': 0.0016886187098953055, 'mean_word_length': 2.5214030915576693, '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': '2455237', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1709, 'n_words': 430}