This commit is contained in:
2019-06-19 21:55:19 +00:00
parent c25df1264b
commit ae0999647c
2 changed files with 44 additions and 23 deletions

View File

@@ -1,5 +1,7 @@
/* Xeslint-disable */ /* Xeslint-disable */
import _ from "../libs/lodash.min.js";
///////////////////////////////// /////////////////////////////////
// General utility library // General utility library
// //
@@ -69,6 +71,31 @@ export default {
} }
} }
return true; return true;
},
///////////////////////////////
// CLEAN TAG NAME
// Clean up a tag with same rules as server
//
normalizeTag: function(tagName) {
//kebab case takes care of all the things we need for tags in one go
tagName = _.kebabCase(tagName);
//No longer than 255 characters
tagName = tagName.length > 255 ? tagName.substr(0, 255 - 1) : tagName;
return tagName;
//
// //This may be naive when we get international customers but for now supporting utf-8 and it appears it's safe to do this with unicode
// inObj = inObj.ToLowerInvariant();
// //No spaces in tags, replace with dashes
// inObj = inObj.Replace(" ", "-");
// //Remove multiple dash sequences
// inObj = System.Text.RegularExpressions.Regex.Replace(inObj, "-+", "-");
// //Ensure doesn't start or end with a dash
// inObj = inObj.Trim('-');
// //No longer than 255 characters
// inObj = StringUtil.MaxLength(inObj, 255);
// return inObj;
} }
//new functions above here //new functions above here

View File

@@ -148,7 +148,8 @@
@change="onChange('tags')" @change="onChange('tags')"
:items="pickLists.tags" :items="pickLists.tags"
:loading="tagSearchUnderway" :loading="tagSearchUnderway"
:search-input.sync="searchTags" :search-input.sync="tagSearchEntry"
no-data-text="ENTER A TAG"
hide-selected hide-selected
multiple multiple
chips chips
@@ -156,16 +157,14 @@
deletable-chips deletable-chips
cache-items cache-items
> >
<template slot="no-data" v-if="searchTags"> <template slot="no-data" v-if="tagSearchEntry">
<v-container> <v-container>
<v-layout row> <v-layout row>
<v-layout justify-start fill-height align-content-center> <v-btn icon @click="addTag()">
Create new tag <v-icon>fa-plus-circle</v-icon>
</v-layout> </v-btn>
<v-layout justify-end> <v-layout justify-start>
<v-icon color="success" @click="addTag()" "{{ this.$gzutil.normalizeTag(tagSearchEntry) }}"
>add {{ searchTags }} tag</v-icon
>
</v-layout> </v-layout>
</v-layout> </v-layout>
</v-container> </v-container>
@@ -298,7 +297,7 @@ export default {
roles: [], roles: [],
tags: [] tags: []
}, },
searchTags: null, tagSearchEntry: null,
tagSearchUnderway: false, tagSearchUnderway: false,
obj: { obj: {
id: 0, id: 0,
@@ -355,7 +354,7 @@ export default {
}, },
deep: true deep: true
}, },
searchTags(val) { tagSearchEntry(val) {
var vm = this; var vm = this;
if (vm.tagSearchUnderway) { if (vm.tagSearchUnderway) {
return; return;
@@ -556,8 +555,13 @@ export default {
}); });
} }
}, },
addTag(a, b, c) { addTag() {
debugger; //todo: clean the tag to server standards first so it's de-duped in the record
var theTag = this.tagSearchEntry;
theTag = this.$gzutil.normalizeTag(theTag);
//make sure there are no existing of the same tag
this.pickLists.tags.push(theTag);
this.obj.tags.push(theTag);
//add tags to existing picklist so that it contains all the unique tags ever searched for or present in the object //add tags to existing picklist so that it contains all the unique tags ever searched for or present in the object
//vm.pickLists.tags+=tags //vm.pickLists.tags+=tags
//vm.pickLists.tags=uniqueonly(vm.pickLists.tags) //vm.pickLists.tags=uniqueonly(vm.pickLists.tags)
@@ -565,16 +569,6 @@ export default {
} }
}; };
// //////////////////////
// //
// //
// function addTag(a,b,c) {
// debugger;
// //add tags to existing picklist so that it contains all the unique tags ever searched for or present in the object
// //vm.pickLists.tags+=tags
// //vm.pickLists.tags=uniqueonly(vm.pickLists.tags)
// }
///////////////////////////// /////////////////////////////
// //
// //