fix unshare list

This commit is contained in:
Nicolas Le Goff
2012-03-06 17:45:28 +01:00
parent d78fd6272e
commit 1445d624aa
2 changed files with 59 additions and 13 deletions

View File

@@ -3,20 +3,21 @@
{% else %} {% else %}
<div id="ListShare"> <div id="ListShare">
<div> <div>
<h2>{% trans 'About Roles : ' %}</h2> <h2 style="font-size:14px; margin-bottom:10px;"><b>{% trans 'About Roles : ' %}</b></h2>
<p> <p>
{% trans 'Admin can edit shares, modify content' %} - {% trans 'Admin can edit shares, modify content' %}
</p> </p>
<p> <p>
{% trans 'Editor can modify content' %} - {% trans 'Editor can modify content' %}
</p> </p>
<p> <p>
{% trans 'Access user have readonly access' %} - {% trans 'Access user have readonly access' %}
</p> </p>
</div> </div>
<div> <div style="margin-top:10px;">
<form name="list_share_user"> <form name="list_share_user">
<input type="text" class="search" name="user" value="" style="width:120px" /> <label for="use">{% trans 'Find a user' %} : </label>
<input type="text" class="search" name="user" value="" style="width:180px" />
</form> </form>
</div> </div>
<div> <div>
@@ -27,11 +28,11 @@
<td> <td>
<img src="/skins/icons/user.png"/> <img src="/skins/icons/user.png"/>
</td> </td>
<td> <td style="width:150px;padding:5px;">
{{ owner.getUser().get_display_name() }} {{ owner.getUser().get_display_name() }}
<input type="hidden" name="usr_id" value="{{ owner.getUser().get_id() }}" /> <input type="hidden" name="usr_id" value="{{ owner.getUser().get_id() }}" />
</td> </td>
<td> <td style="padding-right:10px;min-width:100px;">
{% if user.get_id() == owner.getUser(user).get_id() %} {% if user.get_id() == owner.getUser(user).get_id() %}
{% if owner.getRole() == constant('\\Entities\\UsrListOwner::ROLE_ADMIN') %} {% if owner.getRole() == constant('\\Entities\\UsrListOwner::ROLE_ADMIN') %}
{% trans 'You are Admin' %} {% trans 'You are Admin' %}
@@ -51,10 +52,12 @@
</select> </select>
{% endif %} {% endif %}
</td> </td>
<td> <td style="width:15px">
<a href="#" class="deleter"> {% if user.get_id() != owner.getUser(user).get_id() %}
<img src="/skins/prod/Push/close_badge.png" title="{% trans 'Remove' %}"/> <a href="#" class="deleter">
</a> <img src="/skins/prod/Push/close_badge.png" title="{% trans 'Remove' %}"/>
</a>
{% endif %}
<a href="#" class="notifier"> <a href="#" class="notifier">
<img src="/skins/prod/Push/Notify.png" title="{% trans 'Notify' %}"/> <img src="/skins/prod/Push/Notify.png" title="{% trans 'Notify' %}"/>
</a> </a>
@@ -85,6 +88,17 @@
return false; return false;
}); });
$('.deleter', $container).bind('click', function(){
var owner = $(this).closest('.owner');
var usr_id = owner.find('input[name="usr_id"]').val();
unShareWith(usr_id, function(data){
owner.remove();
});
return false;
});
function shareWith(usr_id, role) function shareWith(usr_id, role)
@@ -119,6 +133,38 @@
} }
}); });
} }
function unShareWith(usr_id, callback)
{
$.ajax({
type: 'POST',
url: '/prod/lists/list/{{ list.getId() }}/unshare/' + usr_id + '/',
dataType: 'json',
data : {},
beforeSend:function(){
},
success: function(data){
if(data.success)
{
humane.info(data.message);
callback(data);
}
else
{
humane.error(data.message);
}
$dialog.refresh();
return;
},
error: function(){
return;
},
timeout: function(){
return;
}
});
}
$autocompleter.autocomplete({ $autocompleter.autocomplete({
minLength: 2, minLength: 2,

View File

@@ -364,4 +364,4 @@
margin: 0 5px 0 0; margin: 0 5px 0 0;
padding: 4px; padding: 4px;
width: 95%; width: 95%;
} }