|
@@ -16,6 +16,7 @@ class GrowiImportForm extends React.Component {
|
|
|
schema: {
|
|
schema: {
|
|
|
pages: {},
|
|
pages: {},
|
|
|
revisions: {},
|
|
revisions: {},
|
|
|
|
|
+ // ...
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -25,6 +26,7 @@ class GrowiImportForm extends React.Component {
|
|
|
|
|
|
|
|
this.toggleCheckbox = this.toggleCheckbox.bind(this);
|
|
this.toggleCheckbox = this.toggleCheckbox.bind(this);
|
|
|
this.import = this.import.bind(this);
|
|
this.import = this.import.bind(this);
|
|
|
|
|
+ this.validateForm = this.validateForm.bind(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
toggleCheckbox(e) {
|
|
toggleCheckbox(e) {
|
|
@@ -56,25 +58,28 @@ class GrowiImportForm extends React.Component {
|
|
|
this.setState(this.initialState);
|
|
this.setState(this.initialState);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ validateForm() {
|
|
|
|
|
+ return this.state.collections.size > 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
render() {
|
|
render() {
|
|
|
const { t } = this.props;
|
|
const { t } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <Fragment>
|
|
|
|
|
- {this.props.fileName && (
|
|
|
|
|
- <form className="row">
|
|
|
|
|
- <div className="col-xs-12">
|
|
|
|
|
- <table className="table table-bordered table-mapping">
|
|
|
|
|
- <thead>
|
|
|
|
|
- <tr>
|
|
|
|
|
- <th></th>
|
|
|
|
|
- <th>Extracted File</th>
|
|
|
|
|
- <th>Collection</th>
|
|
|
|
|
- </tr>
|
|
|
|
|
- </thead>
|
|
|
|
|
- <tbody>
|
|
|
|
|
- {this.props.fileStats.map((fileStat) => {
|
|
|
|
|
|
|
+ <form className="row">
|
|
|
|
|
+ <div className="col-xs-12">
|
|
|
|
|
+ <table className="table table-bordered table-mapping">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th></th>
|
|
|
|
|
+ <th>Extracted File</th>
|
|
|
|
|
+ <th>Collection</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ {this.props.fileStats.map((fileStat) => {
|
|
|
const { fileName, collectionName } = fileStat;
|
|
const { fileName, collectionName } = fileStat;
|
|
|
|
|
+ const checked = this.state.collections.has(collectionName);
|
|
|
return (
|
|
return (
|
|
|
<Fragment key={collectionName}>
|
|
<Fragment key={collectionName}>
|
|
|
<tr>
|
|
<tr>
|
|
@@ -85,14 +90,14 @@ class GrowiImportForm extends React.Component {
|
|
|
name={collectionName}
|
|
name={collectionName}
|
|
|
className="form-check-input"
|
|
className="form-check-input"
|
|
|
value={collectionName}
|
|
value={collectionName}
|
|
|
- checked={this.state.collections.has(collectionName)}
|
|
|
|
|
|
|
+ checked={checked}
|
|
|
onChange={this.toggleCheckbox}
|
|
onChange={this.toggleCheckbox}
|
|
|
/>
|
|
/>
|
|
|
</td>
|
|
</td>
|
|
|
<td>{fileName}</td>
|
|
<td>{fileName}</td>
|
|
|
<td className="text-capitalize">{collectionName}</td>
|
|
<td className="text-capitalize">{collectionName}</td>
|
|
|
</tr>
|
|
</tr>
|
|
|
- {this.state.collections.has(collectionName) && (
|
|
|
|
|
|
|
+ {checked && (
|
|
|
<tr>
|
|
<tr>
|
|
|
<td className="text-muted" colSpan="3">
|
|
<td className="text-muted" colSpan="3">
|
|
|
TBD: define how to import {collectionName}
|
|
TBD: define how to import {collectionName}
|
|
@@ -102,17 +107,15 @@ class GrowiImportForm extends React.Component {
|
|
|
</Fragment>
|
|
</Fragment>
|
|
|
);
|
|
);
|
|
|
})}
|
|
})}
|
|
|
- </tbody>
|
|
|
|
|
- </table>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="col-xs-offset-3 col-xs-6">
|
|
|
|
|
- <button type="submit" className="btn btn-primary" onClick={this.import}>
|
|
|
|
|
- { t('importer_management.import') }
|
|
|
|
|
- </button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </form>
|
|
|
|
|
- )}
|
|
|
|
|
- </Fragment>
|
|
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="col-xs-offset-3 col-xs-6">
|
|
|
|
|
+ <button type="submit" className="btn btn-primary" disabled={!this.validateForm()}>
|
|
|
|
|
+ { t('importer_management.import') }
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </form>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|