<commit_before>import Ember from 'ember'
import frostLink from 'ember-frost-core/components/frost-link'
import layout from '../templates/components/frost-related-details'

const FrostRelatedDetails =  frostLink.extend({
  _routing: Ember.inject.service('-routing'),

  layout: layout,
  classNames: ['frost-related-detail'],

  /**
   @property classNameBindings
   @type Array
   @default ['isSelected']
   */
  classNameBindings: ['isSelected'],

  /**
   The recently visited primary view route from top tabs.
   The targetRouteName of a `frost-link` wrapped by `frost-action-link` would
   be set to `persistedRouteName` if `isSelected` is true and `persistedRouteName`
   is presented.
   @property persistedRouteName
   @type {String}
   */
  persistedRouteName: '',

  /**
   The default route entry for object detail view.
   The targetRouteName of a `frost-link` wrapped by `frost-action-link` would
   be set to `defaultRoute` if `isSelected` is true and `defaultRoute` is NOT presented.
   @property defaultRoute
   @type {String}
   */
  defaultRoute: '',

  /**
   A `frost-action-link` is considered active/isSelected when the application's
   current route is the route the `frost-link` wrapped by `frost-action-link`
   would trigger transitions into.
   @property isSelected
   */
  init() {
    this._super(...arguments);
    let params = this.params.slice();
    this.set('route', params[0])
  },


  isSelected: Ember.computed('route', '_routing.currentRouteName', function () {
    debugger;
    return this.get('route') === this.get('_routing.currentRouteName')
  }),

  willRender() {
    this._super(...arguments);

    this.set('targetRouteName', Ember.computed('isSelected', 'persistedRouteName', 'defaultRoute', function () {
      debugger;
      if(this.get('isSelected')) {
        if(this.get('persistedRouteName')) {
          return this.get('persistedRouteName')
        } else {
          return this.get('defaultRoute')
        }
      } else {
        return this.get('route')
      }
    }))
  },

  //targetRouteName: Ember.computed('isSelected', 'persistedRouteName', 'defaultRoute', function () {
  //  debugger;
  //  if(this.get('isSelected')) {
  //    if(this.get('persistedRouteName')) {
  //      return this.get('persistedRouteName')
  //    } else {
  //      return this.get('defaultRoute')
  //    }
  //  } else {
  //    return this.get('route')
  //  }
  //}),

  didReceiveAttrs() {
    if(!this.get('alias')) {
      let relatedRouteDirName = this.get('relatedRouteDirName') ? this.get('relatedRouteDirName') : 'related'
      this.set('alias', this.get('route').substring(`${this.get('parentRouteName')}.${relatedRouteDirName}.`.length))
    }
    if(!this.get('svgPath')) {
      this.set('svgPath', 'frost/dialog-error')
    }
  }
})

export default FrostRelatedDetails<commit_msg>try use qualifiedRouteNAme<commit_after>import Ember from 'ember'
import frostLink from 'ember-frost-core/components/frost-link'
import layout from '../templates/components/frost-related-details'

const FrostRelatedDetails =  frostLink.extend({
  _routing: Ember.inject.service('-routing'),

  layout: layout,
  classNames: ['frost-related-detail'],

  /**
   @property classNameBindings
   @type Array
   @default ['isSelected']
   */
  classNameBindings: ['isSelected'],

  /**
   The recently visited primary view route from top tabs.
   The targetRouteName of a `frost-link` wrapped by `frost-action-link` would
   be set to `persistedRouteName` if `isSelected` is true and `persistedRouteName`
   is presented.
   @property persistedRouteName
   @type {String}
   */
  persistedRouteName: '',

  /**
   The default route entry for object detail view.
   The targetRouteName of a `frost-link` wrapped by `frost-action-link` would
   be set to `defaultRoute` if `isSelected` is true and `defaultRoute` is NOT presented.
   @property defaultRoute
   @type {String}
   */
  defaultRoute: '',

  /**
   A `frost-action-link` is considered active/isSelected when the application's
   current route is the route the `frost-link` wrapped by `frost-action-link`
   would trigger transitions into.
   @property isSelected
   */
  init() {
    this._super(...arguments);
    let params = this.params.slice();
    this.set('route', params[0])
  },


  isSelected: Ember.computed('route', '_routing.currentRouteName', function () {
    debugger;
    return this.get('route') === this.get('_routing.currentRouteName')
  }),

  myTargetRouteName: Ember.computed('isSelected', 'persistedRouteName', 'defaultRoute', function () {
    if(this.get('isSelected')) {
      if(this.get('persistedRouteName')) {
        return this.get('persistedRouteName')
      } else {
        return this.get('defaultRoute')
      }
    } else {
      return this.get('route')
    }
  }),

  qualifiedRouteName: Ember.computed('myTargetRouteName', '_routing.currentState', function computeLinkToComponentQualifiedRouteName() {
    let params = this.get('params').slice();
    let lastParam = params[params.length - 1];
    if (lastParam && lastParam.isQueryParams) {
      params.pop();
    }
    //debugger;
    //let onlyQueryParamsSupplied = (this[HAS_BLOCK] ? params.length === 0 : params.length === 1);
    //if (onlyQueryParamsSupplied) {
    //  return this.get('_routing.currentRouteName');
    //}
    return this.get('myTargetRouteName');
  }),

  willRender() {
    this._super(...arguments);
  },

  didReceiveAttrs() {
    if(!this.get('alias')) {
      let relatedRouteDirName = this.get('relatedRouteDirName') ? this.get('relatedRouteDirName') : 'related'
      this.set('alias', this.get('route').substring(`${this.get('parentRouteName')}.${relatedRouteDirName}.`.length))
    }
    if(!this.get('svgPath')) {
      this.set('svgPath', 'frost/dialog-error')
    }
  }
})

export default FrostRelatedDetails
{'fraction_non_alphanumeric': 0.147119341563786, 'fraction_numerical': 0.0008573388203017832, 'mean_word_length': 3.459480122324159, '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': '5513690', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1778, 'n_words': 388}