URL can now be removed when editing a post

This commit is contained in:
Sacha Greif 2014-11-18 10:27:58 +09:00
parent 3141c204c2
commit bf90eedf37
2 changed files with 10 additions and 4 deletions

View file

@ -4,6 +4,7 @@
* Updating to Iron Router 1.0.
* Adding view counter (thanks @steffenstraetz! See [PR #489](https://github.com/TelescopeJS/Telescope/pull/489))
* Splitting out `router.js` in multiple files.
* URL can now be removed when editing a post (thanks @massimilianomarini! See [PR 484](https://github.com/TelescopeJS/Telescope/pull/484)).
## v0.9.8

View file

@ -80,6 +80,7 @@ Template[getTemplate('post_edit')].events({
},
'click input[type=submit]': function(e, instance){
var post = this;
var updateObject = {};
e.preventDefault();
@ -107,6 +108,9 @@ Template[getTemplate('post_edit')].events({
var url = $('#url').val();
if(!!url){
properties.url = (url.substring(0, 7) == "http://" || url.substring(0, 8) == "https://") ? url : "http://"+url;
} else {
// if URL is empty, unset it
updateObject.$unset = {url: ""};
}
// ShortURL
@ -175,10 +179,11 @@ Template[getTemplate('post_edit')].events({
// ------------------------------ Update ------------------------------ //
if (properties) {
Posts.update(post._id,{
$set: properties
}, function(error){
if (properties) {
updateObject.$set = properties;
Posts.update(post._id, updateObject, function(error){
if(error){
console.log(error);
throwError(error.reason);