1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-18 00:00:00 +00:00

[details] modified 'grid view', 'share popup', 'repo folder perm', 'select2' & etc.

This commit is contained in:
llj
2016-03-10 13:56:00 +08:00
parent 56ad0d3f04
commit 6fce263e42
11 changed files with 109 additions and 65 deletions

View File

@@ -3494,9 +3494,26 @@ textarea:-moz-placeholder {/* for FF */
width:630px;
padding-right:0;
}
#repo-folder-perm .jstree {
margin:10px 0 4px;
}
.repo-folder-perm-folder-path {
padding:3px 5px;
width:155px;
width:150px;
padding:3px 33px 3px 5px;
}
.repo-folder-perm-add-folder {
position:absolute;
right:0;
top:4px;
width:29px;
height:28px;
line-height:28px;
text-align:center;
font-size:14px;
color:#666;
cursor:pointer;
border-left: 1px solid #ddd;
margin:0;
}
.repo-folder-perm-content {
width:610px; /* for the table in it. */
@@ -3512,6 +3529,7 @@ textarea:-moz-placeholder {/* for FF */
height:30px;
}
#share-popup table,
#repo-folder-perm table,
#folder-perm-tabs table {
margin:0;
}
@@ -3819,19 +3837,20 @@ img.thumbnail {
/* grid view */
.grid-item {
display:inline-block;
width:100px;
padding:10px 24px;
width:140px;
padding:10px 4px;
position:relative;
}
.grid-item .img-link {
position:relative; /* for locked icon */
display:block;
text-align:center;
width:100px;
height:100px;
font-size:0;
line-height:0;
border-radius:3px;
margin-bottom:6px;
margin:0 auto 6px;
}
.grid-item .img-link:before {
content:' ';
@@ -3855,8 +3874,6 @@ img.thumbnail {
color:#333;
font-size:14px;
line-height:17px;
height:34px;
white-space:normal;
}
.grid-item .text-link.hl {
color:#f93;
@@ -3881,5 +3898,5 @@ img.thumbnail {
box-shadow: 0 2px 2px #aaa;
}
#dir-view .grid-item {
padding:10px 20px; /* use less padding */
width:134px;
}

View File

@@ -1287,10 +1287,12 @@
</thead>
<tbody>
<tr>
<td><input name="emails" type="hidden" /></td>
<td><input name="emails" type="hidden" class="w100" /></td>
<td>
<input type="text" name="folder_path" class="repo-folder-perm-folder-path" />
<img src="{{ MEDIA_URL }}img/add.png" alt="" title="{% trans "Select a folder" %}" class="add vam add-folder" />
<div class="pos-rel">
<input type="text" name="folder_path" class="repo-folder-perm-folder-path" />
<span title="{% trans "Select a folder" %}" class="js-add-folder repo-folder-perm-add-folder icon-plus"></span>
</div>
</td>
<td>
<select name="permission" class="w100">
@@ -1333,8 +1335,10 @@
<select name="groups" class="w100" multiple="multiple"></select>
</td>
<td>
<input type="text" name="folder_path" class="repo-folder-perm-folder-path" />
<img src="{{ MEDIA_URL }}img/add.png" alt="" title="{% trans "Select a folder" %}" class="add vam add-folder" />
<div class="pos-rel">
<input type="text" name="folder_path" class="repo-folder-perm-folder-path" />
<span title="{% trans "Select a folder" %}" class="js-add-folder repo-folder-perm-add-folder icon-plus"></span>
</div>
</td>
<td>
<select name="permission" class="w100">

View File

@@ -15,7 +15,7 @@ $('.repo-transfer-btn').click(function(){
$('[name="email"]', form).select2($.extend({
width: '268px',
maximumSelectionSize: 1,
placeholder: "{% trans "Search user or enter email" %}",
placeholder: "{% trans "Search user or enter email and press Enter" %}",
formatInputTooShort: "{% trans "Please enter 1 or more character" %}",
formatNoMatches: "{% trans "No matches" %}",
formatSearching: "{% trans "Searching..." %}",

View File

@@ -35,8 +35,13 @@
border-radius: 2px;
background-image: none; /* rm the shadow */
}
.select2-container-multi .select2-choices .select2-search-field {
float:none;
}
.select2-container-multi .select2-choices .select2-search-field input {
padding:2px 2px 2px 5px;
font-family:inherit;
font-size:13px;
}
.select2-container-multi .select2-choices .select2-search-choice {
border:none;

View File

@@ -88,8 +88,7 @@ define([
if (collection.perm_type == 'user') {
$('[name="emails"]', $panel).select2($.extend(
Common.contactInputOptionsForSelect2(), {
width: '190px',
placeholder: gettext("Search user or enter email"), // to override 'placeholder' returned by `Common.conta...`
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
maximumSelectionSize: 1,
formatSelectionTooBig: gettext("You can only select 1 item")
}));
@@ -101,7 +100,6 @@ define([
}
$('[name="groups"]', $panel).html(g_opts).select2({
placeholder: gettext("Select a group"),
width: '190px',
maximumSelectionSize: 1,
formatSelectionTooBig: gettext("You can only select 1 item"),
escapeMarkup: function(m) { return m; }
@@ -148,7 +146,7 @@ define([
},
events: {
'click .add-folder': 'showFolderSelectForm',
'click .js-add-folder': 'showFolderSelectForm',
'click .js-folder-select-submit': 'addFolder',
'click .js-folder-select-cancel': 'cancelFolderSelect',

View File

@@ -19,8 +19,6 @@ define([
template: _.template($('#dirent-tmpl').html()),
renameTemplate: _.template($("#rename-form-template").html()),
mvcpTemplate: _.template($("#mvcp-form-template").html()),
mvProgressTemplate: _.template($("#mv-progress-popup-template").html()),
initialize: function(options) {
this.dirView = options.dirView;

View File

@@ -35,7 +35,7 @@ define([
this.$modalContainer = $('#simplemodal-container').css({'height':'auto'});
this.$('[name="user_name"]').select2($.extend({
width: '268px',
width: '320px',
}, Common.contactInputOptionsForSelect2()));
this.collection = new GroupMembers();

View File

@@ -176,7 +176,7 @@ define([
Common.contactInputOptionsForSelect2(), {
width: '268px',
maximumSelectionSize: 1,
placeholder: gettext("Search user or enter email"), // to override 'placeholder' returned by `Common.conta...`
placeholder: gettext("Search user or enter email and press Enter"), // to override 'placeholder' returned by `Common.conta...`
formatSelectionTooBig: gettext("You cannot select any more choices")
}));

View File

@@ -474,7 +474,7 @@ define([
var form = this.$('#dir-user-share');
$('[name="emails"]', form).select2($.extend({
width: '297px'
//width: '292px' // the container will copy class 'w100' from the original element to get width
},Common.contactInputOptionsForSelect2()));
// show existing items
@@ -521,7 +521,6 @@ define([
}
$('[name="groups"]', form).html(g_opts).select2({
placeholder: gettext("Select groups"),
width: '297px',
escapeMarkup: function(m) { return m; }
});
@@ -560,10 +559,10 @@ define([
},
dirUserShare: function () {
var panel = $('#dir-user-share');
var form = this.$('#add-dir-user-share-item');
var $panel = $('#dir-user-share');
var $form = this.$('#add-dir-user-share-item'); // pseudo form
var emails_input = $('[name="emails"]', form),
var emails_input = $('[name="emails"]', $form),
emails = emails_input.val(); // string
if (!emails) {
return false;
@@ -572,8 +571,12 @@ define([
var $add_item = $('#add-dir-user-share-item');
var repo_id = this.repo_id,
path = this.dirent_path;
var perm = $('[name="permission"]', form).val();
var $perm = $('[name="permission"]', $form);
var perm = $perm.val();
var $error = $('.error', $panel);
var $submitBtn = $('[type="submit"]', $form);
Common.disableButton($submitBtn);
$.ajax({
url: Common.getUrl({
name: 'dir_shared_items',
@@ -589,26 +592,31 @@ define([
'permission': perm
},
success: function(data) {
$(data.success).each(function(index, item) {
var new_item = new FolderShareItemView({
'repo_id': repo_id,
'path': path,
'item_data': {
"user": item.user_info.name,
"user_name": item.user_info.nickname,
"perm": item.permission,
'for_user': true
}
if (data.success.length > 0) {
$(data.success).each(function(index, item) {
var new_item = new FolderShareItemView({
'repo_id': repo_id,
'path': path,
'item_data': {
"user": item.user_info.name,
"user_name": item.user_info.nickname,
"perm": item.permission,
'for_user': true
}
});
$add_item.after(new_item.el);
});
$add_item.after(new_item.el);
});
emails_input.select2("val", "");
emails_input.select2("val", "");
$('[value="rw"]', $perm).attr('selected', 'selected');
$('[value="r"]', $perm).removeAttr('selected');
$error.addClass('hide');
}
if (data.failed.length > 0) {
var err_msg = '';
$(data.failed).each(function(index, item) {
err_msg += Common.HTMLescape(item.email) + ': ' + item.error_msg + '<br />';
});
$('.error', panel).html(err_msg).removeClass('hide');
$error.html(err_msg).removeClass('hide');
}
},
error: function(xhr) {
@@ -619,17 +627,20 @@ define([
} else {
err_msg = gettext("Failed. Please check the network.")
}
$('.error', panel).html(err_msg).removeClass('hide');
$error.html(err_msg).removeClass('hide');
},
complete: function() {
Common.enableButton($submitBtn);
}
});
},
dirGroupShare: function () {
var panel = $('#dir-group-share');
var form = this.$('#add-dir-group-share-item');
var $panel = $('#dir-group-share');
var $form = this.$('#add-dir-group-share-item'); // pseudo form
var groups_input = $('[name="groups"]', form),
groups = groups_input.val(); // null or [group.id]
var $groups_input = $('[name="groups"]', $form),
groups = $groups_input.val(); // null or [group.id]
if (!groups) {
return false;
@@ -638,8 +649,12 @@ define([
var $add_item = $('#add-dir-group-share-item');
var repo_id = this.repo_id,
path = this.dirent_path;
var perm = $('[name="permission"]', form).val();
var $perm = $('[name="permission"]', $form),
perm = $perm.val();
var $error = $('.error', $panel);
var $submitBtn = $('[type="submit"]', $form);
Common.disableButton($submitBtn);
$.ajax({
url: Common.getUrl({
name: 'dir_shared_items',
@@ -655,26 +670,31 @@ define([
'permission': perm
},
success: function(data) {
$(data.success).each(function(index, item) {
var new_item = new FolderShareItemView({
'repo_id': repo_id,
'path': path,
'item_data': {
"group_id": item.group_info.id,
"group_name": item.group_info.name,
"perm": item.permission,
'for_user': false
}
if (data.success.length > 0) {
$(data.success).each(function(index, item) {
var new_item = new FolderShareItemView({
'repo_id': repo_id,
'path': path,
'item_data': {
"group_id": item.group_info.id,
"group_name": item.group_info.name,
"perm": item.permission,
'for_user': false
}
});
$add_item.after(new_item.el);
});
$add_item.after(new_item.el);
});
groups_input.select2("val", "");
$groups_input.select2("val", "");
$('[value="rw"]', $perm).attr('selected', 'selected');
$('[value="r"]', $perm).removeAttr('selected');
$error.addClass('hide');
}
if (data.failed.length > 0) {
var err_msg = '';
$(data.failed).each(function(index, item) {
err_msg += Common.HTMLescape(item.group_name) + ': ' + item.error_msg + '<br />';
});
$('.error', panel).html(err_msg).removeClass('hide');
$error.html(err_msg).removeClass('hide');
}
},
error: function(xhr) {
@@ -685,7 +705,10 @@ define([
} else {
err_msg = gettext("Failed. Please check the network.")
}
$('.error', panel).html(err_msg).removeClass('hide');
$error.html(err_msg).removeClass('hide');
},
complete: function() {
Common.enableButton($submitBtn);
}
});
}

View File

@@ -631,7 +631,7 @@ define([
contactInputOptionsForSelect2: function() {
var _this = this;
return {
placeholder: gettext("Search users or enter emails"),
placeholder: gettext("Search users or enter emails and press Enter"),
// with 'tags', the user can directly enter, not just select
// tags need `<input type="hidden" />`, not `<select>`

View File

@@ -202,7 +202,6 @@ define([
cur_path += '/';
}
var _this = this;
// container.data('site_root', '{{SITE_ROOT}}');
$.ajax({
url: Common.getUrl({name: 'get_dirents', repo_id: options.repo_id})
+ '?path=' + encodeURIComponent(cur_path) + '&dir_only=true&all_dir=true',