mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 08:53:41 +08:00
FIX: allows to use icon-picker in wizard (#13786)
- inlines dasherize helper in sk - uses an ajax helper to load wizard's ajax lib when in wizard - amends wizard's ajax lib to work with string as first arg - disabled loading spinner in wizard as it's not available
This commit is contained in:
parent
4da0a33524
commit
519528daa2
|
@ -4,10 +4,10 @@ import {
|
|||
enableMissingIconWarning,
|
||||
} from "discourse-common/lib/icon-library";
|
||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { computed } from "@ember/object";
|
||||
import { isDevelopment } from "discourse-common/config/environment";
|
||||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
import { ajax } from "select-kit/lib/ajax-helper";
|
||||
|
||||
export default MultiSelectComponent.extend({
|
||||
pluginApiIdentifiers: ["icon-picker"],
|
||||
|
|
|
@ -69,6 +69,10 @@ export default Component.extend(UtilsMixin, {
|
|||
);
|
||||
}),
|
||||
|
||||
dasherizedTitle: computed("title", function () {
|
||||
return (this.title || "").replace(".", "-").dasherize();
|
||||
}),
|
||||
|
||||
label: computed("rowLabel", "item.label", "title", "rowName", function () {
|
||||
const label =
|
||||
this.rowLabel ||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
let ajax;
|
||||
if (window.Discourse) {
|
||||
ajax = requirejs("discourse/lib/ajax").ajax;
|
||||
} else {
|
||||
ajax = requirejs("wizard/lib/ajax").ajax;
|
||||
}
|
||||
|
||||
export { ajax };
|
|
@ -1,6 +1,6 @@
|
|||
import I18n from "I18n";
|
||||
import Mixin from "@ember/object/mixin";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { ajax } from "select-kit/lib/ajax-helper";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
|
|
|
@ -10,7 +10,9 @@
|
|||
{{#select-kit/select-kit-body selectKit=selectKit id=(concat selectKit.uniqueID "-body")}}
|
||||
{{#if selectKit.isLoading}}
|
||||
<span class="is-loading">
|
||||
{{loading-spinner size="small"}}
|
||||
{{#if site}}
|
||||
{{loading-spinner size="small"}}
|
||||
{{/if}}
|
||||
</span>
|
||||
{{else}}
|
||||
{{#if selectKit.filter}}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{#each icons as |icon|}}
|
||||
{{d-icon icon translatedtitle=(dasherize title)}}
|
||||
{{d-icon icon translatedtitle=dasherizedTitle}}
|
||||
{{/each}}
|
||||
|
||||
<span class="name">
|
||||
|
|
|
@ -14,11 +14,20 @@ export function getToken() {
|
|||
}
|
||||
|
||||
export function ajax(args) {
|
||||
let url;
|
||||
|
||||
if (arguments.length === 2) {
|
||||
url = arguments[0];
|
||||
args = arguments[1];
|
||||
} else {
|
||||
url = args.url;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
args.headers = { "X-CSRF-Token": getToken() };
|
||||
args.success = (data) => run(null, resolve, data);
|
||||
args.error = (xhr) => run(null, reject, xhr);
|
||||
args.url = getUrl(args.url);
|
||||
args.url = getUrl(url);
|
||||
jQuery.ajax(args);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user