Edit: ajout bouton supression item
This commit is contained in:
parent
2b419997f1
commit
2d003fb75c
|
@ -35,7 +35,7 @@ Vous pouvez configurer le comportement de Pitaya en passant des variables d'envi
|
|||
npm run build
|
||||
```
|
||||
|
||||
Un dossier `pitaya-<version>-<target>-<arch>` sera créé dans le répertoire `./build`. Celui ci contient tous les fichiers nécessaires à l'application.
|
||||
Un dossier `pitaya-<target>-<arch>` sera créé dans le répertoire `./build`. Celui ci contient tous les fichiers nécessaires à l'application.
|
||||
|
||||
|
||||
## Comment contribuer
|
||||
|
|
|
@ -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,9 +32,8 @@ 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) {
|
||||
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);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ var SAVE_PROFILE_FAILED = exports.SAVE_PROFILE_FAILED = 'SAVE_PROFILE_FAILED';
|
|||
|
||||
var MOVE_PROFILE_ITEM = exports.MOVE_PROFILE_ITEM = 'MOVE_PROFILE_ITEM';
|
||||
var ADD_PROFILE_ITEM = exports.ADD_PROFILE_ITEM = 'ADD_PROFILE_ITEM';
|
||||
var REMOVE_PROFILE_ITEM = exports.REMOVE_PROFILE_ITEM = 'REMOVE_PROFILE_ITEM';
|
||||
var USE_ICON_THEME = exports.USE_ICON_THEME = 'USE_ICON_THEME';
|
||||
var SELECT_PROFILE_ITEM = exports.SELECT_PROFILE_ITEM = 'SELECT_PROFILE_ITEM';
|
||||
var UPDATE_PROFILE_ITEM = exports.UPDATE_PROFILE_ITEM = 'UPDATE_PROFILE_ITEM';
|
||||
|
@ -71,6 +72,13 @@ exports.moveProfileItem = function(movedItem, targetItem) {
|
|||
};
|
||||
};
|
||||
|
||||
exports.removeProfileItem = function(removedItem) {
|
||||
return {
|
||||
type: REMOVE_PROFILE_ITEM,
|
||||
removedItem: removedItem
|
||||
};
|
||||
};
|
||||
|
||||
exports.addProfileItem = function(newItem, targetItem) {
|
||||
return {
|
||||
type: ADD_PROFILE_ITEM,
|
||||
|
|
|
@ -14,6 +14,9 @@ module.exports = function(oldProfile, action) {
|
|||
case actions.edit.MOVE_PROFILE_ITEM:
|
||||
return moveProfileItem(oldProfile, action.movedItem, action.targetItem);
|
||||
|
||||
case actions.edit.REMOVE_PROFILE_ITEM:
|
||||
return removeProfileItem(oldProfile, action.removedItem);
|
||||
|
||||
case actions.edit.ADD_PROFILE_ITEM:
|
||||
return addProfileItem(oldProfile, action.newItem, action.targetItem);
|
||||
|
||||
|
@ -48,6 +51,18 @@ function updateProfileItem(oldProfile, targetItem, key, value) {
|
|||
return newProfile;
|
||||
}
|
||||
|
||||
function removeProfileItem(oldProfile, removedItem) {
|
||||
|
||||
var newProfile = _.cloneDeep(oldProfile);
|
||||
var parent = tree.find(newProfile, removedItem).parent;
|
||||
|
||||
parent.items = _.reject(parent.items, function(item) {
|
||||
return _.isEqual(item, removedItem);
|
||||
});
|
||||
|
||||
return newProfile;
|
||||
|
||||
}
|
||||
|
||||
function moveProfileItem(oldProfile, movedItem, targetItem) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue