Edit: ajout bouton supression item

This commit is contained in:
2015-10-10 18:44:31 +02:00
parent 2b419997f1
commit 2d003fb75c
6 changed files with 46 additions and 8 deletions

View File

@ -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) {

View 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));
}
});

View File

@ -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>&times;</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);
}
});