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

FIX: various fixes for realtime validations feature

See further https://coop.pavilion.tech/t/similar-posts-category-picker-not-working/3513
Dieser Commit ist enthalten in:
Angus McLeod 2024-05-02 14:57:56 +02:00
Ursprung f066ff938e
Commit 0d0fb83bd1
6 geänderte Dateien mit 17 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { equal } from "@ember/object/computed"; import { equal } from "@ember/object/computed";
import { ajax, getToken } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
export default Component.extend({ export default Component.extend({
classNames: ["validator"], classNames: ["validator"],
@ -20,7 +20,6 @@ export default Component.extend({
return ajax("/realtime-validations", { return ajax("/realtime-validations", {
data: { data: {
type: this.get("type"), type: this.get("type"),
authenticity_token: getToken(),
...params, ...params,
}, },
}); });

Datei anzeigen

@ -35,13 +35,12 @@ export default Component.extend({
} }
const validationBuffer = cloneJSON(this.get("field.validations")); const validationBuffer = cloneJSON(this.get("field.validations"));
let bufferCategories; let bufferCategories = validationBuffer.similar_topics?.categories || [];
if ( if (bufferCategories) {
validationBuffer.similar_topics && validationBuffer.similar_topics.categories =
(bufferCategories = validationBuffer.similar_topics.categories) Category.findByIds(bufferCategories);
) { } else {
const categories = Category.findByIds(bufferCategories); validationBuffer.similar_topics.categories = [];
validationBuffer.similar_topics.categories = categories;
} }
this.set("validationBuffer", validationBuffer); this.set("validationBuffer", validationBuffer);
}, },

Datei anzeigen

@ -1,6 +1,6 @@
<a href={{topic.url}} target="_blank" rel="noopener noreferrer"> <a href={{topic.url}} target="_blank" rel="noopener noreferrer">
<span class="title">{{html-safe topic.fancy_title}}</span> <span class="title">{{html-safe topic.fancy_title}}</span>
<div class="blurb">{{date-node topic.created_at}} <div class="blurb"><RelativeDate @date={{@topic.created_at}} />
- -
{{html-safe topic.blurb}}</div> {{html-safe topic.blurb}}</div>
</a> </a>

Datei anzeigen

@ -18,13 +18,14 @@
}}</label> }}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{category-selector <CategorySelector
categories=(get @categories={{get
this (concat "validationBuffer." type ".categories") this
) (concat "validationBuffer." type ".categories")
onChange=(action "updateValidationCategories" type props) }}
@onChange={{action "updateValidationCategories" type props}}
class="wizard" class="wizard"
}} />
</div> </div>
</div> </div>
<div class="validation-section"> <div class="validation-section">

Datei anzeigen

@ -27,7 +27,7 @@ class CustomWizard::RealtimeValidation::SimilarTopics
result = CustomWizard::RealtimeValidation::Result.new(:similar_topic) result = CustomWizard::RealtimeValidation::Result.new(:similar_topic)
if title.length < SiteSetting.min_title_similar_length || !Topic.count_exceeds_minimum? if title.length < SiteSetting.min_title_similar_length
return result return result
end end

Datei anzeigen

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
# name: discourse-custom-wizard # name: discourse-custom-wizard
# about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more. # about: Forms for Discourse. Better onboarding, structured posting, data enrichment, automated actions and much more.
# version: 2.6.7 # version: 2.6.8
# authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos # authors: Angus McLeod, Faizaan Gagan, Robert Barrow, Keegan George, Kaitlin Maddever, Juan Marcos Gutierrez Ramos
# url: https://github.com/paviliondev/discourse-custom-wizard # url: https://github.com/paviliondev/discourse-custom-wizard
# contact_emails: development@pavilion.tech # contact_emails: development@pavilion.tech