Merge branch 'feature/files' of https://github.com/ONLYOFFICE/CommunityServer-AspNetCore into feature/files

This commit is contained in:
Nikita Gopienko 2020-03-11 17:20:33 +03:00
commit db2b8ca686
6 changed files with 38 additions and 28 deletions

View File

@ -15,8 +15,8 @@ const { isAdmin } = store.auth.selectors;
class PureArticleMainButtonContent extends React.Component {
onCreateFolder = (e) => {
this.props.onCreate(true);
onCreate = (format) => {
this.props.onCreate(format);
}
render() {
@ -34,25 +34,22 @@ class PureArticleMainButtonContent extends React.Component {
<DropDownItem
icon="ActionsDocumentsIcon"
label={t('NewDocument')}
onClick={() => toastr.info("New Document click")}
onClick={this.onCreate.bind(this, 'docx')}
/>
<DropDownItem
icon="SpreadsheetIcon"
label={t('NewSpreadsheet')}
onClick={() => toastr.info("New SpreadSheet click")}
onClick={this.onCreate.bind(this, 'xlsx')}
/>
<DropDownItem
icon="ActionsPresentationIcon"
label={t('NewPresentation')}
onClick={() => toastr.info("New Presentation click")}
onClick={this.onCreate.bind(this, 'pptx')}
/>
<DropDownItem
icon="CatalogFolderIcon"
label={t('NewFolder')}
onClick={() => {
this.onCreateFolder();
toastr.info("New Folder click")
}}
onClick={this.onCreate.bind(this, 'folder')}
/>
<DropDownItem isSeparator />
<DropDownItem

View File

@ -4,7 +4,7 @@ import { connect } from "react-redux";
import { withRouter } from "react-router";
import styled from "styled-components";
import { RowContent, Link, Text, Icons, Badge, TextInput, Button } from "asc-web-components";
import { createFolder, renameFolder, updateFile } from '../../../../../store/files/actions';
import { createFile, createFolder, renameFolder, updateFile } from '../../../../../store/files/actions';
import { canWebEdit, canConvert } from '../../../../../store/files/selectors';
class FilesRowContent extends React.PureComponent {
@ -43,15 +43,18 @@ class FilesRowContent extends React.PureComponent {
};
createItem = () => {
const { createFolder, item, onEditComplete } = this.props;
const { createFile, createFolder, item, onEditComplete } = this.props;
const { itemTitle } = this.state;
this.setState({ editingId: -1 }, () => {
if (itemTitle.trim() === '')
return onEditComplete();
createFolder(item.parentId, itemTitle)
.then(() => onEditComplete());
item.fileExst === 'folder'
? createFolder(item.parentId, itemTitle)
.then(() => onEditComplete())
: createFile(item.parentId, `${itemTitle}.${item.fileExst}`)
.then(() => onEditComplete())
});
}
@ -74,8 +77,8 @@ class FilesRowContent extends React.PureComponent {
onClickUpdateItem = () => {
(this.state.editingId === -2)
? this.createItem()
: this.updateItem();
? this.createItem()
: this.updateItem();
}
onKeyUpUpdateItem = e => {
@ -316,7 +319,7 @@ class FilesRowContent extends React.PureComponent {
onClick={() => { }}
isTextOverflow={true}
>
{`Created: ${createdDate}`}
{createdDate && `Created: ${createdDate}`}
</Link>
<Text
containerWidth='10%'
@ -336,6 +339,6 @@ class FilesRowContent extends React.PureComponent {
}
};
export default connect(null, { createFolder, updateFile, renameFolder })(
export default connect(null, { createFile, createFolder, updateFile, renameFolder })(
withRouter(FilesRowContent)
);

View File

@ -30,7 +30,7 @@ class SectionBodyContent extends React.PureComponent {
this.state = {
editingId: -1,
isEdit: false,
isCreating: false
isCreating: ''
};
}
@ -60,7 +60,7 @@ class SectionBodyContent extends React.PureComponent {
if (this.props.isCreating !== prevProps.isCreating) {
let tempId = this.state.editingId;
if (this.props.isCreating) {
if (this.props.isCreating !== '') {
tempId = -2;
}
@ -83,14 +83,14 @@ class SectionBodyContent extends React.PureComponent {
onCreate(false);
if (this.state.isCreating) {
if (this.state.isCreating !== '') {
fetchFolder(folderId, store.dispatch)
}
this.setState({
editingId: -1,
isEdit: false,
isCreating: false
isCreating: ''
});
}
@ -180,11 +180,12 @@ class SectionBodyContent extends React.PureComponent {
let items = [...folders, ...files];
if (isCreating) {
if (isCreating !== '') {
items.unshift({
id: -2,
title: '',
parentId: folderId
parentId: folderId,
fileExst: isCreating
})
}

View File

@ -30,7 +30,7 @@ class PureHome extends React.Component {
isHeaderIndeterminate: false,
isHeaderChecked: false,
isLoading: false,
isCreating: false
isCreating: ''
};
}

View File

@ -280,6 +280,15 @@ export function testUpdateMyFolder(folders) {
//setRootFolders
}
export function createFile(folderId, title) {
return dispatch => {
return files.createFile(folderId, title)
.then(folder => {
fetchFolder(folderId, dispatch);
});
};
}
export function createFolder(parentFolderId, title) {
return dispatch => {
return files.createFolder(parentFolderId, title)

View File

@ -745,9 +745,9 @@ namespace ASC.Api.Documents
/// <remarks>In case the extension for the file title differs from DOCX/XLSX/PPTX and belongs to one of the known text, spreadsheet or presentation formats, it will be changed to DOCX/XLSX/PPTX accordingly. If the file extension is not set or is unknown, the DOCX extension will be added to the file title.</remarks>
/// <returns>New file info</returns>
[Create("@my/file")]
public FileWrapper CreateFile(string title)
public FileWrapper CreateFile([FromBody]FileModelFull model)
{
return CreateFile(GlobalFolderHelper.FolderMy.ToString(), title);
return CreateFile(GlobalFolderHelper.FolderMy.ToString(), model);
}
/// <summary>
@ -760,9 +760,9 @@ namespace ASC.Api.Documents
/// <remarks>In case the extension for the file title differs from DOCX/XLSX/PPTX and belongs to one of the known text, spreadsheet or presentation formats, it will be changed to DOCX/XLSX/PPTX accordingly. If the file extension is not set or is unknown, the DOCX extension will be added to the file title.</remarks>
/// <returns>New file info</returns>
[Create("{folderId}/file")]
public FileWrapper CreateFile(string folderId, string title)
public FileWrapper CreateFile(string folderId, [FromBody]FileModelFull model)
{
var file = FileStorageService.CreateNewFile(new FileModel { ParentId = folderId, Title = title });
var file = FileStorageService.CreateNewFile(new FileModel { ParentId = folderId, Title = model.Title });
return FileWrapperHelper.Get(file);
}