Method: Scrivito::UserDefinition#suggest_users

Defined in:
app/cms/scrivito/user_definition.rb

#suggest_users(&suggest_users_proc) {|input| ... } ⇒ Object

Note:

Only the first 20 users returned are displayed in the in-place UI.

Note:

suggest_users_proc may also be invoked with an empty string.

Defines the proc for fetching users for autocompletion purposes in the in-place UI. User autocompletion is used in the settings dialog of a workspace. If the proc is not set, Scrivito::User.find is used to fetch the suggested users, assuming the input is part of the user id.

Examples:

class MyUserModel
  def to_scrivito_user
    Scrivito::User.define(id) do |user|
      user.suggest_users do |input|
        MyUserModel.find_by_prefix(input).map(&:to_scrivito_user)
      end
    end
  end
end

Parameters:

  • suggest_users_proc (Proc)

    proc for fetching users to be suggested in the in-place UI

Yield Parameters:

  • input (String)

    an arbitrary string originating from the user autocompletion input field, e.g. the first letters of a user name

Yield Returns:

  • (Array<Scrivito::User>)

    users that were found on account of the given input string



155
156
157
# File 'app/cms/scrivito/user_definition.rb', line 155

def suggest_users(&suggest_users_proc)
  @suggest_users_proc = suggest_users_proc
end