about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authornullkal <nullkal@users.noreply.github.com>2017-08-23 22:16:20 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-08-23 15:16:20 +0200
commit80393a23d0a0c296d4356a2a21cf8504435265bf (patch)
tree6d0bdc6c4e0b3d600c6a786c5e66e1e5ba254114 /app
parent8d23667536cec65292302774b3816467ad427a32 (diff)
Use checkboxes for application scope setting (#4671)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/applications_controller.rb6
-rw-r--r--app/views/settings/applications/_fields.html.haml14
2 files changed, 18 insertions, 2 deletions
diff --git a/app/controllers/settings/applications_controller.rb b/app/controllers/settings/applications_controller.rb
index 894222c2a..8fc9a0fa9 100644
--- a/app/controllers/settings/applications_controller.rb
+++ b/app/controllers/settings/applications_controller.rb
@@ -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
diff --git a/app/views/settings/applications/_fields.html.haml b/app/views/settings/applications/_fields.html.haml
index 536f69e04..83297a1ae 100644
--- a/app/views/settings/applications/_fields.html.haml
+++ b/app/views/settings/applications/_fields.html.haml
@@ -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'
+