mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 18:32:41 +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
|
||||
- Metadata can now be added to brews
|
||||
- Added a metadata editor onto the edit and new pages
|
||||
- Moved deleting a brew into the metadata editor
|
||||
|
||||
|
||||
### Monday, 14/11/2016
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const React = require('react');
|
||||
const _ = require('lodash');
|
||||
const cx = require('classnames');
|
||||
const request = require("superagent");
|
||||
|
||||
const SYSTEMS = ['5e', '4e', '3.5e', 'Pathfinder']
|
||||
|
||||
@@ -8,6 +9,7 @@ const MetadataEditor = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
metadata: {
|
||||
editId : null,
|
||||
title : '',
|
||||
description : '',
|
||||
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(){
|
||||
return _.map(SYSTEMS, (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(){
|
||||
console.log(this.props.metadata);
|
||||
|
||||
|
||||
return <div className='metadataEditor'>
|
||||
|
||||
<div className='field title'>
|
||||
@@ -99,6 +128,8 @@ const MetadataEditor = React.createClass({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{this.renderDelete()}
|
||||
|
||||
</div>
|
||||
}
|
||||
});
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
}
|
||||
.publish.field .value{
|
||||
position : relative;
|
||||
margin-bottom: 15px;
|
||||
button.publish{
|
||||
.button(@blueLight);
|
||||
}
|
||||
@@ -60,4 +61,10 @@
|
||||
font-style : italic;
|
||||
}
|
||||
}
|
||||
|
||||
.delete.field .value{
|
||||
button{
|
||||
.button(@red);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,12 +78,14 @@ const EditPage = React.createClass({
|
||||
|
||||
handleControlKeys : function(e){
|
||||
if(!(e.ctrlKey || e.metaKey)) return;
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
const S_KEY = 83;
|
||||
const P_KEY = 80;
|
||||
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 || e.keyCode == S_KEY){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
handleSplitMove : function(){
|
||||
@@ -116,17 +118,6 @@ const EditPage = React.createClass({
|
||||
(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(){
|
||||
if(this.savedBrew){
|
||||
return !_.isEqual(this.state.brew, this.savedBrew)
|
||||
@@ -205,9 +196,6 @@ const EditPage = React.createClass({
|
||||
Share
|
||||
</Nav.item>
|
||||
<PrintLink shareId={this.props.brew.shareId} />
|
||||
<Nav.item color='red' icon='fa-trash' onClick={this.handleDelete}>
|
||||
Delete
|
||||
</Nav.item>
|
||||
</Nav.section>
|
||||
</Navbar>
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user