Skip to content

Commit

Permalink
Make Admin Set Participants tab layout match Collections Sharing tab …
Browse files Browse the repository at this point in the history
…layout. Also update the add users and add group forms to use Bootstrap inline-forms with cleaner markup
  • Loading branch information
adamjarling committed Nov 9, 2018
1 parent bb83ec9 commit 132061c
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 141 deletions.
18 changes: 2 additions & 16 deletions app/assets/stylesheets/hyrax/_collections.scss
Original file line number Diff line number Diff line change
Expand Up @@ -401,22 +401,8 @@ button.branding-banner-remove:hover {
.section-add-sharing {
padding-bottom: 40px;

.form-inline {
label {
padding-right: 5px;
text-align: right;
width: 100px;
}

input,
select,
.select2-container {
width: 200px;
}

.btn {
width: 75px;
}
.sharing-row-form {
margin-bottom: $padding-large-vertical;
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/assets/stylesheets/hyrax/_file-listing.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ h4 .small {
text-decoration: none;
}

input.batch_document_selector,
input.disabled {
input.batch_document_selector {
margin: 10px 10px 2px 10px;
padding: 0px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<td><%= g.agent_type.titleize %></td>
<td>
<% if g.admin_group? && g.access == Hyrax::PermissionTemplateAccess::MANAGE %>
<%= button_to t(".#{access}.remove"), hyrax.admin_permission_template_access_path(g), method: :delete, class: 'btn btn-danger disabled', disabled: true, title: t('hyrax.admin.admin_sets.form.permission_destroy_errors.admin_group') %>
<%= button_to t(".#{access}.remove"), hyrax.admin_permission_template_access_path(g), method: :delete, class: 'btn btn-sm btn-danger disabled', disabled: true, title: t('hyrax.admin.admin_sets.form.permission_destroy_errors.admin_group') %>
<% else %>
<%= button_to t(".#{access}.remove"), hyrax.admin_permission_template_access_path(g), method: :delete, class: 'btn btn-danger' %>
<%= button_to t(".#{access}.remove"), hyrax.admin_permission_template_access_path(g), method: :delete, class: 'btn btn-sm btn-danger' %>
<% end %>
</td>
</tr>
Expand Down
109 changes: 57 additions & 52 deletions app/views/hyrax/admin/admin_sets/_form_participants.html.erb
Original file line number Diff line number Diff line change
@@ -1,68 +1,73 @@
<div id="participants" class="tab-pane">
<div class="panel panel-default labels">
<div class="panel panel-default labels edit-sharing-tab">
<div class="panel-body">
<h2><%= t('.add_participants') %></h2>
<% access_options = options_for_select([['Manager', 'manage'], ['Depositor', 'deposit'], ['Viewer', 'view']]) %>
<%= simple_form_for @form.permission_template,
url: [hyrax, :admin, @form, :permission_template],
html: { id: 'group-participants-form' } do |f| %>
<div class="clearfix spacer">
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'group'),
index: 0 do |builder| %>
<div class="form-inline">
<label class="col-md-2 col-xs-4 control-label"><%= t('.add_group') %></label>
<section class="section-add-sharing clearfix">
<h3><%= t('.add_participants') %></h3>
<% access_options = options_for_select([['Manager', 'manage'], ['Depositor', 'deposit'], ['Viewer', 'view']]) %>
<div class="sharing-row-form">
<%= simple_form_for @form.permission_template,
url: [hyrax, :admin, @form, :permission_template],
html: { id: 'group-participants-form', class: 'form-inline' } do |f| %>
<div class="col-md-10 col-xs-8 form-group">
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a group...",
class: 'form-control' %>
as
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'group'),
index: 0 do |builder| %>
<div class="form-group">
<label><%= t('.add_group') %></label>
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a group...",
class: 'form-control' %>
</div>
<div class="form-group">
<label>as</label>
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
</div>
<% end %>
<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info' %>
<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info' %>
</div>
</div>
<% end %>
<% end %>
</div>
<% end %>

<%= simple_form_for @form.permission_template,
url: [hyrax, :admin, @form, :permission_template],
html: { id: 'user-participants-form' } do |f| %>
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'user'),
index: 0 do |builder| %>
<div class="form-inline add-users">
<label class="col-md-2 col-xs-4 control-label"><%= t('.add_user') %></label>
<div class="sharing-row-form">
<%= simple_form_for @form.permission_template,
url: [hyrax, :admin, @form, :permission_template],
html: { id: 'user-participants-form', class: 'form-inline add-users' } do |f| %>
<div class="col-md-10 col-xs-8 form-group">
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a user..." %>
as
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'user'),
index: 0 do |builder| %>
<div class="form-group">
<label><%= t('.add_user') %></label>
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a user..." %>
</div>
<div class="form-group">
<label>as</label>
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
</div>
<% end %>
<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info' %>
<% end %>
</div>

<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info' %>
<p class="help-block"><%= t('hyrax.admin.admin_sets.form.note') %></p>
</div>
</div>
<% end %>
<% end %>
<p class="help-block"><%= t('hyrax.admin.admin_sets.form.note') %></p>
</section>

<fieldset class="admin-set-participants">
<fieldset class="admin-set-participants section-collection-sharing">
<legend><%= t(".current_participants") %></legend>
<%= render 'form_participant_table', access: 'managers', filter: :manage? %>
<%= render 'form_participant_table', access: 'depositors', filter: :deposit? %>
<%= render 'form_participant_table', access: 'viewers', filter: :view? %>
</fieldset>
</div>

</div><!-- /.panel-body -->
</div>
</div>
136 changes: 67 additions & 69 deletions app/views/hyrax/dashboard/collections/_form_share.html.erb
Original file line number Diff line number Diff line change
@@ -1,85 +1,83 @@
<% access_options = options_for_select([['Manager', 'manage'], ['Depositor', 'deposit'], ['Viewer', 'view']]) %>

<div id="participants" class="tab-pane">
<div class="panel panel-default labels edit-sharing-tab">
<div class="panel-body">
<div class="edit-sharing-tab">
<section class="section-add-sharing">
<p><%= t('.note') %></p>
<h3><%= t('.add_sharing') %></h3>

<section class="section-add-sharing">
<p><%= t('.note') %></p>
<h3><%= t('.add_sharing') %></h3>
<!-- Add group form -->
<div class="form-add-sharing-wrapper" data-id="<%= @form.id %>">
<%= simple_form_for @form.permission_template,
url: [hyrax, :dashboard, @form, :permission_template],
html: { id: 'group-participants-form' } do |f| %>

<!-- Add group form -->
<div class="form-add-sharing-wrapper" data-id="<%= @form.id %>">
<%= simple_form_for @form.permission_template,
url: [hyrax, :dashboard, @form, :permission_template],
html: { id: 'group-participants-form' } do |f| %>
<div class="clearfix spacer">
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'group'),
index: 0 do |builder| %>
<div class="form-inline add-sharing-form sharing-row-form">
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'group'),
index: 0 do |builder| %>

<div class="form-inline add-sharing-form">
<label class="col-md-2 col-xs-4 control-label"><%= t('.add_group') %>:</label>
<div class="col-md-10 col-xs-8 form-group">
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a group...",
class: 'form-control search-input' %>
as
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info edit-collection-add-sharing-button', :disabled => true %>
</div>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="form-group">
<label><%= t('.add_group') %>:</label>
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a group...",
class: 'form-control search-input' %>
</div>
<div class="form-group">
<label>as</label>
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
</div>
<% end %>
<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info edit-collection-add-sharing-button', :disabled => true %>

<!-- Add user form -->
<div class="form-add-sharing-wrapper" data-id="<%= @form.id %>">
<%= simple_form_for @form.permission_template,
url: [hyrax, :dashboard, @form, :permission_template],
html: { id: 'user-participants-form' } do |f| %>
<div class="clearfix spacer">
</div><!-- /.form-inline -->
<% end %>
</div>

<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'user'),
index: 0 do |builder| %>
<!-- Add user form -->
<div class="form-add-sharing-wrapper" data-id="<%= @form.id %>">
<%= simple_form_for @form.permission_template,
url: [hyrax, :dashboard, @form, :permission_template],
html: { id: 'user-participants-form' } do |f| %>

<div class="form-inline add-users">
<label class="col-md-2 col-xs-4 control-label"><%= t('.add_user') %>:</label>
<div class="col-md-10 col-xs-8 form-group">
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a user..." %>
as
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
<div class="form-inline sharing-row-form add-users">
<%= f.fields_for 'access_grants_attributes',
f.object.access_grants.build(agent_type: 'user'),
index: 0 do |builder| %>

<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info edit-collection-add-sharing-button', :disabled => true %>
</div>
<div class="form-group">
<label><%= t('.add_user') %>:</label>
<%= builder.hidden_field :agent_type %>
<%= builder.text_field :agent_id,
placeholder: "Search for a user..." %>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="form-group">
<label>as</label>
<%= builder.select :access,
access_options,
{ prompt: "Select a role..." },
class: 'form-control' %>
</div>
<% end %>
<%= f.submit t('helpers.submit.hyrax_permission_template_access.create'), class: 'btn btn-info edit-collection-add-sharing-button', :disabled => true %>

<p class="help-block"><%= t('hyrax.admin.admin_sets.form.note') %></p>
</section>
</div> <!-- /.form-inline -->
<% end %>
</div>

<section class="section-collection-sharing">
<legend><%= t(".current_shared") %></legend>
<%= render 'form_share_table', access: 'managers', filter: :manage? %>
<%= render 'form_share_table', access: 'depositors', filter: :deposit? %>
<%= render 'form_share_table', access: 'viewers', filter: :view? %>
</section>
<p class="help-block"><%= t('hyrax.admin.admin_sets.form.note') %></p>
</section>

</div>
<section class="section-collection-sharing">
<legend><%= t(".current_shared") %></legend>
<%= render 'form_share_table', access: 'managers', filter: :manage? %>
<%= render 'form_share_table', access: 'depositors', filter: :deposit? %>
<%= render 'form_share_table', access: 'viewers', filter: :view? %>
</section>
</div>
</div>

0 comments on commit 132061c

Please sign in to comment.