Commit 03a8a1f0 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Astakos project details user actions improvenets

- Split actions partial in a separate template.
- Convert simple A html links to confirm forms and do action requests
  using POST.
- Use a common tempalte tag ``confirm_link`` to prompt user an
  additional step of action confirmation.
- Additionally show a reason field in project deny action.
parent b1d81fb0
......@@ -253,6 +253,7 @@ dl.alt-style dd { overflow:hidden; }
.projects h3 { font-size:1.154em; }
.projects .submit-rt { margin:0; text-align:right; }
.projects +.buttons-list.fixpos { left:0; right:auto; }
.project-actions a { font-size: 0.7em }
/* new faq-userguide styles */
......@@ -512,10 +513,17 @@ form input[type="text"]:-ms-input-placeholder,
.projects .editable form textarea { width:70%; height:50px; max-width:70%; width:270px; height:120px;}
table .msg-wrap { position:relative; display:inline-block; }
table .msg-wrap .dialog { position:absolute; border:1px dashed #ccc; padding:15px; width:200px; bottom:30px; right:0; background:#fff; display:none; }
table .msg-wrap .dialog .submit { min-width:30px; padding:5px 22px; }
table .msg-wrap .dialog .no.submit { float:right; }
h2 .msg-wrap { font-size: 0.7em }
.msg-wrap { position:relative; display:inline-block; }
.msg-wrap .dialog { position:absolute; display: none;}
.msg-wrap .dialog-content { border:1px dashed #ccc; padding:15px; width:200px; bottom:30px; right:0; background:#fff;}
.msg-wrap .dialog .submit { min-width:30px; padding:5px 22px; }
.msg-wrap .dialog .no.submit { float:right; }
.msg-wrap.inline form.link-like { float: none !important; padding:0 !important; margin: 0 !important}
.msg-wrap.inline { display: inline; }
.msg-wrap textarea { width: 90%; height: 100px; padding:4%; font-size: 1.1em;}
table.alt-style .centered { text-align:center; }
table.alt-style form.link-like { float:none}
table.alt-style .project_action div:first-child form { margin:0; }
......
......@@ -229,9 +229,27 @@ $(document).ready(function() {
});
$("input.leave, input.join").click(function () {
$('dialog').hide();
$("input.leave, input.join").click(function (e) {
e.preventDefault();
var form = $(this).parents('form');
var dialog = $(this).parents('.msg-wrap').find('.dialog');
$('.dialog').hide();
$(this).parents('.msg-wrap').find('.dialog').show();
var offset = dialog.offset();
if (offset.left <= 10) {
dialog.css({'left': '10px'})
}
if (offset.top <= 10) {
dialog.css({'top': '10px'})
}
if (dialog.find('textarea').length > 0) {
dialog.find('textarea').val('');
dialog.find('textarea').focus();
}
return false;
});
......@@ -243,7 +261,20 @@ $(document).ready(function() {
$('.msg-wrap .yes').click( function(e){
e.preventDefault();
$(this).parents('.dialog').siblings('form').submit();
var dialog = $(this).parents('.msg-wrap').find('.dialog');
var form = $(this).parents('.msg-wrap').find('form');
var fields = dialog.find('input, textarea')
var toremove = [];
fields.each(function(){
var f = $(this).clone();
f.hide();
form.append(f);
f.val($(this).val());
toremove.push(f);
});
form.submit();
})
$('.hidden-submit input[readonly!="True"]').focus(function () {
......@@ -338,4 +369,4 @@ $(window).resize(function() {
setContainerMinHeight('.container .wrapper');
});
\ No newline at end of file
});
{% load astakos_tags i18n %}
<!-- make room for buttons -->
{% if owner_mode or admin_mode or can_join_request or can_leave_request %}
<br />
{% endif %}
<div class="project-actions">
{% if owner_mode or admin_mode %}
<a class="owner-action" href="{% url astakos.im.views.project_modify object.pk %}">MODIFY</a>
{% if owner_mode %}
{% with object.last_pending_incl_me as last_pending %}
{% if last_pending %}
{% if object.project_exists %}
- {% confirm_link "CANCEL PROJECT MODIFICATION" "project_modification_cancel" "project_app_cancel" last_pending.pk "" "OK" %}
{% else %}
- {% confirm_link "CANCEL PROJECT APPLICATION" "project_app_cancel" "project_app_cancel" last_pending.pk "" "OK" %}
{% endif %}
{% endif %}
{% endwith %}
{% endif %}
{% if admin_mode %}
{% if object.can_approve %}
- {% confirm_link "APPROVE" "project_app_approve" "project_app_approve" object.pk "" "OK" %}
- {% confirm_link "DENY" "project_app_deny" "project_app_deny" object.pk %}
{% endif %}
{% endif %}
{% if owner_mode %}
{% if object.can_dismiss %}
- {% confirm_link "DISMISS" "project_app_dismiss" "project_app_dismiss" object.pk %}
{% endif %}
{% endif %}
<!-- only one is possible, perhaps add cancel button too -->
{% if can_join_request or can_leave_request %}
-
{% endif %}
{% endif %}
{% if can_join_request %}
<a class="user-action" href="{% url astakos.im.views.project_join project.pk %}">JOIN</a>
{% endif %}
{% if can_leave_request %}
<a class="user-action" href="{% url astakos.im.views.project_leave project.pk %}">LEAVE</a>
{% endif %}
</div>
......@@ -47,62 +47,10 @@
{% endif %}
{{ object.name|upper }}
</span>
<!-- make room for buttons -->
{% if owner_mode or admin_mode or can_join_request or can_leave_request %}
<br />
{% endif %}
{% if owner_mode or admin_mode %}
<a style="font-size:0.7em"
href="{% url astakos.im.views.project_modify object.pk %}">MODIFY</a>
{% if owner_mode %}
{% with object.last_pending_incl_me as last_pending %}
{% if last_pending %}
-
<a style="font-size:0.7em"
href="{% url astakos.im.views.project_app_cancel last_pending.pk %}">
CANCEL PROJECT {% if object.project_exists %} MODIFICATION {% else %}
APPLICATION {% endif %}
</a>
{% endif %}
{% endwith %}
{% endif %}
{% if admin_mode %}
{% if object.can_approve %}
- <a style="font-size:0.7em"
href="{% url astakos.im.views.project_app_approve object.pk %}">
APPROVE</a>
- <a style="font-size:0.7em"
href="{% url astakos.im.views.project_app_deny object.pk %}">
DENY</a>
{% endif %}
{% endif %}
{% if owner_mode %}
{% if object.can_dismiss %}
- <a style="font-size:0.7em"
href="{% url astakos.im.views.project_app_dismiss object.pk %}">
DISMISS</a>
{% endif %}
{% endif %}
<!-- only one is possible, perhaps add cancel button too -->
{% if can_join_request or can_leave_request %}
<br />
{% endif %}
{% endif %}
{% if can_join_request %}
<a style="font-size:0.7em"
href="{% url astakos.im.views.project_join project.pk %}">JOIN</a>
{% endif %}
{% if can_leave_request %}
<a style="font-size:0.7em"
href="{% url astakos.im.views.project_leave project.pk %}">LEAVE</a>
{% endif %}
{% block project.actions %}
{% include "im/projects/_project_detail_actions.html" %}
{% endblock %}
</h2>
<div class="full-dotted">
......
<div class="msg-wrap">
<div class="msg-wrap {% if inline %}inline{% endif %}">
{% if url %}
{% if confirm %}
<form method="{{ col.method }}"
......@@ -8,6 +8,7 @@
<input type="submit" value="{{ action }}" class="join_group join" />
</form>
<div class="dialog" style="display: none">
<div class="dialog-content">
{{ prompt }}
<br />
<br />
......@@ -15,6 +16,7 @@
&nbsp;
<a href="#" class="no submit">{{ col.cancel_prompt }}</a>
</div>
</div>
{% else %}
<a href="{{ url }}">{{ action }}</a>
{% endif %}
......
......@@ -39,6 +39,11 @@ from django import template
from django.core.urlresolvers import resolve
from django.conf import settings
from django.template import TemplateSyntaxError, Variable
from django.utils.translation import ugettext as _
from django.template.loader import render_to_string
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
register = template.Library()
......@@ -207,3 +212,61 @@ def provider_login_url(context, provider, from_login=False):
return "%s%s%s" % (provider.add_url, joinchar, urllib.urlencode(attrs))
EXTRA_CONTENT_MAP = {
'confirm_text': '<textarea name="reason"></textarea>'
}
CONFIRM_LINK_PROMPT_MAP = {
'project_modification_cancel': _('Are you sure you want to dismiss this '
'project ?'),
'project_app_cancel': _('Are you sure you want to cancel this project ?'),
'project_app_approve': _('Are you sure you want to approve this '
'project ?'),
'project_app_deny': _('Are you sure you want to deny this project ? '
'<br /><br />You '
'may optionally provide denial reason in the '
'following field: <br /><br /><textarea class="deny_reason" '
'name="reason"></textarea>'),
'project_app_dismiss': _('Are you sure you want to dismiss this '
'project ?'),
'project_app_join': _('Are you sure you want to join this project ?'),
'project_app_leave': _('Are you sure you want to leave this project ?'),
}
@register.tag(name="confirm_link")
@basictag(takes_context=True)
def confirm_link(context, title, prompt='', url=None, urlarg=None,
extracontent='',
confirm_prompt=None,
inline=True,
template="im/table_rich_link_column.html"):
urlargs = None
if urlarg:
urlargs = (urlarg,)
if CONFIRM_LINK_PROMPT_MAP.get(prompt, None):
prompt = mark_safe(CONFIRM_LINK_PROMPT_MAP.get(prompt))
url = reverse(url, args=urlargs)
title = _(title)
tpl_context = RequestContext(context.get('request'))
tpl_context.update({
'col': {
'method': 'POST',
'cancel_prompt': 'CANCEL',
'confirm_prompt': confirm_prompt or title
},
'inline': inline,
'url': url,
'action': title,
'prompt': prompt,
'extra_form_content': EXTRA_CONTENT_MAP.get(extracontent, ''),
'confirm': True
})
content = render_to_string(template, tpl_context)
return content
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment