A platform for community discussion. Free, open, simple.
UX: add confirmation when adding tag synonyms
Neil Lalondeb63d146128bc
diff --git a/app/assets/javascripts/discourse/components/tag-info.js.es6 b/app/assets/javascripts/discourse/components/tag-info.js.es6index 6421f47f593..5f2d0e7d6c5 100644--- a/app/assets/javascripts/discourse/components/tag-info.js.es6+++ b/app/assets/javascripts/discourse/components/tag-info.js.es6@@ -98,27 +98,37 @@ export default Component.extend({},addSynonyms() {- ajax(`/tag/${this.tagInfo.name}/synonyms`, {- type: "POST",- data: {- synonyms: this.newSynonyms+ bootbox.confirm(+ I18n.t("tagging.add_synonyms_explanation", {+ count: this.newSynonyms.length,+ tag_name: this.tagInfo.name+ }),+ result => {+ if (!result) return;++ ajax(`/tag/${this.tagInfo.name}/synonyms`, {+ type: "POST",+ data: {+ synonyms: this.newSynonyms+ }+ })+ .then(response => {+ if (response.success) {+ this.set("newSynonyms", null);+ this.loadTagInfo();+ } else if (response.failed_tags) {+ bootbox.alert(+ I18n.t("tagging.add_synonyms_failed", {+ tag_names: Object.keys(response.failed_tags).join(", ")+ })+ );+ } else {+ bootbox.alert(I18n.t("generic_error"));+ }+ })+ .catch(popupAjaxError);}- })- .then(result => {- if (result.success) {- this.set("newSynonyms", null);- this.loadTagInfo();- } else if (result.failed_tags) {- bootbox.alert(- I18n.t("tagging.add_synonyms_failed", {- tag_names: Object.keys(result.failed_tags).join(", ")- })- );- } else {- bootbox.alert(I18n.t("generic_error"));- }- })- .catch(popupAjaxError);+ );}}});diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 697ae7fb80f..b447c667577 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3107,6 +3107,9 @@ en:edit_synonyms: "Manage Synonyms"add_synonyms_label: "Add synonyms:"add_synonyms: "Add"+ add_synonyms_explanation:+ one: "Any place that currently uses this tag will be changed to use <b>%{tag_name}</b> instead. Are you sure you want to make this change?"+ other: "Any place that currently uses these tags will be changed to use <b>%{tag_name}</b> instead. Are you sure you want to make this change?"add_synonyms_failed: "The following tags couldn't be added as synonyms: <b>%{tag_names}</b>. Ensure they don't have synonyms and aren't synonyms of another tag."remove_synonym: "Remove Synonym"delete_synonym_confirm: 'Are you sure you want to delete the synonym "%{tag_name}"?'