Skip to content

Commit

Permalink
migrate a few components to NcSelect
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <szaimen@e.mail.de>
  • Loading branch information
szaimen committed May 19, 2023
1 parent 60baf88 commit 06d8a03
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 37 deletions.
15 changes: 4 additions & 11 deletions apps/files/src/components/TransferOwnershipDialogue.vue
Expand Up @@ -37,22 +37,15 @@
<label for="targetUser">
<span>{{ t('files', 'New owner') }}</span>
</label>
<NcMultiselect id="targetUser"
<NcSelect id="targetUser"
v-model="selectedUser"
:options="formatedUserSuggestions"
:multiple="false"
:searchable="true"
:placeholder="t('files', 'Search for an account')"
:preselect-first="true"
:preserve-search="true"
:loading="loadingUsers"
track-by="user"
label="displayName"
:internal-search="false"
:clear-on-select="false"
:user-select="true"
class="middle-align"
@search-change="findUserDebounced" />
@search="findUserDebounced" />
</p>
<p>
<input type="submit"
Expand All @@ -70,7 +63,7 @@ import axios from '@nextcloud/axios'
import debounce from 'debounce'
import { generateOcsUrl } from '@nextcloud/router'
import { getFilePickerBuilder, showSuccess } from '@nextcloud/dialogs'
import NcMultiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import Vue from 'vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
Expand All @@ -86,7 +79,7 @@ const picker = getFilePickerBuilder(t('files', 'Choose a file or folder to trans
export default {
name: 'TransferOwnershipDialogue',
components: {
NcMultiselect,
NcSelect,
NcButton,
},
data() {
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/src/admin.js
@@ -1,5 +1,5 @@
window.addEventListener('DOMContentLoaded', () => {
$('#excludedGroups,#linksExcludedGroups,#passwordsExcludedGroups').each(function(index, element) {
$('#linksExcludedGroups,#passwordsExcludedGroups').each(function(index, element) {
OC.Settings.setupGroupsSelect($(element))
$(element).change(function(ev) {
let groups = ev.val || []
Expand Down
26 changes: 14 additions & 12 deletions apps/settings/src/components/AdminTwoFactor.vue
Expand Up @@ -19,31 +19,33 @@
{{ t('settings', 'Two-factor authentication is enforced for all members of the following groups.') }}
</p>
<p>
<NcMultiselect v-model="enforcedGroups"
<label for="enforcedGroups">
<span>{{ t('settings', 'Enforced groups') }}</span>
</label>
<NcSelect id="enforcedGroups"
v-model="enforcedGroups"
:options="groups"
:placeholder="t('settings', 'Enforced groups')"
:disabled="loading"
:multiple="true"
:searchable="true"
:loading="loadingGroups"
:show-no-options="false"
:close-on-select="false"
@search-change="searchGroup" />
@search="searchGroup" />
</p>
<p class="top-margin">
{{ t('settings', 'Two-factor authentication is not enforced for members of the following groups.') }}
</p>
<p>
<NcMultiselect v-model="excludedGroups"
<label for="excludedGroups">
<span>{{ t('settings', 'Excluded groups') }}</span>
</label>
<NcSelect id="excludedGroups"
v-model="excludedGroups"
:options="groups"
:placeholder="t('settings', 'Excluded groups')"
:disabled="loading"
:multiple="true"
:searchable="true"
:loading="loadingGroups"
:show-no-options="false"
:close-on-select="false"
@search-change="searchGroup" />
@search="searchGroup" />
</p>
<p class="top-margin">
<em>
Expand All @@ -65,7 +67,7 @@

<script>
import axios from '@nextcloud/axios'
import NcMultiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
Expand All @@ -77,7 +79,7 @@ import { generateUrl, generateOcsUrl } from '@nextcloud/router'
export default {
name: 'AdminTwoFactor',
components: {
NcMultiselect,
NcSelect,
NcButton,
NcCheckboxRadioSwitch,
NcSettingsSection,
Expand Down
25 changes: 13 additions & 12 deletions apps/settings/src/components/AppDetails.vue
Expand Up @@ -35,22 +35,23 @@
class="group_select"
:title="t('settings', 'All')"
value="">
<NcMultiselect v-if="isLimitedToGroups(app)"
<br />
<label for="limitToGroups">
<span>{{ t('settings', 'Limit app usage to groups') }}</span>
</label>
<NcSelect v-if="isLimitedToGroups(app)"
id="limitToGroups"
:options="groups"
:value="appGroups"
:options-limit="5"
:placeholder="t('settings', 'Limit app usage to groups')"
:limit="5"
label="name"
track-by="id"
class="multiselect-vue"
:multiple="true"
:close-on-select="false"
:tag-width="60"
@select="addGroupLimitation"
@remove="removeGroupLimitation"
@search-change="asyncFindGroup">
@option:selected="addGroupLimitation"
@option:deselected="removeGroupLimitation"
@search="asyncFindGroup">
<span slot="noResult">{{ t('settings', 'No results') }}</span>
</NcMultiselect>
</NcSelect>
</div>
<div class="app-details__actions-manage">
<input v-if="app.update"
Expand Down Expand Up @@ -146,7 +147,7 @@
</template>

<script>
import NcMultiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import AppManagement from '../mixins/AppManagement.js'
import PrefixMixin from './PrefixMixin.vue'
Expand All @@ -156,7 +157,7 @@ export default {
name: 'AppDetails',
components: {
NcMultiselect,
NcSelect,
Markdown,
},
mixins: [AppManagement, PrefixMixin],
Expand Down
3 changes: 2 additions & 1 deletion apps/settings/src/mixins/AppManagement.js
Expand Up @@ -98,7 +98,8 @@ export default {
}
return true
},
addGroupLimitation(group) {
addGroupLimitation(groupArray) {
const group = groupArray.pop()
const groups = this.app.groups.concat([]).concat([group.id])
this.$store.dispatch('enableApp', { appId: this.app.id, groups })
},
Expand Down

0 comments on commit 06d8a03

Please sign in to comment.