Skip to content

TagSpaces is an offline, open source, document manager with tagging support

ui improvements location dialogs

Ilian Sapundshieva72f099a1bec
diff --git a/app/components/dialogs/CreateLocationDialog.js b/app/components/dialogs/CreateLocationDialog.js
index f70fae6f5..257331365 100644
--- a/app/components/dialogs/CreateLocationDialog.js
+++ b/app/components/dialogs/CreateLocationDialog.js
@@ -122,11 +122,12 @@ class CreateLocationDialog extends React.Component<Props, State> {
}
}
- openDirectory() {
+ openDirectory = () => {
if (AppConfig.isElectron) {
PlatformIO.selectDirectoryDialog().then((selectedPaths) => {
+ const newName = (this.state.name.length < 1) ? extractDirectoryName(selectedPaths[0]) : this.state.name;
this.setState({
- name: extractDirectoryName(selectedPaths[0]),
+ name: newName,
path: selectedPaths[0]
});
this.handleValidation();
@@ -137,7 +138,7 @@ class CreateLocationDialog extends React.Component<Props, State> {
} else {
this.props.showSelectDirectoryDialog();
}
- }
+ };
onConfirm = () => {
if (!this.state.disableConfirmButton) {
@@ -168,6 +169,23 @@ class CreateLocationDialog extends React.Component<Props, State> {
renderContent = () => {
return (
<DialogContent>
+ <FormControl
+ fullWidth={true}
+ error={this.state.errorTextPath}
+ >
+ <TextField
+ error={this.state.errorTextPath}
+ required
+ margin="dense"
+ name="name"
+ label={i18n.t('core:createLocationName')}
+ onChange={this.handleInputChange}
+ value={this.state.name}
+ data-tid="locationName"
+ fullWidth={true}
+ />
+ {this.state.errorTextName && <FormHelperText>Invalid Name</FormHelperText>}
+ </FormControl>
<FormControl
fullWidth={true}
error={this.state.errorTextPath}
@@ -185,7 +203,7 @@ class CreateLocationDialog extends React.Component<Props, State> {
endAdornment={
<InputAdornment position="end" style={{ height: 32 }}>
<IconButton
- onClick={this.openDirectory.bind(this)}
+ onClick={this.openDirectory}
>
<FolderIcon />
</IconButton>
@@ -194,23 +212,6 @@ class CreateLocationDialog extends React.Component<Props, State> {
/>
{this.state.errorTextPath && <FormHelperText>{i18n.t('core:invalidPath')}</FormHelperText>}
</FormControl>
- <FormControl
- fullWidth={true}
- error={this.state.errorTextPath}
- >
- <TextField
- error={this.state.errorTextPath}
- required
- margin="dense"
- name="name"
- label={i18n.t('core:createLocationName')}
- onChange={this.handleInputChange}
- value={this.state.name}
- data-tid="locationName"
- fullWidth={true}
- />
- {this.state.errorTextName && <FormHelperText>Invalid Name</FormHelperText>}
- </FormControl>
<FormGroup>
<FormControlLabel
control={
diff --git a/app/components/dialogs/EditLocationDialog.js b/app/components/dialogs/EditLocationDialog.js
index ee5c34954..402d20ff2 100644
--- a/app/components/dialogs/EditLocationDialog.js
+++ b/app/components/dialogs/EditLocationDialog.js
@@ -122,13 +122,14 @@ class EditLocationDialog extends React.Component<Props, State> {
}
}
- openDirectory() {
+ openDirectory = () => {
if (AppConfig.isElectron) {
this.setState({ openDirectoryButtonDisabled: true });
PlatformIO.selectDirectoryDialog().then((selectedPaths) => {
+ const newName = (this.state.name.length < 1) ? extractDirectoryName(selectedPaths[0]) : this.state.name;
this.setState({
openDirectoryButtonDisabled: false,
- name: extractDirectoryName(selectedPaths[0]),
+ name: newName,
path: selectedPaths[0]
});
this.handleValidation();
@@ -166,6 +167,22 @@ class EditLocationDialog extends React.Component<Props, State> {
renderContent = () => (
<DialogContent>
+ <FormControl
+ fullWidth={true}
+ error={this.state.errorTextPath}
+ >
+ <TextField
+ error={this.state.errorTextPath}
+ margin="dense"
+ name="name"
+ label={i18n.t('core:createLocationName')}
+ onChange={this.handleInputChange}
+ value={this.state.name}
+ data-tid="editLocationName"
+ fullWidth={true}
+ />
+ {this.state.errorTextName && <FormHelperText>Invalid Name</FormHelperText>}
+ </FormControl>
<FormControl
fullWidth={true}
error={this.state.errorTextPath}
@@ -185,7 +202,7 @@ class EditLocationDialog extends React.Component<Props, State> {
<InputAdornment position="end" style={{ height: 32 }}>
<IconButton
disabled={this.state.openDirectoryButtonDisabled}
- onClick={this.openDirectory.bind(this)}
+ onClick={this.openDirectory}
>
<FolderIcon />
</IconButton>
@@ -194,22 +211,6 @@ class EditLocationDialog extends React.Component<Props, State> {
/>
{this.state.errorTextPath && <FormHelperText>{i18n.t('core:invalidPath')}</FormHelperText>}
</FormControl>
- <FormControl
- fullWidth={true}
- error={this.state.errorTextPath}
- >
- <TextField
- error={this.state.errorTextPath}
- margin="dense"
- name="name"
- label={i18n.t('core:createLocationName')}
- onChange={this.handleInputChange}
- value={this.state.name}
- data-tid="editLocationName"
- fullWidth={true}
- />
- {this.state.errorTextName && <FormHelperText>Invalid Name</FormHelperText>}
- </FormControl>
<FormControl>
<FormGroup>
<FormControlLabel