mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 04:12:47 +00:00
Moved deleting a brew into the emtadata editor
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
### Wednesday, 23/11/2016 - v2.5.0
|
### Wednesday, 23/11/2016 - v2.5.0
|
||||||
- Metadata can now be added to brews
|
- Metadata can now be added to brews
|
||||||
- Added a metadata editor onto the edit and new pages
|
- Added a metadata editor onto the edit and new pages
|
||||||
|
- Moved deleting a brew into the metadata editor
|
||||||
|
|
||||||
|
|
||||||
### Monday, 14/11/2016
|
### Monday, 14/11/2016
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const cx = require('classnames');
|
const cx = require('classnames');
|
||||||
|
const request = require("superagent");
|
||||||
|
|
||||||
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder']
|
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder']
|
||||||
|
|
||||||
@@ -8,6 +9,7 @@ const MetadataEditor = React.createClass({
|
|||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
metadata: {
|
metadata: {
|
||||||
|
editId : null,
|
||||||
title : '',
|
title : '',
|
||||||
description : '',
|
description : '',
|
||||||
tags : '',
|
tags : '',
|
||||||
@@ -38,6 +40,17 @@ const MetadataEditor = React.createClass({
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleDelete : function(){
|
||||||
|
if(!confirm("are you sure you want to delete this brew?")) return;
|
||||||
|
if(!confirm("are you REALLY sure? You will not be able to recover it")) return;
|
||||||
|
|
||||||
|
request.get('/api/remove/' + this.props.metadata.editId)
|
||||||
|
.send()
|
||||||
|
.end(function(err, res){
|
||||||
|
window.location.href = '/';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
renderSystems : function(){
|
renderSystems : function(){
|
||||||
return _.map(SYSTEMS, (val)=>{
|
return _.map(SYSTEMS, (val)=>{
|
||||||
return <label key={val}>
|
return <label key={val}>
|
||||||
@@ -62,7 +75,23 @@ const MetadataEditor = React.createClass({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderDelete : function(){
|
||||||
|
if(!this.props.metadata.editId) return;
|
||||||
|
|
||||||
|
return <div className='field delete'>
|
||||||
|
<label>delete</label>
|
||||||
|
<div className='value'>
|
||||||
|
<button className='publish' onClick={this.handleDelete}>
|
||||||
|
<i className='fa fa-trash' /> delete brew
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function(){
|
||||||
|
console.log(this.props.metadata);
|
||||||
|
|
||||||
|
|
||||||
return <div className='metadataEditor'>
|
return <div className='metadataEditor'>
|
||||||
|
|
||||||
<div className='field title'>
|
<div className='field title'>
|
||||||
@@ -99,6 +128,8 @@ const MetadataEditor = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{this.renderDelete()}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
}
|
}
|
||||||
.publish.field .value{
|
.publish.field .value{
|
||||||
position : relative;
|
position : relative;
|
||||||
|
margin-bottom: 15px;
|
||||||
button.publish{
|
button.publish{
|
||||||
.button(@blueLight);
|
.button(@blueLight);
|
||||||
}
|
}
|
||||||
@@ -60,4 +61,10 @@
|
|||||||
font-style : italic;
|
font-style : italic;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.delete.field .value{
|
||||||
|
button{
|
||||||
|
.button(@red);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -78,12 +78,14 @@ const EditPage = React.createClass({
|
|||||||
|
|
||||||
handleControlKeys : function(e){
|
handleControlKeys : function(e){
|
||||||
if(!(e.ctrlKey || e.metaKey)) return;
|
if(!(e.ctrlKey || e.metaKey)) return;
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
const S_KEY = 83;
|
const S_KEY = 83;
|
||||||
const P_KEY = 80;
|
const P_KEY = 80;
|
||||||
if(e.keyCode == S_KEY) this.save();
|
if(e.keyCode == S_KEY) this.save();
|
||||||
if(e.keyCode == P_KEY) window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
|
if(e.keyCode == P_KEY) window.open(`/print/${this.props.brew.shareId}?dialog=true`, '_blank').focus();
|
||||||
|
if(e.keyCode == P_KEY || e.keyCode == S_KEY){
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSplitMove : function(){
|
handleSplitMove : function(){
|
||||||
@@ -116,17 +118,6 @@ const EditPage = React.createClass({
|
|||||||
(this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel());
|
(this.hasChanges() ? this.debounceSave() : this.debounceSave.cancel());
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDelete : function(){
|
|
||||||
if(!confirm("are you sure you want to delete this brew?")) return;
|
|
||||||
if(!confirm("are you REALLY sure? You will not be able to recover it")) return;
|
|
||||||
|
|
||||||
request.get('/api/remove/' + this.props.brew.editId)
|
|
||||||
.send()
|
|
||||||
.end(function(err, res){
|
|
||||||
window.location.href = '/';
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
hasChanges : function(){
|
hasChanges : function(){
|
||||||
if(this.savedBrew){
|
if(this.savedBrew){
|
||||||
return !_.isEqual(this.state.brew, this.savedBrew)
|
return !_.isEqual(this.state.brew, this.savedBrew)
|
||||||
@@ -205,9 +196,6 @@ const EditPage = React.createClass({
|
|||||||
Share
|
Share
|
||||||
</Nav.item>
|
</Nav.item>
|
||||||
<PrintLink shareId={this.props.brew.shareId} />
|
<PrintLink shareId={this.props.brew.shareId} />
|
||||||
<Nav.item color='red' icon='fa-trash' onClick={this.handleDelete}>
|
|
||||||
Delete
|
|
||||||
</Nav.item>
|
|
||||||
</Nav.section>
|
</Nav.section>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user