-
@@ -46,53 +56,56 @@ export default {
return {
modalShow: false, // modal handle
q: '', // search query
- val:'',
+ val: '',
}
},
emits: ['update:modelValue'],
props: {
+ xlang: {
+ default: null
+ },
modelValue: {
default: NaN,
},
- items:{
+ items: {
required: true,
default: [],
type: Array,
},
- valueField:{
+ valueField: {
default: 'id',
type: String,
},
- titleField:{
+ titleField: {
default: 'title',
type: String,
},
- xname:{
+ xname: {
default: "",
type: String,
},
- xtitle:{
+ xtitle: {
default: "Please select",
type: String,
},
- xvalue:{
+ xvalue: {
default: "",
type: String,
},
- xid:{
+ xid: {
default: "",
type: String,
},
- customClass:{
+ customClass: {
default: "",
type: String,
},
- err:{
+ err: {
default: false,
type: Boolean,
},
- onSelect:{
+ onSelect: {
default: function () {
},
@@ -106,33 +119,56 @@ export default {
mounted() {
if (!isNaN(this.modelValue)) {
this.val = this.modelValue;
- }else{
+ } else {
this.val = this.xvalue;
}
},
computed: {
getClass: function () {
- if (this.err == true || ( typeof this.err == 'String' && this.err.trim() == '1' )) {
- return 'form-control is-invalid '+this.customClass;
+ if (this.err == true || (typeof this.err == 'String' && this.err.trim() == '1')) {
+ return 'form-control is-invalid ' + this.customClass;
}
- return 'form-control '+this.customClass;
+ return 'form-control ' + this.customClass;
},
},
methods: {
- selecting(i){
+ finder(term = '') {
+ //(q != '' && item[titleField].indexOf(q) != -1) || (q == '')
+ if (this.q == '' || term == '') {
+ return true;
+ }
+ if (typeof term == 'string' && term.toLocaleLowerCase().indexOf(this.q.toLocaleLowerCase()) != -1) {
+ return true
+ } else if (typeof term == 'object') {
+ try {
+ for (const t in term) {
+ if (term[t].toLowerCase().indexOf(this.q.toLocaleLowerCase()) != -1) {
+ return true;
+ }
+ }
+ } catch (e) {
+
+ console.log(e.message);
+ }
+ } else {
+ return true;
+ }
+ return false;
+ },
+ selecting(i) {
this.val = i;
this.onSelect(this.val);
- if (this.closeOnSelect){
+ if (this.closeOnSelect) {
this.hideModal();
}
},
- select(){
+ select() {
this.onSelect(this.val);
},
- hideModal:function () {
+ hideModal: function () {
this.modalShow = false;
},
- showModal(){
+ showModal() {
this.modalShow = true;
}
},
@@ -151,17 +187,17 @@ export default {
}
-#vue-search-btn{
+#vue-search-btn {
cursor: pointer;
user-select: none;
}
-#vue-search-btn:hover .input-group-text{
+#vue-search-btn:hover .input-group-text {
background: darkred;
}
-#ss-modal{
+#ss-modal {
position: fixed;
left: 0;
right: 0;
@@ -173,7 +209,7 @@ export default {
user-select: none;
}
-#ss-selector{
+#ss-selector {
height: 60vh;
border-radius: 7px;
min-width: 350px;
@@ -184,15 +220,16 @@ export default {
padding: 5px;
}
-#vue-search-list{
+#vue-search-list {
height: calc(60vh - 90px);
- overflow-x: auto ;
+ overflow-x: auto;
}
-#vue-search-list .list-group-item:hover{
+#vue-search-list .list-group-item:hover {
background: deepskyblue;
}
-#vue-search-list .list-group-item.selected{
+
+#vue-search-list .list-group-item.selected {
background: dodgerblue;
color: white;;
}
diff --git a/resources/js/components/TagInput.vue b/resources/js/components/TagInput.vue
index 39c1d97..13d38c4 100644
--- a/resources/js/components/TagInput.vue
+++ b/resources/js/components/TagInput.vue
@@ -5,7 +5,7 @@
{{$tag}}
-
@@ -30,6 +30,9 @@ export default {
},
emits: ['update:modelValue'],
props: {
+ xid:{
+ default: 'tags',
+ },
modelValue: {
default: null,
},
@@ -77,9 +80,11 @@ export default {
},
disableSubmit(e){
e.target.closest('form').addEventListener('submit',noSubmit);
+ window.noSubmit = true;
},
enableSubmit(e){
e.target.closest('form').removeEventListener('submit',noSubmit);
+ window.noSubmit = false;
},
rem(tag){
this.tags.splice(this.tags.indexOf(tag),1);
@@ -91,7 +96,7 @@ export default {