Node.js based forum software built for the modern web
Fix maximumTagsPerTopic
yaripluse112190bee3c
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.jsindex 4bcdffff5d..1e32892617 100644--- a/public/src/modules/composer.js+++ b/public/src/modules/composer.js@@ -497,8 +497,6 @@ define('composer', [return composerAlert(post_uuid, '[[error:title-too-long, ' + config.maximumTitleLength + ']]');} else if (checkTitle && !utils.slugify(titleEl.val()).length) {return composerAlert(post_uuid, '[[error:invalid-title]]');- } else if (checkTitle && tags.getTags(post_uuid) && tags.getTags(post_uuid).length < parseInt(config.minimumTagsPerTopic, 10)) {- return composerAlert(post_uuid, '[[error:not-enough-tags]]');} else if (bodyEl.val().length < parseInt(config.minimumPostLength, 10)) {return composerAlert(post_uuid, '[[error:content-too-short, ' + config.minimumPostLength + ']]');} else if (bodyEl.val().length > parseInt(config.maximumPostLength, 10)) {diff --git a/public/src/modules/composer/tags.js b/public/src/modules/composer/tags.jsindex ab2d9effb4..8e516e83b8 100644--- a/public/src/modules/composer/tags.js+++ b/public/src/modules/composer/tags.js@@ -13,7 +13,6 @@ define('composer/tags', function() {}tagEl.tagsinput({- minTags: config.minimumTagsPerTopic,maxTags: config.tagsPerTopic,maxChars: config.maximumTagLength,confirmKeys: [13, 44],diff --git a/src/controllers/api.js b/src/controllers/api.jsindex 20b0b1978f..5518addd45 100644--- a/src/controllers/api.js+++ b/src/controllers/api.js@@ -56,7 +56,7 @@ apiController.getConfig = function(req, res, next) {config.maxReconnectionAttempts = meta.config.maxReconnectionAttempts || 5;config.reconnectionDelay = meta.config.reconnectionDelay || 1500;config.minimumTagsPerTopic = meta.config.minimumTagsPerTopic || 0;- config.tagsPerTopic = meta.config.tagsPerTopic || 5;+ config.maximumTagsPerTopic = meta.config.maximumTagsPerTopic || 5;config.minimumTagLength = meta.config.minimumTagLength || 3;config.maximumTagLength = meta.config.maximumTagLength || 15;config.topicsPerPage = meta.config.topicsPerPage || 20;diff --git a/src/topics/create.js b/src/topics/create.jsindex 5d0ca7b34f..bfec57e491 100644--- a/src/topics/create.js+++ b/src/topics/create.js@@ -296,6 +296,8 @@ module.exports = function(Topics) {function checkTagsLength(tags, callback) {if (!tags || tags.length < parseInt(meta.config.minimumTagsPerTopic, 10)) {return callback(new Error('[[error:not-enough-tags, ' + meta.config.minimumTagsPerTopic + ']]'));+ } else if (tags.length > parseInt(meta.config.maximumTagsPerTopic, 10)) {+ return callback(new Error('[[error:too-many-tags, ' + meta.config.maximumTagsPerTopic + ']]'));}callback();}diff --git a/src/topics/tags.js b/src/topics/tags.jsindex f19738b315..dfbdf5ab03 100644--- a/src/topics/tags.js+++ b/src/topics/tags.js@@ -23,7 +23,7 @@ module.exports = function(Topics) {return callback(err);}- tags = data.tags.slice(0, meta.config.tagsPerTopic || 5);+ tags = data.tags.slice(0, meta.config.maximumTagsPerTopic || 5);async.each(tags, function(tag, next) {tag = Topics.cleanUpTag(tag);diff --git a/src/views/admin/settings/tags.tpl b/src/views/admin/settings/tags.tplindex 65f3b22d06..857080ddcf 100644--- a/src/views/admin/settings/tags.tpl+++ b/src/views/admin/settings/tags.tpl@@ -14,8 +14,8 @@<input id="minimumTagsPerTopics" type="text" class="form-control" value="0" data-field="minimumTagsPerTopic"></div><div class="form-group">- <label for="tagsPerTopics">Maximum Tags per Topic</label>- <input id="tagsPerTopics" type="text" class="form-control" value="5" data-field="tagsPerTopic">+ <label for="maximumTagsPerTopics">Maximum Tags per Topic</label>+ <input id="maximumTagsPerTopics" type="text" class="form-control" value="5" data-field="maximumTagsPerTopic"></div><div class="form-group"><label for="minimumTagLength">Minimum Tag Length</label>