% extends 'settings', title => 'KorAP: '.loc('Auth_oauthSettings'), page => 'oauth';

%= page_title

% my $list = stash('client_list');
% if ($list) {
<ul class="client-list">
%   foreach (@$list) {
  <li class="client">
    <span class="client-name"><%= link_to $_->{client_name} => url_for('oauth-tokens', client_id => $_->{client_id}) %></span>
    <span class="client-desc"><%= $_->{client_description} %></span>
% if ($_->{client_url}) {
    <span class="client-url"><a href="<%= $_->{client_url} %>"><%= $_->{client_url} %></a></span>
% }
  </li>
%   };
</ul>
% };


%= form_for 'oauth-register', class => 'form-table oauth-register', begin
  <fieldset>
    %= csrf_field
    <legend><%= loc('Auth_clientRegister') %></legend>

    <div>
      %= label_for name => loc('Auth_clientName'), class => 'field-required', maxlength => 255
      %= text_field 'name'
    </div>

    <div>
      %= label_for type => loc('Auth_clientType'), class => 'field-required'
      <%= radio_button type => 'PUBLIC', checked => 'checked' %>
      <label>Public</label>
%#      <br />
%#      <%= radio_button type => 'CONFIDENTIAL' %>
%#      <label>Confidential</label>
    </div>

    <div>
      %= label_for 'desc' => loc('Auth_desc'), class => 'field-required'
      %= text_field 'desc'
    </div>

    <div>
      %= label_for name => loc('Auth_homepage')
      %= url_field 'url', placeholder => 'https://...'
    </div>

%#    <div>
%#      %= label_for name => loc('Auth_redirectUri')
%#      %= url_field 'redirect_uri', placeholder => 'https://...'
%#    </div>

    %= submit_button loc('Auth_clientRegister')
  </fieldset>
% end
