Merge branch 'UserEdit/fix-template-handling' into 'master'
fixed template handling in new useredit view See merge request fronk/thetool!1738
This commit is contained in:
@@ -34,7 +34,7 @@ Vue.component("UserEdit", {
|
||||
<transition name="slide-fade">
|
||||
<tt-card v-show="!collapsedSections.permissions">
|
||||
<div class="permission-template-section">
|
||||
<tt-select label="Vorlage anwenden" :options="templateOptions" v-model="selectedTemplate" @input="applyTemplate" sm/>
|
||||
<tt-select label="Vorlage anwenden" :options="templateOptions" v-model="selectedTemplate" @input="applyTemplate" ref="templateSelect" sm/>
|
||||
<tt-autocomplete label="Aus bestehenden User laden" :items="lookups.users" v-model="userToLoad" @input="loadDataFromUser" sm/>
|
||||
</div>
|
||||
<hr>
|
||||
@@ -218,7 +218,7 @@ Vue.component("UserEdit", {
|
||||
applyTemplate(templateId) {
|
||||
if (!templateId) return;
|
||||
const template = this.lookups.permissionTemplates.find(t => t.id == templateId);
|
||||
template.permissions = JSON.parse(template.permissions);
|
||||
template.permissions = typeof template.permissions === 'string' ? JSON.parse(template.permissions) : template.permissions;
|
||||
if (template) {
|
||||
const newPermissions = { ...this.user.permissions };
|
||||
for (const key in template.permissions) {
|
||||
@@ -227,7 +227,12 @@ Vue.component("UserEdit", {
|
||||
this.user.permissions = newPermissions;
|
||||
window.notify('success', `Vorlage "${template.name}" angewendet.`);
|
||||
}
|
||||
this.selectedTemplate = null;
|
||||
|
||||
setTimeout(() => {
|
||||
this.selectedTemplate = null;
|
||||
this.$refs.templateSelect.selected = null
|
||||
this.$refs.templateSelect.searchQuery = '';
|
||||
}, 250);
|
||||
},
|
||||
async loadDataFromUser(userId) {
|
||||
if(!userId) return;
|
||||
|
||||
@@ -58,9 +58,16 @@ Vue.component('tt-select', {
|
||||
},
|
||||
|
||||
filteredOptions() {
|
||||
if (!this.searchable || !this.searchQuery) return this.normalizedOptions;
|
||||
const displayLimit = 100;
|
||||
|
||||
if (!this.searchable || !this.searchQuery) {
|
||||
return this.normalizedOptions.slice(0, displayLimit);
|
||||
}
|
||||
|
||||
const q = this.searchQuery.toLowerCase();
|
||||
return this.normalizedOptions.filter(o => o.text.toLowerCase().includes(q));
|
||||
return this.normalizedOptions
|
||||
.filter(option => option.text.toLowerCase().includes(q))
|
||||
.slice(0, displayLimit);
|
||||
},
|
||||
|
||||
displayText() {
|
||||
|
||||
Reference in New Issue
Block a user