Fixed Bug 52443 - Client.Files. Fixed downloadAs action
This commit is contained in:
parent
b70a9cd115
commit
74011d7328
@ -156,18 +156,4 @@ export const TenantTrustedDomainsType = Object.freeze({
|
|||||||
All: 2,
|
All: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const FilesFormats = Object.freeze({
|
|
||||||
OriginalFormat: 0,
|
|
||||||
TxtFormat: 1,
|
|
||||||
DocxFormat: 2,
|
|
||||||
OdtFormat: 3,
|
|
||||||
OdsFormat: 4,
|
|
||||||
OdpFormat: 5,
|
|
||||||
PdfFormat: 6,
|
|
||||||
RtfFormat: 7,
|
|
||||||
XlsxFormat: 8,
|
|
||||||
PptxFormat: 9,
|
|
||||||
CustomFormat: 10,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const PasswordLimitSpecialCharacters = "!@#$%^&*";
|
export const PasswordLimitSpecialCharacters = "!@#$%^&*";
|
||||||
|
@ -45,9 +45,11 @@ class LinkWithDropdown extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickDropDownItem = (item) => {
|
onClickDropDownItem = (e) => {
|
||||||
|
const { key } = e.target.dataset;
|
||||||
|
const item = this.props.data.find((x) => x.key === key);
|
||||||
this.setIsOpen(!this.state.isOpen);
|
this.setIsOpen(!this.state.isOpen);
|
||||||
item.onClick && item.onClick();
|
item && item.onClick && item.onClick(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
@ -115,7 +117,8 @@ class LinkWithDropdown extends React.Component {
|
|||||||
className="drop-down-item"
|
className="drop-down-item"
|
||||||
key={item.key}
|
key={item.key}
|
||||||
{...item}
|
{...item}
|
||||||
onClick={this.onClickDropDownItem.bind(this.props, item)}
|
onClick={this.onClickDropDownItem}
|
||||||
|
data-key={item.key}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</DropDown>
|
</DropDown>
|
||||||
|
@ -5,7 +5,6 @@ import RowContainer from "@appserver/components/row-container";
|
|||||||
import Text from "@appserver/components/text";
|
import Text from "@appserver/components/text";
|
||||||
import LinkWithDropdown from "@appserver/components/link-with-dropdown";
|
import LinkWithDropdown from "@appserver/components/link-with-dropdown";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { FilesFormats } from "@appserver/common/constants";
|
|
||||||
|
|
||||||
const StyledDownloadContent = styled.div`
|
const StyledDownloadContent = styled.div`
|
||||||
.row_content,
|
.row_content,
|
||||||
@ -24,222 +23,96 @@ const DownloadContent = (props) => {
|
|||||||
onRowSelect,
|
onRowSelect,
|
||||||
getItemIcon,
|
getItemIcon,
|
||||||
titleFormat,
|
titleFormat,
|
||||||
getTitleLabel,
|
|
||||||
type,
|
type,
|
||||||
|
filesConverts,
|
||||||
|
title,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const getTitleExtensions = () => {
|
||||||
|
let arr = [];
|
||||||
|
for (let item of items) {
|
||||||
|
const exst = item.fileExst;
|
||||||
|
const arrayExst = filesConverts.find((f) => f[exst])[exst];
|
||||||
|
arr = [...arr, ...arrayExst];
|
||||||
|
}
|
||||||
|
|
||||||
|
arr = arr.filter((x, pos) => arr.indexOf(x) !== pos);
|
||||||
|
arr = arr.filter((x, pos) => arr.indexOf(x) === pos);
|
||||||
|
|
||||||
|
const formats = [
|
||||||
|
{
|
||||||
|
key: "original",
|
||||||
|
label: t("OriginalFormat"),
|
||||||
|
onClick: onSelectFormat,
|
||||||
|
"data-format": t("OriginalFormat"),
|
||||||
|
"data-type": type,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
for (let f of arr) {
|
||||||
|
formats.push({
|
||||||
|
key: f,
|
||||||
|
label: f,
|
||||||
|
onClick: onSelectFormat,
|
||||||
|
"data-format": f,
|
||||||
|
"data-type": type,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
formats.push({
|
||||||
|
key: "custom",
|
||||||
|
label: t("CustomFormat"),
|
||||||
|
onClick: onSelectFormat,
|
||||||
|
"data-format": t("CustomFormat"),
|
||||||
|
"data-type": type,
|
||||||
|
});
|
||||||
|
|
||||||
|
return formats;
|
||||||
|
};
|
||||||
|
|
||||||
const getFormats = (item) => {
|
const getFormats = (item) => {
|
||||||
const documentFormats = [
|
const conversionFormats = item
|
||||||
{
|
? filesConverts.find((f) => f[item.fileExst])[item.fileExst]
|
||||||
key: "key1",
|
: [];
|
||||||
label: t("OriginalFormat"),
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.OriginalFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key2",
|
|
||||||
label: ".txt",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.TxtFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key3",
|
|
||||||
label: ".docx",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.DocxFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key4",
|
|
||||||
label: ".odt",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.OdtFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key5",
|
|
||||||
label: ".pdf",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.PdfFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key6",
|
|
||||||
label: ".rtf",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.RtfFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key7",
|
|
||||||
label: t("CustomFormat"),
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.CustomFormat,
|
|
||||||
item,
|
|
||||||
"document"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const presentationFormats = [
|
const formats = [
|
||||||
{
|
{
|
||||||
key: "key1",
|
key: "original",
|
||||||
label: t("OriginalFormat"),
|
label: t("OriginalFormat"),
|
||||||
onClick: onSelectFormat.bind(
|
onClick: onSelectFormat,
|
||||||
this,
|
"data-format": t("OriginalFormat"),
|
||||||
FilesFormats.OriginalFormat,
|
"data-type": type,
|
||||||
item,
|
"data-file-id": item.id,
|
||||||
"presentation"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key2",
|
|
||||||
label: ".odp",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.OdpFormat,
|
|
||||||
item,
|
|
||||||
"presentation"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key3",
|
|
||||||
label: ".pdf",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.PdfFormat,
|
|
||||||
item,
|
|
||||||
"presentation"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key4",
|
|
||||||
label: ".pptx",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.PptxFormat,
|
|
||||||
item,
|
|
||||||
"presentation"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key5",
|
|
||||||
label: t("CustomFormat"),
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.CustomFormat,
|
|
||||||
item,
|
|
||||||
"presentation"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const spreadsheetFormats = [
|
|
||||||
{
|
|
||||||
key: "key1",
|
|
||||||
label: t("OriginalFormat"),
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.OriginalFormat,
|
|
||||||
item,
|
|
||||||
"spreadsheet"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key2",
|
|
||||||
label: ".odp",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.OdsFormat,
|
|
||||||
item,
|
|
||||||
"spreadsheet"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key3",
|
|
||||||
label: ".pdf",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.PdfFormat,
|
|
||||||
item,
|
|
||||||
"spreadsheet"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key4",
|
|
||||||
label: ".xlsx",
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.XlsxFormat,
|
|
||||||
item,
|
|
||||||
"spreadsheet"
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "key5",
|
|
||||||
label: t("CustomFormat"),
|
|
||||||
onClick: onSelectFormat.bind(
|
|
||||||
this,
|
|
||||||
FilesFormats.CustomFormat,
|
|
||||||
item,
|
|
||||||
"spreadsheet"
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
for (let f of conversionFormats) {
|
||||||
|
formats.push({
|
||||||
|
key: f,
|
||||||
|
label: f,
|
||||||
|
onClick: onSelectFormat,
|
||||||
|
"data-format": f,
|
||||||
|
"data-type": type,
|
||||||
|
"data-file-id": item.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "document":
|
case "document":
|
||||||
return documentFormats;
|
return formats;
|
||||||
case "spreadsheet":
|
case "spreadsheet":
|
||||||
return spreadsheetFormats;
|
return formats;
|
||||||
case "presentation":
|
case "presentation":
|
||||||
return presentationFormats;
|
return formats;
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTitle = () => {
|
|
||||||
switch (type) {
|
|
||||||
case "document":
|
|
||||||
return t("Common:Documents");
|
|
||||||
case "spreadsheet":
|
|
||||||
return t("Translations:Spreadsheets");
|
|
||||||
case "presentation":
|
|
||||||
return t("Translations:Presentations");
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const title = getTitle();
|
|
||||||
|
|
||||||
const length = items.length;
|
const length = items.length;
|
||||||
const minHeight = length > 2 ? 110 : length * 50;
|
const minHeight = length > 2 ? 110 : length * 50;
|
||||||
const showTitle = length > 1;
|
const showTitle = length > 1;
|
||||||
const formats = getFormats();
|
|
||||||
const documentsTitle = getTitleLabel(titleFormat);
|
const titleData = getTitleExtensions();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledDownloadContent>
|
<StyledDownloadContent>
|
||||||
@ -261,13 +134,13 @@ const DownloadContent = (props) => {
|
|||||||
{checkedTitle || indeterminateTitle ? (
|
{checkedTitle || indeterminateTitle ? (
|
||||||
<LinkWithDropdown
|
<LinkWithDropdown
|
||||||
containerWidth="auto"
|
containerWidth="auto"
|
||||||
data={formats}
|
data={titleData}
|
||||||
directionX="left"
|
directionX="left"
|
||||||
directionY="bottom"
|
directionY="bottom"
|
||||||
dropdownType="appearDashedAfterHover"
|
dropdownType="appearDashedAfterHover"
|
||||||
fontSize="12px"
|
fontSize="12px"
|
||||||
>
|
>
|
||||||
{documentsTitle}
|
{titleFormat}
|
||||||
</LinkWithDropdown>
|
</LinkWithDropdown>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
@ -284,8 +157,6 @@ const DownloadContent = (props) => {
|
|||||||
{items.map((file) => {
|
{items.map((file) => {
|
||||||
const element = getItemIcon(file);
|
const element = getItemIcon(file);
|
||||||
let dropdownItems = getFormats(file);
|
let dropdownItems = getFormats(file);
|
||||||
const format = getTitleLabel(file.format);
|
|
||||||
dropdownItems = dropdownItems.slice(1, -1);
|
|
||||||
dropdownItems = dropdownItems.filter(
|
dropdownItems = dropdownItems.filter(
|
||||||
(x) => x.label !== file.fileExst
|
(x) => x.label !== file.fileExst
|
||||||
);
|
);
|
||||||
@ -322,7 +193,7 @@ const DownloadContent = (props) => {
|
|||||||
directionY="bottom"
|
directionY="bottom"
|
||||||
fontSize="12px"
|
fontSize="12px"
|
||||||
>
|
>
|
||||||
{format}
|
{file.format || t("OriginalFormat")}
|
||||||
</LinkWithDropdown>
|
</LinkWithDropdown>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
|
@ -13,12 +13,11 @@ import { downloadFormatFiles } from "@appserver/common/api/files";
|
|||||||
import { TIMEOUT } from "../../../helpers/constants";
|
import { TIMEOUT } from "../../../helpers/constants";
|
||||||
import DownloadContent from "./DownloadContent";
|
import DownloadContent from "./DownloadContent";
|
||||||
import { inject, observer } from "mobx-react";
|
import { inject, observer } from "mobx-react";
|
||||||
import { FilesFormats } from "@appserver/common/constants";
|
|
||||||
|
|
||||||
class DownloadDialogComponent extends React.Component {
|
class DownloadDialogComponent extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
const { sortedFiles } = this.props;
|
const { sortedFiles, t } = this.props;
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
documents: sortedFiles.documents,
|
documents: sortedFiles.documents,
|
||||||
@ -26,9 +25,9 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
presentations: sortedFiles.presentations,
|
presentations: sortedFiles.presentations,
|
||||||
other: sortedFiles.other,
|
other: sortedFiles.other,
|
||||||
|
|
||||||
documentsTitleFormat: FilesFormats.OriginalFormat,
|
documentsTitleFormat: null,
|
||||||
spreadsheetsTitleFormat: FilesFormats.OriginalFormat,
|
spreadsheetsTitleFormat: null,
|
||||||
presentationsTitleFormat: FilesFormats.OriginalFormat,
|
presentationsTitleFormat: null,
|
||||||
|
|
||||||
checkedDocTitle: true,
|
checkedDocTitle: true,
|
||||||
checkedSpreadsheetTitle: true,
|
checkedSpreadsheetTitle: true,
|
||||||
@ -44,35 +43,6 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
|
|
||||||
onClose = () => this.props.setDownloadDialogVisible(false);
|
onClose = () => this.props.setDownloadDialogVisible(false);
|
||||||
|
|
||||||
getTitleLabel = (format) => {
|
|
||||||
switch (format) {
|
|
||||||
case 0:
|
|
||||||
return this.props.t("OriginalFormat");
|
|
||||||
case 1:
|
|
||||||
return ".txt";
|
|
||||||
case 2:
|
|
||||||
return ".docx";
|
|
||||||
case 3:
|
|
||||||
return ".odt";
|
|
||||||
case 4:
|
|
||||||
return ".ods";
|
|
||||||
case 5:
|
|
||||||
return ".odp";
|
|
||||||
case 6:
|
|
||||||
return ".pdf";
|
|
||||||
case 7:
|
|
||||||
return ".rtf";
|
|
||||||
case 8:
|
|
||||||
return ".xlsx";
|
|
||||||
case 9:
|
|
||||||
return ".pptx";
|
|
||||||
case 10:
|
|
||||||
return this.props.t("CustomFormat");
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
getDownloadItems = () => {
|
getDownloadItems = () => {
|
||||||
const { documents, spreadsheets, presentations, other } = this.state;
|
const { documents, spreadsheets, presentations, other } = this.state;
|
||||||
const files = [];
|
const files = [];
|
||||||
@ -83,9 +53,9 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
if (item.checked) {
|
if (item.checked) {
|
||||||
if (item.fileExst) {
|
if (item.fileExst) {
|
||||||
const format =
|
const format =
|
||||||
item.format === 0
|
item.format === this.props.t("OriginalFormat")
|
||||||
? item.fileExst
|
? item.fileExst
|
||||||
: this.getTitleLabel(item.format);
|
: item.format;
|
||||||
const viewUrl = item.viewUrl;
|
const viewUrl = item.viewUrl;
|
||||||
files.push({ key: item.id, value: format, viewUrl });
|
files.push({ key: item.id, value: format, viewUrl });
|
||||||
} else {
|
} else {
|
||||||
@ -168,85 +138,62 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
onSelectFormat = (format, file, type) => {
|
getNewArrayFiles = (fileId, array, format) => {
|
||||||
const { documents, spreadsheets, presentations } = this.state;
|
//Set all documents format
|
||||||
|
if (!fileId) {
|
||||||
|
for (let file of array) {
|
||||||
|
file.format =
|
||||||
|
format === this.props.t("CustomFormat") || file.fileExst === format
|
||||||
|
? this.props.t("OriginalFormat")
|
||||||
|
: format;
|
||||||
|
}
|
||||||
|
|
||||||
const newDocuments = documents;
|
return array;
|
||||||
const newSpreadsheets = spreadsheets;
|
} else {
|
||||||
const newPresentations = presentations;
|
//Set single document format
|
||||||
|
const newDoc = array.find((x) => x.id == fileId);
|
||||||
|
if (newDoc.format !== format) {
|
||||||
|
newDoc.format = format;
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onSelectFormat = (e) => {
|
||||||
|
const { format, type, fileId } = e.target.dataset;
|
||||||
|
const { documents, spreadsheets, presentations } = this.state;
|
||||||
|
const { t } = this.props;
|
||||||
|
|
||||||
|
const newDocuments = documents.slice();
|
||||||
|
const newSpreadsheets = spreadsheets.slice();
|
||||||
|
const newPresentations = presentations.slice();
|
||||||
|
|
||||||
if (type === "document") {
|
if (type === "document") {
|
||||||
//Set all documents format
|
const documents = this.getNewArrayFiles(fileId, newDocuments, format);
|
||||||
if (!file) {
|
this.setState({
|
||||||
for (let file of newDocuments) {
|
documents,
|
||||||
file.format =
|
documentsTitleFormat: !fileId ? format : t("CustomFormat"),
|
||||||
format === FilesFormats.CustomFormat || file.fileExst === format
|
});
|
||||||
? FilesFormats.OriginalFormat
|
|
||||||
: format;
|
|
||||||
}
|
|
||||||
this.setState({
|
|
||||||
documents: newDocuments,
|
|
||||||
documentsTitleFormat: format,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
//Set single document format
|
|
||||||
const newDoc = newDocuments.find((x) => x.id === file.id);
|
|
||||||
if (newDoc.format !== format) {
|
|
||||||
newDoc.format = format;
|
|
||||||
this.setState({
|
|
||||||
documents: newDocuments,
|
|
||||||
documentsTitleFormat: FilesFormats.CustomFormat,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type === "spreadsheet") {
|
} else if (type === "spreadsheet") {
|
||||||
//Set all spreadsheets format
|
const spreadsheets = this.getNewArrayFiles(
|
||||||
if (!file) {
|
fileId,
|
||||||
for (let file of newSpreadsheets) {
|
newSpreadsheets,
|
||||||
file.format =
|
format
|
||||||
format === FilesFormats.CustomFormat || file.fileExst === format
|
);
|
||||||
? FilesFormats.OriginalFormat
|
this.setState({
|
||||||
: format;
|
spreadsheets,
|
||||||
}
|
spreadsheetsTitleFormat: !fileId ? format : t("CustomFormat"),
|
||||||
this.setState({
|
});
|
||||||
spreadsheets: newSpreadsheets,
|
|
||||||
spreadsheetsTitleFormat: format,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
//Set single spreadsheet format
|
|
||||||
const newSpreadsheet = newSpreadsheets.find((x) => x.id === file.id);
|
|
||||||
if (newSpreadsheet.format !== format) {
|
|
||||||
newSpreadsheet.format = format;
|
|
||||||
this.setState({
|
|
||||||
spreadsheets: newSpreadsheets,
|
|
||||||
spreadsheetsTitleFormat: FilesFormats.CustomFormat,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (type === "presentation") {
|
} else if (type === "presentation") {
|
||||||
//Set all presentations format
|
const presentations = this.getNewArrayFiles(
|
||||||
if (!file) {
|
fileId,
|
||||||
for (let file of newPresentations) {
|
newPresentations,
|
||||||
file.format =
|
format
|
||||||
format === FilesFormats.CustomFormat || file.fileExst === format
|
);
|
||||||
? FilesFormats.OriginalFormat
|
this.setState({
|
||||||
: format;
|
presentations,
|
||||||
}
|
presentationsTitleFormat: !fileId ? format : t("CustomFormat"),
|
||||||
this.setState({
|
});
|
||||||
presentations: newPresentations,
|
|
||||||
presentationsTitleFormat: format,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
//Set single presentation format
|
|
||||||
const newPresentation = newPresentations.find((x) => x.id === file.id);
|
|
||||||
if (newPresentation.format !== format) {
|
|
||||||
newPresentation.format = format;
|
|
||||||
this.setState({
|
|
||||||
presentations: newPresentations,
|
|
||||||
presentationsTitleFormat: FilesFormats.CustomFormat,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -396,7 +343,7 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { visible, t, tReady } = this.props;
|
const { visible, t, tReady, filesConverts } = this.props;
|
||||||
const {
|
const {
|
||||||
documentsTitleFormat,
|
documentsTitleFormat,
|
||||||
spreadsheetsTitleFormat,
|
spreadsheetsTitleFormat,
|
||||||
@ -438,45 +385,48 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
{documents.length > 0 && (
|
{documents.length > 0 && (
|
||||||
<DownloadContent
|
<DownloadContent
|
||||||
t={t}
|
t={t}
|
||||||
|
filesConverts={filesConverts}
|
||||||
checkedTitle={checkedDocTitle}
|
checkedTitle={checkedDocTitle}
|
||||||
indeterminateTitle={indeterminateDocTitle}
|
indeterminateTitle={indeterminateDocTitle}
|
||||||
items={documents}
|
items={documents}
|
||||||
onSelectFormat={this.onSelectFormat}
|
onSelectFormat={this.onSelectFormat}
|
||||||
onRowSelect={this.onRowSelect}
|
onRowSelect={this.onRowSelect}
|
||||||
getItemIcon={this.getItemIcon}
|
getItemIcon={this.getItemIcon}
|
||||||
getTitleLabel={this.getTitleLabel}
|
titleFormat={documentsTitleFormat || t("OriginalFormat")}
|
||||||
titleFormat={documentsTitleFormat}
|
|
||||||
type="document"
|
type="document"
|
||||||
|
title={t("Common:Documents")}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{spreadsheets.length > 0 && (
|
{spreadsheets.length > 0 && (
|
||||||
<DownloadContent
|
<DownloadContent
|
||||||
t={t}
|
t={t}
|
||||||
|
filesConverts={filesConverts}
|
||||||
checkedTitle={checkedSpreadsheetTitle}
|
checkedTitle={checkedSpreadsheetTitle}
|
||||||
indeterminateTitle={indeterminateSpreadsheetTitle}
|
indeterminateTitle={indeterminateSpreadsheetTitle}
|
||||||
items={spreadsheets}
|
items={spreadsheets}
|
||||||
onSelectFormat={this.onSelectFormat}
|
onSelectFormat={this.onSelectFormat}
|
||||||
onRowSelect={this.onRowSelect}
|
onRowSelect={this.onRowSelect}
|
||||||
getItemIcon={this.getItemIcon}
|
getItemIcon={this.getItemIcon}
|
||||||
getTitleLabel={this.getTitleLabel}
|
titleFormat={spreadsheetsTitleFormat || t("OriginalFormat")}
|
||||||
titleFormat={spreadsheetsTitleFormat}
|
|
||||||
type="spreadsheet"
|
type="spreadsheet"
|
||||||
|
title={t("Translations:Spreadsheets")}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{presentations.length > 0 && (
|
{presentations.length > 0 && (
|
||||||
<DownloadContent
|
<DownloadContent
|
||||||
t={t}
|
t={t}
|
||||||
|
filesConverts={filesConverts}
|
||||||
checkedTitle={checkedPresentationTitle}
|
checkedTitle={checkedPresentationTitle}
|
||||||
indeterminateTitle={indeterminatePresentationTitle}
|
indeterminateTitle={indeterminatePresentationTitle}
|
||||||
items={presentations}
|
items={presentations}
|
||||||
onSelectFormat={this.onSelectFormat}
|
onSelectFormat={this.onSelectFormat}
|
||||||
onRowSelect={this.onRowSelect}
|
onRowSelect={this.onRowSelect}
|
||||||
getItemIcon={this.getItemIcon}
|
getItemIcon={this.getItemIcon}
|
||||||
getTitleLabel={this.getTitleLabel}
|
titleFormat={presentationsTitleFormat || t("OriginalFormat")}
|
||||||
titleFormat={presentationsTitleFormat}
|
|
||||||
type="presentation"
|
type="presentation"
|
||||||
|
title={t("Translations:Presentations")}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -551,7 +501,6 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
size="medium"
|
size="medium"
|
||||||
primary
|
primary
|
||||||
onClick={this.onDownload}
|
onClick={this.onDownload}
|
||||||
//isLoading={isLoading}
|
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className="button-dialog"
|
className="button-dialog"
|
||||||
@ -559,7 +508,6 @@ class DownloadDialogComponent extends React.Component {
|
|||||||
label={t("Common:CancelButton")}
|
label={t("Common:CancelButton")}
|
||||||
size="medium"
|
size="medium"
|
||||||
onClick={this.onClose}
|
onClick={this.onClose}
|
||||||
//isLoading={isLoading}
|
|
||||||
/>
|
/>
|
||||||
</ModalDialog.Footer>
|
</ModalDialog.Footer>
|
||||||
</ModalDialogContainer>
|
</ModalDialogContainer>
|
||||||
@ -584,6 +532,7 @@ export default inject(
|
|||||||
const { secondaryProgressDataStore } = uploadDataStore;
|
const { secondaryProgressDataStore } = uploadDataStore;
|
||||||
const { sortedFiles } = filesStore;
|
const { sortedFiles } = filesStore;
|
||||||
const { getIcon, getFolderIcon } = formatsStore.iconFormatsStore;
|
const { getIcon, getFolderIcon } = formatsStore.iconFormatsStore;
|
||||||
|
const { filesConverts } = formatsStore.docserviceStore;
|
||||||
const {
|
const {
|
||||||
setSecondaryProgressBarData,
|
setSecondaryProgressBarData,
|
||||||
clearSecondaryProgressData,
|
clearSecondaryProgressData,
|
||||||
@ -599,6 +548,7 @@ export default inject(
|
|||||||
return {
|
return {
|
||||||
sortedFiles,
|
sortedFiles,
|
||||||
visible,
|
visible,
|
||||||
|
filesConverts,
|
||||||
|
|
||||||
setSecondaryProgressBarData,
|
setSecondaryProgressBarData,
|
||||||
clearSecondaryProgressData,
|
clearSecondaryProgressData,
|
||||||
|
@ -5,33 +5,28 @@ class DocserviceStore {
|
|||||||
coauthorDocs = [".pptx", ".ppsx", ".xlsx", ".csv", ".docx", ".txt"];
|
coauthorDocs = [".pptx", ".ppsx", ".xlsx", ".csv", ".docx", ".txt"];
|
||||||
commentedDocs = [".docx", ".xlsx", ".pptx"];
|
commentedDocs = [".docx", ".xlsx", ".pptx"];
|
||||||
convertDocs = [
|
convertDocs = [
|
||||||
".pptm",
|
|
||||||
".ppt",
|
|
||||||
".ppsm",
|
|
||||||
".pps",
|
|
||||||
".potx",
|
|
||||||
".potm",
|
|
||||||
".pot",
|
|
||||||
".odp",
|
|
||||||
".fodp",
|
|
||||||
".otp",
|
|
||||||
".xlsm",
|
|
||||||
".xls",
|
|
||||||
".xltx",
|
|
||||||
".xltm",
|
|
||||||
".xlt",
|
|
||||||
".ods",
|
|
||||||
".fods",
|
|
||||||
".ots",
|
|
||||||
".docm",
|
|
||||||
".doc",
|
".doc",
|
||||||
|
".docx",
|
||||||
|
".docm",
|
||||||
|
".dot",
|
||||||
".dotx",
|
".dotx",
|
||||||
".dotm",
|
".dotm",
|
||||||
".dot",
|
|
||||||
".odt",
|
".odt",
|
||||||
".fodt",
|
".fodt",
|
||||||
".ott",
|
".ott",
|
||||||
".rtf",
|
".rtf",
|
||||||
|
".txt",
|
||||||
|
".html",
|
||||||
|
".htm",
|
||||||
|
".mht",
|
||||||
|
".pdf",
|
||||||
|
".djvu",
|
||||||
|
".fb2",
|
||||||
|
".epub",
|
||||||
|
".xps",
|
||||||
|
".doct",
|
||||||
|
".docy",
|
||||||
|
".gdoc",
|
||||||
];
|
];
|
||||||
editedDocs = [
|
editedDocs = [
|
||||||
".pptx",
|
".pptx",
|
||||||
@ -121,6 +116,50 @@ class DocserviceStore {
|
|||||||
".xps",
|
".xps",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
filesConverts = [
|
||||||
|
{ ".csv": [".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".doc": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".docm": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".doct": [".docx"] },
|
||||||
|
{ ".docx": [".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".dot": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".dotm": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".dotx": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".epub": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".fb2": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".fodp": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".fods": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".fodt": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".html": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".mht": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".odp": [".pdf", ".pptx"] },
|
||||||
|
{ ".otp": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".ods": [".csv", ".pdf", ".xlsx"] },
|
||||||
|
{ ".ots": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".odt": [".docx", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".ott": [".docx", ".odt", ".pdf", ".rtf", ".txt"] },
|
||||||
|
{ ".pot": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".potm": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".potx": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".pps": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".ppsm": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".ppsx": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".ppt": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".pptm": [".odp", ".pdf", ".pptx"] },
|
||||||
|
{ ".pptt": [".pptx"] },
|
||||||
|
{ ".pptx": [".odp", ".pdf"] },
|
||||||
|
{ ".rtf": [".docx", ".odt", ".pdf", ".txt"] },
|
||||||
|
{ ".txt": [".docx", ".odt", ".pdf", ".rtf"] },
|
||||||
|
{ ".xls": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".xlsm": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".xlst": [".xlsx"] },
|
||||||
|
{ ".xlsx": [".csv", ".ods", ".pdf"] },
|
||||||
|
{ ".xlt": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".xltm": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".xltx": [".csv", ".ods", ".pdf", ".xlsx"] },
|
||||||
|
{ ".xps": [".pdf"] },
|
||||||
|
];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
makeObservable(this, {});
|
makeObservable(this, {});
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import {
|
|||||||
FileType,
|
FileType,
|
||||||
FileAction,
|
FileAction,
|
||||||
AppServerConfig,
|
AppServerConfig,
|
||||||
FilesFormats,
|
|
||||||
} from "@appserver/common/constants";
|
} from "@appserver/common/constants";
|
||||||
import history from "@appserver/common/history";
|
import history from "@appserver/common/history";
|
||||||
import { loopTreeFolders } from "../helpers/files-helpers";
|
import { loopTreeFolders } from "../helpers/files-helpers";
|
||||||
@ -1208,8 +1207,8 @@ class FilesStore {
|
|||||||
const {
|
const {
|
||||||
isSpreadsheet,
|
isSpreadsheet,
|
||||||
isPresentation,
|
isPresentation,
|
||||||
|
isDocument,
|
||||||
} = this.formatsStore.iconFormatsStore;
|
} = this.formatsStore.iconFormatsStore;
|
||||||
const { canWebEdit } = this.formatsStore.docserviceStore;
|
|
||||||
|
|
||||||
let sortedFiles = {
|
let sortedFiles = {
|
||||||
documents: [],
|
documents: [],
|
||||||
@ -1220,14 +1219,14 @@ class FilesStore {
|
|||||||
|
|
||||||
for (let item of this.selection) {
|
for (let item of this.selection) {
|
||||||
item.checked = true;
|
item.checked = true;
|
||||||
item.format = FilesFormats.OriginalFormat;
|
item.format = null;
|
||||||
|
|
||||||
if (item.fileExst) {
|
if (item.fileExst) {
|
||||||
if (isSpreadsheet(item.fileExst)) {
|
if (isSpreadsheet(item.fileExst)) {
|
||||||
sortedFiles.spreadsheets.push(item);
|
sortedFiles.spreadsheets.push(item);
|
||||||
} else if (isPresentation(item.fileExst)) {
|
} else if (isPresentation(item.fileExst)) {
|
||||||
sortedFiles.presentations.push(item);
|
sortedFiles.presentations.push(item);
|
||||||
} else if (item.fileExst !== ".pdf" && canWebEdit(item.fileExst)) {
|
} else if (isDocument(item.fileExst)) {
|
||||||
sortedFiles.documents.push(item);
|
sortedFiles.documents.push(item);
|
||||||
} else {
|
} else {
|
||||||
sortedFiles.other.push(item);
|
sortedFiles.other.push(item);
|
||||||
@ -1278,11 +1277,12 @@ class FilesStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get isWebEditSelected() {
|
get isWebEditSelected() {
|
||||||
const { editedDocs } = this.formatsStore.docserviceStore;
|
const { filesConverts } = this.formatsStore.docserviceStore;
|
||||||
|
|
||||||
return this.selection.some((selected) => {
|
return this.selection.some((selected) => {
|
||||||
if (selected.isFolder === true || !selected.fileExst) return false;
|
if (selected.isFolder === true || !selected.fileExst) return false;
|
||||||
return editedDocs.find((format) => selected.fileExst === format);
|
const index = filesConverts.findIndex((f) => f[selected.fileExst]);
|
||||||
|
return index !== -1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1377,9 +1377,9 @@ class FilesStore {
|
|||||||
: splitValue.slice(1).join("_");
|
: splitValue.slice(1).join("_");
|
||||||
|
|
||||||
if (fileType === "file") {
|
if (fileType === "file") {
|
||||||
newSelection.push(this.files.find((f) => f.id == id && f.fileExst));
|
newSelection.push(this.files.find((f) => f.id == id));
|
||||||
} else {
|
} else {
|
||||||
newSelection.push(this.folders.find((f) => f.id == id && !f.fileExst));
|
newSelection.push(this.folders.find((f) => f.id == id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user