mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 10:10:12 +01:00
migrate user js
This commit is contained in:
parent
a02f1d2584
commit
f0ec5647d4
5 changed files with 38 additions and 14 deletions
|
|
@ -1,2 +1,12 @@
|
||||||
module UsersHelper
|
module UsersHelper
|
||||||
|
def remote_delete_user(user)
|
||||||
|
return link_to(
|
||||||
|
image_tag("blank.png", :title =>t('users.destroy_user'), :class=>"delete_item"),
|
||||||
|
url_for({:controller => 'users', :action => 'destroy', :id => user.id}),
|
||||||
|
{:id => "delete_user_#{user.id}",
|
||||||
|
:class => "delete_user_button",
|
||||||
|
:title => t('users.destroy_user'),
|
||||||
|
:x_confirm_message => t('users.destroy_confirmation', :login => user.login)
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
if @saved
|
<% if @saved -%>
|
||||||
page["user-#{@deleted_user.id}"].remove
|
remove_user_from_page();
|
||||||
page['user_count'].replace_html @total_users.to_s
|
TracksPages.set_page_badge(<%= @total_users %>);
|
||||||
page.notify :notice, t('users.destroy_successful', :login => @deleted_user.login), 2.0
|
TracksPages.page_notify('notice', '<%= t('users.destroy_successful', :login => @deleted_user.login) %>', 5);
|
||||||
else
|
<% else -%>
|
||||||
page.notify :error, t('users.destroy_error', :login => @deleted_user.login), 8.0
|
TracksPages.page_notify('error', '<%= t('users.destroy_error', :login => @deleted_user.login) %>', 8);
|
||||||
end
|
<% end -%>
|
||||||
|
|
||||||
|
function remove_user_from_page() {
|
||||||
|
$("#user-<%= @deleted_user.id%>").remove();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,7 @@
|
||||||
<td><%= h user.contexts.size %></td>
|
<td><%= h user.contexts.size %></td>
|
||||||
<td><%= h user.projects.size %></td>
|
<td><%= h user.projects.size %></td>
|
||||||
<td><%= h user.notes.size %></td>
|
<td><%= h user.notes.size %></td>
|
||||||
<td><%= !user.is_admin? ? link_to_remote(
|
<td><%= !user.is_admin? ? remote_delete_user(user) : " " %></td>
|
||||||
image_tag("blank.png", :title =>t('users.destroy_user'), :class=>"delete_item"),
|
|
||||||
{ :url => user_path(user.id), :method => :delete,
|
|
||||||
:confirm => t('users.destroy_confirmation', :login => user.login) },
|
|
||||||
{ :class => "icon" } ) : " " %></td>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ Feature: Manage users
|
||||||
Then I should be on the manage users page
|
Then I should be on the manage users page
|
||||||
And I should see "new.user"
|
And I should see "new.user"
|
||||||
|
|
||||||
@selenium @wip
|
@selenium
|
||||||
Scenario: Delete account from users page
|
Scenario: Delete account from users page
|
||||||
When I go to the manage users page
|
When I go to the manage users page
|
||||||
And I delete the user "testuser"
|
And I delete the user "testuser"
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,20 @@ var TodoItems = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var UsersPage = {
|
||||||
|
setup_behavior: function() {
|
||||||
|
/* delete button to delete a usedr from the list */
|
||||||
|
$('a.delete_user_button').live('click', function(evt){
|
||||||
|
confirm_message = $(this).attr("x_confirm_message")
|
||||||
|
if(confirm(confirm_message)){
|
||||||
|
delete_with_ajax_and_block_element(this.href, $(this).parents('.project'));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ProjectListPage = {
|
var ProjectListPage = {
|
||||||
update_state_count: function(state, count) {
|
update_state_count: function(state, count) {
|
||||||
$('#'+state+'-projects-count').html(count);
|
$('#'+state+'-projects-count').html(count);
|
||||||
|
|
@ -1081,7 +1095,7 @@ $(document).ready(function() {
|
||||||
/* enable page specific behavior */
|
/* enable page specific behavior */
|
||||||
$([ 'IntegrationsPage', 'NotesPage', 'ProjectListPage', 'ContextListPage',
|
$([ 'IntegrationsPage', 'NotesPage', 'ProjectListPage', 'ContextListPage',
|
||||||
'FeedsPage', 'RecurringTodosPage', 'TodoItems', 'TracksPages',
|
'FeedsPage', 'RecurringTodosPage', 'TodoItems', 'TracksPages',
|
||||||
'TracksForm', 'SearchPage' ]).each(function() {
|
'TracksForm', 'SearchPage', 'UsersPage' ]).each(function() {
|
||||||
eval(this+'.setup_behavior();');
|
eval(this+'.setup_behavior();');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue