mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-06-23 19:04:18 +00:00
(feat) improved the attachments handling code for the message editor
This commit is contained in:
committed by
Francis Lachapelle
parent
290264262c
commit
23d7c06829
@@ -1,5 +1,4 @@
|
||||
/*
|
||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
||||
Copyright (C) 2008-2015 Inverse inc.
|
||||
|
||||
This file is part of SOGo.
|
||||
|
||||
@@ -92,30 +92,43 @@
|
||||
</md-slider>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<div class="pseudo-input-container" ng-hide="hideAttachments">
|
||||
<label class="pseudo-input-label">
|
||||
<var:string label:value="Attachments"/>
|
||||
</label>
|
||||
<div class="pseudoInput-text">
|
||||
<input type="file"
|
||||
nv-file-select="nv-file-select"
|
||||
uploader="uploader"/>
|
||||
</div>
|
||||
|
||||
<md-list>
|
||||
<md-list-item ng-repeat="item in message.editable.attachmentAttrs">
|
||||
|
||||
<md-list>
|
||||
<!-- FILES ALREADY UPLOADED, FOR EXAMPLE WHEN WE FORWARD A
|
||||
MAIL WITH ATTACHMENTS -->
|
||||
<md-list-item ng-repeat="item in message.editable.attachmentAttrs">
|
||||
<div layout="row" layout-align="space-between center">
|
||||
<span ng-bind="item.filename"><!-- filename --></span>
|
||||
</md-list-item>
|
||||
<md-list-item ng-repeat="item in uploader.queue">
|
||||
<md-button class="iconButton"
|
||||
ng-click="message.$deleteAttachment(item.filename);">
|
||||
<i class="md-icon-remove-circle-outline"><!--remove --></i>
|
||||
</md-button>
|
||||
</div>
|
||||
</md-list-item>
|
||||
<!-- FILE BEING ATTACHED TO A MAIL -->
|
||||
<md-list-item ng-repeat="item in uploader.queue">
|
||||
<div layout="row" layout-align="space-between center">
|
||||
<span ng-bind="item.file.name"><!-- filename --></span>
|
||||
(<span ng-bind="item.file.progress"><!-- progress --></span>)
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</div>
|
||||
|
||||
<md-progress-linear md-mode="determinate"
|
||||
value="{{item.progress}}"
|
||||
ng-show="item.isUploading" ><!-- progress--></md-progress-linear>
|
||||
<md-button class="iconButton"
|
||||
ng-click="uploader.cancelItem(item)"
|
||||
ng-show="item.isUploading">
|
||||
<i class="md-icon-cancel"><!--cancel --></i>
|
||||
</md-button>
|
||||
<md-button class="iconButton"
|
||||
ng-click="message.$deleteAttachment(item.file.name);item.remove();"
|
||||
ng-show="!item.isUploading">
|
||||
<i class="md-icon-remove-circle-outline"><!--remove --></i>
|
||||
</md-button>
|
||||
</div>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</div>
|
||||
|
||||
<!-- </div> -->
|
||||
|
||||
<!-- TOOLBAR TO SHOW CC/BCC/ATTACHMENT FIELDS -->
|
||||
<div layout="column" layout-align="start end">
|
||||
<md-button class="iconButton" ng-show="hideCc" ng-click="hideCc = false">Cc</md-button>
|
||||
@@ -126,9 +139,17 @@
|
||||
<i class="md-icon-info-outline"></i>
|
||||
</md-button>
|
||||
-->
|
||||
<md-button class="iconButton" ng-show="hideAttachments" ng-click="hideAttachments = false">
|
||||
<i class="md-icon-attach-file"><!-- show attachment --></i>
|
||||
<md-button class="iconButton">
|
||||
<label for="file-input">
|
||||
Add files
|
||||
</label>
|
||||
</md-button>
|
||||
<input id="file-input" type="file"
|
||||
nv-file-select="nv-file-select"
|
||||
multiple="multiple"
|
||||
uploader="uploader"
|
||||
ng-show="false"/>
|
||||
|
||||
<!--
|
||||
<md-button class="iconButton" ng-click="returnReceipt = !returnReceipt">
|
||||
<i class="md-icon-receipt"></i>
|
||||
|
||||
@@ -310,6 +310,25 @@
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @function $deleteAttachment
|
||||
* @memberof Message.prototype
|
||||
* @desc Delete an attachment from a message being composed
|
||||
* @param {string} filename - the filename of the attachment to delete
|
||||
*/
|
||||
Message.prototype.$deleteAttachment = function(filename) {
|
||||
var action = 'deleteAttachment?filename=' + filename;
|
||||
var _this = this;
|
||||
Message.$$resource.post(this.$absolutePath({asDraft: true}), action).then(function(data) {
|
||||
Message.$timeout(function() {
|
||||
_this.editable.attachmentAttrs = _.filter(_this.editable.attachmentAttrs, function(attachment) {
|
||||
return attachment.filename != filename});
|
||||
}, function() {
|
||||
// TODO: show toast
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @function $markAsFlaggedOrUnflagged
|
||||
* @memberof Message.prototype
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
$scope.autocomplete = {to: {}, cc: {}, bcc: {}};
|
||||
$scope.hideCc = true;
|
||||
$scope.hideBcc = true;
|
||||
$scope.hideAttachments = true;
|
||||
if ($stateParams.actionName == 'reply') {
|
||||
stateMessage.$reply().then(function(msgObject) {
|
||||
console.debug("foo");
|
||||
@@ -19,7 +18,6 @@
|
||||
$scope.message = msgObject;
|
||||
$scope.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length == 0);
|
||||
$scope.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length == 0);
|
||||
$scope.hideAttachments = true;
|
||||
});
|
||||
}
|
||||
else if ($stateParams.actionName == 'replyall') {
|
||||
@@ -27,7 +25,6 @@
|
||||
$scope.message = msgObject;
|
||||
$scope.hideCc = (!msgObject.editable.cc || msgObject.editable.cc.length == 0);
|
||||
$scope.hideBcc = (!msgObject.editable.bcc || msgObject.editable.bcc.length == 0);
|
||||
$scope.hideAttachments = true;
|
||||
});
|
||||
}
|
||||
else if ($stateParams.actionName == 'forward') {
|
||||
@@ -35,7 +32,6 @@
|
||||
$scope.message = msgObject;
|
||||
$scope.hideCc = true;
|
||||
$scope.hideBcc = true;
|
||||
$scope.hideAttachments = (!msgObject.editable.attachmentAttrs || msgObject.editable.attachmentAttrs.length == 0);
|
||||
});
|
||||
}
|
||||
else if (angular.isDefined(stateMessage)) {
|
||||
@@ -75,6 +71,13 @@
|
||||
stateMessage.$reload();
|
||||
console.debug(item); console.debug('success = ' + JSON.stringify(response, undefined, 2));
|
||||
},
|
||||
onCancelItem: function(item, response, status, headers) {
|
||||
console.debug(item); console.debug('cancel = ' + JSON.stringify(response, undefined, 2));
|
||||
|
||||
// We remove the attachment
|
||||
stateMessage.$deleteAttachment(item.file.name);
|
||||
this.removeFromQueue(item);
|
||||
},
|
||||
onErrorItem: function(item, response, status, headers) {
|
||||
console.debug(item); console.debug('error = ' + JSON.stringify(response, undefined, 2));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
@import 'components/list/list';
|
||||
@import 'components/autoScrollList/autoScrollList';
|
||||
//@import 'components/progressCircular/progressCircular';
|
||||
//@import 'components/progressLinear/progressLinear';
|
||||
@import 'components/progressLinear/progressLinear';
|
||||
@import 'components/radioButton/radio-button';
|
||||
@import 'components/select/select';
|
||||
@import 'components/sidenav/sidenav';
|
||||
|
||||
Reference in New Issue
Block a user