Skip to content

Commit

Permalink
Merge pull request #9 from Sugaroverdose/server_side_errors
Browse files Browse the repository at this point in the history
Display error response from clipboard.php instead of predefined errors in clipboard.js
  • Loading branch information
leizh committed Apr 2, 2015
2 parents e0bb46a + 39e6b0a commit b7a5bd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 6 additions & 0 deletions css/clipboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ tr:hover td.filename:before, tr.selected td.filename:before {
opacity: 0.3;
cursor:default;
}

#notification .files_clipboard_error {
text-align:left;
margin-bottom: 0.4em;
padding: 0.2em;
}
16 changes: 13 additions & 3 deletions js/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,20 @@ function paste() {
success: function (data) {
if (data.status == 'error') {
var message;
if (clipboard.operation == 'cut') message = t(appid, "An error occurred during the move.");
else message = t(appid, "An error occurred during the copy.");
if (data.messages.length === 1) {
message = data.messages[0];
} else {
if (clipboard.operation == 'cut') {
message = '<b>' + n(appid, "%n error occurred during the move:", "%n errors occurred during the move:", data.messages.length) + '</b>';
} else {
message = '<b>' + n(appid, "%n error occurred during the copy:", "%n errors occurred during the copy:", data.messages.length) + '</b>';
}
message += '<p class="files_clipboard_error">';
for (var i = data.messages.length - 1; i >= 0; --i) message += data.messages[i] + '<br>';
message += '</p>';
}
OC.Notification.hide();
OC.Notification.show(message);
OC.Notification.showHtml(message);
} else {
if (clipboard.operation == 'cut') {
sessionStorage.removeItem(appid);
Expand Down

0 comments on commit b7a5bd2

Please sign in to comment.