]> source.dussan.org Git - nextcloud-server.git/commitdiff
Deletes Group Clientside Effectively.
authorraghunayyar <me@iraghu.com>
Thu, 30 Jan 2014 15:48:18 +0000 (21:18 +0530)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 2 Jun 2014 10:52:52 +0000 (12:52 +0200)
settings/css/settings.css
settings/js/users.js
settings/templates/users.php

index 39290308cbe66e7d00c7e37e6f6c445d2ab9af75..ae986ccb9b40009bcbc5edec5c232a0ebe83f2ca 100644 (file)
@@ -51,7 +51,11 @@ table.nostyle label { margin-right: 2em; }
 table.nostyle td { padding: 0.2em 0; }
 
 /* USERS */
-.usercount { float: right; margin:6px;}
+.usercount { float: left; margin: 5px; }
+span.utils .delete {
+       float: left; position: relative;
+       margin: 3px; top: 4px;
+}
 form { display:inline; }
 table.grid th { height:2em; color:#999; }
 table.grid th, table.grid td { border-bottom:1px solid #ddd; padding:0 .5em; padding-left:.8em; text-align:left; font-weight:normal; }
index 7b06d961b1a192f371647a7b13143b9aee05e00e..8107a98df0b8494abebfc0d8b3a2ac328a734dc3 100644 (file)
@@ -16,6 +16,48 @@ function setQuota (uid, quota, ready) {
        );
 }
 
+var GroupList = {
+
+       delete_group: function (gid) {
+               if(GroupList.deleteGid !=='undefined') {
+                       GroupList.finishDelete(null);
+               }
+
+               //Set the undo flag
+               GroupList.deleteCanceled = false;
+
+               //Provide an option to undo
+               $('#notification').data('deletegroup', true);
+               OC.Notification.showHtml(t('settings', 'deleted') + ' ' + escapeHTML(gid) + '<span class="undo">' + t('settings', 'undo') + '</span>');
+       },
+
+       finishDelete: function (ready) {
+               if (!GroupList.deleteCanceled && GroupList.deleteGid) {
+                       $.ajax({
+                               type: 'POST',
+                               url: OC.filePath('settings', 'ajax', 'removegroup.php'),
+                               async: false,
+                               data: { groupname: GroupList.deleteGid },
+                               success: function (result) {
+                                       if (result.status === 'success') {
+                                               // Remove undo option, & remove user from table
+                                               OC.Notification.hide();
+                                               $('li').filterAttr('data-gid', GroupList.deleteGid).remove();
+                                               GroupList.deleteCanceled = true;
+                                               if (ready) {
+                                                       ready();
+                                               }
+                                       } else {
+                                               OC.dialogs.alert(result.data.message, t('settings', 'Unable to remove group'));
+                                       }
+                               }
+                       });
+               }
+
+       },
+
+}
+
 var UserList = {
        useUndo: true,
        availableGroups: [],
@@ -477,6 +519,14 @@ $(document).ready(function () {
                });
        });
 
+       $('ul').on('click', 'span.utils>a', function (event) {
+               var li = $(this).parent().parent();
+               var gid = $(li).attr('data-gid');
+               $(li).hide();
+               // Call function for handling delete/undo on Groups
+               GroupList.delete_group(gid);
+       });
+
        $('#newuser').submit(function (event) {
                event.preventDefault();
                var username = $('#newusername').val();
index 83ac79365b64fa09d04610f9fddbd5ad4bf9cc30..daf0ee49e4a06bc894a029624f3a44ddcb8db3c2 100644 (file)
@@ -30,10 +30,13 @@ $_['subadmingroups'] = array_flip($items);
                </li>
                <!--List of Groups-->
                <?php foreach($_["groups"] as $group): ?>
-               <li>
+               <li data-gid="<?php p($group['name']) ?>">
                        <a href="#"><?php p($group['name']); ?></a>
                        <span class="utils">
                                <span class="usercount"><?php p(count($group['useringroup'])); ?></span>
+                               <a href="#" class="action delete" original-title="<?php p($l->t('Delete'))?>">
+                                       <img src="<?php print_unescaped(image_path('core', 'actions/delete.svg')) ?>" class="svg" />
+                               </a>
                        </span>
                </li>
        <?php endforeach; ?>