Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Add field and action messages
Dieser Commit ist enthalten in:
Ursprung
7cffacafd2
Commit
8cd8c3aeaa
11 geänderte Dateien mit 168 neuen und 87 gelöschten Zeilen
|
@ -1,5 +1,5 @@
|
|||
import { default as discourseComputed } from 'discourse-common/utils/decorators';
|
||||
import { equal, empty, or } from "@ember/object/computed";
|
||||
import { equal, empty, or, and } from "@ember/object/computed";
|
||||
import { generateName, selectKitContent } from '../lib/wizard';
|
||||
import { computed } from "@ember/object";
|
||||
import wizardSchema from '../lib/wizard-schema';
|
||||
|
@ -10,7 +10,6 @@ export default Component.extend(UndoChanges, {
|
|||
componentType: 'action',
|
||||
classNameBindings: [':wizard-custom-action', 'visible'],
|
||||
visible: computed('currentActionId', function() { return this.action.id === this.currentActionId }),
|
||||
actionTypes: Object.keys(wizardSchema.action.types).map(t => ({ id: t, name: generateName(t) })),
|
||||
createTopic: equal('action.type', 'create_topic'),
|
||||
updateProfile: equal('action.type', 'update_profile'),
|
||||
sendMessage: equal('action.type', 'send_message'),
|
||||
|
@ -21,10 +20,28 @@ export default Component.extend(UndoChanges, {
|
|||
apiEmpty: empty('action.api'),
|
||||
groupPropertyTypes: selectKitContent(['id', 'name']),
|
||||
hasAdvanced: or('hasCustomFields', 'routeTo'),
|
||||
showAdvanced: and('hasAdvanced', 'action.type'),
|
||||
hasCustomFields: or('basicTopicFields', 'updateProfile'),
|
||||
basicTopicFields: or('createTopic', 'sendMessage', 'openComposer'),
|
||||
publicTopicFields: or('createTopic', 'openComposer'),
|
||||
showSkipRedirect: or('createTopic', 'sendMessage'),
|
||||
actionTypes: Object.keys(wizardSchema.action.types).map(type => {
|
||||
return {
|
||||
id: type,
|
||||
name: I18n.t(`admin.wizard.action.${type}.label`)
|
||||
};
|
||||
}),
|
||||
|
||||
messageUrl: 'https://thepavilion.io/t/2810',
|
||||
|
||||
@discourseComputed('action.type')
|
||||
messageKey(type) {
|
||||
let key = 'type';
|
||||
if (type) {
|
||||
key = 'edit';
|
||||
}
|
||||
return key;
|
||||
},
|
||||
|
||||
@discourseComputed('wizard.steps')
|
||||
runAfterContent(steps) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { default as discourseComputed } from 'discourse-common/utils/decorators';
|
||||
import { equal, or } from "@ember/object/computed";
|
||||
import { equal, or, alias } from "@ember/object/computed";
|
||||
import { computed } from "@ember/object";
|
||||
import { selectKitContent } from '../lib/wizard';
|
||||
import UndoChanges from '../mixins/undo-changes';
|
||||
|
@ -22,6 +22,17 @@ export default Component.extend(UndoChanges, {
|
|||
showLimit: or('isCategory', 'isTag'),
|
||||
showMinLength: or('isText', 'isTextarea', 'isUrl', 'isComposer'),
|
||||
categoryPropertyTypes: selectKitContent(['id', 'slug']),
|
||||
showAdvanced: alias('field.type'),
|
||||
messageUrl: 'https://thepavilion.io/t/2809',
|
||||
|
||||
@discourseComputed('field.type')
|
||||
messageKey(type) {
|
||||
let key = 'type';
|
||||
if (type) {
|
||||
key = 'edit';
|
||||
}
|
||||
return key;
|
||||
},
|
||||
|
||||
setupTypeOutput(fieldType, options) {
|
||||
const selectionType = {
|
||||
|
|
16
assets/javascripts/discourse/components/wizard-message.js.es6
Normale Datei
16
assets/javascripts/discourse/components/wizard-message.js.es6
Normale Datei
|
@ -0,0 +1,16 @@
|
|||
import { default as discourseComputed } from 'discourse-common/utils/decorators';
|
||||
import Component from "@ember/component";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: 'wizard-message',
|
||||
|
||||
@discourseComputed('key', 'component')
|
||||
message(key, component) {
|
||||
return I18n.t(`admin.wizard.message.${component}.${key}`);
|
||||
},
|
||||
|
||||
@discourseComputed('component')
|
||||
documentation(component) {
|
||||
return I18n.t(`admin.wizard.message.${component}.documentation`);
|
||||
}
|
||||
})
|
|
@ -11,15 +11,15 @@ export default Controller.extend({
|
|||
},
|
||||
|
||||
@discourseComputed('creating', 'wizardId')
|
||||
message(creating, wizardId) {
|
||||
let type = 'select';
|
||||
|
||||
messageKey(creating, wizardId) {
|
||||
let key = 'select';
|
||||
if (creating) {
|
||||
type = 'create';
|
||||
key = 'create';
|
||||
} else if (wizardId) {
|
||||
type = 'edit';
|
||||
key = 'edit';
|
||||
}
|
||||
return key;
|
||||
},
|
||||
|
||||
return I18n.t(`admin.wizard.message.${type}`);
|
||||
}
|
||||
messageUrl: "https://thepavilion.io/c/knowledge/custom-wizard"
|
||||
});
|
|
@ -1,7 +1,6 @@
|
|||
import CustomWizard from '../models/custom-wizard';
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { selectKitContent } from '../lib/wizard';
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
model(params) {
|
||||
|
@ -21,10 +20,16 @@ export default DiscourseRoute.extend({
|
|||
setupController(controller, model) {
|
||||
const parentModel = this.modelFor('adminWizardsWizard');
|
||||
const wizard = CustomWizard.create((!model || model.create) ? {} : model);
|
||||
const fieldTypes = Object.keys(parentModel.field_types).map(type => {
|
||||
return {
|
||||
id: type,
|
||||
name: I18n.t(`admin.wizard.field.type.${type}`)
|
||||
};
|
||||
})
|
||||
|
||||
let props = {
|
||||
wizardList: parentModel.wizard_list,
|
||||
fieldTypes: selectKitContent(Object.keys(parentModel.field_types)),
|
||||
fieldTypes,
|
||||
userFields: parentModel.userFields,
|
||||
apis: parentModel.apis,
|
||||
themes: parentModel.themes,
|
||||
|
|
|
@ -13,24 +13,10 @@
|
|||
icon="plus"}}
|
||||
</div>
|
||||
|
||||
<div class="admin-wizard-message">
|
||||
<div class="wizard-message">
|
||||
{{d-icon 'info-circle'}}
|
||||
<span>{{message}}</span>
|
||||
</div>
|
||||
|
||||
<div class="wizard-message">
|
||||
{{d-icon 'question-circle'}}
|
||||
|
||||
<a href="https://thepavilion.io/c/knowledge/custom-wizard" target="_blank">
|
||||
{{i18n 'admin.wizard.message.documentation'}}
|
||||
</a>
|
||||
|
||||
{{!--<a href="mailto:help@thepavilion.io" target="_blank">
|
||||
{{i18n 'admin.wizard.message.contact'}}
|
||||
</a>--}}
|
||||
</div>
|
||||
</div>
|
||||
{{wizard-message
|
||||
key=messageKey
|
||||
url=messageUrl
|
||||
component='wizard'}}
|
||||
|
||||
<div class="admin-wizard-container settings">
|
||||
{{outlet}}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
content=actionTypes
|
||||
onChange=(action "changeType")
|
||||
options=(hash
|
||||
none="admin.wizard.field.type"
|
||||
none="admin.wizard.select_type"
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -35,6 +35,11 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{wizard-message
|
||||
key=messageKey
|
||||
url=messageUrl
|
||||
component='action'}}
|
||||
|
||||
{{#if basicTopicFields}}
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
|
@ -267,7 +272,7 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if hasAdvanced}}
|
||||
{{#if showAdvanced}}
|
||||
{{wizard-advanced-toggle showAdvanced=action.showAdvanced}}
|
||||
|
||||
{{#if action.showAdvanced}}
|
||||
|
|
|
@ -60,11 +60,16 @@
|
|||
content=fieldTypes
|
||||
onChange=(action "changeType")
|
||||
options=(hash
|
||||
none="admin.wizard.field.type"
|
||||
none="admin.wizard.select_type"
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{wizard-message
|
||||
key=messageKey
|
||||
url=messageUrl
|
||||
component='field'}}
|
||||
|
||||
{{#if showMinLength}}
|
||||
<div class="setting">
|
||||
<div class="setting-label">
|
||||
|
@ -137,6 +142,7 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if showAdvanced}}
|
||||
{{wizard-advanced-toggle showAdvanced=field.showAdvanced}}
|
||||
|
||||
{{#if field.showAdvanced}}
|
||||
|
@ -175,3 +181,4 @@
|
|||
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
12
assets/javascripts/discourse/templates/components/wizard-message.hbs
Normale Datei
12
assets/javascripts/discourse/templates/components/wizard-message.hbs
Normale Datei
|
@ -0,0 +1,12 @@
|
|||
<div class="message-block">
|
||||
{{d-icon 'info-circle'}}
|
||||
<span>{{message}}</span>
|
||||
</div>
|
||||
|
||||
<div class="message-block">
|
||||
{{d-icon 'question-circle'}}
|
||||
|
||||
<a href={{url}} target="_blank">
|
||||
{{documentation}}
|
||||
</a>
|
||||
</div>
|
|
@ -7,15 +7,21 @@
|
|||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
|
||||
&+ .wizard-message + div {
|
||||
margin-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-wizard-message {
|
||||
.wizard-message {
|
||||
background-color: $primary-low;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.wizard-message {
|
||||
.message-block {
|
||||
.d-icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
@ -26,10 +32,10 @@
|
|||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.admin-wizard-container {
|
||||
margin-top: 20px;
|
||||
& + div {
|
||||
margin-top: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
.wizard-submissions {
|
||||
|
@ -55,7 +61,6 @@
|
|||
}
|
||||
|
||||
.wizard-settings-parent {
|
||||
margin-bottom: 30px;
|
||||
padding: 20px;
|
||||
border: 1px solid $primary-low;
|
||||
}
|
||||
|
@ -419,7 +424,7 @@
|
|||
}
|
||||
|
||||
.wizard-links {
|
||||
margin: 20px 0;
|
||||
margin: 40px 0 20px 0;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
|
||||
|
|
|
@ -55,13 +55,23 @@ en:
|
|||
advanced: "Advanced"
|
||||
undo: "Undo"
|
||||
clear: "Clear"
|
||||
select_type: "Select a type"
|
||||
|
||||
message:
|
||||
wizard:
|
||||
select: "Select a wizard, or create a new one"
|
||||
edit: "You're editing a wizard"
|
||||
create: "You're creating a new wizard"
|
||||
documentation: "Check out the documentation"
|
||||
documentation: "Check out the wizard documentation"
|
||||
contact: "Contact the developer"
|
||||
field:
|
||||
type: "Select a field type"
|
||||
edit: "You're editing a field"
|
||||
documentation: "Check out the field documentation"
|
||||
action:
|
||||
type: "Select an action type"
|
||||
edit: "You're editing an action"
|
||||
documentation: "Check out the action documentation"
|
||||
|
||||
editor:
|
||||
show: "Show"
|
||||
|
@ -124,7 +134,6 @@ en:
|
|||
label: "Params"
|
||||
|
||||
field:
|
||||
type: "Choose a type"
|
||||
header: "Fields"
|
||||
label: "Label"
|
||||
description: "Description"
|
||||
|
@ -135,13 +144,26 @@ en:
|
|||
min_length: "Min Length"
|
||||
min_length_placeholder: "Minimum length in characters"
|
||||
file_types: "File Types"
|
||||
tag: "Tag"
|
||||
category: "Category"
|
||||
limit: "Limit"
|
||||
property: "Property"
|
||||
prefill: "Prefill"
|
||||
content: "Content"
|
||||
|
||||
type:
|
||||
text: "Text"
|
||||
textarea: Textarea
|
||||
composer: Composer
|
||||
text_only: Text Only
|
||||
number: Number
|
||||
checkbox: Checkbox
|
||||
url: Url
|
||||
upload: Upload
|
||||
dropdown: Dropdown
|
||||
tag: Tag
|
||||
category: Category
|
||||
group: Group
|
||||
user_selector: User Selector
|
||||
|
||||
connector:
|
||||
and: "and"
|
||||
or: "or"
|
||||
|
@ -166,7 +188,6 @@ en:
|
|||
run_after:
|
||||
label: "Run After"
|
||||
wizard_completion: "Wizard Completion"
|
||||
|
||||
custom_fields:
|
||||
label: "Custom"
|
||||
key: "field"
|
||||
|
@ -180,6 +201,8 @@ en:
|
|||
label: "Create Topic"
|
||||
category: "Category"
|
||||
tags: "Tags"
|
||||
open_composer:
|
||||
label: "Open Composer"
|
||||
update_profile:
|
||||
label: "Fields"
|
||||
key: "field"
|
||||
|
@ -195,12 +218,6 @@ en:
|
|||
label: "Route To"
|
||||
url: "Url"
|
||||
code: "Code"
|
||||
custom_title: "Custom Title"
|
||||
custom_category:
|
||||
label: "Custom Category"
|
||||
user_field: "User Field"
|
||||
custom_tag:
|
||||
label: "Custom Tag"
|
||||
send_to_api:
|
||||
label: "Send to API"
|
||||
api: "API"
|
||||
|
|
Laden …
In neuem Issue referenzieren