update profile edit view
This commit is contained in:
@ -5,17 +5,25 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<label for="searchText" class="form-label fw-bold">{{ label }}</label>
|
||||
<div class="row mb-2">
|
||||
<profile-list
|
||||
:values="values"
|
||||
:type="type"
|
||||
:editable="true"
|
||||
@remove-value="removeValue($event)"
|
||||
@update-values="this.$emit('update-values', this.values)"
|
||||
>
|
||||
</profile-list>
|
||||
<div v-bind="$attrs" class="card-body">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input
|
||||
autocomplete="off"
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="searchText"
|
||||
maxlength="25"
|
||||
v-model="searchText"
|
||||
@keyup="search()"
|
||||
@input="search()"
|
||||
@keyup.enter="addResult()"
|
||||
/>
|
||||
</div>
|
||||
@ -32,7 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="" v-if="searchResults">
|
||||
<div v-if="searchResults">
|
||||
<ul class="list-group">
|
||||
<li
|
||||
class="list-group-item"
|
||||
@ -44,24 +52,16 @@ SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<profile-list
|
||||
:values="values"
|
||||
:type="type"
|
||||
:editable="true"
|
||||
@remove-value="removeValue($event)"
|
||||
@update-values="this.$emit('update-values', this.values)"
|
||||
>
|
||||
</profile-list>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import RequestMixin from "@/mixins/request.mixin"
|
||||
import ProfileList from "@/components/ProfileList";
|
||||
import RequestMixin from '@/mixins/request.mixin'
|
||||
import ProfileList from '@/components/ProfileList';
|
||||
|
||||
export default {
|
||||
name: "AutoComplete",
|
||||
name: 'AutoComplete',
|
||||
mixins: [RequestMixin],
|
||||
components: {
|
||||
ProfileList,
|
||||
@ -80,7 +80,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
iconUrl: this.apiUrl,
|
||||
searchText: "",
|
||||
searchText: '',
|
||||
searchResults: [],
|
||||
showErrorMessage: false,
|
||||
};
|
||||
@ -91,6 +91,7 @@ export default {
|
||||
methods: {
|
||||
addResult(result = false) {
|
||||
if (!result) result = this.searchResults[0];
|
||||
|
||||
if (
|
||||
this.values.map((item) => item[this.type].name).includes(result.name)
|
||||
) {
|
||||
@ -101,16 +102,19 @@ export default {
|
||||
let newValue = {
|
||||
profile_id: this.currentUserId,
|
||||
};
|
||||
if (this.type != "contacttype") {
|
||||
|
||||
if (this.type != 'contacttype') {
|
||||
newValue.level = 1;
|
||||
} else {
|
||||
newValue.content = "";
|
||||
newValue.content = '';
|
||||
}
|
||||
|
||||
newValue[this.type] = result;
|
||||
changeValues.unshift(newValue);
|
||||
this.searchText = "";
|
||||
|
||||
this.searchText = '';
|
||||
this.searchResults = [];
|
||||
this.$emit("update-values", changeValues);
|
||||
this.$emit('update-values', changeValues);
|
||||
},
|
||||
removeValue(valueName) {
|
||||
const newValues = this.values.filter((value) => {
|
||||
@ -120,7 +124,7 @@ export default {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.$emit("update-values", newValues);
|
||||
this.$emit('update-values', newValues);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user