Skip to content

Commit

Permalink
Fix visibility related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Jan 17, 2025
1 parent 23d4623 commit c619ff5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
24 changes: 20 additions & 4 deletions rdmo/projects/assets/js/projects/components/main/Projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,36 @@ const Projects = ({ config, configActions, currentUserObject, projectsActions, p

if (myProjects) {
visibleColumns.splice(2, 0, 'role')
columnWidths = ['35%', '20%', '20%', '20%', '5%']
columnWidths = ['40%', '18%', '18%', '18%', '6%']
} else {
visibleColumns.splice(2, 0, 'created')
visibleColumns.splice(2, 0, 'owner')
columnWidths = ['35%', '10%', '20%', '20%', '20%', '5%']
columnWidths = ['30%', '10%', '18%', '18%', '18%', '6%']
}

const cellFormatters = {
title: (content, row) => renderTitle(content, row),
role: (_content, row) => {
const { rolesString } = getUserRoles(row, currentUserId)
return rolesString
return <>
{
rolesString && <p>{rolesString}</p>
}
{
row.visibility && <p className="text-muted">{row.visibility}</p>
}
</>
},
owner: (_content, row) => row.owners.map(owner => `${owner.first_name} ${owner.last_name}`).join('; '),
owner: (_content, row) => (
<>
<p>
{row.owners.map(owner => `${owner.first_name} ${owner.last_name}`).join('; ')}
</p>
{
row.visibility && <p className="text-muted">{row.visibility}</p>
}
</>
),
progress: (_content, row) => getProgressString(row),
created: content => useFormattedDateTime(content, language),
last_changed: content => useFormattedDateTime(content, language),
Expand Down
5 changes: 4 additions & 1 deletion rdmo/projects/serializers/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def get_queryset(self):

last_changed = serializers.DateTimeField(read_only=True)

visibility = serializers.CharField(source='visibility.get_help_display')

class Meta:
model = Project
fields = (
Expand All @@ -85,7 +87,8 @@ class Meta:
'site',
'views',
'progress_total',
'progress_count'
'progress_count',
'visibility'
)
read_only_fields = (
'snapshots',
Expand Down
8 changes: 4 additions & 4 deletions rdmo/projects/templates/projects/project_form_visibility.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ <h1>
{% endblocktrans %}
</p>

{% if object.visibility and 'sites' in form.fields or 'groups' in form.fields %}
{% if not object.visibility %}
{% bootstrap_form submit=_('Make visible') %}
{% elif object.visibility and 'sites' in form.fields or 'groups' in form.fields %}
{% bootstrap_form submit=_('Update visibility') delete=_('Remove visibility') %}
{% elif object.visibility %}
{% bootstrap_form delete=_('Remove visibility') %}
{% else %}
{% bootstrap_form submit=_('Make visible') %}
{% bootstrap_form delete=_('Remove visibility') %}
{% endif %}

{% endblock %}

0 comments on commit c619ff5

Please sign in to comment.