<commit_before><template>
  <div>
    <h2 class="title">Calibrate {{ instrument.label }} pipette</h2>
    <div class="instructions">
      Calibrate {{ instrument.label }}'s plunger. Be sure to save top, bottom, blowout, and droptip. Enter max volume.
    </div>

    <section>
      <div class="step step-calibrate">
        <Jog :instrument="instrument.axis"></Jog>
        <JogPlunger :axis="instrument.axis"></JogPlunger>
        <div class="save-pipette">
            <h3 class="title">Current Position</h3>
            <coordinates :instrument="instrument" :axis="instrument.axis.toUpperCase()"></coordinates>
            <h3 class="title">Calibrate {{ instrument.label }} axis {{instrument.axis.toUpperCase() }}</h3>
            <CalibrateInstrument :instrument="instrument"></CalibrateInstrument>
        </div>
      </div>
      <Navigation :prev="prev" :next="next"></Navigation>
    </section>
  </div>
</template>

<script>
  import Navigation from './Navigation.vue'
  import Jog from './Jog.vue'
  import JogPlunger from './JogPlunger.vue'
  import Coordinates from './Coordinates.vue'
  import CalibrateInstrument from './CalibrateInstrument.vue'

  export default {
    name: "Instrument",
    data: function() {
      return {}
    },
    components: {
      Navigation,
      Jog,
      JogPlunger,
      Coordinates,
      CalibrateInstrument
    },
    methods: {
      currentInstrument(tasks) {
        return tasks.filter((instrument) => {
          return instrument.axis == this.$route.params.instrument
        })[0]
      }
    },
    computed: {
      instrument() {
        let tasks = this.$store.state.tasks
        let instrument = this.currentInstrument(tasks)
        return instrument
      },
      next() {
        let tasks = this.$store.state.tasks
        let instrument = this.currentInstrument(tasks)
        let currentInstrumentIndex = tasks.indexOf(instrument)
        let nextInstrument = tasks[currentInstrumentIndex + 1]
        if(nextInstrument) {
          return nextInstrument.href
        } else {
          return '/run'
        }
      },
      prev() {
        let tasks = this.$store.state.tasks
        let instrument = this.currentInstrument(tasks)
        let currentInstrumentIndex = tasks.indexOf(instrument)
        let prevInstrument = tasks[currentInstrumentIndex - 1]
        let prevPlaceables = tasks[tasks.length - 1].placeables
        let prevPlaceable = prevPlaceables[prevPlaceables.length - 1]

        if(prevInstrument) {
          return prevInstrument.href
        } else {
          return prevPlaceable.href
        }
      }
    }
  }
</script>
<commit_msg>added logic for prev/next when an instrument has no placebales associated with it<commit_after><template>
  <div>
    <h2 class="title">Calibrate {{ instrument.label }} pipette</h2>
    <div class="instructions">
      Calibrate {{ instrument.label }}'s plunger. Be sure to save top, bottom, blowout, and droptip. Enter max volume.
    </div>

    <section>
      <div class="step step-calibrate">
        <Jog :instrument="instrument.axis"></Jog>
        <JogPlunger :axis="instrument.axis"></JogPlunger>
        <div class="save-pipette">
            <h3 class="title">Current Position</h3>
            <coordinates :instrument="instrument" :axis="instrument.axis.toUpperCase()"></coordinates>
            <h3 class="title">Calibrate {{ instrument.label }} axis {{instrument.axis.toUpperCase() }}</h3>
            <CalibrateInstrument :instrument="instrument"></CalibrateInstrument>
        </div>
      </div>
      <Navigation :prev="prev" :next="next"></Navigation>
    </section>
  </div>
</template>

<script>
  import Navigation from './Navigation.vue'
  import Jog from './Jog.vue'
  import JogPlunger from './JogPlunger.vue'
  import Coordinates from './Coordinates.vue'
  import CalibrateInstrument from './CalibrateInstrument.vue'

  export default {
    name: "Instrument",
    data: function() {
      return {}
    },
    components: {
      Navigation,
      Jog,
      JogPlunger,
      Coordinates,
      CalibrateInstrument
    },
    methods: {
      currentInstrument(tasks) {
        return tasks.filter((instrument) => {
          return instrument.axis == this.$route.params.instrument
        })[0]
      }
    },
    computed: {
      instrument() {
        let tasks = this.$store.state.tasks
        let instrument = this.currentInstrument(tasks)
        return instrument
      },
      next() {
        let tasks = this.$store.state.tasks
        let instrument = this.currentInstrument(tasks)
        let currentInstrumentIndex = tasks.indexOf(instrument)
        let nextInstrument = tasks[currentInstrumentIndex + 1]
        if(nextInstrument) {
          return nextInstrument.href
        } else {
          return '/run'
        }
      },
      prev() {
        let tasks = this.$store.state.tasks
        let instrument = this.currentInstrument(tasks)
        let currentInstrumentIndex = tasks.indexOf(instrument)
        
        let prevInstrument = tasks[currentInstrumentIndex - 1]
        let prevPlaceables = tasks[tasks.length - 1].placeables
        let prevPlaceable = prevPlaceables[prevPlaceables.length - 1]

        if(!prevPlaceable){
          prevPlaceables = tasks[currentInstrumentIndex].placeables
          prevPlaceable = prevPlaceables[prevPlaceables.length-1]
          
        }

        if(prevInstrument) {
          return prevInstrument.href
        } 

        else {
          return prevPlaceable.href
        }
      }
    }
  }
</script>

{'fraction_non_alphanumeric': 0.11943793911007025, 'fraction_numerical': 0.004143397586020537, 'mean_word_length': 2.41871921182266, 'pattern_counts': {'":': 0, '<': 63, '<?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': '5514683', 'n_tokens_mistral': 1622, 'n_tokens_neox': 1590, 'n_words': 333}