1. showing the currently loaded xmlfile in the topbar

2. new file show save
This commit is contained in:
Malar Kannan
2017-07-31 11:23:24 +05:30
parent 6c92ac627c
commit c1952dc8ac
2 changed files with 41 additions and 37 deletions

View File

@@ -10,29 +10,31 @@ export class LexXMLSelect extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.state = {
xmlFiles: [], xmlFileName: 'new_es.xml'
xmlFiles: [], xmlFileName: props.xmlFileName
};
}
public componentDidMount() {
this.getXMLFiles();
}
render() {
let files: string[] = [].concat(this.state.xmlFiles);
if (files.indexOf(this.state.xmlFileName as string) === -1) {
files.push(this.state.xmlFileName);
}
let dropOptions = files.map((k: any, i: any, c: any) => {
let dropOptions = this.state.xmlFiles.map((k: any, i: any, c: any) => {
return { key: i, value: k, text: k };
});
let onFileChange = (e: any, d: any) => {
this.setState({ xmlFileName: d.value as string });
this.props.onFileSelected(d.value);
let xmlFileName = d.value as string;
let xmlFiles: string[] = [].concat(this.state.xmlFiles);
if (xmlFiles.indexOf(xmlFileName as string) === -1) {
xmlFiles.push(xmlFileName);
this.props.onFileSelected(xmlFileName, true);
} else {
this.props.onFileSelected(xmlFileName, false);
}
this.setState({ xmlFileName, xmlFiles });
};
return (
<Dropdown
options={dropOptions}
onChange={onFileChange}
onAddItem={onFileChange}
value={this.state.xmlFileName}
compact={true}
selection={true}
@@ -97,9 +99,11 @@ export class LexSetup extends React.Component<any, any> {
{saveButton}
{loadButton}
<LexXMLSelect
onFileSelected={(nf: string) => {
this.xmlFileName = nf;
onFileSelected={(fileName: string, newFile: Boolean) => {
this.xmlFileName = fileName;
this.setState({ dirty: newFile });
}}
xmlFileName={this.xmlFileName}
/>
<Icon name="edit" size="small" />
<Header.Content>