mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-19 23:48:51 +00:00
Squashed commit of the following:
commit 12f52311df704e48c282b2a47f59f7a283cfa5c5
Author: zhengxie <xiez1989@gmail.com>
Date: Tue Sep 11 15:14:34 2018 +0800
[API] Update client sync and list dir items apis
commit bc18d19dc0f648732c5933c6918d8e784fc0f910
Author: llj <lingjun.li1@gmail.com>
Date: Tue Sep 4 12:22:10 2018 +0800
Add preview related share perms
Squashed commit of the following:
commit 658bdbdc7acf262f2c0abb0387cf3142b2d8ee37
Author: llj <lingjun.li1@gmail.com>
Date: Tue Sep 4 12:17:47 2018 +0800
[library icon title] added title for 'admin' permission
commit 51a088fd7987e2307e5666facb6627d42a7843ec
Author: zhengxie <xiez1989@gmail.com>
Date: Sat Sep 1 15:33:09 2018 +0800
Add preview related share perms
Squashed commit of the following:
commit 42fe21ef0ba3bad4fb68dc5283194cb34eb7775a
Author: llj <lingjun.li1@gmail.com>
Date: Sat Sep 1 13:33:59 2018 +0800
[icon tip] modified library/folder icon title
commit 077fecdce80bce966296a1735896a24bf32c282f
Author: zhengxie <xiez1989@gmail.com>
Date: Mon Aug 27 11:05:34 2018 +0800
Add preview related share perms
Squashed commit of the following:
commit 5783325eb25d7298ea3db7f59595446d122889e5
Author: llj <lingjun.li1@gmail.com>
Date: Fri Aug 24 21:14:59 2018 +0800
fixup
commit 5f4f4025221f4026a4e7a9bc1c7bba5d6decf5a9
Author: zhengxie <xiez1989@gmail.com>
Date: Fri Aug 24 20:55:41 2018 +0800
Fix wopi perm
commit 632744cd5e56f8812af0efe523cf5751bbf57b66
Author: zhengxie <xiez1989@gmail.com>
Date: Fri Aug 24 17:29:31 2018 +0800
Add preview related share perms
Squashed commit of the following:
commit 683296449601960d76a2d0245dab694ab16f67b2
Author: llj <lingjun.li1@gmail.com>
Date: Fri Aug 24 15:54:59 2018 +0800
modification after adding 2 new permissions
commit 3eff1ec06fc7566942b736261a1d5b613d706117
Author: llj <lingjun.li1@gmail.com>
Date: Thu Aug 23 14:58:33 2018 +0800
[permission] added 2 new permissions for 'share' & 'folder permission'
commit 73a0bfc6560860ac11e96a675fe789a984a194c8
Author: zhengxie <xiez1989@gmail.com>
Date: Fri Aug 24 16:34:47 2018 +0800
Add prevew related perms in history file view and text_diff
commit 533b3ff0ca4aa5564ecc87456772b70eedfa816f
Author: zhengxie <xiez1989@gmail.com>
Date: Fri Aug 24 13:49:28 2018 +0800
Add prevew related perms on file views
commit 03db78a841baddf6c042988358d20417f06be4ae
Author: zhengxie <xiez1989@gmail.com>
Date: Thu Aug 23 10:56:17 2018 +0800
[api2] Update repo perms and add is pro version check
commit c025319fe56658da3a3dc077743ee016ac5acd4d
Author: ilearnit <helloworld.c@outlook.com>
Date: Wed Aug 22 11:09:27 2018 +0800
update perm copy/download/share
commit ea19ab4c695c99c0c2817616f2177bebae0777a2
Author: zhengxie <xiez1989@gmail.com>
Date: Mon Aug 20 16:00:11 2018 +0800
wip: add repo preview related perms.
Updated APIs:
1. [api2] group libraries
2. [api2] dir shared items
3. [api2] share link zip tasks
Updated Views:
1. wiki & wopi
2. ajax copy/download files/dirs
139 lines
4.5 KiB
JavaScript
139 lines
4.5 KiB
JavaScript
define([
|
|
'jquery',
|
|
'underscore',
|
|
'backbone',
|
|
'common',
|
|
'app/views/widgets/hl-item-view'
|
|
], function($, _, Backbone, Common, HLItemView) {
|
|
'use strict';
|
|
|
|
var ShareAdminFolderView = HLItemView.extend({
|
|
|
|
tagName: 'tr',
|
|
|
|
template: _.template($('#share-admin-folder-tmpl').html()),
|
|
|
|
events: {
|
|
'click .perm-edit-icon': 'showPermSelect',
|
|
'change .perm-select': 'updatePermission',
|
|
'click .unshare': 'removeShare'
|
|
},
|
|
|
|
initialize: function(option) {
|
|
HLItemView.prototype.initialize.call(this);
|
|
this.listenTo(this.model, "change", this.render);
|
|
},
|
|
|
|
showPermSelect: function() {
|
|
this.$el.closest('table')
|
|
.find('.perm-select').hide().end()
|
|
.find('.cur-perm, .perm-edit-icon').show();
|
|
|
|
this.$('.cur-perm, .perm-edit-icon').hide();
|
|
this.$('.perm-select').show();
|
|
|
|
return false;
|
|
},
|
|
|
|
updatePermission: function() {
|
|
var _this = this;
|
|
var share_type = this.model.get('share_type');
|
|
var perm = this.$('.perm-select').val();
|
|
var url = Common.getUrl({
|
|
name: 'dir_shared_items',
|
|
repo_id: this.model.get('repo_id')
|
|
}) + '?p=' + encodeURIComponent(this.model.get('path'));
|
|
|
|
if (share_type == 'personal') {
|
|
url += '&share_type=user&username=' + encodeURIComponent(this.model.get('user_email'));
|
|
} else if (share_type == 'group') {
|
|
url += '&share_type=group&group_id=' + this.model.get('group_id');
|
|
}
|
|
|
|
$.ajax({
|
|
url: url,
|
|
method: 'POST',
|
|
dataType: 'json',
|
|
beforeSend: Common.prepareCSRFToken,
|
|
data: {
|
|
'permission': perm
|
|
},
|
|
success: function() {
|
|
_this.model.set({'share_permission': perm});
|
|
Common.feedback(gettext("Successfully modified permission"), 'success');
|
|
},
|
|
error: function(xhr) {
|
|
Common.ajaxErrorHandler(xhr);
|
|
}
|
|
});
|
|
},
|
|
|
|
removeShare: function() {
|
|
var _this = this;
|
|
var share_type = this.model.get('share_type');
|
|
var url = Common.getUrl({
|
|
name: 'dir_shared_items',
|
|
repo_id: this.model.get('repo_id')
|
|
}) + '?p=' + Common.encodePath(this.model.get('path'));
|
|
|
|
if (share_type == 'personal') {
|
|
url += '&share_type=user&username=' + Common.encodePath(this.model.get('user_email'));
|
|
} else if (share_type == 'group') {
|
|
url += '&share_type=group&group_id=' + this.model.get('group_id');
|
|
}
|
|
|
|
$.ajax({
|
|
url: url,
|
|
type: 'DELETE',
|
|
beforeSend: Common.prepareCSRFToken,
|
|
success: function() {
|
|
_this.remove();
|
|
Common.feedback(gettext("Successfully deleted 1 item"), 'success');
|
|
},
|
|
error: function (xhr) {
|
|
Common.ajaxErrorHandler(xhr);
|
|
}
|
|
});
|
|
|
|
return false;
|
|
},
|
|
|
|
render: function() {
|
|
var obj = this.model.toJSON(),
|
|
icon_size = Common.isHiDPI() ? 96 : 24,
|
|
icon_url = this.model.getIconUrl(icon_size),
|
|
cur_perm_text;
|
|
|
|
switch(obj.share_permission) {
|
|
case 'rw':
|
|
cur_perm_text = gettext("Read-Write");
|
|
break;
|
|
case 'r':
|
|
cur_perm_text = gettext("Read-Only");
|
|
break;
|
|
case 'cloud-edit':
|
|
cur_perm_text = gettext("Preview-Edit-on-Cloud");
|
|
break;
|
|
case 'preview':
|
|
cur_perm_text = gettext("Preview-on-Cloud");
|
|
break;
|
|
}
|
|
|
|
_.extend(obj, {
|
|
'icon_url': icon_url,
|
|
'icon_title': this.model.getIconTitle(),
|
|
'url': this.model.getWebUrl(),
|
|
'name': this.model.get('folder_name'),
|
|
'cur_perm_text': cur_perm_text
|
|
});
|
|
|
|
this.$el.html(this.template(obj));
|
|
|
|
return this;
|
|
}
|
|
|
|
});
|
|
|
|
return ShareAdminFolderView;
|
|
});
|