]> git.openstreetmap.org Git - rails.git/commitdiff
Refactor client application pages to use bootstrap forms
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 19 Aug 2020 10:30:06 +0000 (12:30 +0200)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 19 Aug 2020 14:58:43 +0000 (16:58 +0200)
Also rework the client application show page to be responsive

app/views/oauth_clients/_form.html.erb
app/views/oauth_clients/edit.html.erb
app/views/oauth_clients/new.html.erb
app/views/oauth_clients/show.html.erb
config/locales/en.yml

index 4c4b2c519132564d59922c4bd164ce559d2a1a17..4554504121c3872874df01f8a37ac580146297bc 100644 (file)
@@ -1,29 +1,11 @@
-<div class='standard-form'>
-  <fieldset>
-    <div class="standard-form-row">
-      <label class='standard-label' for="client_application_name"><%= t ".name" %> (<%= t ".required" %>)</label>
-      <%= f.text_field :name %>
-    </div>
-    <div class="standard-form-row">
-      <label class='standard-label' for="client_application_url"><%= t ".url" %> (<%= t ".required" %>)</label>
-      <%= f.text_field :url %>
-    </div>
-    <div class="standard-form-row">
-      <label class='standard-label' for="client_application_callback_url"><%= t ".callback_url" %></label>
-      <%= f.text_field :callback_url %>
-    </div>
-    <div class="standard-form-row">
-      <label class='standard-label' for="client_application_support_url"><%= t ".support_url" %></label>
-      <%= f.text_field :support_url %>
-    </div>
-  </fieldset>
-  <fieldset class='form-divider'>
-      <p><%= t ".requests" %></p>
-      <% ClientApplication.all_permissions.each do |perm| %>
-        <div class="standard-form-row">
-          <%= f.check_box perm %>
-          <label class='standard-label' for="client_application_<%= perm.to_s %>"><%= t("." + perm.to_s) %></label>
-        </div>
-      <% end %>
-  </fieldset>
+<%= f.text_field :name %>
+<%= f.text_field :url %>
+<%= f.text_field :callback_url %>
+<%= f.text_field :support_url %>
+<div class='form-group'>
+  <p><%= t ".requests" %></p>
+  <% ClientApplication.all_permissions.each do |perm| %>
+    <%= f.check_box perm %>
+  <% end %>
 </div>
+<%= f.primary %>
index 551bb68fcbd696750d904ccad2cd203482005d4b..f31063ae02fc57c4da5773cfda5425cbe678b929 100644 (file)
@@ -2,7 +2,6 @@
   <h1><%= t ".title" %></h1>
 <% 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 %>
index d9cc05d0224f9922143e055710f8b75531099f76..7b4ea5bb0593cd7e238bd781ea5134fcb7b618fe 100644 (file)
@@ -2,9 +2,6 @@
   <h1><%= t ".title" %></h1>
 <% end %>
 
-<div class='standard-form'>
-  <%= form_for @client_application, :url => { :action => :create } do |f| %>
-    <%= render :partial => "form", :locals => { :f => f } %>
-    <%= f.submit %>
-  <% end %>
-</div>
+<%= bootstrap_form_for @client_application, :url => { :action => :create } do |f| %>
+  <%= render :partial => "form", :locals => { :f => f } %>
+<% end %>
index 19c1d9f6e7574907d7388160777aca8f563de4e8..5f828a05798495a1a146bdf10fc68eb4841b2236 100644 (file)
@@ -1,33 +1,31 @@
 <% content_for :heading do %>
   <h1><%= t(".title", :app_name => @client_application.name) %></h1>
 <% end %>
-<div class='prose'>
-  <p>
-    <strong><%= t ".key" %></strong> <%= @client_application.key %>
-  </p>
-  <p>
-    <strong><%= t ".secret" %></strong> <%= @client_application.secret %>
-  </p>
-  <p>
-    <strong><%= t ".url" %></strong> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %>
-  </p>
-  <p>
-    <strong><%= t ".access_url" %></strong> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %>
-  </p>
-  <p>
-    <strong><%= t ".authorize_url" %></strong> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %>
-  </p>
 
-  <p><%= t ".requests" %></p>
-  <ul><% @client_application.permissions.each do |perm| %>
-  <div class="field">
-    <li><%= t("oauth_clients.form." + perm.to_s) %></li>
-  </div>
-  <% end %></ul>
+<dl class="row">
+  <dt class="col-sm-3"><%= t ".key" %></dt>
+  <dd class="col-sm-9"><%= @client_application.key %></dt>
+  <dt class="col-sm-3"><%= t ".secret" %></dt>
+  <dd class="col-sm-9"><%= @client_application.secret %></dd>
+  <dt class="col-sm-3"><%= t ".url" %></dt>
+  <dd class="col-sm-9">http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %></dd>
+  <dt class="col-sm-3"><%= t ".access_url" %></dt>
+  <dd class="col-sm-9">http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %></dd>
+  <dt class="col-sm-3"><%= t ".authorize_url" %></dt>
+  <dd class="col-sm-9">http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %></dd>
+</dl>
 
+<div>
+  <p><%= t ".requests" %></p>
+  <ul>
+    <% @client_application.permissions.each do |perm| %>
+      <li><%= t("activerecord.attributes.client_application." + perm.to_s) %></li>
+    <% end %>
+  </ul>
   <p><%= t ".support_notice" %></p>
 </div>
-<div class="buttons standard-form">
-  <%= 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" %>
+
+<div>
+  <%= 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" %>
 </div>
index fe07bab929acf35aaf3625ea2030ae71bf06e16d..d5801da40a0a7bc30f2802fa42bdc512fb62bf77 100644 (file)
@@ -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: