[Bps-public-commit] rt-extension-assets branch, bulk-update, created. 90d555c0e2a81dfe75decfade8002f6e16d200eb

Alex Vandiver alexmv at bestpractical.com
Mon Sep 30 14:44:26 EDT 2013


The branch, bulk-update has been created
        at  90d555c0e2a81dfe75decfade8002f6e16d200eb (commit)

- Log -----------------------------------------------------------------
commit aa97a5d7c5e353698b21561dce2f414b56df02a0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Aug 30 21:59:18 2013 +0400

    missing tds

diff --git a/html/Asset/Search/Bulk.html b/html/Asset/Search/Bulk.html
index 73be766..edb0ffe 100644
--- a/html/Asset/Search/Bulk.html
+++ b/html/Asset/Search/Bulk.html
@@ -55,19 +55,19 @@
 % my $input = "SetRoleMember-$rname";
 <tr>
 <td class="label"><label for="<% $input %>"><% loc($rname) %></label></td>
-<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" />
+<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" /></td>
 </tr>
 % } else {
 <tr>
 % my $input = "AddRoleMember-$rname";
 <td class="label"><label for="<% $input %>"><% loc("Add [_1]", loc($rname)) %></label></td>
-<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" />
+<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" /></td>
 </tr>
 
 <tr>
 % $input = "RemoveRoleMember-$rname";
 <td class="label"><label for="<% $input %>"><% loc("Remove [_1]", loc($rname)) %></label></td>
-<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" />
+<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" /></td>
 </tr>
 % }
 % }

commit 5e4bf090fba4c13b0571174cbe46dc9e57dfd327
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 3 13:47:41 2013 +0400

    change AddRoleMember* argument name
    
    renaming AddRoleMember-{User,Group}[-Type] arguments to
    Add{User,Group}RoleMember[-Role] arguments so they don't
    look like {Set,Remove}RoleMember-<role name> arguments.
    Two sets are different in meaning and what is expected,
    but con conflict if we want to add AddRoleMember-<role name>
    argument and we want to add it.

diff --git a/html/Elements/Assets/AddPeople b/html/Elements/Assets/AddPeople
index f59cace..b652c57 100644
--- a/html/Elements/Assets/AddPeople
+++ b/html/Elements/Assets/AddPeople
@@ -3,8 +3,8 @@ $Object
 </%args>
 <div class="add-user">
 <h3>Add a person</h3>
-<& SelectRoleType, Object => $Object, Name => "AddRoleMember-User-Type" &>
-<input type="text" name="AddRoleMember-User"
+<& SelectRoleType, Object => $Object, Name => "AddUserRoleMember-Role" &>
+<input type="text" name="AddUserRoleMember"
        data-autocomplete="Users"
        data-autocomplete-return="Name"
        placeholder="<% loc("Find a user...") %>">
@@ -12,8 +12,8 @@ $Object
 
 <div class="add-group">
 <h3>Add a group</h3>
-<& SelectRoleType, Object => $Object, Name => "AddRoleMember-Group-Type" &>
-<input type="text" name="AddRoleMember-Group"
+<& SelectRoleType, Object => $Object, Name => "AddGroupRoleMember-Role" &>
+<input type="text" name="AddGroupRoleMember"
        data-autocomplete="Groups"
        data-autocomplete-return="Name"
        placeholder="<% loc("Find a group...") %>">
diff --git a/lib/RT/Extension/Assets.pm b/lib/RT/Extension/Assets.pm
index 622679a..d3ba834 100644
--- a/lib/RT/Extension/Assets.pm
+++ b/lib/RT/Extension/Assets.pm
@@ -76,11 +76,11 @@ RT->AddJavaScript("RTx-Assets.js");
         my @results;
 
         for my $arg (keys %ARGS) {
-            if ($arg =~ /^AddRoleMember-(User|Group)$/) {
-                next unless $ARGS{$arg} and $ARGS{"$arg-Type"};
+            if ($arg =~ /^Add(User|Group)RoleMember$/) {
+                next unless $ARGS{$arg} and $ARGS{"$arg-Role"};
 
                 my ($ok, $msg) = $object->AddRoleMember(
-                    Type => $ARGS{"$arg-Type"},
+                    Type => $ARGS{"$arg-Role"},
                     $1   => $ARGS{$arg},
                 );
                 push @results, $msg;

commit fc8b52ad0fd4dabb5bdc1687e9ace31f9daefc2e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 3 22:31:23 2013 +0400

    $type is overloaded, rename var so meaning is more clear

diff --git a/lib/RT/Extension/Assets.pm b/lib/RT/Extension/Assets.pm
index d3ba834..d176030 100644
--- a/lib/RT/Extension/Assets.pm
+++ b/lib/RT/Extension/Assets.pm
@@ -86,12 +86,12 @@ RT->AddJavaScript("RTx-Assets.js");
                 push @results, $msg;
             }
             elsif ($arg =~ /^SetRoleMember-(.+)$/) {
-                my $type = $1;
-                my $group = $object->RoleGroup($type);
+                my $role = $1;
+                my $group = $object->RoleGroup($role);
                 next unless $group->id and $group->SingleMemberRoleGroup;
                 next if $ARGS{$arg} eq $group->UserMembersObj->First->Name;
                 my ($ok, $msg) = $object->AddRoleMember(
-                    Type => $type,
+                    Type => $role,
                     User => $ARGS{$arg} || 'Nobody',
                 );
                 push @results, $msg;

commit 37d0400b8d4af7de6b2527e5e8c38e33f5905883
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Sep 3 22:32:58 2013 +0400

    fix adding/removing watchers in bulk update
    
    ProcessRoleMembers was desgined for Asset/People.html, so
    it was not suitable for bulk updates. It works for roles
    with single user, but failed for roles with multiple users
    and groups.
    
    Now it works for both pages.

diff --git a/lib/RT/Extension/Assets.pm b/lib/RT/Extension/Assets.pm
index d176030..9652eeb 100644
--- a/lib/RT/Extension/Assets.pm
+++ b/lib/RT/Extension/Assets.pm
@@ -96,10 +96,21 @@ RT->AddJavaScript("RTx-Assets.js");
                 );
                 push @results, $msg;
             }
-            elsif ($arg =~ /^RemoveRoleMember-(.+)$/) {
-                my ($ok, $msg) = $object->DeleteRoleMember(
-                    Type        => $1,
-                    PrincipalId => $ARGS{$arg},
+            elsif ($arg =~ /^(Add|Remove)RoleMember-(.+)$/) {
+                my $role = $2;
+                my $method = $1 eq 'Add'? 'AddRoleMember' : 'DeleteRoleMember';
+
+                my $is = 'User';
+                if ( ($ARGS{"$arg-Type"}||'') =~ /^(User|Group)$/ ) {
+                    $is = $1;
+                }
+
+                my ($ok, $msg) = $object->$method(
+                    Type        => $role,
+                    ($ARGS{$arg} =~ /\D/
+                        ? ($is => $ARGS{$arg})
+                        : (PrincipalId => $ARGS{$arg})
+                    ),
                 );
                 push @results, $msg;
             }

commit 90d555c0e2a81dfe75decfade8002f6e16d200eb
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Sep 4 00:03:55 2013 +0400

    implement "remove all watchers of this type" in bulk update

diff --git a/html/Asset/Search/Bulk.html b/html/Asset/Search/Bulk.html
index edb0ffe..5070551 100644
--- a/html/Asset/Search/Bulk.html
+++ b/html/Asset/Search/Bulk.html
@@ -67,7 +67,13 @@
 <tr>
 % $input = "RemoveRoleMember-$rname";
 <td class="label"><label for="<% $input %>"><% loc("Remove [_1]", loc($rname)) %></label></td>
-<td><input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" /></td>
+<td>
+  <input type="text" value="<% $ARGS{ $input } || '' %>" name="<% $input %>" id="<% $input %>" data-autocomplete="Users" data-autocomplete-return="Name" />
+  <label>
+    <input type="checkbox" name="RemoveAllRoleMembers-<% $rname %>" value="1"/>
+    <em>check box to delete all</em>
+  </label>
+</td>
 </tr>
 % }
 % }
diff --git a/lib/RT/Extension/Assets.pm b/lib/RT/Extension/Assets.pm
index 9652eeb..403b958 100644
--- a/lib/RT/Extension/Assets.pm
+++ b/lib/RT/Extension/Assets.pm
@@ -114,6 +114,20 @@ RT->AddJavaScript("RTx-Assets.js");
                 );
                 push @results, $msg;
             }
+            elsif ($arg =~ /^RemoveAllRoleMembers-(.+)$/) {
+                my $role = $1;
+                my $group = $object->RoleGroup($role);
+                next unless $group->id;
+
+                my $gms = $group->MembersObj;
+                while ( my $gm = $gms->Next ) {
+                    my ($ok, $msg) = $object->DeleteRoleMember(
+                        Type        => $role,
+                        PrincipalId => $gm->MemberId,
+                    );
+                    push @results, $msg;
+                }
+            }
         }
         return @results;
     }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list