<commit_before>import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
  showPersonal: computed('fragment.nameType', function() {
    return this.get('fragment.nameType') !== 'Organizational';
  }),
  isReadonlyNameType: false,
  isReadonly: false,
  isReadonlyNameParts: false,

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

    this.selectNameType(this.fragment.get('nameType'));

    // if no givenName and familyName, and set for nameType "Personal"
    if (this.fragment.get('name') && this.fragment.get('nameType') === 'Personal' && (!this.fragment.get('givenName') || this.fragment.get('familyName'))) {
      let familyName = this.fragment.get('name').split(',', 2)[0];
      let givenName = this.fragment.get('name').split(',', 2)[1];
      familyName = (familyName) ? familyName.trim() : null;
      givenName = (givenName) ? givenName.trim() : null;
      this.fragment.set('givenName', givenName);
      this.fragment.set('familyName', familyName);
    }
    this.joinNameParts({});

    if (!this.fragment.get('nameIdentifiers')) {
      this.fragment.set('nameIdentifiers', []);
    }
    if (this.fragment.get('nameIdentifiers').length == 0) {
      this.fragment.get('nameIdentifiers').createFragment();<commit_msg>Fixes issue where an empty givenName and familyName could make all name fields blank in person base component.<commit_after>import Component from '@ember/component';
import { computed } from '@ember/object';

export default Component.extend({
  showPersonal: computed('fragment.nameType', function() {
    return this.get('fragment.nameType') !== 'Organizational';
  }),
  isReadonlyNameType: false,
  isReadonly: false,
  isReadonlyNameParts: false,

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

    // if no givenName and familyName, and set for nameType "Personal"
    if (this.fragment.get('name') && this.fragment.get('nameType') === 'Personal' && (!this.fragment.get('givenName') || this.fragment.get('familyName'))) {
      let familyName = this.fragment.get('name').split(',', 2)[0];
      let givenName = this.fragment.get('name').split(',', 2)[1];
      familyName = (familyName) ? familyName.trim() : null;
      givenName = (givenName) ? givenName.trim() : null;
      this.fragment.set('givenName', givenName);
      this.fragment.set('familyName', familyName);
    }
    this.joinNameParts({});

    this.selectNameType(this.fragment.get('nameType'));

    if (!this.fragment.get('nameIdentifiers')) {
      this.fragment.set('nameIdentifiers', []);
    }
    if (this.fragment.get('nameIdentifiers').length == 0) {
      this.fragment.get('nameIdentifiers').createFragment();
{'fraction_non_alphanumeric': 0.17215845982969272, 'fraction_numerical': 0.0037023324694557573, 'mean_word_length': 4.287671232876712, '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': '6068879', 'n_tokens_mistral': 823, 'n_tokens_neox': 794, 'n_words': 156}