REFACTOR: changes from tag synonym feedback

This commit is contained in:
Neil Lalonde 2019-12-06 15:42:06 -05:00
parent 68124caae2
commit d0e191a9d5
4 changed files with 76 additions and 82 deletions

View File

@ -1,10 +1,7 @@
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import showModal from "discourse/lib/show-modal";
import {
default as discourseComputed,
observes
} from "discourse-common/utils/decorators";
import { default as discourseComputed } from "discourse-common/utils/decorators";
import Component from "@ember/component";
import { reads, and } from "@ember/object/computed";
import { isEmpty } from "@ember/utils";
@ -43,11 +40,9 @@ export default Component.extend({
return isEmpty(tagGroupNames) && isEmpty(categories) && isEmpty(synonyms);
},
@observes("expanded")
toggleExpanded() {
if (this.expanded && !this.tagInfo) {
didInsertElement() {
this._super(...arguments);
this.loadTagInfo();
}
},
loadTagInfo() {
@ -68,7 +63,8 @@ export default Component.extend({
result.category_ids.map(id => Category.findById(id))
);
})
.finally(() => this.set("loading", false));
.finally(() => this.set("loading", false))
.catch(popupAjaxError);
},
actions: {
@ -89,7 +85,7 @@ export default Component.extend({
type: "DELETE"
})
.then(() => this.tagInfo.synonyms.removeObject(tag))
.catch(() => bootbox.alert(I18n.t("generic_error")));
.catch(popupAjaxError);
},
deleteSynonym(tag) {
@ -101,7 +97,7 @@ export default Component.extend({
tag
.destroyRecord()
.then(() => this.tagInfo.synonyms.removeObject(tag))
.catch(() => bootbox.alert(I18n.t("generic_error")));
.catch(popupAjaxError);
}
);
},

View File

@ -1,5 +1,4 @@
{{#if expanded}}
<section class="tag-info">
<section class="tag-info">
{{#if tagInfo}}
<div class="tag-name">
{{discourse-tag tagInfo.name tagName="div" size="large"}}
@ -45,7 +44,6 @@
</div>
{{/each}}
</div>
<div class="clearfix" />
</div>
{{/if}}
{{#if editSynonymsMode}}
@ -69,5 +67,4 @@
{{#if loading}}
<div>{{i18n 'loading'}}</div>
{{/if}}
</section>
{{/if}}
</section>

View File

@ -46,8 +46,8 @@
</div>
</div>
{{#if showToggleInfo}}
{{tag-info tag=tag expanded=showInfo list=list deleteAction=(action "deleteTag")}}
{{#if showInfo}}
{{tag-info tag=tag list=list deleteAction=(action "deleteTag")}}
{{/if}}
{{plugin-outlet name="discovery-list-container-top"}}

View File

@ -280,6 +280,7 @@ header .discourse-tag {
.add-synonyms,
.tag-associations {
margin-top: 1em;
clear: both;
}
.tag-list {
border: none;