BigW Consortium Gitlab

description_template.vue 2.77 KB
Newer Older
1 2 3
<script>
  export default {
    props: {
4 5 6 7
      formState: {
        type: Object,
        required: true,
      },
8 9 10 11 12
      issuableTemplates: {
        type: Array,
        required: false,
        default: () => [],
      },
13 14 15 16 17 18 19 20
      projectPath: {
        type: String,
        required: true,
      },
      projectNamespace: {
        type: String,
        required: true,
      },
21
    },
22 23 24 25 26
    computed: {
      issuableTemplatesJson() {
        return JSON.stringify(this.issuableTemplates);
      },
    },
27
    mounted() {
28
      // Create the editor for the template
29
      const editor = document.querySelector('.detail-page-description .note-textarea') || {};
30 31 32 33 34 35 36 37 38
      editor.setValue = (val) => {
        this.formState.description = val;
      };
      editor.getValue = () => this.formState.description;

      this.issuableTemplate = new gl.IssuableTemplateSelectors({
        $dropdowns: $(this.$refs.toggle),
        editor,
      });
39 40 41 42 43 44 45 46 47 48 49
    },
  };
</script>

<template>
  <div
    class="dropdown js-issuable-selector-wrap"
    data-issuable-type="issue">
    <button
      class="dropdown-menu-toggle js-issuable-selector"
      type="button"
50
      ref="toggle"
51 52
      data-field-name="issuable_template"
      data-selected="null"
53 54 55
      data-toggle="dropdown"
      :data-namespace-path="projectNamespace"
      :data-project-path="projectPath"
56
      :data-data="issuableTemplatesJson">
57
      <span class="dropdown-toggle-text">
58 59 60 61 62 63 64 65 66 67 68
        Choose a template
      </span>
      <i
        aria-hidden="true"
        class="fa fa-chevron-down">
      </i>
    </button>
    <div class="dropdown-menu dropdown-select">
      <div class="dropdown-title">
        Choose a template
        <button
Phil Hughes committed
69 70 71
          class="dropdown-title-button dropdown-menu-close"
          aria-label="Close"
          type="button">
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
          <i
            aria-hidden="true"
            class="fa fa-times dropdown-menu-close-icon">
          </i>
        </button>
      </div>
      <div class="dropdown-input">
        <input
          type="search"
          class="dropdown-input-field"
          placeholder="Filter"
          autocomplete="off" />
        <i
          aria-hidden="true"
          class="fa fa-search dropdown-input-search">
        </i>
        <i
          role="button"
Phil Hughes committed
90
          aria-label="Clear templates search input"
91 92 93
          class="fa fa-times dropdown-input-clear js-dropdown-input-clear">
        </i>
      </div>
94
      <div class="dropdown-content"></div>
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
      <div class="dropdown-footer">
        <ul class="dropdown-footer-list">
          <li>
            <a class="no-template">
              No template
            </a>
          </li>
          <li>
            <a class="reset-template">
              Reset template
            </a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>