Use checkboxes for application scope setting (#4671)

This commit is contained in:
nullkal 2017-08-23 22:16:20 +09:00 committed by Eugen Rochko
parent 8d23667536
commit 80393a23d0
3 changed files with 44 additions and 6 deletions

View file

@ -5,6 +5,7 @@ class Settings::ApplicationsController < ApplicationController
before_action :authenticate_user!
before_action :set_application, only: [:show, :update, :destroy, :regenerate]
before_action :prepare_scopes, only: [:create, :update]
def index
@applications = current_user.applications.page(params[:page])
@ -63,4 +64,9 @@ class Settings::ApplicationsController < ApplicationController
:website
)
end
def prepare_scopes
scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
params[:doorkeeper_application][:scopes] = scopes.join(' ') if scopes.is_a? Array
end
end

View file

@ -7,5 +7,15 @@
%p.hint= t('doorkeeper.applications.help.native_redirect_uri', native_redirect_uri: Doorkeeper.configuration.native_redirect_uri)
.fields-group
= f.input :scopes, wrapper: :with_label, label: t('activerecord.attributes.doorkeeper/application.scopes'), hint: t('doorkeeper.applications.help.scopes')
.field-group
= f.input :scopes,
label: t('activerecord.attributes.doorkeeper/application.scopes'),
collection: Doorkeeper.configuration.scopes,
wrapper: :with_label,
include_blank: false,
selected: f.object.scopes.all,
required: false,
as: :check_boxes,
collection_wrapper_tag: 'ul',
item_wrapper_tag: 'li'