<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -84,32 +84,63 @@ module AuthorizationRulesHelper
           role_color(role))
   end
 
+  def human_privilege (privilege)
+    begin
+      I18n.t(privilege, :scope =&gt; [:declarative_authorization, :privilege], :raise =&gt; true)
+    rescue
+      privilege.to_s
+    end
+  end
+
+  def human_context (context)
+    begin
+      context.to_s.classify.constantize.human_name
+    rescue
+      context.to_s
+    end
+  end
+
+  def human_privilege_context (privilege, context)
+    human = [human_privilege(privilege), human_context(context)]
+    begin
+      unless I18n.t(:verb_in_front_of_object, :scope =&gt; :declarative_authorization, :raise =&gt; true)
+        human.reverse!
+      end
+    rescue
+    end
+    human * &quot; &quot;
+  end
+
+  def human_role (role)
+    Authorization::Engine.instance.title_for(role) or role.to_s
+  end
+
   def describe_step (step, options = {})
     options = {:with_removal =&gt; false}.merge(options)
 
     case step[0]
     when :add_privilege
       dont_assign = prohibit_link(step[0,3],
-          &quot;Add privilege &lt;strong&gt;#{h step[1].to_sym.inspect} #{h step[2].to_sym.inspect}&lt;/strong&gt; to any role&quot;,
-          &quot;Don't suggest adding #{h step[1].to_sym.inspect} #{h step[2].to_sym.inspect}.&quot;, options)
-      &quot;Add privilege &lt;strong&gt;#{h step[1].inspect} #{h step[2].inspect}&lt;/strong&gt;#{dont_assign} to role &lt;strong&gt;#{h step[3].to_sym.inspect}&lt;/strong&gt;&quot;
+          &quot;Add privilege &lt;strong&gt;#{h human_privilege_context(step[1], step[2])}&lt;/strong&gt; to any role&quot;,
+          &quot;Don't suggest adding #{h human_privilege_context(step[1], step[2])}.&quot;, options)
+      &quot;Add privilege &lt;strong&gt;#{h human_privilege_context(step[1], step[2])}&lt;/strong&gt;#{dont_assign} to role &lt;strong&gt;#{h human_role(step[3].to_sym)}&lt;/strong&gt;&quot;
     when :remove_privilege
       dont_remove = prohibit_link(step[0,3], 
-          &quot;Remove privilege &lt;strong&gt;#{h step[1].to_sym.inspect} #{h step[2].to_sym.inspect}&lt;/strong&gt; from any role&quot;, 
-          &quot;Don't suggest removing #{h step[1].to_sym.inspect} #{h step[2].to_sym.inspect}.&quot;, options)
-      &quot;Remove privilege &lt;strong&gt;#{h step[1].inspect} #{h step[2].inspect}&lt;/strong&gt;#{dont_remove} from role &lt;strong&gt;#{h step[3].to_sym.inspect}&lt;/strong&gt;&quot;
+          &quot;Remove privilege &lt;strong&gt;#{h human_privilege_context(step[1], step[2])}&lt;/strong&gt; from any role&quot;,
+          &quot;Don't suggest removing #{h human_privilege_context(step[1], step[2])}.&quot;, options)
+      &quot;Remove privilege &lt;strong&gt;#{h human_privilege_context(step[1], step[2])}&lt;/strong&gt;#{dont_remove} from role &lt;strong&gt;#{h human_role(step[3].to_sym)}&lt;/strong&gt;&quot;
     when :add_role
-      &quot;New role &lt;strong&gt;#{h step[1].to_sym.inspect}&lt;/strong&gt;&quot;
+      &quot;New role &lt;strong&gt;#{h human_role(step[1].to_sym)}&lt;/strong&gt;&quot;
     when :assign_role_to_user
       dont_assign = prohibit_link(step[0,2],
-          &quot;Assign role &lt;strong&gt;#{h step[1].to_sym.inspect}&lt;/strong&gt; to any user&quot;,
-          &quot;Don't suggest assigning #{h step[1].to_sym.inspect}.&quot;, options)
-      &quot;Assign role &lt;strong&gt;#{h step[1].to_sym.inspect}&lt;/strong&gt;#{dont_assign} to &lt;strong&gt;#{h readable_step_info(step[2])}&lt;/strong&gt;&quot;
+          &quot;Assign role &lt;strong&gt;#{h human_role(step[1].to_sym)}&lt;/strong&gt; to any user&quot;,
+          &quot;Don't suggest assigning #{h human_role(step[1].to_sym)}.&quot;, options)
+      &quot;Assign role &lt;strong&gt;#{h human_role(step[1].to_sym)}&lt;/strong&gt;#{dont_assign} to &lt;strong&gt;#{h readable_step_info(step[2])}&lt;/strong&gt;&quot;
     when :remove_role_from_user
       dont_remove = prohibit_link(step[0,2],
-          &quot;Remove role &lt;strong&gt;#{h step[1].to_sym.inspect}&lt;/strong&gt; from any user&quot;,
-          &quot;Don't suggest removing #{h step[1].to_sym.inspect}.&quot;, options)
-      &quot;Remove role &lt;strong&gt;#{h step[1].to_sym.inspect}&lt;/strong&gt;#{dont_remove} from &lt;strong&gt;#{h readable_step_info(step[2])}&lt;/strong&gt;&quot;
+          &quot;Remove role &lt;strong&gt;#{h human_role(step[1].to_sym)}&lt;/strong&gt; from any user&quot;,
+          &quot;Don't suggest removing #{h human_role(step[1].to_sym)}.&quot;, options)
+      &quot;Remove role &lt;strong&gt;#{h human_role(step[1].to_sym)}&lt;/strong&gt;#{dont_remove} from &lt;strong&gt;#{h readable_step_info(step[2])}&lt;/strong&gt;&quot;
     else
       step.collect {|info| readable_step_info(info) }.map {|str| h str } * ', '
     end + prohibit_link(step, options[:with_removal] ? &quot;#{escape_javascript(describe_step(step))}&quot; : '',</diff>
      <filename>app/helpers/authorization_rules_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,10 +2,10 @@
 &lt;h2&gt;Which permission to change?&lt;/h2&gt;
 &lt;p class=&quot;action-options&quot;&gt;
   &lt;label&gt;Privilege&lt;/label&gt;
-  &lt;%= select_tag :privilege, options_for_select(@privileges.map(&amp;:to_s).sort, @privilege.to_s) %&gt;
+  &lt;%= select_tag :privilege, options_for_select(@privileges.map {|p| [human_privilege(p), p.to_s]}.sort, @privilege.to_s) %&gt;
   &lt;br/&gt;
   &lt;label&gt;On&lt;/label&gt;
-  &lt;%= select_tag :context, options_for_select(@contexts.map(&amp;:to_s).sort, @context.to_s) %&gt;
+  &lt;%= select_tag :context, options_for_select(@contexts.map {|c| [human_context(c), c.to_s]}.sort, @context.to_s) %&gt;
   &lt;br/&gt;
   &lt;label&gt;&lt;/label&gt;
   &lt;%= link_to_function &quot;Show current permissions&quot;, &quot;show_current_permissions()&quot;, :class =&gt; 'unimportant' %&gt;
@@ -35,7 +35,7 @@
       &lt;tr class=&quot;&lt;%= controller.authorization_engine.permit?(@privilege, :context =&gt; @context, :user =&gt; user, :skip_attribute_test =&gt; true) ? 'permitted' : 'not-permitted' %&gt;&quot;&gt;
         &lt;td class=&quot;user_id&quot;&gt;&lt;%=h user.id %&gt;&lt;/td&gt;
         &lt;td style=&quot;font-weight:bold&quot;&gt;&lt;%=h user.login %&gt;&lt;/td&gt;
-        &lt;td&gt;&lt;%=h user.role_symbols * ', ' %&gt;&lt;/td&gt;
+        &lt;td&gt;&lt;%=h user.role_symbols.map {|r| human_role(r)} * ', ' %&gt;&lt;/td&gt;
         &lt;td&gt;&lt;%= radio_button_tag &quot;user[#{user.id}][permission]&quot;, &quot;undetermined&quot;, true %&gt;&lt;/td&gt;
         &lt;td class=&quot;yes&quot;&gt;&lt;%= radio_button_tag &quot;user[#{user.id}][permission]&quot;, &quot;yes&quot; %&gt;&lt;/td&gt;
         &lt;td class=&quot;no&quot;&gt;&lt;%= radio_button_tag &quot;user[#{user.id}][permission]&quot;, &quot;no&quot; %&gt;&lt;/td&gt;</diff>
      <filename>app/views/authorization_rules/_change.erb</filename>
    </modified>
    <modified>
      <diff>@@ -30,13 +30,13 @@
               &lt;% if grouped_approach.similar_approaches.empty? %&gt;
                 &lt;span class=&quot;unimportant show-others-in-group&quot;&gt;No further suggestions in this group&lt;/span&gt;
               &lt;% else %&gt;
-                &lt;%= link_to_function &quot;Show further #{pluralize grouped_approach.similar_approaches.length, &quot;suggestion&quot;} in this group&quot;, &quot;show_group_approaches(#{group_index})&quot;, :class =&gt; &quot;show-others-in-group&quot; %&gt;
+                &lt;%= link_to_function &quot;Show further &lt;strong&gt;#{pluralize grouped_approach.similar_approaches.length, &quot;suggestion&quot;}&lt;/strong&gt; in this group&quot;, &quot;show_group_approaches(#{group_index})&quot;, :class =&gt; &quot;show-others-in-group&quot; %&gt;
               &lt;% end %&gt;
             &lt;% end %&gt;
             &lt;%= link_to_function &quot;Hide further suggestions&quot;, &quot;hide_group_approaches(#{group_index})&quot; if index &gt; 0 and index == grouped_approach.similar_approaches.length %&gt;
           &lt;/li&gt;
           &lt;% if index == 0 and group_index == 2 and @grouped_approaches.length &gt; 3 %&gt;
-            &lt;li &lt;%= !params[:show_all] ? '' : 'style=&quot;display: none&quot;' %&gt;&gt;&lt;%= link_to_function &quot;Show further #{pluralize(@grouped_approaches.length - 3, 'group')}&quot;, &quot;show_all_groups(); $(this).up().hide()&quot; %&gt;&lt;/li&gt;
+            &lt;li &lt;%= !params[:show_all] ? '' : 'style=&quot;display: none&quot;' %&gt;&gt;&lt;%= link_to_function &quot;Show further &lt;strong&gt;#{pluralize(@grouped_approaches.length - 3, 'group')}&lt;/strong&gt;&quot;, &quot;show_all_groups(); $(this).up().hide()&quot; %&gt;&lt;/li&gt;
           &lt;% end %&gt;
         &lt;% end %&gt;
       &lt;% end %&gt;</diff>
      <filename>app/views/authorization_rules/_suggestions.erb</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,8 @@
 &lt;/div&gt;
 &lt;%= render 'show_graph' %&gt;
 
+&lt;div id=&quot;spinner&quot; style=&quot;display:none&quot;&gt;Searching...&lt;/div&gt;
+
 &lt;style type=&quot;text/css&quot;&gt;
   .action-options label { display: block; float: left; width: 7em; padding-bottom: 0.5em }
   .action-options label.inline { display: inline; float: none }
@@ -52,17 +54,32 @@
   .unimportant, .remove, .prohibit { color: grey }
   .important { font-weight: bold }
   .remove { cursor: pointer }
+  #spinner { position: fixed; top: 0; right: 0; background: #FFE599; padding: 1em }
 &lt;/style&gt;
 &lt;% javascript_tag do %&gt;
     function suggest_changes (refresh) {
-        if (!refresh)
+        var opened_groups = $$(&quot;#suggest-result&gt;ul&gt;li.secondary&quot;).select(function (li) {return li.visible()}).collect(function (li) {
+            return li.classNames().toArray()[1].split(&quot;-&quot;)[1];
+        }).uniq();
+
+        if (refresh)
+          $(&quot;spinner&quot;).show();
+        else
           $(&quot;suggest-result&quot;).innerHTML = &quot;Searching...&quot;;
+
+
         $(&quot;suggest-result&quot;).show();
         new Ajax.Updater({success: 'suggest-result'}, '&lt;%= suggest_change_authorization_rules_path %&gt;', {
             method: 'get',
             onFailure: function(request) {
                 $(&quot;suggest-result&quot;).innerHTML = &quot;Error while searching.&quot;
             },
+            onComplete: function () {
+                $(&quot;spinner&quot;).hide();
+                opened_groups.each(function (group_no) {
+                  show_group_approaches(group_no);
+                });
+            },
             parameters: $H($('change').down('form').serialize(true)).merge(refresh ? {show_all: &quot;true&quot;} : {}).toQueryString()
         });
         if (!refresh)
@@ -70,7 +87,7 @@
     }
 
     function show_suggest_graph (changes, filter_roles_params, filter_context, user_ids) {
-        var params = {changes: changes, highlight_privilege: $F('privilege')};
+        var params = {changes: changes, highlight_privilege: $F('privilege'), stacked_roles: '1'};
         if (filter_context)
           params['filter_contexts'] = filter_context;
         if (user_ids)</diff>
      <filename>app/views/authorization_rules/change.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,7 @@ digraph rules {
     node [shape=ellipse,style=filled]
     &lt;%= @stacked_roles ? '' : &quot;rank = same&quot; %&gt;
     &lt;% @roles.each do |role| %&gt;
-    &quot;&lt;%= role.inspect %&gt;&quot; [fillcolor=&quot;&lt;%= role_fill_color(role) %&gt;&quot;]
+    &quot;&lt;%= role.inspect %&gt;&quot; [fillcolor=&quot;&lt;%= role_fill_color(role) %&gt;&quot;,label=&quot;&lt;%= human_role(role) %&gt;&quot;]
     // ,URL=&quot;javascript:set_filter({roles: '&lt;%= role %&gt;'})&quot;
     &lt;% end %&gt;
     &lt;% @roles.each do |role| %&gt;
@@ -42,11 +42,11 @@ digraph rules {
 
   &lt;% @contexts.each do |context| %&gt;
     subgraph cluster_&lt;%= context %&gt;  {
-      label = &quot;&lt;%= context.inspect %&gt;&quot;
+      label = &quot;&lt;%= human_context(context) %&gt;&quot;
       style=filled; fillcolor=&quot;#eeeeee&quot;
       node[fillcolor=white,style=filled]
       &lt;% (@context_privs[context] || []).each do |priv| %&gt;
-      &lt;%= priv %&gt;_&lt;%= context %&gt; [label=&quot;&lt;%= priv.inspect %&gt;&quot;&lt;%= ',fontcolor=&quot;#ff0000&quot;' if @highlight_privilege == priv %&gt;]
+      &lt;%= priv %&gt;_&lt;%= context %&gt; [label=&quot;&lt;%= human_privilege(priv) %&gt;&quot;&lt;%= ',fontcolor=&quot;#ff0000&quot;' if @highlight_privilege == priv %&gt;]
       &lt;% end %&gt;
       &lt;% (@context_privs[context] || []).each do |priv| %&gt;
         &lt;% (@privilege_hierarchy[priv] || []).</diff>
      <filename>app/views/authorization_rules/graph.dot.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c6ee88ec3e1ebb617d496f89f6fdc128f66b6743</id>
    </parent>
  </parents>
  <author>
    <name>Steffen Bartsch</name>
    <email>sbartsch@tzi.org</email>
  </author>
  <url>http://github.com/stffn/declarative_authorization/commit/26c5ac4e29f15a1fd5e316477a60a81e040dea89</url>
  <id>26c5ac4e29f15a1fd5e316477a60a81e040dea89</id>
  <committed-date>2009-11-06T01:21:09-08:00</committed-date>
  <authored-date>2009-09-10T04:55:34-07:00</authored-date>
  <message>Change support i18n</message>
  <tree>a97aa20c5cdda3c10152e64d5fec7574508a1bae</tree>
  <committer>
    <name>Steffen Bartsch</name>
    <email>sbartsch@tzi.org</email>
  </committer>
</commit>
