|
|
|
|
@ -63,29 +63,37 @@ Template.directory.helpers({ |
|
|
|
|
end, |
|
|
|
|
page, |
|
|
|
|
} = Template.instance(); |
|
|
|
|
const channelsTab = { |
|
|
|
|
label: t('Channels'), |
|
|
|
|
value: 'channels', |
|
|
|
|
condition() { |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
const usersTab = { |
|
|
|
|
label: t('Users'), |
|
|
|
|
value: 'users', |
|
|
|
|
condition() { |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
if (searchType.get() === 'channels') { |
|
|
|
|
channelsTab.active = true; |
|
|
|
|
} else { |
|
|
|
|
usersTab.active = true; |
|
|
|
|
} |
|
|
|
|
return { |
|
|
|
|
tabs: [ |
|
|
|
|
{ |
|
|
|
|
label: t('Channels'), |
|
|
|
|
value: 'channels', |
|
|
|
|
condition() { |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
active: true, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: t('Users'), |
|
|
|
|
value: 'users', |
|
|
|
|
condition() { |
|
|
|
|
return true; |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
tabs: [channelsTab, usersTab], |
|
|
|
|
onChange(value) { |
|
|
|
|
results.set([]); |
|
|
|
|
end.set(false); |
|
|
|
|
searchSortBy.set('name'); |
|
|
|
|
sortDirection.set('asc'); |
|
|
|
|
if (value === 'channels') { |
|
|
|
|
searchSortBy.set('usersCount'); |
|
|
|
|
sortDirection.set('desc'); |
|
|
|
|
} else { |
|
|
|
|
searchSortBy.set('name'); |
|
|
|
|
sortDirection.set('asc'); |
|
|
|
|
} |
|
|
|
|
page.set(0); |
|
|
|
|
searchType.set(value); |
|
|
|
|
}, |
|
|
|
|
@ -190,10 +198,16 @@ Template.directory.onRendered(function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Template.directory.onCreated(function() { |
|
|
|
|
const viewType = RocketChat.settings.get('Accounts_Directory_DefaultView') || 'channels'; |
|
|
|
|
this.searchType = new ReactiveVar(viewType); |
|
|
|
|
if (viewType === 'channels') { |
|
|
|
|
this.searchSortBy = new ReactiveVar('usersCount'); |
|
|
|
|
this.sortDirection = new ReactiveVar('desc'); |
|
|
|
|
} else { |
|
|
|
|
this.searchSortBy = new ReactiveVar('name'); |
|
|
|
|
this.sortDirection = new ReactiveVar('asc'); |
|
|
|
|
} |
|
|
|
|
this.searchText = new ReactiveVar(''); |
|
|
|
|
this.searchType = new ReactiveVar('channels'); |
|
|
|
|
this.searchSortBy = new ReactiveVar('usersCount'); |
|
|
|
|
this.sortDirection = new ReactiveVar('desc'); |
|
|
|
|
this.limit = new ReactiveVar(0); |
|
|
|
|
this.page = new ReactiveVar(0); |
|
|
|
|
this.end = new ReactiveVar(false); |
|
|
|
|
|