Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable22] Fix add group button #27878

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/settings/js/vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions apps/settings/js/vue-settings-users-8a973f1b2b78e43a05ac.js

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions apps/settings/js/vue-settings-users-af6707a7ab3e065b4b6e.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

39 changes: 14 additions & 25 deletions apps/settings/src/views/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
:loading="loadingAddGroup"
:title="t('settings', 'Add group')"
icon="icon-add"
@click="toggleAddGroupEntry(true)"
@click="showAddGroupForm"
@update:title="createGroup" />
<AppNavigationItem
id="everyone"
Expand Down Expand Up @@ -445,51 +445,40 @@ export default {
async createGroup(gid) {
// group is not valid
if (gid.trim() === '') {
Vue.nextTick(() => {
this.toggleAddGroupEntry(true)
})
return
}

try {
this.loadingAddGroup = true
await this.$store.dispatch('addGroup', gid.trim())

this.toggleAddGroupEntry(false)
this.$router.push({
this.hideAddGroupForm()
await this.$router.push({
name: 'group',
params: {
selectedGroup: encodeURIComponent(gid.trim()),
},
})
} catch {
this.toggleAddGroupEntry(true)
this.showAddGroupForm()
} finally {
this.loadingAddGroup = false
}
},

/**
* Toggle the add group entry editing state
* @param {boolean} [state] set state instead of toggling
*/
toggleAddGroupEntry(state) {
if (state === undefined) {
state = !this.$refs.addGroup.editing
}
this.$refs.addGroup.editing = state

// focus input
Vue.nextTick(() => {
if (this.$refs.addGroup.$el) {
const input = this.$refs.addGroup.$el.querySelector('form > input[type="text"]')
if (input) {
input.focus()
}
}
showAddGroupForm() {
this.$refs.addGroup.editingActive = true
this.$refs.addGroup.onMenuToggle(false)
this.$nextTick(() => {
this.$refs.addGroup.$refs.editingInput.focusInput()
})
},

hideAddGroupForm() {
this.$refs.addGroup.editingActive = false
this.$refs.addGroup.editingValue = ''
},

/**
* Format a group to a menu entry
* @param {Object} group the group
Expand Down