From: Andy Allan Date: Wed, 19 Aug 2020 10:30:06 +0000 (+0200) Subject: Refactor client application pages to use bootstrap forms X-Git-Tag: live~2564^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/adfb4dc61945b7b441695885b3b273bfdf712332 Refactor client application pages to use bootstrap forms Also rework the client application show page to be responsive --- diff --git a/app/views/oauth_clients/_form.html.erb b/app/views/oauth_clients/_form.html.erb index 4c4b2c519..455450412 100644 --- a/app/views/oauth_clients/_form.html.erb +++ b/app/views/oauth_clients/_form.html.erb @@ -1,29 +1,11 @@ -
-
-
- - <%= f.text_field :name %> -
-
- - <%= f.text_field :url %> -
-
- - <%= f.text_field :callback_url %> -
-
- - <%= f.text_field :support_url %> -
-
-
-

<%= t ".requests" %>

- <% ClientApplication.all_permissions.each do |perm| %> -
- <%= f.check_box perm %> - -
- <% end %> -
+<%= f.text_field :name %> +<%= f.text_field :url %> +<%= f.text_field :callback_url %> +<%= f.text_field :support_url %> +
+

<%= t ".requests" %>

+ <% ClientApplication.all_permissions.each do |perm| %> + <%= f.check_box perm %> + <% end %>
+<%= f.primary %> diff --git a/app/views/oauth_clients/edit.html.erb b/app/views/oauth_clients/edit.html.erb index 551bb68fc..f31063ae0 100644 --- a/app/views/oauth_clients/edit.html.erb +++ b/app/views/oauth_clients/edit.html.erb @@ -2,7 +2,6 @@

<%= t ".title" %>

<% end %> -<%= form_for @client_application, :url => oauth_client_path(@client_application.user.display_name, @client_application), :html => { :method => :put, :class => "standard-form" } do |f| %> +<%= bootstrap_form_for @client_application, :url => oauth_client_path(@client_application.user.display_name, @client_application), :html => { :method => :put } do |f| %> <%= render :partial => "form", :locals => { :f => f } %> - <%= f.submit %> <% end %> diff --git a/app/views/oauth_clients/new.html.erb b/app/views/oauth_clients/new.html.erb index d9cc05d02..7b4ea5bb0 100644 --- a/app/views/oauth_clients/new.html.erb +++ b/app/views/oauth_clients/new.html.erb @@ -2,9 +2,6 @@

<%= t ".title" %>

<% end %> -
- <%= form_for @client_application, :url => { :action => :create } do |f| %> - <%= render :partial => "form", :locals => { :f => f } %> - <%= f.submit %> - <% end %> -
+<%= bootstrap_form_for @client_application, :url => { :action => :create } do |f| %> + <%= render :partial => "form", :locals => { :f => f } %> +<% end %> diff --git a/app/views/oauth_clients/show.html.erb b/app/views/oauth_clients/show.html.erb index 19c1d9f6e..5f828a057 100644 --- a/app/views/oauth_clients/show.html.erb +++ b/app/views/oauth_clients/show.html.erb @@ -1,33 +1,31 @@ <% content_for :heading do %>

<%= t(".title", :app_name => @client_application.name) %>

<% end %> -
-

- <%= t ".key" %> <%= @client_application.key %> -

-

- <%= t ".secret" %> <%= @client_application.secret %> -

-

- <%= t ".url" %> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %> -

-

- <%= t ".access_url" %> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %> -

-

- <%= t ".authorize_url" %> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %> -

-

<%= t ".requests" %>

-
    <% @client_application.permissions.each do |perm| %> -
    -
  • <%= t("oauth_clients.form." + perm.to_s) %>
  • -
    - <% end %>
+
+
<%= t ".key" %>
+
<%= @client_application.key %> +
<%= t ".secret" %>
+
<%= @client_application.secret %>
+
<%= t ".url" %>
+
http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %>
+
<%= t ".access_url" %>
+
http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %>
+
<%= t ".authorize_url" %>
+
http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %>
+
+
+

<%= t ".requests" %>

+
    + <% @client_application.permissions.each do |perm| %> +
  • <%= t("activerecord.attributes.client_application." + perm.to_s) %>
  • + <% end %> +

<%= t ".support_notice" %>

-
- <%= button_to t(".edit"), edit_oauth_client_path(@client_application.user.display_name, @client_application), :method => :get, :class => "oauth-edit" %> - <%= button_to t(".delete"), oauth_client_path(@client_application.user.display_name, @client_application), :method => :delete, :data => { :confirm => t(".confirm") }, :class => "oauth-delete deemphasize" %> + +
+ <%= link_to t(".edit"), edit_oauth_client_path(@client_application.user.display_name, @client_application), :method => :get, :class => "btn btn-outline-primary" %> + <%= link_to t(".delete"), oauth_client_path(@client_application.user.display_name, @client_application), :method => :delete, :data => { :confirm => t(".confirm") }, :class => "btn btn-outline-danger" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index fe07bab92..d5801da40 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,7 +20,7 @@ en: create: Send client_application: create: Register - update: Edit + update: Update redaction: create: Create redaction update: Save redaction @@ -75,6 +75,18 @@ en: # Translates all the model attributes, which is used in error handling on the web site # Only the ones that are used on the web site are translated at the moment attributes: + client_application: + name: Name (Required) + url: Main Application URL (Required) + callback_url: Callback URL + support_url: Support URL + allow_read_prefs: read their user preferences + allow_write_prefs: modify their user preferences + allow_write_diary: create diary entries, comments and make friends + allow_write_api: modify the map + allow_read_gpx: read their private GPS traces + allow_write_gpx: upload GPS traces + allow_write_notes: modify notes diary_comment: body: "Body" diary_entry: @@ -1973,13 +1985,6 @@ en: delete: "Delete Client" confirm: "Are you sure?" requests: "Requesting the following permissions from the user:" - allow_read_prefs: "read their user preferences." - allow_write_prefs: "modify their user preferences." - allow_write_diary: "create diary entries, comments and make friends." - allow_write_api: "modify the map." - allow_read_gpx: "read their private GPS traces." - allow_write_gpx: "upload GPS traces." - allow_write_notes: "modify notes." index: title: "My OAuth Details" my_tokens: "My Authorised Applications" @@ -1993,19 +1998,7 @@ en: registered_apps: "You have the following client applications registered:" register_new: "Register your application" form: - name: "Name" - required: "Required" - url: "Main Application URL" - callback_url: "Callback URL" - support_url: "Support URL" requests: "Request the following permissions from the user:" - allow_read_prefs: "read their user preferences." - allow_write_prefs: "modify their user preferences." - allow_write_diary: "create diary entries, comments and make friends." - allow_write_api: "modify the map." - allow_read_gpx: "read their private GPS traces." - allow_write_gpx: "upload GPS traces." - allow_write_notes: "modify notes." not_found: sorry: "Sorry, that %{type} could not be found." create: