Skip to content

Commit

Permalink
Merge pull request #5892 from samvera/fileset-visibility-component
Browse files Browse the repository at this point in the history
Use VisibilityComponent for FileSet permissions
  • Loading branch information
dlpierce authored Oct 11, 2022
2 parents 4003345 + d078cbb commit 09aa789
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/hyrax/app.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Hyrax = {
// On the edit work page
new PermissionsControl($("#share"), 'tmpl-work-grant');
// On the edit fileset page
new PermissionsControl($("#permission"), 'tmpl-file-set-grant');
new PermissionsControl($("#permission"), 'tmpl-file-set-grant', { with_visibility_component: true });
// On the batch edit page
new PermissionsControl($("#form_permissions"), 'tmpl-work-grant');
// On the edit collection page
Expand Down
9 changes: 8 additions & 1 deletion app/assets/javascripts/hyrax/permissions/control.es6
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { Registry } from './registry'
import { UserControls } from './user_controls'
import { GroupControls } from './group_controls'
import VisibilityComponent from '../save_work/visibility_component'

export default class PermissionsControl {
/**
* Initialize the save controls
* @param {jQuery} element the jquery selector for the permissions container
* @param {String} template_id the identifier of the template for the added elements
*/
constructor(element, template_id) {
constructor(element, template_id, options = {}) {
const { with_visibility_component } = options
if (element.length === 0) {
return
}
Expand All @@ -17,6 +19,11 @@ export default class PermissionsControl {
this.registry = new Registry(this.element, this.object_name(), template_id)
this.user_controls = new UserControls(this.element, this.registry)
this.group_controls = new GroupControls(this.element, this.registry)
if (with_visibility_component) {
this.visibility_component = new VisibilityComponent(this.element)
} else {
this.visibility_component = null
}
}

// retrieve object_name the name of the object to create
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_form_progress.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</div>

<div class="set-access-controls list-group-item">
<%= render 'form_visibility_component', f: f %>
<%= render 'form_visibility_component', f: f, save_work: true %>
</div>
<% if Flipflop.proxy_deposit? && current_user.can_make_deposits_for.any? %>
<div class="list-group-item">
Expand Down
6 changes: 5 additions & 1 deletion app/views/hyrax/base/_form_visibility_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<%= render 'form_permission_under_lease', f: f %>
<% else %>
<fieldset>
<legend class="legend-save-work"><%= t('.visibility') %></legend>
<% if local_assigns[:save_work] %>
<legend class="legend-save-work"><%= t('.visibility') %></legend>
<% else %>
<legend><%= t('.visibility') %><%= raw(t('.subtitle_html')) %></legend>
<% end %>
<ul class="visibility">
<li class="form-check">
<label class="form-check-label">
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/file_sets/_permission_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span id="permissions_error_text"></span>
</div>

<%= render 'hyrax/base/form_permission', f: f %>
<%= render 'hyrax/base/form_visibility_component', f: f %>

<!-- Share With -->
<div class="row">
Expand Down
3 changes: 2 additions & 1 deletion config/locales/hyrax.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ de:
actions: Aktion
title: Sammlungstitel
form_permission:
visibility: Sichtbarkeit <small> Wer sollte diesen Inhalt anzeigen oder herunterladen können? </ Small>
visibility: Sichtbarkeit <small> Wer sollte diesen Inhalt anzeigen oder herunterladen können? </small>
form_permission_under_embargo:
help_html: "<strong>Diese Arbeit ist unter Embargo.</strong> Hier können Sie die Einstellungen des Embargos ändern, oder Sie können den %{edit_link} besuchen, um ihn zu deaktivieren."
legend_html: Sichtbarkeit <small>Wer sollte in der Lage sein, diesen Inhalt anzusehen oder herunterzuladen?</small>
Expand Down Expand Up @@ -596,6 +596,7 @@ de:
legend_html: Miniaturansicht
form_visibility_component:
visibility: Sichtbarkeit
subtitle_html: <small>Wer sollte diesen Inhalt anzeigen oder herunterladen können?</small>
inspect_work:
back_to: Zurück zu
entity_id: Mandanten-ID
Expand Down
1 change: 1 addition & 0 deletions config/locales/hyrax.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ en:
legend_html: Thumbnail
form_visibility_component:
visibility: Visibility
subtitle_html: <small>Who should be able to view or download this content?</small>
inspect_work:
back_to: Back to
entity_id: Entity ID
Expand Down
1 change: 1 addition & 0 deletions config/locales/hyrax.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ es:
legend_html: Miniatura
form_visibility_component:
visibility: La visibilidad
subtitle_html: <small>¿Quién debería poder ver o descargar este contenido?</small>
inspect_work:
back_to: De regreso
entity_id: ID de entidad
Expand Down
3 changes: 2 additions & 1 deletion config/locales/hyrax.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ fr:
actions: action
title: Titre de la collection
form_permission:
visibility: Visibilité <small> Qui devrait être en mesure d’afficher ou de télécharger ce contenu? </ Small>
visibility: Visibilité <small> Qui devrait être en mesure d’afficher ou de télécharger ce contenu? </small>
form_permission_under_embargo:
help_html: "<strong>Ce travail est sous embargo.</strong> Vous pouvez modifier les paramètres de l'embargo ici, ou vous pouvez visiter le %{edit_link} pour le désactiver."
legend_html: Visibilité <small>Qui devrait pouvoir afficher ou télécharger ce contenu?</small>
Expand Down Expand Up @@ -602,6 +602,7 @@ fr:
legend_html: La vignette
form_visibility_component:
visibility: Visibilité
subtitle_html: <small>Qui devrait être en mesure d’afficher ou de télécharger ce contenu?</small>
inspect_work:
back_to: Retour à
entity_id: ID d'entité
Expand Down
1 change: 1 addition & 0 deletions config/locales/hyrax.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ it:
legend_html: Thumbnail
form_visibility_component:
visibility: Visibilità
subtitle_html: <small>Chi dovrebbe essere in grado di visualizzare o scaricare questo contenuto?</small>
inspect_work:
back_to: Torna a
entity_id: ID entità
Expand Down
1 change: 1 addition & 0 deletions config/locales/hyrax.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ pt-BR:
legend_html: Miniatura
form_visibility_component:
visibility: Visibilidade
subtitle_html: <small>Quem deve conseguir visualizar ou baixar este conteúdo?</small>
inspect_work:
back_to: De volta a
entity_id: ID da entidade
Expand Down
1 change: 1 addition & 0 deletions config/locales/hyrax.zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ zh:
legend_html: 缩略图
form_visibility_component:
visibility: 可见性
subtitle_html: <small>谁应该能够查看或下载此内容?</ small>
inspect_work:
back_to: 回到
entity_id: 实体ID
Expand Down

0 comments on commit 09aa789

Please sign in to comment.