Browse Source

Merge branch 'feature/visual_feedback' into develop

develop
Sam Black 4 years ago
parent
commit
656ee299a6
Signed by: samwwwblack GPG Key ID: 0FF0223994EA47D8
  1. 4
      css/multishare.css
  2. 139
      js/multisharedialogview.js

4
css/multishare.css

@ -37,3 +37,7 @@
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
background-color: #ebebeb;
}
.multishare {
padding-top: 10px;
}

139
js/multisharedialogview.js

@ -20,23 +20,31 @@ var MultiShare = MultiShare || {};
(function() {
var TEMPLATE_BASE =
'<div class="shareTabView">' +
'<h3 style="padding-top: 15px;">Multi share</h3>' +
'{{#if isSharingAllowed}}' +
'<label for="shareWith-{{cid}}" class="hidden-visually">{{shareLabel}}</label>' +
'<div class="oneline">' +
' <input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{sharePlaceholder}}" />' +
' <span class="shareWithLoading icon-loading-small hidden"></span>'+
'{{{shareInfo}}}' +
'</div>' +
'{{/if}}' +
'<div class="loading hidden" style="height: 50px"></div>' +
'<a class="close icon-close" href="#" alt="{{closeLabel}}"></a>' +
'</div>';
var TEMPLATE_SHARE_INFO =
'<span class="icon icon-info shareWithRemoteInfo hasTooltip" ' +
'title="{{tooltip}}"></span>';
'<div class="shareTabView">' +
'<h3 style="padding-top: 15px;">Multi share</h3>' +
'{{#if isSharingAllowed}}' +
'<label for="shareWith-{{cid}}" class="hidden-visually">{{shareLabel}}</label>' +
'<div class="oneline">' +
' <input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{sharePlaceholder}}" />' +
' <span class="shareWithLoading icon-loading-small hidden"></span>'+
'{{{shareInfo}}}' +
'</div>' +
'<div class="multishare hidden">' +
' <p>' +
' <span id="multishare-complete">0</span> of ' +
' <span id="multishare-total">0</span> completed' +
' </p>' +
' <div class="multishare hidden multishare-error">' +
' Error when sharing:' +
' <ul id="multishare-errors"></ul>' +
' </div>' +
'</div>' +
'{{/if}}' +
'<div class="loading hidden" style="height: 50px"></div>' +
'<a class="close icon-close" href="#" alt="{{closeLabel}}"></a>' +
'</div>',
TEMPLATE_SHARE_INFO =
'<span class="icon icon-info shareWithRemoteInfo hasTooltip" title="{{tooltip}}"></span>';
var ShareDialogView = OC.Backbone.View.extend({
_templates: {},
@ -70,19 +78,21 @@ var MultiShare = MultiShare || {};
},
_onClose: function(event) {
OC.Apps.hideAppSidebar(this.$el);
this._sidebar_visible = false;
this.showHide(false);
event.preventDefault();
},
showHide: function () {
if (!this._sidebar_visible) {
showHide: function (show) {
var forceShow = show !== undefined ? show : false;
if (forceShow || !this._sidebar_visible) {
OC.Apps.showAppSidebar(this.$el);
this._sidebar_visible = true;
}
else {
OC.Apps.hideAppSidebar(this.$el);
this._sidebar_visible = false;
this.$el.find(".multishare").addClass("hidden");
}
},
@ -93,7 +103,6 @@ var MultiShare = MultiShare || {};
}
},
/* trigger search after the field was re-selected */
onShareWithFieldFocus: function() {
this.$el.find('.shareWithField').autocomplete("search");
},
@ -190,7 +199,7 @@ var MultiShare = MultiShare || {};
} else {
var title = t('core', 'No users or groups found for {search}', {search: $shareWithField.val()});
if (!view.configModel.get('allowGroupSharing')) {
title = t('core', 'No users found for {search}', {search: $('.shareWithField').val()});
title = t('core', 'No users found for {search}', {search: $shareWithField.val()});
}
$shareWithField.addClass('error')
.attr('data-original-title', title)
@ -258,13 +267,17 @@ var MultiShare = MultiShare || {};
_onSelectRecipient: function(e, s) {
e.preventDefault();
$(e.target).attr('disabled', true).val(s.item.label);
var $loading = this.$el.find('.shareWithLoading');
$loading.removeClass('hidden').addClass('inlineblock');
var $shareInfo = this.$el.find('.shareWithRemoteInfo');
$shareInfo.addClass('hidden');
var files = OCA.Files.App.fileList.getSelectedFiles(),
var $loading = this.$el.find('.shareWithLoading'),
$shareInfo = this.$el.find('.shareWithRemoteInfo'),
$fileTotal = $("#multishare-total"),
$fileComplete = $("#multishare-complete"),
$fileErrorList = $("#multishare-errors"),
files = OCA.Files.App.fileList.getSelectedFiles(),
self = this,
fileErrorListVisible = false,
tempRunningShare = [],
uploadedFiles = 0,
fileInfoTemp,
modelTemp;
@ -276,11 +289,18 @@ var MultiShare = MultiShare || {};
return
}
files.forEach(function(element, idx) {
$loading.removeClass('hidden').addClass('inlineblock');
$shareInfo.addClass('hidden');
$fileTotal.text(files.length);
$fileComplete.text(0);
this.$el.find(".multishare.hidden").not(".multishare-error").removeClass("hidden");
files.forEach(function(element) {
fileInfoTemp = new OCA.Files.FileInfoModel(element);
var options = {
fileInfoModel: fileInfoTemp,
configModel: self.configModel},
fileInfoModel: fileInfoTemp,
configModel: self.configModel},
attributes = {
itemType: fileInfoTemp.isDirectory() ? 'folder' : 'file',
itemSource: fileInfoTemp.get('id'),
@ -288,24 +308,53 @@ var MultiShare = MultiShare || {};
};
modelTemp = new OC.Share.ShareItemModel(attributes, options);
//modelTemp.fetch();
modelTemp.addShare(s.item.value, {
error: function (obj, msg) {
OC.Notification.showTemporary(msg);
}
});
tempRunningShare.push(
modelTemp.addShare(s.item.value, {
complete: function () {
uploadedFiles = uploadedFiles + 1;
$fileComplete.text(uploadedFiles);
},
error: function (obj, msg) {
var existingShare = false,
fullMsg = "";
// Get up to date information from the server
obj.fetch()
.done(function () {
existingShare = obj.getSharesWithCurrentItem().find(function (share) {
return share.share_with === s.item.label;
});
if (existingShare) {
// Ignore existing shares, as they are returned as "errors",
// when, to the user, they are successful
return;
}
if (!fileErrorListVisible) {
$fileErrorList.parent().removeClass("hidden");
fileErrorListVisible = true;
}
fullMsg = obj.fileInfoModel.attributes.name + " with " + s.item.label;
$fileErrorList.append(
$("<li>").text(fullMsg)
);
});
}
})
);
});
if (idx % 10 === 0) {
// Refresh the file list to update the share icons,
// useful if the user has shared a number of files
// Wait for the call backs to finish,
// then refresh the file list to show shared status
$.when.apply(null, tempRunningShare).always(function () {
window.setTimeout(function() {
OC.Share.loadIcons("file", OCA.Files.App.fileList);
}
}, 1000);
});
// Refresh the file list to update the share icons
OC.Share.loadIcons("file", OCA.Files.App.fileList);
$(e.target).val('').attr('disabled', false);
$loading.addClass('hidden').removeClass('inlineblock');
$shareInfo.removeClass('hidden');
@ -377,7 +426,7 @@ var MultiShare = MultiShare || {};
return t('core', 'Name, federated cloud ID or email address...');
}
return t('core', 'Name...');
return t('core', 'Name...');
},
_getTemplate: function (key, template) {

Loading…
Cancel
Save