Add search field in admin

pull/5169/head
Rodrigo Nascimento 9 years ago
parent ba617694cb
commit b72d6cd90c
No known key found for this signature in database
GPG Key ID: 2C85B3AFE75D23F9
  1. 28
      packages/rocketchat-ui-admin/admin/adminFlex.coffee
  2. 4
      packages/rocketchat-ui-admin/admin/adminFlex.html

@ -1,4 +1,6 @@
Template.adminFlex.onCreated ->
@settingsFilter = new ReactiveVar('')
if not RocketChat.settings.cachedCollectionPrivate?
RocketChat.settings.cachedCollectionPrivate = new RocketChat.CachedCollection({ name: 'private-settings', eventType: 'onAll' })
RocketChat.settings.collectionPrivate = RocketChat.settings.cachedCollectionPrivate.collection
@ -7,9 +9,30 @@ Template.adminFlex.onCreated ->
Template.adminFlex.helpers
groups: ->
return RocketChat.settings.collectionPrivate.find({type: 'group'}, { sort: { sort: 1, i18nLabel: 1 } }).fetch()
filter = Template.instance().settingsFilter.get()
query =
type: 'group'
if filter
filterRegex = new RegExp(_.escapeRegExp(filter), 'i')
records = RocketChat.settings.collectionPrivate.find().fetch()
groups = []
records = records.forEach (record) ->
if filterRegex.test(TAPi18n.__(record.i18nLabel or record._id))
groups.push(record.group or record._id)
groups = _.unique(groups)
if groups.length > 0
query._id =
$in: groups
return RocketChat.settings.collectionPrivate.find(query, { sort: { sort: 1, i18nLabel: 1 } }).fetch()
label: ->
return TAPi18n.__(@i18nLabel or @_id)
adminBoxOptions: ->
return RocketChat.AdminBox.getOptions()
@ -29,3 +52,6 @@ Template.adminFlex.events
'click .admin-link': ->
menu.close()
'keyup [name=settings-search]': (e, t) ->
t.settingsFilter.set(e.target.value)

@ -42,6 +42,10 @@
{{_ "Settings"}}
</h3>
<li>
<input type="text" name="settings-search" placeholder="{{_ 'Search'}}">
</li>
{{#each groups}}
<li>
<a href="{{pathFor 'admin' group=_id}}" class="admin-link">{{label}}</a>

Loading…
Cancel
Save