project_move.vue 1.98 KB
Newer Older
1
<script>
2
  import tooltip from '../../../vue_shared/directives/tooltip';
3 4

  export default {
5 6 7
    directives: {
      tooltip,
    },
8 9 10 11 12
    props: {
      formState: {
        type: Object,
        required: true,
      },
13
      projectsAutocompletePath: {
14 15 16 17 18 19 20 21 22
        type: String,
        required: true,
      },
    },
    mounted() {
      const $moveDropdown = $(this.$refs['move-dropdown']);

      $moveDropdown.select2({
        ajax: {
23
          url: this.projectsAutocompletePath,
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
          quietMillis: 125,
          data(term, page, context) {
            return {
              search: term,
              offset_id: context,
            };
          },
          results(data) {
            const more = data.length >= 50;
            const context = data[data.length - 1] ? data[data.length - 1].id : null;

            return {
              results: data,
              more,
              context,
            };
          },
        },
        formatResult(project) {
          return project.name_with_namespace;
        },
        formatSelection(project) {
          return project.name_with_namespace;
        },
      })
      .on('change', (e) => {
        this.formState.move_to_project_id = parseInt(e.target.value, 10);
      });
    },
    beforeDestroy() {
      $(this.$refs['move-dropdown']).select2('destroy');
    },
  };
</script>

<template>
  <fieldset>
    <label
      for="issuable-move"
      class="sr-only">
      Move
    </label>
    <div class="issuable-form-select-holder append-right-5">
      <input
        ref="move-dropdown"
        type="hidden"
        id="issuable-move"
        data-placeholder="Move to a different project" />
    </div>
    <span
74
      v-tooltip
75
      data-placement="auto top"
76
      title="Moving an issue will copy the discussion to a different project and close it here. All participants will be notified of the new location.">
77 78 79 80 81 82 83
      <i
        class="fa fa-question-circle"
        aria-hidden="true">
      </i>
    </span>
  </fieldset>
</template>