Edit: ajout bouton supression item
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
/* jhsint node:true, jsx: true */
|
||||
var React = require('react');
|
||||
var connect = require('react-redux').connect;
|
||||
var actions = require('../../store/actions');
|
||||
@ -31,11 +32,10 @@ var ProfileMenu = React.createClass({
|
||||
var profile = this.props.profile;
|
||||
var profilePath = this.props.profilePath;
|
||||
|
||||
var promise = profilePath ? Promise.resolve(profilePath) : this.showSaveProfileDialog();
|
||||
|
||||
promise.then(function(profilePath) {
|
||||
if(profilePath) dispatch(actions.edit.saveProfile(profilePath, profile));
|
||||
});
|
||||
this.showSaveProfileDialog(profilePath)
|
||||
.then(function(profilePath) {
|
||||
if(profilePath) dispatch(actions.edit.saveProfile(profilePath, profile));
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@ -56,12 +56,13 @@ var ProfileMenu = React.createClass({
|
||||
|
||||
},
|
||||
|
||||
showSaveProfileDialog: function() {
|
||||
showSaveProfileDialog: function(defaultPath) {
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
dialog.showSaveDialog(
|
||||
{
|
||||
title: 'Éditer un profil',
|
||||
defaultPath: defaultPath,
|
||||
title: 'Enregistrer un profil',
|
||||
filters: [ {name: 'Profils Pitaya', extensions: ['json'] } ]
|
||||
},
|
||||
function(file) {
|
||||
|
@ -17,6 +17,7 @@ var TreeNode = React.createClass({
|
||||
selectedItem={this.props.selectedItem}
|
||||
onItemClicked={this.props.onItemClicked}
|
||||
onItemMoved={this.props.onItemMoved}
|
||||
onItemRemoved={this.props.onItemRemoved}
|
||||
theme={this.props.theme} />
|
||||
</li>
|
||||
);
|
||||
@ -66,6 +67,7 @@ var ProfileTree = React.createClass({
|
||||
selectedItem={this.props.selectedItem}
|
||||
onItemClicked={this.onItemSelected}
|
||||
onItemMoved={this.onItemMoved}
|
||||
onItemRemoved={this.onItemRemoved}
|
||||
theme={this.props.theme} />
|
||||
);
|
||||
},
|
||||
@ -76,6 +78,10 @@ var ProfileTree = React.createClass({
|
||||
|
||||
onItemSelected: function(selectedItem) {
|
||||
this.props.dispatch(actions.edit.selectProfileItem(selectedItem));
|
||||
},
|
||||
|
||||
onItemRemoved: function(selectedItem) {
|
||||
this.props.dispatch(actions.edit.removeProfileItem(selectedItem));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -30,6 +30,9 @@ var TreeItem = React.createClass({
|
||||
<div className={classes} style={style} onClick={this.handleClick}>
|
||||
{appIcon}
|
||||
<span className="app-label">{data.label}</span>
|
||||
<button type="button" className="close pull-right" onClick={this.handleRemoveClick}>
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
));
|
||||
|
||||
@ -38,6 +41,11 @@ var TreeItem = React.createClass({
|
||||
handleClick: function(evt) {
|
||||
evt.preventDefault();
|
||||
this.props.onItemClicked(this.props.data);
|
||||
},
|
||||
|
||||
handleRemoveClick: function(evt) {
|
||||
evt.preventDefault();
|
||||
this.props.onItemRemoved(this.props.data);
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user