1
0
Fork 0

Merge branch 'main' into subscription_client_update

Dieser Commit ist enthalten in:
Angus McLeod 2023-05-04 17:27:07 +02:00 committet von GitHub
Commit 6be5511d18
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
61 geänderte Dateien mit 739 neuen und 248 gelöschten Zeilen

Datei anzeigen

@ -5,6 +5,8 @@ on:
branches:
- main
pull_request:
schedule:
- cron: "0 0 * * *"
jobs:
ci:

Datei anzeigen

@ -10,7 +10,7 @@ class CustomWizard::SubmissionSerializer < ApplicationSerializer
end
def user
::BasicUserSerializer.new(object.wizard.user).as_json
::BasicUserSerializer.new(object.wizard.user, root: false).as_json
end
def fields

Datei anzeigen

@ -12,6 +12,7 @@ import { alias } from "@ember/object/computed";
import Site from "discourse/models/site";
import { uploadIcon } from "discourse/lib/uploads";
import { dasherize } from "@ember/string";
import showModal from "discourse/lib/show-modal";
const IMAGE_MARKDOWN_REGEX = /!\[(.*?)\|(\d{1,4}x\d{1,4})(,\s*\d{1,3}%)?(.*?)\]\((upload:\/\/.*?)\)(?!(.*`))/g;
@ -19,7 +20,6 @@ export default ComposerEditor.extend({
classNameBindings: ["fieldClass"],
allowUpload: true,
showLink: false,
showHyperlinkBox: false,
topic: null,
showToolbar: true,
focusTarget: "reply",
@ -29,6 +29,7 @@ export default ComposerEditor.extend({
draftStatus: "null",
replyPlaceholder: alias("field.translatedPlaceholder"),
wizardEventFieldId: null,
composerEventPrefix: "wizard-editor",
@on("didInsertElement")
_composerEditorInit() {
@ -77,24 +78,13 @@ export default ComposerEditor.extend({
$input.on("scroll", this._throttledSyncEditorAndPreviewScroll);
this._bindUploadTarget();
const wizardEventNames = ["insert-text", "replace-text"];
const eventPrefix = this.eventPrefix;
this.appEvents.reopen({
trigger(name, ...args) {
let eventParts = name.split(":");
let currentEventPrefix = eventParts[0];
let currentEventName = eventParts[1];
const field = this.field;
this.editorInputClass = `.${dasherize(field.type)}-${dasherize(
field.id
)} .d-editor-input`;
if (
currentEventPrefix !== "wizard-editor" &&
wizardEventNames.some((wen) => wen === currentEventName)
) {
let wizardEventName = name.replace(eventPrefix, "wizard-editor");
return this._super(wizardEventName, ...args);
} else {
return this._super(name, ...args);
}
},
this._uppyInstance.on("file-added", () => {
this.session.set("wizardEventFieldId", field.id);
});
},
@ -116,12 +106,6 @@ export default ComposerEditor.extend({
return uploadIcon(false, this.siteSettings);
},
click(e) {
if ($(e.target).hasClass("wizard-composer-hyperlink")) {
this.set("showHyperlinkBox", false);
}
},
@bind
_handleImageDeleteButtonClick(event) {
if (!event.target.classList.contains("delete-image-button")) {
@ -165,7 +149,7 @@ export default ComposerEditor.extend({
shortcut: "K",
trimLeading: true,
unshift: true,
sendAction: () => component.set("showHyperlinkBox", true),
sendAction: (event) => component.send("showLinkModal", event),
});
if (this.siteSettings.mentionables_enabled) {
@ -206,17 +190,18 @@ export default ComposerEditor.extend({
this._super(...arguments);
},
addLink(linkName, linkUrl) {
let link = `[${linkName}](${linkUrl})`;
this.appEvents.trigger("wizard-editor:insert-text", {
fieldId: this.field.id,
text: link,
});
this.set("showHyperlinkBox", false);
},
showLinkModal(toolbarEvent) {
let linkText = "";
this._lastSel = toolbarEvent.selected;
hideBox() {
this.set("showHyperlinkBox", false);
if (this._lastSel) {
linkText = this._lastSel.value;
}
showModal("insert-hyperlink").setProperties({
linkText,
toolbarEvent,
});
},
showUploadModal() {

Datei anzeigen

@ -1,15 +0,0 @@
import Component from "@ember/component";
export default Component.extend({
classNames: ["wizard-composer-hyperlink"],
actions: {
addLink() {
this.addLink(this.linkName, this.linkUrl);
},
hideBox() {
this.hideBox();
},
},
});

Datei anzeigen

@ -3,6 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
export default DateInput.extend({
useNativePicker: false,
classNameBindings: ["fieldClass"],
@discourseComputed()
placeholder() {

Datei anzeigen

@ -2,6 +2,8 @@ import DateTimeInput from "discourse/components/date-time-input";
import discourseComputed from "discourse-common/utils/decorators";
export default DateTimeInput.extend({
classNameBindings: ["fieldClass"],
@discourseComputed("timeFirst", "tabindex")
timeTabindex(timeFirst, tabindex) {
return timeFirst ? tabindex : tabindex + 1;

Datei anzeigen

@ -2,6 +2,8 @@ import Component from "@ember/component";
import { observes } from "discourse-common/utils/decorators";
export default Component.extend({
classNameBindings: ["fieldClass"],
@observes("time")
setValue() {
this.set("field.value", this.time.format(this.field.format));

Datei anzeigen

@ -4,7 +4,7 @@ import { computed } from "@ember/object";
export default Component.extend(UppyUploadMixin, {
classNames: ["wizard-field-upload"],
classNameBindings: ["isImage"],
classNameBindings: ["isImage", "fieldClass"],
uploading: false,
type: computed(function () {
return `wizard_${this.field.id}`;

Datei anzeigen

@ -1,3 +1,5 @@
import Component from "@ember/component";
export default Component.extend({});
export default Component.extend({
classNameBindings: ["fieldClass"],
});

Datei anzeigen

@ -9,6 +9,7 @@ import CustomWizard, {
updateCachedWizard,
} from "discourse/plugins/discourse-custom-wizard/discourse/models/custom-wizard";
import { alias, not } from "@ember/object/computed";
import discourseLater from "discourse-common/lib/later";
const alreadyWarned = {};
@ -110,29 +111,22 @@ export default Component.extend({
},
autoFocus() {
schedule("afterRender", () => {
const $invalid = $(
".wizard-field.invalid:nth-of-type(1) .wizard-focusable"
);
if ($invalid.length) {
return $invalid.focus();
}
$(".wizard-focusable:first").focus();
discourseLater(() => {
schedule("afterRender", () => {
if ($(".invalid .wizard-focusable").length) {
this.animateInvalidFields();
}
});
});
},
animateInvalidFields() {
schedule("afterRender", () => {
let $element = $(
".invalid input[type=text],.invalid textarea,.invalid input[type=checkbox],.invalid .select-kit"
);
if ($element.length) {
let $invalid = $(".invalid .wizard-focusable");
if ($invalid.length) {
$([document.documentElement, document.body]).animate(
{
scrollTop: $element.offset().top - 200,
scrollTop: $invalid.offset().top - 200,
},
400
);

Datei anzeigen

@ -7,7 +7,7 @@ export default Component.extend(Subscription, {
@discourseComputed("subscribed")
subscribedIcon(subscribed) {
return subscribed ? "check" : "dash";
return subscribed ? "check" : "times";
},
@discourseComputed("subscribed")

Datei anzeigen

@ -1,22 +0,0 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n";
import Handlebars from "handlebars";
export default registerUnbound("char-counter", function (body, maxLength) {
let bodyLength = body ? body.length : 0;
let finalString;
if (maxLength) {
let isOverMax = bodyLength > maxLength ? "true" : "false";
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
"wizard.x_characters",
{ count: parseInt(maxLength, 10) }
)}</div>`;
} else {
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
count: parseInt(bodyLength, 10),
})}</div>`;
}
return new Handlebars.SafeString(finalString);
});

Datei anzeigen

@ -0,0 +1,25 @@
import { registerUnbound } from "discourse-common/lib/helpers";
import I18n from "I18n";
import Handlebars from "handlebars";
export default registerUnbound(
"wizard-char-counter",
function (body, maxLength) {
let bodyLength = body ? body.length : 0;
let finalString;
if (maxLength) {
let isOverMax = bodyLength > maxLength ? "true" : "false";
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
"wizard.x_characters",
{ count: parseInt(maxLength, 10) }
)}</div>`;
} else {
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
count: parseInt(bodyLength, 10),
})}</div>`;
}
return new Handlebars.SafeString(finalString);
}
);

Datei anzeigen

@ -35,6 +35,7 @@ function inputTypesContent(options = {}) {
const connectors = {
pair: [
"equal",
"not_equal",
"greater",
"less",
"greater_or_equal",

Datei anzeigen

@ -4,6 +4,8 @@ import { get, set } from "@ember/object";
import Mixin from "@ember/object/mixin";
import { deepEqual } from "discourse-common/lib/object";
const observedCache = [];
export default Mixin.create({
didInsertElement() {
this._super(...arguments);
@ -32,7 +34,13 @@ export default Mixin.create({
};
listProperties(componentType, opts).forEach((property) => {
obj.removeObserver(property, this, this.toggleUndo);
if (observedCache.includes(property)) {
obj.removeObserver(property, this, this.toggleUndo);
let index = observedCache.indexOf(property);
if (index !== -1) {
observedCache.splice(index, 1);
}
}
});
},
@ -45,6 +53,9 @@ export default Mixin.create({
};
listProperties(componentType, opts).forEach((property) => {
if (observedCache.indexOf(property) === -1) {
observedCache.push(property);
}
obj.addObserver(property, this, this.toggleUndo);
});
},

Datei anzeigen

@ -72,7 +72,7 @@ export default EmberObject.extend(ValidState, {
valid = true;
}
this.setValid(valid);
this.setValid(Boolean(valid));
return valid;
},

Datei anzeigen

@ -1,6 +1,8 @@
import I18n from "I18n";
import { getCachedWizard } from "../models/custom-wizard";
import Route from "@ember/routing/route";
import { scrollTop } from "discourse/mixins/scroll-top";
import { action } from "@ember/object";
export default Route.extend({
beforeModel() {
@ -48,4 +50,10 @@ export default Route.extend({
controller.setProperties(props);
},
@action
didTransition() {
scrollTop();
return true;
},
});

Datei anzeigen

@ -32,13 +32,19 @@
<div class="metadata">
<div class="title">
<label>{{i18n "admin.wizard.api.title"}}</label>
{{input value=api.title placeholder=(i18n "admin.wizard.api.title_placeholder")}}
<Input
@value={{this.api.title}}
placeholder={{i18n "admin.wizard.api.title_placeholder"}}
/>
</div>
<div class="name {{nameClass}}">
<label>{{i18n "admin.wizard.api.name"}}</label>
{{#if api.isNew}}
{{input value=api.name placeholder=(i18n "admin.wizard.api.name_placeholder")}}
<Input
@value={{this.api.name}}
placeholder={{i18n "admin.wizard.api.name_placeholder"}}
/>
{{else}}
<span>{{api.name}}</span>
{{/if}}
@ -104,7 +110,9 @@
<div class="control-group">
<label>{{i18n "admin.wizard.api.auth.url"}}</label>
<div class="controls">
{{input value=api.authUrl}}
<Input
@value={{this.api.authUrl}}
/>
</div>
</div>
{{/if}}
@ -112,21 +120,27 @@
<div class="control-group">
<label>{{i18n "admin.wizard.api.auth.token_url"}}</label>
<div class="controls">
{{input value=api.tokenUrl}}
<Input
@value={{this.api.tokenUrl}}
/>
</div>
</div>
<div class="control-group">
<label>{{i18n "admin.wizard.api.auth.client_id"}}</label>
<div class="controls">
{{input value=api.clientId}}
<Input
@value={{this.api.clientId}}
/>
</div>
</div>
<div class="control-group">
<label>{{i18n "admin.wizard.api.auth.client_secret"}}</label>
<div class="controls">
{{input value=api.clientSecret}}
<Input
@value={{this.api.clientSecret}}
/>
</div>
</div>
@ -135,8 +149,14 @@
<div class="controls">
{{#each api.authParams as |param|}}
<div class="param">
{{input value=param.key placeholder=(i18n "admin.wizard.key")}}
{{input value=param.value placeholder=(i18n "admin.wizard.value")}}
<Input
@value={{this.param.key}}
placeholder={{i18n "admin.wizard.key"}}
/>
<Input
@value={{this.param.value}}
placeholder={{i18n "admin.wizard.value"}}
/>
{{d-button action=(action "removeParam") actionParam=param icon="times"}}
</div>
{{/each}}
@ -149,14 +169,18 @@
<div class="control-group">
<label>{{i18n "admin.wizard.api.auth.username"}}</label>
<div class="controls">
{{input value=api.username}}
<Input
@value={{this.api.username}}
/>
</div>
</div>
<div class="control-group">
<label>{{i18n "admin.wizard.api.auth.password"}}</label>
<div class="controls">
{{input value=api.password}}
<Input
@value={{this.api.password}}
/>
</div>
</div>
{{/if}}
@ -235,11 +259,15 @@
<div class="endpoint">
<div class="endpoint-">
<div class="top">
{{input value=endpoint.name
placeholder=(i18n "admin.wizard.api.endpoint.name")}}
{{input value=endpoint.url
placeholder=(i18n "admin.wizard.api.endpoint.url")
class="endpoint-url"}}
<Input
@value={{this.endpoint.name}}
placeholder={{i18n "admin.wizard.api.endpoint.name"}}
/>
<Input
@value={{this.endpoint.url}}
placeholder={{i18n "admin.wizard.api.endpoint.url"}}
class="endpoint-url"
/>
{{d-button action=(action "removeEndpoint")
actionParam=endpoint
icon="times"

Datei anzeigen

@ -11,11 +11,12 @@
</div>
{{/if}}
{{input
<Input
id="custom-wizard-file-upload"
type="file"
@type="file"
accept="application/json"
input=(action "setFile")}}
{{on "input" (action "setFile")}}
/>
{{d-button
id="upload-button"
label="admin.wizard.manager.upload"
@ -65,16 +66,18 @@
{{/link-to}}
</td>
<td class="control-column">
{{input
type="checkbox"
<Input
@type="checkbox"
class="export"
change=(action "selectWizard")}}
{{on "change" (action "selectWizard")}}
/>
</td>
<td class="control-column">
{{input
type="checkbox"
<Input
@type="checkbox"
class="destroy"
change=(action "selectWizard")}}
{{on "change" (action "selectWizard")}}
/>
</td>
</tr>
{{/each}}

Datei anzeigen

@ -1,9 +1,10 @@
{{#if wizard}}
<div class="wizard-header large">
{{input
<Input
@value={{this.wizard.name}}
name="name"
value=wizard.name
placeholderKey="admin.wizard.name_placeholder"}}
placeholder={{i18n "admin.wizard.name_placeholder"}}
/>
<div class="wizard-url">
{{#if wizard.name}}
@ -23,11 +24,12 @@
<label>{{i18n "admin.wizard.background"}}</label>
</div>
<div class="setting-value">
{{input
<Input
@value={{this.wizard.background}}
name="background"
value=wizard.background
placeholderKey="admin.wizard.background_placeholder"
class="small"}}
placeholder={{i18n "admin.wizard.background_placeholder"}}
class="small"
/>
</div>
</div>
@ -58,7 +60,10 @@
<label>{{i18n "admin.wizard.save_submissions"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.save_submissions}}
<Input
@type="checkbox"
@checked={{this.wizard.save_submissions}}
/>
<span>{{i18n "admin.wizard.save_submissions_label"}}</span>
</div>
</div>
@ -68,7 +73,10 @@
<label>{{i18n "admin.wizard.multiple_submissions"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.multiple_submissions}}
<Input
@type="checkbox"
@checked={{this.wizard.multiple_submissions}}
/>
<span>{{i18n "admin.wizard.multiple_submissions_label"}}</span>
</div>
</div>
@ -78,7 +86,10 @@
<label>{{i18n "admin.wizard.after_signup"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.after_signup}}
<Input
@type="checkbox"
@checked={{this.wizard.after_signup}}
/>
<span>{{i18n "admin.wizard.after_signup_label"}}</span>
</div>
</div>
@ -88,7 +99,10 @@
<label>{{i18n "admin.wizard.prompt_completion"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.prompt_completion}}
<Input
@type="checkbox"
@checked={{this.wizard.prompt_completion}}
/>
<span>{{i18n "admin.wizard.prompt_completion_label"}}</span>
</div>
</div>
@ -98,7 +112,10 @@
<label>{{i18n "admin.wizard.after_time"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.after_time}}
<Input
@type="checkbox"
@checked={{this.wizard.after_time}}
/>
<span>{{i18n "admin.wizard.after_time_label"}}</span>
{{d-button
action=(action "setNextSessionScheduled")
@ -114,7 +131,10 @@
<label>{{i18n "admin.wizard.required"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.required}}
<Input
@type="checkbox"
@checked={{this.wizard.required}}
/>
<span>{{i18n "admin.wizard.required_label"}}</span>
</div>
</div>
@ -124,7 +144,10 @@
<label>{{i18n "admin.wizard.restart_on_revisit"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=wizard.restart_on_revisit}}
<Input
@type="checkbox"
@checked={{this.wizard.restart_on_revisit}}
/>
<span>{{i18n "admin.wizard.restart_on_revisit_label"}}</span>
</div>
</div>

Datei anzeigen

@ -20,9 +20,10 @@
)}}
</td>
<td class="input">
{{input
value=field.name
placeholder=(i18n "admin.wizard.custom_field.name.select")}}
<Input
@value={{this.field.name}}
placeholder={{i18n "admin.wizard.custom_field.name.select"}}
/>
</td>
<td class="multi-select">
{{multi-select

Datei anzeigen

@ -1,21 +0,0 @@
<div class="wizard-composer-hyperlink-contents">
<h3>{{i18n "composer.link_dialog_title"}}</h3>
{{input
class="composer-link-name"
placeholder=(i18n "composer.link_optional_text")
type="text"
value=linkName}}
{{input
class="composer-link-url"
placeholder=(i18n "composer.link_url_placeholder")
type="text"
value=linkUrl}}
{{d-button
label="wizard_composer.modal_ok"
class="add-link btn-primary"
click=(action "addLink")}}
{{d-button
label="wizard_composer.modal_cancel"
class="hide-hyperlink-box btn-danger"
click=(action "hideBox")}}
</div>

Datei anzeigen

@ -1,11 +1,11 @@
{{input
type=inputType
<Input
@type={{this.inputType}}
@value={{readonly this.value}}
class="date-picker"
placeholder=placeholder
value=(readonly value)
input=(action "onChangeDate")
tabindex=tabindex
placeholder={{this.placeholder}}
tabindex={{this.tabindex}}
{{on "input" (action "onChangeDate")}}
autocomplete="off"
}}
/>
<div class="picker-container"></div>

Datei anzeigen

@ -40,7 +40,12 @@
</div>
{{conditional-loading-spinner condition=loading}}
{{textarea tabindex=tabindex value=value class="d-editor-input" placeholder=placeholder}}
<Textarea
tabindex={{this.tabindex}}
@value={{this.value}}
class="d-editor-input"
placeholder={{this.placeholder}}
/>
</div>
{{/if}}
</div>

Datei anzeigen

@ -1,5 +1,6 @@
{{custom-wizard-category-selector
categories=categories
class=fieldClass
whitelist=field.content
onChange=(action (mut categories))
tabindex=field.tabindex

Datei anzeigen

@ -1 +1,7 @@
{{input type="checkbox" id=field.id checked=field.value tabindex=field.tabindex}}
<Input
id={{this.field.id}}
@type="checkbox"
@checked={{this.field.value}}
tabindex={{this.field.tabindex}}
class={{this.fieldClass}}
/>

Datei anzeigen

@ -2,6 +2,7 @@
field=field
composer=composer
wizard=wizard
fieldClass=fieldClass
groupsMentioned=(action "groupsMentioned")
cannotSeeMention=(action "cannotSeeMention")
importQuote=(action "importQuote")
@ -14,6 +15,6 @@
</button>
{{#if field.char_counter}}
{{char-counter field.value field.max_length}}
{{wizard-char-counter field.value field.max_length}}
{{/if}}
</div>

Datei anzeigen

@ -1,5 +1,6 @@
{{custom-wizard-group-selector
groups=site.groups
class=fieldClass
field=field
whitelist=field.content
value=field.value

Datei anzeigen

@ -1 +1,9 @@
{{input type="number" step="0.01" id=field.id value=field.value tabindex=field.tabindex}}
<Input
id={{this.field.id}}
step="0.01"
@type="number"
@value={{this.field.value}}
tabindex={{this.field.tabindex}}
class={{this.fieldClass}}
/>

Datei anzeigen

@ -1,5 +1,6 @@
{{custom-wizard-tag-chooser
tags=field.value
class=fieldClass
tabindex=field.tabindex
tagGroups=field.tag_groups
everyTag=true

Datei anzeigen

@ -1 +1,8 @@
{{input id=field.id value=field.value class=fieldClass placeholder=field.translatedPlaceholder tabindex=field.tabindex autocomplete=autocomplete}}
<Input
id={{this.field.id}}
@value={{this.field.value}}
tabindex={{this.field.tabindex}}
class={{this.fieldClass}}
placeholder={{this.field.translatedPlaceholder}}
autocomplete={{this.autocomplete}}
/>

Datei anzeigen

@ -1 +1,7 @@
{{textarea id=field.id value=field.value class=fieldClass placeholder=field.translatedPlaceholder tabindex=field.tabindex}}
<Textarea
id={{this.field.id}}
@value={{this.field.value}}
tabindex={{this.field.tabindex}}
class={{this.fieldClass}}
placeholder={{this.field.translatedPlaceholder}}
/>

Datei anzeigen

@ -1 +1,6 @@
{{input type="text" id=field.id value=field.value tabindex=field.tabindex}}
<Input
id={{this.field.id}}
@value={{this.field.value}}
tabindex={{this.field.tabindex}}
class={{this.fieldClass}}
/>

Datei anzeigen

@ -20,7 +20,7 @@
{{#if field.char_counter}}
{{#if textType}}
{{char-counter field.value field.max_length}}
{{wizard-char-counter field.value field.max_length}}
{{/if}}
{{/if}}

Datei anzeigen

@ -79,7 +79,10 @@
)}}
<div class="setting-gutter">
{{input type="checkbox" checked=action.post_builder}}
<Input
@type="checkbox"
@checked={{this.action.post_builder}}
/>
<span>{{i18n "admin.wizard.action.post_builder.checkbox"}}</span>
</div>
</div>
@ -408,7 +411,10 @@
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.wizard_user}}
<Input
@type="checkbox"
@checked={{this.action.wizard_user}}
/>
</div>
</div>
@ -477,7 +483,10 @@
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.wizard_user}}
<Input
@type="checkbox"
@checked={{this.action.wizard_user}}
/>
</div>
</div>
@ -716,7 +725,7 @@
property="name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="key,value"
textSelection="key,value,output"
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
@ -877,7 +886,10 @@
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.skip_redirect}}
<Input
@type="checkbox"
@checked={{this.action.skip_redirect}}
/>
<span>
{{i18n "admin.wizard.action.skip_redirect.description" type="topic"}}
@ -891,7 +903,10 @@
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.suppress_notifications}}
<Input
@type="checkbox"
@checked={{this.action.suppress_notifications}}
/>
<span>
{{i18n "admin.wizard.action.suppress_notifications.description" type="topic"}}
@ -907,7 +922,7 @@
</div>
<div class="setting-value">
{{input value=action.code}}
<Input @value={{this.action.code}} />
</div>
</div>
{{/if}}

Datei anzeigen

@ -11,7 +11,10 @@
<label>{{i18n "admin.wizard.field.label"}}</label>
</div>
<div class="setting-value">
{{input name="label" value=field.label}}
<Input
name="label"
@value={{this.field.label}}
/>
</div>
</div>
@ -22,7 +25,10 @@
<div class="setting-value">
<span>{{i18n "admin.wizard.field.required_label"}}</span>
{{input type="checkbox" checked=field.required}}
<Input
@type="checkbox"
@checked={{this.field.required}}
/>
</div>
</div>
@ -31,7 +37,10 @@
<label>{{i18n "admin.wizard.field.description"}}</label>
</div>
<div class="setting-value">
{{textarea name="description" value=field.description}}
<Textarea
name="description"
@value={{this.field.description}}
/>
</div>
</div>
@ -78,11 +87,12 @@
</div>
<div class="setting-value">
{{input
type="number"
<Input
@type="number"
name="min_length"
value=field.min_length
class="small"}}
@value={{this.field.min_length}}
class="small"
/>
</div>
</div>
@ -92,11 +102,12 @@
</div>
<div class="setting-value">
{{input
type="number"
<Input
@type="number"
name="max_length"
value=field.max_length
class="small"}}
@value={{this.field.max_length}}
class="small"
/>
</div>
</div>
@ -107,9 +118,10 @@
<div class="setting-value">
<span>{{i18n "admin.wizard.field.char_counter_placeholder"}}</span>
{{input
type="checkbox"
checked=field.char_counter}}
<Input
@type="checkbox"
@checked={{this.field.char_counter}}
/>
</div>
</div>
@ -119,10 +131,11 @@
</div>
<div class="setting-value">
{{textarea
<Textarea
name="field_placeholder"
class="medium"
value=field.placeholder}}
@value={{this.field.placeholder}}
/>
</div>
</div>
{{/if}}
@ -134,7 +147,11 @@
</div>
<div class="setting-value">
{{textarea name="preview-template" value=field.preview_template class="preview-template"}}
<Textarea
name="preview-template"
class="preview-template"
@value={{this.field.preview_template}}
/>
</div>
</div>
{{/if}}
@ -146,7 +163,10 @@
</div>
<div class="setting-value">
{{input value=field.file_types class="medium"}}
<Input
@value={{this.field.file_types}}
class="medium"
/>
</div>
</div>
{{/if}}
@ -158,7 +178,11 @@
</div>
<div class="setting-value">
{{input type="number" value=field.limit class="small"}}
<Input
@type="number"
@value={{this.field.limit}}
class="small"
/>
</div>
</div>
{{/if}}
@ -170,7 +194,10 @@
</div>
<div class="setting-value">
{{input value=field.format class="medium"}}
<Input
@value={{this.field.format}}
class="medium"
/>
<label>{{html-safe (i18n "admin.wizard.field.date_time_format.instructions")}}</label>
</div>
</div>
@ -229,9 +256,10 @@
</div>
<div class="setting-value">
{{input
type="checkbox"
checked=field.can_create_tag}}
<Input
@type="checkbox"
@checked={{this.field.can_create_tag}}
/>
</div>
</div>
{{/if}}

Datei anzeigen

@ -3,9 +3,10 @@
<label>{{i18n "admin.wizard.step.title"}}</label>
</div>
<div class="setting-value">
{{input
<Input
name="title"
value=step.title}}
@value={{this.step.title}}
/>
</div>
</div>
@ -51,7 +52,10 @@
<div class="setting-label"></div>
<div class="setting-value force-final">
<h4>{{i18n "admin.wizard.step.force_final.label"}}</h4>
{{input type="checkbox" checked=step.force_final}}
<Input
@type="checkbox"
@checked={{this.step.force_final}}
/>
<span>{{i18n "admin.wizard.step.force_final.description"}}</span>
</div>
</div>
@ -77,7 +81,9 @@
<div class="label">
{{i18n "admin.wizard.step.required_data.not_permitted_message"}}
</div>
{{input value=step.required_data_message}}
<Input
@value={{this.step.required_data_message}}
/>
</div>
{{/if}}
</div>

Datei anzeigen

@ -21,11 +21,12 @@
<div class="input">
{{#if showText}}
{{input
type="text"
value=value
placeholder=(i18n placeholderKey)
change=(action "changeInputValue")}}
<Input
@type="text"
@value={{this.value}}
placeholder={{i18n placeholderKey}}
{{on "change" (action "changeInputValue")}}
/>
{{/if}}
{{#if showComboBox}}

Datei anzeigen

@ -7,7 +7,10 @@
<li>
<span class="setting-title">
<h4>{{i18n (concat "admin.wizard.field.validations." type)}}</h4>
{{input type="checkbox" checked=props.status}}
<Input
@type="checkbox"
@checked={{this.props.status}}
/>
{{i18n "admin.wizard.field.validations.enabled"}}
</span>
<div class="validation-container">
@ -27,7 +30,11 @@
<label>{{i18n "admin.wizard.field.validations.max_topic_age"}}</label>
</div>
<div class="setting-value">
{{input type="number" class="time-n-value" value=props.time_n_value}}
<Input
@type="number"
@value={{this.props.time_n_value}}
class="time-n-value"
/>
{{combo-box
value=(readonly props.time_unit)
content=timeUnits

Datei anzeigen

@ -32,13 +32,8 @@ body.custom-wizard {
}
}
&.invalid {
textarea,
input[type="text"],
input[type="checkbox"],
.select-kit {
outline: 4px solid var(--danger);
}
&.invalid .wizard-focusable {
outline: 4px solid var(--danger);
}
}

Datei anzeigen

@ -324,6 +324,7 @@ en:
then: "then"
set: "set"
equal: '='
not_equal: '!='
greater: '>'
less: '<'
greater_or_equal: '>='

Datei anzeigen

@ -456,11 +456,16 @@ class CustomWizard::Action
if new_group_params[:usernames].present?
user_ids = get_user_ids(new_group_params[:usernames])
if user_ids.count < new_group_params[:usernames].count
log_error("Warning, group creation: some users were not found!")
end
user_ids -= owner_ids if owner_ids
user_ids.each { |user_id| group.group_users.build(user_id: user_id) }
end
log_success("Group created", group.name)
if group.save
log_success("Group created", group.name)
end
result.output = group.name
else

Datei anzeigen

@ -15,13 +15,13 @@ class CustomWizard::Log
@username = attrs['username']
end
def self.create(wizard_id, action, username, message)
def self.create(wizard_id, action, username, message, date = Time.now)
log_id = SecureRandom.hex(12)
PluginStore.set('custom_wizard_log',
log_id.to_s,
{
date: Time.now,
date: date,
wizard_id: wizard_id,
action: action,
username: username,

Datei anzeigen

@ -30,6 +30,7 @@ class CustomWizard::Mapper
OPERATORS = {
equal: '==',
not_equal: "!=",
greater: '>',
less: '<',
greater_or_equal: '>=',
@ -44,7 +45,7 @@ class CustomWizard::Mapper
def initialize(params)
@inputs = params[:inputs] || {}
@data = params[:data] || {}
@data = params[:data] ? params[:data].with_indifferent_access : {}
@user = params[:user]
@opts = params[:opts] || {}
end
@ -255,7 +256,7 @@ class CustomWizard::Mapper
end
end
if opts[:template] && CustomWizard::Subscription.subscribed?
if opts[:template] #&& CustomWizard::Subscription.subscribed?
template = Liquid::Template.parse(string)
string = template.render(data)
end
@ -267,7 +268,12 @@ class CustomWizard::Mapper
return nil if data.nil?
k = keys.shift
result = data[k]
keys.empty? ? result : self.recurse(result, keys)
if keys.empty?
result.is_a?(Hash) ? "" : result
else
self.recurse(result, keys)
end
end
def bool(value)

Datei anzeigen

@ -84,6 +84,10 @@ class CustomWizard::Submission
data
end
def submitted?
!!submitted_at
end
def self.get(wizard)
data = PluginStore.get("#{wizard.id}_#{KEY}", wizard.actor_id).last
new(wizard, data)
@ -120,16 +124,23 @@ class CustomWizard::Submission
end
def self.list(wizard, order_by: nil, page: nil)
list_actor_id = wizard.actor_id
list_user = wizard.user if wizard.user.present?
params = { plugin_name: "#{wizard.id}_#{KEY}" }
params[:key] = wizard.actor_id if wizard.actor_id
params[:key] = list_actor_id if list_actor_id
query = PluginStoreRow.where(params)
result = OpenStruct.new(submissions: [], total: nil)
query.each do |record|
if (submission_data = ::JSON.parse(record.value)).any?
submission_user = list_user || User.find_by(id: record.key.to_i)
submission_data.each do |data|
result.submissions.push(new(wizard, data))
_wizard = wizard.clone
_wizard.user = submission_user if submission_user.present?
result.submissions.push(new(_wizard, data))
end
end
end

Datei anzeigen

@ -84,7 +84,7 @@ class CustomWizard::TemplateValidator
def validate_guests(object, type)
guests_permitted = @data[:permitted] && @data[:permitted].any? do |m|
m["output"].include?(CustomWizard::Wizard::GUEST_GROUP_ID)
m["output"]&.include?(CustomWizard::Wizard::GUEST_GROUP_ID)
end
return unless guests_permitted

Datei anzeigen

@ -176,6 +176,7 @@ class CustomWizard::Wizard
def unfinished?
return nil unless actor_id
return false if last_submission&.submitted?
most_recent = CustomWizard::UserHistory.where(
actor_id: actor_id,
@ -194,6 +195,7 @@ class CustomWizard::Wizard
def completed?
return nil unless actor_id
return true if last_submission&.submitted?
history = CustomWizard::UserHistory.where(
actor_id: actor_id,
@ -230,6 +232,7 @@ class CustomWizard::Wizard
m[:type] === 'assignment' && [*m[:result]].include?(GUEST_GROUP_ID)
else
if m[:type] === 'assignment'
[*m[:result]].include?(GUEST_GROUP_ID) ||
[*m[:result]].include?(Group::AUTO_GROUPS[:everyone]) ||
GroupUser.exists?(group_id: m[:result], user_id: user.id)
elsif m[:type] === 'validation'
@ -281,6 +284,10 @@ class CustomWizard::Wizard
@submissions ||= CustomWizard::Submission.list(self).submissions
end
def last_submission
@last_submission ||= submissions&.last
end
def current_submission
@current_submission ||= begin
if submissions.present?

Datei anzeigen

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

Datei anzeigen

@ -2,6 +2,7 @@
describe CustomWizard::Action do
fab!(:user) { Fabricate(:user, name: "Angus", username: 'angus', email: "angus@email.com", trust_level: TrustLevel[2]) }
fab!(:user1) { Fabricate(:user, name: "Angus One", username: 'angus1', email: "angus_one@email.com", trust_level: TrustLevel[2]) }
fab!(:category) { Fabricate(:category, name: 'cat1', slug: 'cat-slug') }
fab!(:tag) { Fabricate(:tag, name: 'tag1') }
fab!(:group) { Fabricate(:group) }
@ -12,6 +13,7 @@ describe CustomWizard::Action do
let(:watch_categories) { get_wizard_fixture("actions/watch_categories") }
let(:watch_tags) { get_wizard_fixture("actions/watch_tags") }
let(:create_group) { get_wizard_fixture("actions/create_group") }
let(:create_group_with_nonexistent_user) { get_wizard_fixture("actions/create_group_bad_user") }
let(:add_to_group) { get_wizard_fixture("actions/add_to_group") }
let(:send_message) { get_wizard_fixture("actions/send_message") }
let(:send_message_multi) { get_wizard_fixture("actions/send_message_multi") }
@ -350,7 +352,25 @@ describe CustomWizard::Action do
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update
group_id = Group.where(name: wizard.current_submission.fields['action_9']).first.id
user_id = User.find_by(username: wizard_template['actions'][4]['usernames'][0]["output"][0]).id
expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true)
expect(GroupUser.where(group_id: group_id, user_id: user_id).exists?).to eq(true)
end
it '#create_group completes successfully when user included in usernames does not exist but excludes users who do not exist and includes warning in log' do
wizard_template['actions'] << create_group_with_nonexistent_user
update_template(wizard_template)
wizard = CustomWizard::Builder.new(@template[:id], user).build
wizard.create_updater(wizard.steps[0].id, step_1_field_1: "Text input").update
group_id = Group.where(name: wizard.current_submission.fields['action_9']).first.id
expect(CustomWizard::Log.list_query.all.last.value.include? "some users were not found").to eq(true)
expect(Group.where(name: wizard.current_submission.fields['action_9']).exists?).to eq(true)
expect(GroupUser.where(group_id: group_id).count).to eq(1)
end
it '#add_to_group' do

Datei anzeigen

@ -58,6 +58,11 @@ describe CustomWizard::Mapper do
"step_1_field_3" => "Value"
}
}
let(:template_params_object) {
{
"step_1_field_1": get_wizard_fixture("field/upload")
}
}
def create_template_mapper(data, user)
CustomWizard::Mapper.new(
@ -286,6 +291,19 @@ describe CustomWizard::Mapper do
end
end
it "handles not equal pairs" do
expect(CustomWizard::Mapper.new(
inputs: inputs['not_equals_pair'],
data: data,
user: user1
).perform).to eq(true)
expect(CustomWizard::Mapper.new(
inputs: inputs['not_equals_pair'],
data: data,
user: user2
).perform).to eq(false)
end
it "handles greater than pairs" do
expect(CustomWizard::Mapper.new(
inputs: inputs['greater_than_pair'],
@ -373,7 +391,7 @@ describe CustomWizard::Mapper do
expect(result).to eq(template_params["step_1_field_1"])
end
it "requires a subscription" do
it "does not require a subscription" do
template = '{{ "w{step_1_field_1}" | size }}'
mapper = create_template_mapper(template_params, user1)
result = mapper.interpolate(
@ -383,7 +401,7 @@ describe CustomWizard::Mapper do
wizard: true,
value: true
)
expect(result).to eq("{{ \"#{template_params["step_1_field_1"]}\" | size }}")
expect(result).to eq("5")
end
context "with a subscription" do
@ -448,6 +466,40 @@ describe CustomWizard::Mapper do
expect(result).to eq(template)
end
it "handles correct object variable references" do
template = <<-LIQUID.strip
{%- if "w{step_1_field_1.id}" == "step_2_field_7" -%}
Correct
{%- else -%}
Incorrect
{%-endif-%}
LIQUID
mapper = create_template_mapper(template_params_object, user1)
result = mapper.interpolate(
template.dup,
template: true,
wizard: true
)
expect(result).to eq("Correct")
end
it "handles incorrect object variable references" do
template = <<-LIQUID.strip
{%- if "w{step_1_field_1}" == "step_2_field_7" -%}
Correct
{%- else -%}
Incorrect
{%-endif-%}
LIQUID
mapper = create_template_mapper(template_params_object, user1)
result = mapper.interpolate(
template.dup,
template: true,
wizard: true
)
expect(result).to eq("Incorrect")
end
context "custom filter: 'first_non_empty'" do
it "gives first non empty element from list" do
template = <<-LIQUID.strip

Datei anzeigen

@ -9,6 +9,7 @@ describe CustomWizard::TemplateValidator do
let(:composer_preview) { get_wizard_fixture("field/composer_preview") }
let(:guests_permitted) { get_wizard_fixture("wizard/guests_permitted") }
let(:upload_field) { get_wizard_fixture("field/upload") }
let(:validation_condition) { get_wizard_fixture("condition/validation_condition") }
let(:valid_liquid_template) {
<<-LIQUID.strip
@ -182,6 +183,13 @@ describe CustomWizard::TemplateValidator do
CustomWizard::TemplateValidator.new(template).perform
).to eq(true)
end
it "validates settings with validation conditions" do
template[:permitted] = validation_condition["condition"]
expect(
CustomWizard::TemplateValidator.new(template).perform
).to eq(true)
end
end
context "steps" do

Datei anzeigen

@ -6,11 +6,15 @@ describe CustomWizard::Wizard do
fab!(:admin_user) { Fabricate(:user, admin: true) }
let(:template_json) { get_wizard_fixture("wizard") }
let(:permitted_json) { get_wizard_fixture("wizard/permitted") }
let(:guests_permitted_json) { get_wizard_fixture("wizard/guests_permitted") }
let(:step_json) { get_wizard_fixture("step/step") }
before do
Group.refresh_automatic_group!(:trust_level_3)
@permitted_template = template_json.dup
@permitted_template["permitted"] = permitted_json["permitted"]
@guests_permitted_template = template_json.dup
@guests_permitted_template["permitted"] = guests_permitted_json["permitted"]
@wizard = CustomWizard::Wizard.new(template_json, user)
end
@ -72,6 +76,28 @@ describe CustomWizard::Wizard do
expect(@wizard.start).to eq('step_2')
end
it "determines the user's current step if steps are added" do
append_steps
progress_step('step_1')
progress_step('step_2')
progress_step("step_3")
fourth_step = step_json.dup
fourth_step['id'] = "step_4"
template = template_json.dup
template['steps'] << fourth_step
CustomWizard::Template.save(template, skip_jobs: true)
wizard = CustomWizard::Wizard.new(template, user)
template['steps'].each do |step_template|
wizard.append_step(step_template['id'])
end
expect(wizard.steps.size).to eq(4)
expect(wizard.start).to eq(nil)
end
it "creates a step updater" do
expect(
@wizard.create_updater('step_1', step_1_field_1: "Text input")
@ -200,6 +226,30 @@ describe CustomWizard::Wizard do
end
end
context "with subscription and guest wizard" do
before do
enable_subscription("standard")
end
it "permits admins" do
expect(
CustomWizard::Wizard.new(@guests_permitted_template, admin_user).permitted?
).to eq(true)
end
it "permits regular users" do
expect(
CustomWizard::Wizard.new(@guests_permitted_template, user).permitted?
).to eq(true)
end
it "permits guests" do
expect(
CustomWizard::Wizard.new(@guests_permitted_template, nil, "guest123").permitted?
).to eq(true)
end
end
context "submissions" do
before do
CustomWizard::Submission.new(@wizard, step_1_field_1: "I am a user submission").save

Datei anzeigen

@ -0,0 +1,104 @@
{
"id": "action_9",
"run_after": "step_1",
"type": "create_group",
"title": [
{
"type": "assignment",
"output": "New Group Member",
"output_type": "text",
"output_connector": "set"
}
],
"custom_fields": [
{
"type": "association",
"pairs": [
{
"index": 0,
"key": "group_custom_field",
"key_type": "text",
"value": "step_3_field_1",
"value_type": "wizard_field",
"connector": "association"
}
]
}
],
"name": [
{
"type": "assignment",
"output": "step_1_field_1",
"output_type": "wizard_field",
"output_connector": "set"
}
],
"full_name": [
{
"type": "assignment",
"output": "step_1_field_1",
"output_type": "wizard_field",
"output_connector": "set"
}
],
"usernames": [
{
"type": "assignment",
"output_type": "user",
"output_connector": "set",
"output": [
"angus3"
]
}
],
"owner_usernames": [
{
"type": "assignment",
"output_type": "user",
"output_connector": "set",
"output": [
"angus"
]
}
],
"grant_trust_level": [
{
"type": "assignment",
"output": "3",
"output_type": "text",
"output_connector": "set"
}
],
"mentionable_level": [
{
"type": "assignment",
"output": "1",
"output_type": "text",
"output_connector": "set"
}
],
"messageable_level": [
{
"type": "assignment",
"output": "2",
"output_type": "text",
"output_connector": "set"
}
],
"visibility_level": [
{
"type": "assignment",
"output": "3",
"output_type": "text",
"output_connector": "set"
}
],
"members_visibility_level": [
{
"type": "assignment",
"output": "99",
"output_type": "text",
"output_connector": "set"
}
]
}

Datei anzeigen

@ -0,0 +1,17 @@
{
"condition": [
{
"type": "validation",
"pairs": [
{
"index": 0,
"key": "trust_level",
"key_type": "user_field",
"value": "2",
"value_type": "text",
"connector": "greater_or_equal"
}
]
}
]
}

Datei anzeigen

@ -195,6 +195,21 @@
]
}
],
"not_equals_pair": [
{
"type": "validation",
"pairs": [
{
"index": 0,
"key": "trust_level",
"key_type": "user_field",
"value": "1",
"value_type": "text",
"connector": "not_equal"
}
]
}
],
"greater_than_pair": [
{
"type": "validation",

Datei anzeigen

@ -1 +1 @@
//= require_tree_discourse
//= require_tree_discourse

Datei anzeigen

@ -1 +1 @@
//= require_tree_discourse dummy_path
//= require_tree_discourse dummy_path

Datei anzeigen

@ -1 +1 @@
//= require_tree_discourse sptest
//= require_tree_discourse sptest

Datei anzeigen

@ -4,7 +4,7 @@ describe CustomWizard::LogSerializer do
fab!(:user) { Fabricate(:user) }
it 'should return log attributes' do
CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message')
CustomWizard::Log.create('first-test-wizard', 'perform_first_action', 'first_test_user', 'First log message', 1.day.ago)
CustomWizard::Log.create('second-test-wizard', 'perform_second_action', 'second_test_user', 'Second log message')
json_array = ActiveModel::ArraySerializer.new(

Datei anzeigen

@ -3,7 +3,8 @@
require_relative '../../plugin_helper'
describe CustomWizard::SubmissionSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
let(:template_json) {
JSON.parse(File.open(
@ -13,36 +14,43 @@ describe CustomWizard::SubmissionSerializer do
before do
CustomWizard::Template.save(template_json, skip_jobs: true)
wizard = CustomWizard::Wizard.create(template_json["id"], user)
CustomWizard::Submission.new(wizard,
step_1_field_1: "I am user submission",
submitted_at: Time.now.iso8601
).save
@list = CustomWizard::Submission.list(wizard, page: 0)
wizard = CustomWizard::Wizard.create(template_json["id"], user1)
CustomWizard::Submission.new(wizard, step_1_field_1: "I am user1 submission", submitted_at: Time.now.iso8601).save
wizard = CustomWizard::Wizard.create(template_json["id"], user2)
CustomWizard::Submission.new(wizard, step_1_field_1: "I am user2 submission", submitted_at: Time.now.iso8601).save
end
it 'should return submission attributes' do
wizard = CustomWizard::Wizard.create(template_json["id"])
list = CustomWizard::Submission.list(wizard, page: 0)
json_array = ActiveModel::ArraySerializer.new(
@list.submissions,
list.submissions,
each_serializer: described_class
).as_json
expect(json_array.length).to eq(1)
expect(json_array.length).to eq(2)
expect(json_array[0][:id].present?).to eq(true)
expect(json_array[0][:user].present?).to eq(true)
expect(json_array[0][:submitted_at].present?).to eq(true)
expect(json_array[0][:user]).to eq(BasicUserSerializer.new(user2, root: false).as_json)
expect(json_array[1][:user]).to eq(BasicUserSerializer.new(user1, root: false).as_json)
end
it "should return field values, types and labels" do
wizard = CustomWizard::Wizard.create(template_json["id"])
list = CustomWizard::Submission.list(wizard, page: 0)
json_array = ActiveModel::ArraySerializer.new(
@list.submissions,
list.submissions,
each_serializer: described_class
).as_json
expect(json_array.length).to eq(1)
expect(json_array.length).to eq(2)
expect(json_array[0][:fields].as_json).to eq({
"step_1_field_1": {
"value": "I am user submission",
"value": "I am user2 submission",
"type": "text",
"label": "Text"
}

Datei anzeigen

@ -54,6 +54,70 @@ acceptance("Field | Fields", function (needs) {
"Input in composer"
);
});
test("Composer - Hyperlink", async function (assert) {
await visit("/w/wizard");
assert.ok(
visible(".wizard-field.composer-field .wizard-field-composer textarea")
);
assert.ok(
exists(".wizard-field.composer-field .d-editor-button-bar button")
);
assert.ok(visible(".wizard-btn.toggle-preview"));
await fillIn(
".wizard-field.composer-field .wizard-field-composer textarea",
"This is a link to "
);
assert.ok(
!exists(".insert-link.modal-body"),
"no hyperlink modal by default"
);
await click(
".wizard-field.composer-field .wizard-field-composer .d-editor button.link"
);
assert.ok(exists(".insert-link.modal-body"), "hyperlink modal visible");
await fillIn(".modal-body .link-url", "google.com");
await fillIn(".modal-body .link-text", "Google");
await click(".modal-footer button.btn-primary");
assert.strictEqual(
query(".wizard-field.composer-field .wizard-field-composer textarea")
.value,
"This is a link to [Google](https://google.com)",
"adds link with url and text, prepends 'https://'"
);
assert.ok(
!exists(
".wizard-field.composer-field .wizard-field-composer .insert-link.modal-body"
),
"modal dismissed after submitting link"
);
await fillIn(
".wizard-field.composer-field .wizard-field-composer textarea",
"Reset textarea contents."
);
await click(
".wizard-field.composer-field .wizard-field-composer .d-editor button.link"
);
await fillIn(".modal-body .link-url", "google.com");
await fillIn(".modal-body .link-text", "Google");
await click(".modal-footer button.btn-danger");
assert.strictEqual(
query(".wizard-field.composer-field .wizard-field-composer textarea")
.value,
"Reset textarea contents.",
"does not insert anything after cancelling"
);
assert.ok(
!exists(".insert-link.modal-body"),
"modal dismissed after cancelling"
);
});
test("Text Only", async function (assert) {
await visit("/w/wizard");