mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-21 16:11:29 +00:00
Added delete button to the edit page
This commit is contained in:
@@ -25,11 +25,9 @@ var HomebrewAdmin = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
deleteBrew : function(brewId){
|
deleteBrew : function(brewId){
|
||||||
console.log('removing');
|
|
||||||
request.get('/homebrew/remove/' + brewId +'?admin_key=' + this.props.admin_key)
|
request.get('/homebrew/remove/' + brewId +'?admin_key=' + this.props.admin_key)
|
||||||
.send()
|
.send()
|
||||||
.end(function(err, res){
|
.end(function(err, res){
|
||||||
console.log('DONE');
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ var React = require('react');
|
|||||||
var _ = require('lodash');
|
var _ = require('lodash');
|
||||||
var cx = require('classnames');
|
var cx = require('classnames');
|
||||||
var Moment = require('moment');
|
var Moment = require('moment');
|
||||||
|
var request = require('superagent')
|
||||||
|
|
||||||
var Logo = require('naturalCrit/logo/logo.jsx');
|
var Logo = require('naturalCrit/logo/logo.jsx');
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ var Statusbar = React.createClass({
|
|||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
//editId: null,
|
editId: null,
|
||||||
sourceText : null,
|
sourceText : null,
|
||||||
shareId : null,
|
shareId : null,
|
||||||
printId : null,
|
printId : null,
|
||||||
@@ -38,14 +39,22 @@ var Statusbar = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
deleteBrew : 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('/homebrew/remove/' + this.props.editId)
|
||||||
|
.send()
|
||||||
|
.end(function(err, res){
|
||||||
|
window.location.href = '/homebrew';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
openSourceWindow : function(){
|
openSourceWindow : function(){
|
||||||
var sourceWindow = window.open();
|
var sourceWindow = window.open();
|
||||||
|
|
||||||
var content = replaceAll(this.props.sourceText, '<', '<');
|
var content = replaceAll(this.props.sourceText, '<', '<');
|
||||||
content = replaceAll(content, '>', '>');
|
content = replaceAll(content, '>', '>');
|
||||||
|
|
||||||
console.log(content);
|
|
||||||
|
|
||||||
sourceWindow.document.write('<code><pre>' + content + '</pre></code>');
|
sourceWindow.document.write('<code><pre>' + content + '</pre></code>');
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -97,6 +106,15 @@ var Statusbar = React.createClass({
|
|||||||
</a>
|
</a>
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderDeleteButton : function(){
|
||||||
|
if(!this.props.editId) return null;
|
||||||
|
|
||||||
|
|
||||||
|
return <div className='deleteButton' onClick={this.deleteBrew}>
|
||||||
|
Delete <i className='fa fa-trash' />
|
||||||
|
</div>
|
||||||
|
},
|
||||||
|
|
||||||
renderStatus : function(){
|
renderStatus : function(){
|
||||||
if(!this.props.editId) return null;
|
if(!this.props.editId) return null;
|
||||||
|
|
||||||
@@ -123,6 +141,7 @@ var Statusbar = React.createClass({
|
|||||||
{this.renderStatus()}
|
{this.renderStatus()}
|
||||||
{this.renderInfo()}
|
{this.renderInfo()}
|
||||||
{this.renderSourceButton()}
|
{this.renderSourceButton()}
|
||||||
|
{this.renderDeleteButton()}
|
||||||
{this.renderPrintButton()}
|
{this.renderPrintButton()}
|
||||||
{this.renderShare()}
|
{this.renderShare()}
|
||||||
{this.renderNewButton()}
|
{this.renderNewButton()}
|
||||||
|
|||||||
@@ -58,6 +58,15 @@
|
|||||||
background-color : fade(@green, 70%);
|
background-color : fade(@green, 70%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.deleteButton{
|
||||||
|
.animate(background-color);
|
||||||
|
color : white;
|
||||||
|
text-decoration : none;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover{
|
||||||
|
background-color : fade(@red, 70%);
|
||||||
|
}
|
||||||
|
}
|
||||||
.shareField{
|
.shareField{
|
||||||
.animate(background-color);
|
.animate(background-color);
|
||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ module.exports = function(app){
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.get('/homebrew/remove/:id', function(req, res){
|
app.get('/homebrew/remove/:id', function(req, res){
|
||||||
if(req.query && req.query.admin_key == process.env.ADMIN_KEY){
|
//if(req.query && req.query.admin_key == process.env.ADMIN_KEY){
|
||||||
HomebrewModel.find({editId : req.params.id}, function(err, objs){
|
HomebrewModel.find({editId : req.params.id}, function(err, objs){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
if(!objs.length || err) return res.status(404).send("Can not find homebrew with that id");
|
if(!objs.length || err) return res.status(404).send("Can not find homebrew with that id");
|
||||||
@@ -53,9 +53,9 @@ module.exports = function(app){
|
|||||||
return res.status(200).send();
|
return res.status(200).send();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}else{
|
//}else{
|
||||||
return res.status(401).send('Access denied');
|
// return res.status(401).send('Access denied');
|
||||||
}
|
//}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/homebrew/clear', function(req, res){
|
app.get('/homebrew/clear', function(req, res){
|
||||||
|
|||||||
Reference in New Issue
Block a user