REFACTOR: changes from tag synonym feedback
This commit is contained in:
parent
68124caae2
commit
d0e191a9d5
|
@ -1,10 +1,7 @@
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import showModal from "discourse/lib/show-modal";
|
import showModal from "discourse/lib/show-modal";
|
||||||
import {
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
default as discourseComputed,
|
|
||||||
observes
|
|
||||||
} from "discourse-common/utils/decorators";
|
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { reads, and } from "@ember/object/computed";
|
import { reads, and } from "@ember/object/computed";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
|
@ -43,11 +40,9 @@ export default Component.extend({
|
||||||
return isEmpty(tagGroupNames) && isEmpty(categories) && isEmpty(synonyms);
|
return isEmpty(tagGroupNames) && isEmpty(categories) && isEmpty(synonyms);
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("expanded")
|
didInsertElement() {
|
||||||
toggleExpanded() {
|
this._super(...arguments);
|
||||||
if (this.expanded && !this.tagInfo) {
|
|
||||||
this.loadTagInfo();
|
this.loadTagInfo();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loadTagInfo() {
|
loadTagInfo() {
|
||||||
|
@ -68,7 +63,8 @@ export default Component.extend({
|
||||||
result.category_ids.map(id => Category.findById(id))
|
result.category_ids.map(id => Category.findById(id))
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.finally(() => this.set("loading", false));
|
.finally(() => this.set("loading", false))
|
||||||
|
.catch(popupAjaxError);
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -89,7 +85,7 @@ export default Component.extend({
|
||||||
type: "DELETE"
|
type: "DELETE"
|
||||||
})
|
})
|
||||||
.then(() => this.tagInfo.synonyms.removeObject(tag))
|
.then(() => this.tagInfo.synonyms.removeObject(tag))
|
||||||
.catch(() => bootbox.alert(I18n.t("generic_error")));
|
.catch(popupAjaxError);
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteSynonym(tag) {
|
deleteSynonym(tag) {
|
||||||
|
@ -101,7 +97,7 @@ export default Component.extend({
|
||||||
tag
|
tag
|
||||||
.destroyRecord()
|
.destroyRecord()
|
||||||
.then(() => this.tagInfo.synonyms.removeObject(tag))
|
.then(() => this.tagInfo.synonyms.removeObject(tag))
|
||||||
.catch(() => bootbox.alert(I18n.t("generic_error")));
|
.catch(popupAjaxError);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{{#if expanded}}
|
<section class="tag-info">
|
||||||
<section class="tag-info">
|
|
||||||
{{#if tagInfo}}
|
{{#if tagInfo}}
|
||||||
<div class="tag-name">
|
<div class="tag-name">
|
||||||
{{discourse-tag tagInfo.name tagName="div" size="large"}}
|
{{discourse-tag tagInfo.name tagName="div" size="large"}}
|
||||||
|
@ -45,7 +44,6 @@
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix" />
|
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if editSynonymsMode}}
|
{{#if editSynonymsMode}}
|
||||||
|
@ -69,5 +67,4 @@
|
||||||
{{#if loading}}
|
{{#if loading}}
|
||||||
<div>{{i18n 'loading'}}</div>
|
<div>{{i18n 'loading'}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if showToggleInfo}}
|
{{#if showInfo}}
|
||||||
{{tag-info tag=tag expanded=showInfo list=list deleteAction=(action "deleteTag")}}
|
{{tag-info tag=tag list=list deleteAction=(action "deleteTag")}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{plugin-outlet name="discovery-list-container-top"}}
|
{{plugin-outlet name="discovery-list-container-top"}}
|
||||||
|
|
|
@ -280,6 +280,7 @@ header .discourse-tag {
|
||||||
.add-synonyms,
|
.add-synonyms,
|
||||||
.tag-associations {
|
.tag-associations {
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
|
clear: both;
|
||||||
}
|
}
|
||||||
.tag-list {
|
.tag-list {
|
||||||
border: none;
|
border: none;
|
||||||
|
|
Loading…
Reference in New Issue