Added tag list refreshing on tag edits

Result: suggestions etc. gets updated without the need to refresh the
page
This commit is contained in:
Marcin Kurczewski 2014-11-03 13:08:58 +01:00
parent 703cc4724a
commit 150d585860
4 changed files with 20 additions and 14 deletions

1
TODO
View file

@ -5,7 +5,6 @@ first major release.
- posts/upload: ability to paste many urls (unsure)
- posts/listing: add buttons for toggling safety
- users: add user-configurable "about me" (should support Markdown)
- tags: refresh tags.json when editing post
- tags: add tag merging
- tags: add tag descriptions
- tags: add tag edit snapshots (backed-only)

View file

@ -5,7 +5,8 @@ App.Presenters.PostEditPresenter = function(
util,
promise,
api,
auth) {
auth,
tagList) {
var $target;
var post;
@ -132,6 +133,7 @@ App.Presenters.PostEditPresenter = function(
promise.wait(api.put('/posts/' + post.id, formData))
.then(function(response) {
tagList.refreshTags();
if (typeof(updateCallback) !== 'undefined') {
updateCallback(post = response.json);
}
@ -153,4 +155,4 @@ App.Presenters.PostEditPresenter = function(
};
App.DI.register('postEditPresenter', ['util', 'promise', 'api', 'auth'], App.Presenters.PostEditPresenter);
App.DI.register('postEditPresenter', ['util', 'promise', 'api', 'auth', 'tagList'], App.Presenters.PostEditPresenter);

View file

@ -8,6 +8,7 @@ App.Presenters.TagPresenter = function(
promise,
auth,
api,
tagList,
router,
keyboard,
topNavigationPresenter,
@ -117,6 +118,7 @@ App.Presenters.TagPresenter = function(
tag = response.json;
render();
renderPosts(posts);
tagList.refreshTags();
}).fail(function(response) {
window.alert(response.json && response.json.error || 'An error occured.');
});
@ -147,4 +149,4 @@ App.Presenters.TagPresenter = function(
};
App.DI.register('tagPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'api', 'router', 'keyboard', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.TagPresenter);
App.DI.register('tagPresenter', ['_', 'jQuery', 'util', 'promise', 'auth', 'api', 'tagList', 'router', 'keyboard', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.TagPresenter);

View file

@ -4,6 +4,7 @@ App.Services = App.Services || {};
App.Services.TagList = function(jQuery) {
var tags = [];
function refreshTags() {
jQuery.ajax({
success: function(data, textStatus, xhr) {
tags = data;
@ -14,12 +15,14 @@ App.Services.TagList = function(jQuery) {
type: 'GET',
url: '/data/tags.json',
});
}
function getTags() {
return tags;
}
return {
refreshTags: refreshTags,
getTags: getTags,
};
};