diff --git a/TODO b/TODO index 1747b543..9a36ba57 100644 --- a/TODO +++ b/TODO @@ -24,7 +24,6 @@ everything related to users: everything related to tags: - tags.json refresh when editing post - basic tags - - mass tag - merging - tag editing - name diff --git a/data/config.ini b/data/config.ini index ba628486..be888d38 100644 --- a/data/config.ini +++ b/data/config.ini @@ -56,6 +56,7 @@ changePostRelations = regularUser, powerUser, moderator, administrator changePostFlags = regularUser, powerUser, moderator, administrator listTags = anonymous, regularUser, powerUser, moderator, administrator +massTag = powerUser, moderator, administrator listComments = anonymous, regularUser, powerUser, moderator, administrator addComments = regularUser, powerUser, moderator, administrator diff --git a/public_html/css/post-list.css b/public_html/css/post-list.css index cfa84c04..af9fe988 100644 --- a/public_html/css/post-list.css +++ b/public_html/css/post-list.css @@ -23,6 +23,9 @@ justify-content: center; } +.post-small { + position: relative; +} .post-small a { display: inline-block; margin: 0.4em; @@ -112,3 +115,42 @@ .post-small.post-type-flash a:after { content: 'flash'; } + +.post-small .action { + display: none; + position: absolute; + z-index: 3; + left: 0; + right: 0; + top: 50%; + bottom: 0; +} + +.post-small .action button { + padding: 0.5em 1em; + height: 1em; + line-height: 1em; + display: block; + margin: -1em auto 0 auto; + box-sizing: content-box; + opacity: .7; +} + +.tagged .action button, +.untagged .action button { + border: 1px solid black; + font-weight: bold; + box-shadow: none; +} +.untagged .action button { + background: red; + color: white; +} +.tagged .action button { + background: lime; + color: black; +} +.untagged .post-small img, +.tagged .post-small img { + opacity: .85; +} diff --git a/public_html/js/Auth.js b/public_html/js/Auth.js index 993cd6cc..152de6b8 100644 --- a/public_html/js/Auth.js +++ b/public_html/js/Auth.js @@ -42,6 +42,7 @@ App.Auth = function(_, jQuery, util, api, appState, promise) { deleteAllComments: 'deleteAllComments', listTags: 'listTags', + massTag: 'massTag', viewHistory: 'viewHistory', }; diff --git a/public_html/js/Pager.js b/public_html/js/Pager.js index a9803f93..bdc6ef9d 100644 --- a/public_html/js/Pager.js +++ b/public_html/js/Pager.js @@ -57,7 +57,7 @@ App.Pager = function( function retrieve() { return promise.make(function(resolve, reject) { - promise.wait(api.get(url, _.extend({page: pageNumber}, searchParams))) + promise.wait(api.get(url, _.extend({}, searchParams, {page: pageNumber}))) .then(function(response) { var pageSize = response.json.pageSize; var totalRecords = response.json.totalRecords; diff --git a/public_html/js/Presenters/PostListPresenter.js b/public_html/js/Presenters/PostListPresenter.js index f454add7..6b8db18f 100644 --- a/public_html/js/Presenters/PostListPresenter.js +++ b/public_html/js/Presenters/PostListPresenter.js @@ -7,6 +7,7 @@ App.Presenters.PostListPresenter = function( util, promise, auth, + api, keyboard, pagerPresenter, topNavigationPresenter) { @@ -16,6 +17,7 @@ App.Presenters.PostListPresenter = function( var templates = {}; var $el = jQuery('#content'); var $searchInput; + var privileges = {}; var params; @@ -25,6 +27,8 @@ App.Presenters.PostListPresenter = function( params = _params; params.query = params.query || {}; + privileges.canMassTag = auth.hasPrivilege(auth.privileges.massTag); + promise.wait( util.promiseTemplate('post-list'), util.promiseTemplate('post-list-item')) @@ -52,6 +56,7 @@ App.Presenters.PostListPresenter = function( function reinit(params, loaded) { pagerPresenter.reinit({query: params.query}); loaded(); + softRender(); } function deinit() { @@ -59,13 +64,14 @@ App.Presenters.PostListPresenter = function( } function render() { - $el.html(templates.list()); + $el.html(templates.list({massTag: params.query.massTag, privileges: privileges})); $searchInput = $el.find('input[name=query]'); App.Controls.AutoCompleteInput($searchInput); $searchInput.val(params.query.query); $searchInput.keydown(searchInputKeyPressed); $el.find('form').submit(searchFormSubmitted); + $el.find('[name=mass-tag]').click(massTagButtonClicked); keyboard.keyup('p', function() { $el.find('.posts li a').eq(0).focus(); @@ -76,6 +82,19 @@ App.Presenters.PostListPresenter = function( }); } + function softRender() { + $searchInput.val(params.query.query); + + var $massTagInfo = $el.find('.mass-tag-info'); + if (params.query.massTag) { + $massTagInfo.show(); + $massTagInfo.find('span').text(params.query.massTag); + } else { + $massTagInfo.hide(); + } + _.map($el.find('.posts .post-small'), function(postNode) { softRenderPost(jQuery(postNode).parents('li')); }); + } + function renderPosts(posts, clear) { var $target = $el.find('.posts'); @@ -84,16 +103,62 @@ App.Presenters.PostListPresenter = function( } _.each(posts, function(post) { - var $post = jQuery('
Tagging with <%= massTag %>
+