Skip to content

Commit

Permalink
[#844] Make group members page more similar to organization members page
Browse files Browse the repository at this point in the history
- When editing a member (as opposed to adding a new one):
  - Prefill username field, and make it non-editable
  - Prefill role field with user's current role
  - Add a delete button to the form
  - Label the submit button 'Save' rather than 'Add'
  • Loading branch information
Sean Hammond committed Jun 26, 2013
1 parent 3577a19 commit f1eebbe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions ckan/templates/group/edit_base.html
@@ -1,5 +1,7 @@
{% extends "group/read_base.html" %}

{% set group = c.group_dict %}

{% block actions_content %}
<li>{% link_for _('View group'), controller='group', action='read', id=c.group_dict.name, class_='btn', icon='eye-open' %}</li>
{% endblock %}
Expand Down
27 changes: 21 additions & 6 deletions ckan/templates/group/member_new.html
@@ -1,24 +1,39 @@
{% extends "group/edit_base.html" %}

{% import 'macros/form.html' as form %}

{% set user = c.user_dict %}

{% block primary_content_inner %}
<div class="module-content">
{% link_for _('Back to all members'), controller='group', action='members', id=c.group_dict.id, class_='btn pull-right', icon='arrow-left' %}
{% link_for _('Back to all members'), controller='group', action='members', id=group.name, class_='btn pull-right', icon='arrow-left' %}
<h1 class="page-heading">
{% block page_heading %}{{ _('Edit Member') if c.user_name else _('Add Member') }}{% endblock %}
{% block page_heading %}{{ _('Edit Member') if user else _('Add Member') }}{% endblock %}
</h1>
{% block form %}
<form class="dataset-form form-horizontal" method='post'>
{% if c.user_name %}
<input type="hidden" name="username" value="{{ c.user_name }}" />
{% if user %}
<input type="hidden" name="username" value="{{ user.name }}" />
{% set format_attrs = {'disabled': true} %}
{{ form.input('username', label=_('User'), value=user.name, classes=['control-medium'], attrs=format_attrs) }}
{% else %}
{% set format_attrs = {'data-module': 'autocomplete', 'data-module-source': '/api/2/util/user/autocomplete?q=?'} %}
{{ form.input('username', id='field-username', label=_('User'), placeholder=_('Username'), value='', error='', classes=['control-medium'], attrs=format_attrs) }}
{% endif %}
{% set format_attrs = {'data-module': 'autocomplete'} %}
{{ form.select('role', label=_('Role'), options=c.roles, selected='', error='', attrs=format_attrs) }}
{{ form.select('role', label=_('Role'), options=c.roles, selected=c.user_role, error='', attrs=format_attrs) }}
<div class="form-actions">
<button class="btn btn-primary" type="submit" name="submit" >{{ _('Add') }}</button>
{% if user %}
{% set locale = h.dump_json({'content': _('Are you sure you want to delete this member?')}) %}
<a href="{% url_for controller='group', action='member_delete', id=c.group_dict.id, user=user.id %}" class="btn btn-danger pull-left" data-module="confirm-action" data-module-i18n="{{ locale }}">{{ _('Delete') }}</a>
<button class="btn btn-primary" type="submit" name="submit" >
{{ _('Save') }}
</button>
{% else %}
<button class="btn btn-primary" type="submit" name="submit" >
{{ _('Add') }}
</button>
{% endif %}
</div>
</form>
{% endblock %}
Expand Down

0 comments on commit f1eebbe

Please sign in to comment.