0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 02:50:28 +01:00

fixed similar topics validator formatting

Dieser Commit ist enthalten in:
Faizaan Gagan 2021-02-15 13:46:19 +05:30
Ursprung 70cc20a919
Commit afbc4e1f57

Datei anzeigen

@ -2,14 +2,13 @@ import WizardFieldValidator from "../../wizard/components/validator";
import { deepMerge } from "discourse-common/lib/object"; import { deepMerge } from "discourse-common/lib/object";
import { observes } from "discourse-common/utils/decorators"; import { observes } from "discourse-common/utils/decorators";
import { cancel, later } from "@ember/runloop"; import { cancel, later } from "@ember/runloop";
import { A } from '@ember/array'; import { A } from "@ember/array";
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
export default WizardFieldValidator.extend({ export default WizardFieldValidator.extend({
similarTopics: [], similarTopics: [],
validate() { validate() {},
},
@observes("field.value") @observes("field.value")
customValidate() { customValidate() {
const lastKeyUp = new Date(); const lastKeyUp = new Date();
@ -30,24 +29,25 @@ export default WizardFieldValidator.extend({
updateSimilarTopics() { updateSimilarTopics() {
this.backendValidate({ this.backendValidate({
title: this.get("field.value"), title: this.get("field.value"),
categories: this.get('validation.categories'), categories: this.get("validation.categories"),
date_after: this.get('validation.date_after') date_after: this.get("validation.date_after"),
}).then((result) => { }).then((result) => {
const similarTopics = A(deepMerge(result['topics'], result['similar_topics'])); const similarTopics = A(
deepMerge(result["topics"], result["similar_topics"])
);
similarTopics.forEach(function (topic, index) { similarTopics.forEach(function (topic, index) {
similarTopics[index] = EmberObject.create(topic); similarTopics[index] = EmberObject.create(topic);
}); });
this.set('similarTopics', similarTopics); this.set("similarTopics", similarTopics);
}); });
}, },
init() { init() {
this._super(...arguments); this._super(...arguments);
}, },
actions: { actions: {
closeMessage() { closeMessage() {
this.set('showMessage', false); this.set("showMessage", false);
} },
} },
}); });