@@ -35,6 +35,7 @@ import SelectTeamModal from '../../administration/accessmanagement/SelectTeamMod
35
35
import permissionsMixin from ' ../../../mixins/permissionsMixin' ;
36
36
import BToggleableDisplayButton from ' ../../components/BToggleableDisplayButton' ;
37
37
import BInputGroupFormInput from ' ../../../forms/BInputGroupFormInput' ;
38
+ import VueTagsInput from ' @johmun/vue-tags-input' ;
38
39
import { Switch as cSwitch } from ' @coreui/vue' ;
39
40
40
41
export default {
@@ -170,6 +171,18 @@ export default {
170
171
<actionable-list-group-item :add-icon="true" v-on:actionClicked="$root.$emit('bv::show::modal', 'selectProjectModal')"/>
171
172
</div>
172
173
</b-form-group>
174
+ <b-form-group v-if="limitToVisible" id="tagLimits" :label="this.$t('admin.limit_to_tags')">
175
+ <vue-tags-input
176
+ id="limitToTagsInput"
177
+ v-model="tag"
178
+ :tags="tags"
179
+ :add-on-key="addOnKeys"
180
+ :placeholder="$t('message.add_tag')"
181
+ :autocomplete-items="tagsAutoCompleteItems"
182
+ @tags-changed="(newTags) => (this.tags = newTags)"
183
+ class="mw-100 bg-transparent text-lowercase"
184
+ />
185
+ </b-form-group>
173
186
<div v-if="limitToVisible === true">
174
187
<c-switch id="isNotifyChildrenEnabled" color="primary" v-model="notifyChildren" label v-bind="labelIcon"/>
175
188
{{ $t('admin.include_active_children') }}
@@ -227,6 +240,7 @@ export default {
227
240
SelectTeamModal,
228
241
BToggleableDisplayButton,
229
242
BInputGroupFormInput,
243
+ VueTagsInput,
230
244
cSwitch,
231
245
},
232
246
data () {
@@ -249,6 +263,11 @@ export default {
249
263
projects: row .projects ,
250
264
teams: row .teams ,
251
265
limitToVisible: false ,
266
+ tag: ' ' , // The contents of a tag as its being typed into the vue-tag-input
267
+ tags: [], // An array of tags bound to the vue-tag-input
268
+ tagsAutoCompleteItems: [],
269
+ tagsAutoCompleteDebounce: null ,
270
+ addOnKeys: [9 , 13 , 32 , ' :' , ' ;' , ' ,' ], // Separators used when typing tags into the vue-tag-input
252
271
labelIcon: {
253
272
dataOn: ' \u2713 ' ,
254
273
dataOff: ' \u2715 ' ,
@@ -265,29 +284,24 @@ export default {
265
284
};
266
285
},
267
286
created () {
287
+ this .initializeTags ();
268
288
this .parseDestination (this .alert );
269
289
this .parseToken (this .alert );
270
290
this .parseTokenHeader (this .alert );
271
291
this .parseJiraTicketType (this .alert );
272
292
},
273
293
watch: {
274
- enabled () {
275
- this .updateNotificationRule ();
276
- },
277
- logSuccessfulPublish () {
278
- this .updateNotificationRule ();
279
- },
280
- notifyChildren () {
281
- this .updateNotificationRule ();
282
- },
283
- notifyOn () {
284
- this .updateNotificationRule ();
285
- },
286
- teams () {
287
- this .updateNotificationRule ();
294
+ alert () {
295
+ this .initializeTags ();
288
296
},
297
+ tag: ' searchTags' ,
289
298
},
290
299
methods: {
300
+ initializeTags : function () {
301
+ this .tags = (this .alert .tags || []).map ((tag ) => ({
302
+ text: tag .name ,
303
+ }));
304
+ },
291
305
formatProjectLabel : function (projectName , projectVersion ) {
292
306
if (projectName && projectVersion) {
293
307
return projectName + ' ' + projectVersion;
@@ -348,6 +362,9 @@ export default {
348
362
tokenHeader: this .tokenHeader ,
349
363
}),
350
364
notifyOn: this .notifyOn ,
365
+ tags: this .tags .map ((tag ) => {
366
+ return { name: tag .text };
367
+ }),
351
368
})
352
369
.then ((response ) => {
353
370
this .alert = response .data ;
@@ -485,6 +502,21 @@ export default {
485
502
this .$toastr .w (this .$t (' condition.unsuccessful_action' ));
486
503
});
487
504
},
505
+ searchTags : function () {
506
+ if (! this .tag ) {
507
+ return ;
508
+ }
509
+
510
+ clearTimeout (this .tagsAutoCompleteDebounce );
511
+ this .tagsAutoCompleteDebounce = setTimeout (() => {
512
+ const url = ` ${ this .$api .BASE_URL } /${ this .$api .URL_TAG } ?searchText=${ encodeURIComponent (this .tag )} &pageNumber=1&pageSize=6` ;
513
+ this .axios .get (url).then ((response ) => {
514
+ this .tagsAutoCompleteItems = response .data .map ((tag ) => {
515
+ return { text: tag .name };
516
+ });
517
+ });
518
+ }, 250 );
519
+ },
488
520
},
489
521
});
490
522
},
@@ -507,3 +539,7 @@ export default {
507
539
},
508
540
};
509
541
</script >
542
+
543
+ <style lang="scss">
544
+ @import ' ../../../assets/scss/vendors/vue-tags-input/vue-tags-input' ;
545
+ </style >
0 commit comments