added download feature to SlateLayout

This commit is contained in:
Aminejvm 2021-03-05 19:12:41 +01:00
parent 6c25da3280
commit 228d3a9934
2 changed files with 17 additions and 0 deletions

View File

@ -834,6 +834,15 @@ export class SlateLayout extends React.Component {
this.setState({ layout });
};
_handleDownloadFiles = async () => {
const selectedFiles = this.props.items.filter((_, i) => this.state.checked[i]);
UserBehaviors.compressAndDownloadFiles({
files: selectedFiles,
resourceURI: this.props.resources.download,
});
this.setState({ checked: {} });
};
_handleMouseUp = (e) => {
window.removeEventListener("mousemove", this._handleDrag);
window.removeEventListener("mouseup", this._handleMouseUp);
@ -1783,6 +1792,13 @@ export class SlateLayout extends React.Component {
{/* <ButtonPrimary transparent onClick={this._handleDownload}>
Download
</ButtonPrimary> */}
<ButtonWarning
transparent
style={{ marginLeft: 8, color: Constants.system.white }}
onClick={this._handleDownloadFiles}
>
download
</ButtonWarning>
<ButtonWarning
transparent
style={{ marginLeft: 8, color: Constants.system.white }}

View File

@ -549,6 +549,7 @@ class SlatePage extends React.Component {
preview={preview}
onSavePreview={(preview) => this._handleSave(null, null, null, false, preview)}
items={objects}
resources={this.props.resources}
onSelect={this._handleSelect}
defaultLayout={layouts && layouts.ver === "2.0" ? layouts.defaultLayout : true}
onAction={this.props.onAction}