Commit 89834425 authored by Axel García's avatar Axel García

Add labels selector to new epic form

parent 51c19ec0
<script> <script>
import { GlButton, GlDatepicker, GlForm, GlFormCheckbox, GlFormInput } from '@gitlab/ui'; import { GlButton, GlDatepicker, GlForm, GlFormCheckbox, GlFormInput } from '@gitlab/ui';
import { visitUrl, joinPaths } from '~/lib/utils/url_utility';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
import LabelsSelectVue from '~/vue_shared/components/sidebar/labels_select_vue/labels_select_root.vue';
import MarkdownField from '~/vue_shared/components/markdown/field.vue'; import MarkdownField from '~/vue_shared/components/markdown/field.vue';
import createEpic from '../queries/createEpic.mutation.graphql'; import createEpic from '../queries/createEpic.mutation.graphql';
...@@ -14,6 +15,7 @@ export default { ...@@ -14,6 +15,7 @@ export default {
GlFormCheckbox, GlFormCheckbox,
GlFormInput, GlFormInput,
MarkdownField, MarkdownField,
LabelsSelectVue,
}, },
props: { props: {
groupPath: { groupPath: {
...@@ -32,7 +34,7 @@ export default { ...@@ -32,7 +34,7 @@ export default {
}, },
data() { data() {
return { return {
labelIds: [], labels: [],
confidential: false, confidential: false,
description: '', description: '',
title: '', title: '',
...@@ -41,7 +43,15 @@ export default { ...@@ -41,7 +43,15 @@ export default {
loading: false, loading: false,
}; };
}, },
computed: {
labelIds() {
return this.labels.map(label => label.id);
},
},
methods: { methods: {
groupUrl(path) {
return joinPaths('/groups', this.groupPath, '/-/', path);
},
save() { save() {
this.loading = true; this.loading = true;
...@@ -50,7 +60,7 @@ export default { ...@@ -50,7 +60,7 @@ export default {
mutation: createEpic, mutation: createEpic,
variables: { variables: {
input: { input: {
addLabelIds: this.labels, addLabelIds: this.labelIds,
groupPath: this.groupPath, groupPath: this.groupPath,
title: this.title, title: this.title,
description: this.description, description: this.description,
...@@ -84,6 +94,17 @@ export default { ...@@ -84,6 +94,17 @@ export default {
updateStartDate(val) { updateStartDate(val) {
this.startDateFixed = val; this.startDateFixed = val;
}, },
handleUpdateSelectedLabels(labels) {
const ids = [];
const allLabels = [...labels, ...this.labels];
this.labels = allLabels.filter(label => {
const exists = ids.includes(label.id);
ids.push(label.id);
return !exists && label.set;
});
},
}, },
}; };
</script> </script>
...@@ -155,7 +176,26 @@ export default { ...@@ -155,7 +176,26 @@ export default {
<div class="col-form-label col-md-2 col-lg-4"> <div class="col-form-label col-md-2 col-lg-4">
<label for="epic-title">{{ __('Labels') }}</label> <label for="epic-title">{{ __('Labels') }}</label>
</div> </div>
<div class="col-md-8 col-sm-10"></div> <div class="col-md-8 col-sm-10">
<div class="issuable-form-select-holder">
<labels-select-vue
:allow-label-edit="false"
:allow-label-create="true"
:allow-multiselect="true"
:allow-scoped-labels="false"
:selected-labels="labels"
:labels-fetch-path="
groupUrl('labels.json?include_ancestor_groups=true&only_group_labels=true')
"
:labels-manage-path="groupUrl('labels')"
:labels-filter-base-path="groupUrl('epics')"
variant="standalone"
class="block labels js-labels-block"
@updateSelectedLabels="handleUpdateSelectedLabels"
>{{ __('None') }}</labels-select-vue
>
</div>
</div>
</div> </div>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
......
...@@ -81,3 +81,38 @@ ...@@ -81,3 +81,38 @@
.tooltip .tooltip-inner .milestone-date-range { .tooltip .tooltip-inner .milestone-date-range {
color: $gl-text-color-tertiary; color: $gl-text-color-tertiary;
} }
.labels-select-wrapper.is-standalone {
@include gl-bg-white;
@include gl-font-regular;
@include gl-font-base;
@include gl-line-height-normal;
@include gl-py-3;
@include gl-px-4;
@include gl-h-auto;
@include gl-text-left;
@include gl-border-none;
@include gl-inset-border-1-gray-400;
@include gl-rounded-base;
@include gl-white-space-nowrap;
.labels-select-dropdown-button {
@include gl-bg-none;
@include gl-border-none;
@include gl-shadow-none;
@include gl-p-0;
.gl-button-text {
@include gl-text-gray-700;
@include gl-display-flex;
@include gl-justify-content-space-between;
@include gl-w-full;
}
}
.labels-select-dropdown-contents {
@include gl-left-0;
@include gl-shadow-x0-y2-b4-s0;
top: 100%;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment