Added manual tag removal

This commit is contained in:
Marcin Kurczewski
2014-11-04 19:26:27 +01:00
parent 78ccff843c
commit 005d857cfb
7 changed files with 42 additions and 3 deletions

View File

@ -45,6 +45,7 @@ App.Auth = function(_, jQuery, util, api, appState, promise) {
editAllComments: 'editAllComments',
deleteOwnComments: 'deleteOwnComments',
deleteAllComments: 'deleteAllComments',
deleteTags: 'deleteTags',
listTags: 'listTags',
massTag: 'massTag',

View File

@ -83,12 +83,14 @@ App.Presenters.TagPresenter = function(
tagCategories: JSON.parse(jQuery('head').attr('data-tag-categories')),
}));
$el.find('.post-list').hide();
$el.find('form').submit(editFormSubmitted);
$el.find('form').submit(function(e) { e.preventDefault(); });
$el.find('form button[name=update]').click(updateButtonClicked);
$el.find('form button[name=delete]').click(deleteButtonClicked);
implicationsTagInput = App.Controls.TagInput($el.find('[name=implications]'));
suggestionsTagInput = App.Controls.TagInput($el.find('[name=suggestions]'));
}
function editFormSubmitted(e) {
function updateButtonClicked(e) {
e.preventDefault();
var $form = $el.find('form');
var formData = {};
@ -121,6 +123,18 @@ App.Presenters.TagPresenter = function(
});
}
function deleteButtonClicked(e) {
if (!window.confirm('Are you sure you want to delete this tag?')) {
return;
}
promise.wait(api.delete('/tags/' + tag.name))
.then(function(response) {
router.navigate('#/tags');
}).fail(function(response) {
window.alert(response.json && response.json.error || 'An error occured.');
});
}
function renderPosts(posts) {
var $target = $el.find('.post-list ul');
_.each(posts, function(post) {