<commit_before><template>
  <div class="container">
    <div class="notification is-danger" v-if="error">
      <p>
        {{ error }}
      </p>
    </div>
    <h5 class="title is-5">Add Merit Badge Preferences for {{ scout.fullname }}</h5>
    <div class="columns is-multiline">

    </div>
    <button class="button is-primary"
            :class="{ 'is-disabled is-loading': creating }"
            @click="registerScout()">
      Register Scout
    </button>
    <button class="button"
            @click="cancel()">
      Cancel
    </button>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  props: {
    scout: {
      type: Object,
      required: true
    },
    event: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      creating: false,
      error: ''
    };
  },
  computed: {
    offerings() {
      return _.orderBy(this.event.offerings, 'name');
    }
  },
  methods: {
    cancel() {
      this.$emit('cancel');
    },
    registerScout() {
      this.creating = true;
      this.$store.dispatch('addRegistration', {
        scoutId: this.scout.id,
        eventId: this.event.id
      })
        .then(() => {
          this.creating = false;
          this.$emit('created', projectedCost);
        })
        .catch(() => {
          this.creating = false;
          this.error = 'Failed to register scout for this event.';
        });
    }
  }
}
</script><commit_msg>Initial work on preference selection<commit_after><template>
  <div class="container">
    <div class="notification is-danger" v-if="error">
      <p>
        {{ error }}
      </p>
    </div>
    <h5 class="title is-5">Add Merit Badge Preferences for {{ scout.fullname }}</h5>

    <div class="columns is-multiline">
      <p class="column is-12">
        Please select the top six merit badges that {{ scout.firstname}} would
        like to attend classes for. We will do our best to accommodate
        preferences.
      </p>
      <template v-for="(preference, index) in preferences">
        <div class="column is-6">
          <div class="control is-horizontal">
            <div class="control-label">
              <label class="label"
                :for="'registration-rank' + index">
                {{ index + 1 }}:
                </label>
            </div>
            <div class="control">
              <span class="select">
                <select class="form-control"
                        :id="'registration-rank' + index"
                        v-model="preference.offering">
                  <option v-for="option in offerings" :value="option.id">
                    {{ option.name }}
                  </option>
                </select>
              </span>
            </div>
          </div>
        </div>
      </template>
    </div>
    <div class="is-pulled-right">
      <button class="button is-primary"
              :class="{ 'is-disabled is-loading': creating }"
              @click="registerScout()">
        Register Scout
      </button>
      <button class="button"
              @click="cancel()">
        Cancel
      </button>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';

export default {
  props: {
    scout: {
      type: Object,
      required: true
    },
    event: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      preferences: [],
      creating: false,
      error: ''
    };
  },
  computed: {
    offerings() {
      return _.orderBy(this.event.offerings, 'name');
    }
  },
  methods: {
    cancel() {
      this.$emit('cancel');
    },
    registerScout() {
      this.creating = true;
      this.$store.dispatch('addRegistration', {
        scoutId: this.scout.id,
        eventId: this.event.id
      })
        .then(() => {
          this.creating = false;
          this.$emit('created', projectedCost);
        })
        .catch(() => {
          this.creating = false;
          this.error = 'Failed to register scout for this event.';
        });
    }
  },
  mounted() {
    for (var i = 1; i <= 6; i++) {
      this.preferences.push({
        rank: i,
        offering: ''
      })
    }
  }
}
</script>
{'fraction_non_alphanumeric': 0.15485252140818268, 'fraction_numerical': 0.0028544243577545195, 'mean_word_length': 1.673235855054037, 'pattern_counts': {'":': 0, '<': 62, '<?xml version=': 0, '>': 65, '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': '3516718', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1254, 'n_words': 285}