0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-16 06:40:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs
Angus McLeod af3e61fe75
Add custom field improvements (#115)
* Add custom field improvements

This PR does a few things to improve our support of custom fields
1. Adds custom fields added by other plugins to the list in admin/wizards/custom-fields and the custom field list in the mapper selector
2. Adds support for json custom fields in the wizard actions

* Make eslint happy

* Make prettier happy

* Make rubocop happy

* Make ember template lint happy

* Don't assume we have the context in the selector

* Ensure custom fields don't require optional attributes (with tests)
2021-06-08 17:09:49 +05:30

812 Zeilen
22 KiB
Handlebars

{{#if showUndo}}
{{d-button
action="undoChanges"
icon=undoIcon
label=undoKey
class="undo-changes"}}
{{/if}}
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.type"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.type
content=actionTypes
onChange=(action "changeType")
options=(hash
none="admin.wizard.select_type"
)}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.run_after.label"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.run_after
content=runAfterContent
onChange=(action (mut action.run_after))}}
</div>
</div>
{{wizard-message
key=messageKey
url=messageUrl
component="action"}}
{{#if basicTopicFields}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.title"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.title
property="title"
onUpdate=(action "mappedFieldUpdated")
options=(hash
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
)}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.post"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.post
content=wizardFields
nameProperty="label"
onChange=(action (mut action.post))
options=(hash
none="admin.wizard.selector.placeholder.wizard_field"
isDisabled=showPostBuilder
)}}
<div class="setting-gutter">
{{input type="checkbox" checked=action.post_builder}}
<span>{{i18n "admin.wizard.action.post_builder.checkbox"}}</span>
</div>
</div>
</div>
{{#if action.post_builder}}
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.post_builder.label"}}</label>
</div>
<div class="setting-value editor">
{{wizard-text-editor
value=action.post_template
wizardFields=wizardFields}}
</div>
</div>
{{/if}}
{{/if}}
{{#if publicTopicFields}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.category"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.category
property="category"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="key,value"
wizardFieldSelection=true
userFieldSelection="key,value"
categorySelection="output"
wizardActionSelection="output"
outputDefaultSelection="category"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.tags"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.tags
property="tags"
onUpdate=(action "mappedFieldUpdated")
options=(hash
tagSelection="output"
outputDefaultSelection="tag"
listSelection="output"
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.visible"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.visible
property="visible"
onUpdate=(action "mappedFieldUpdated")
options=(hash
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
{{/if}}
{{#if sendMessage}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_message.recipient"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.recipient
property="recipient"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="value,output"
wizardFieldSelection=true
userFieldSelection="key,value"
groupSelection="key,value"
userSelection="output"
outputDefaultSelection="user"
context="action"
)}}
</div>
</div>
{{/if}}
{{#if updateProfile}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.update_profile.setting"}}</label>
</div>
{{wizard-mapper
inputs=action.profile_updates
property="profile_updates"
onUpdate=(action "mappedFieldUpdated")
options=(hash
inputTypes="association"
textSelection="value"
userFieldSelection="key"
wizardFieldSelection="value"
wizardActionSelection="value"
keyDefaultSelection="userField"
context="action"
)}}
</div>
{{/if}}
{{#if sendToApi}}
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_to_api.api"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.api
content=availableApis
onChange=(action (mut action.api))
options=(hash
isDisabled=action.custom_title_enabled
none="admin.wizard.action.send_to_api.select_an_api"
)}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_to_api.endpoint"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.api_endpoint
content=availableEndpoints
onChange=(action (mut action.api_endpoint))
options=(hash
isDisabled=apiEmpty
none="admin.wizard.action.send_to_api.select_an_endpoint"
)}}
</div>
</div>
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_to_api.body"}}</label>
</div>
<div class="setting-value">
{{wizard-text-editor
value=action.api_body
previewEnabled=false
barEnabled=false
wizardFields=wizardFields
placeholder="admin.wizard.action.send_to_api.body_placeholder"}}
</div>
</div>
{{/if}}
{{#if addToGroup}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.group"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.group
property="group"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="value,output"
wizardFieldSelection="key,value,assignment"
userFieldSelection="key,value,assignment"
wizardActionSelection=true
groupSelection="value,output"
outputDefaultSelection="group"
context="action"
)}}
</div>
</div>
{{/if}}
{{#if routeTo}}
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.route_to.url"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.url
property="url"
onUpdate=(action "mappedFieldUpdated")
options=(hash
context="action"
wizardFieldSelection=true
userFieldSelection="key,value"
groupSelection="key,value"
categorySelection="key,value"
userSelection="key,value"
)}}
</div>
</div>
{{/if}}
{{#if watchCategories}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.watch_categories.categories"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.categories
property="categories"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="key,value"
wizardFieldSelection=true
wizardActionSelection=true
userFieldSelection="key,value"
categorySelection="output"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.watch_categories.mute_remainder"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.mute_remainder
property="mute_remainder"
onUpdate=(action "mappedFieldUpdated")
options=(hash
context="action"
wizardFieldSelection=true
userFieldSelection="key,value"
)}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.watch_categories.notification_level.label"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.notification_level
content=availableNotificationLevels
onChange=(action (mut action.notification_level))
options=(hash
isDisabled=action.custom_title_enabled
none="admin.wizard.action.watch_categories.select_a_notification_level"
)}}
</div>
</div>
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.watch_categories.wizard_user"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.wizard_user}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.watch_categories.usernames"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.usernames
property="usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
context="action"
wizardFieldSelection=true
userFieldSelection="key,value"
userSelection="output"
)}}
</div>
</div>
{{/if}}
{{#if createGroup}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.name"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.name
property="name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.full_name"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.full_name
property="full_name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.title"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.title
property="title"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.bio_raw"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.bio_raw
property="bio_raw"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.owner_usernames"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.owner_usernames
property="owner_usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
userSelection="output"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.usernames"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.usernames
property="usernames"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
userSelection="output"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.grant_trust_level"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.grant_trust_level
property="grant_trust_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.mentionable_level"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.mentionable_level
property="mentionable_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.messageable_level"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.messageable_level
property="messageable_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.visibility_level"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.visibility_level
property="visibility_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_group.members_visibility_level"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.members_visibility_level
property="members_visibility_level"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection=true
context="action"
)}}
</div>
</div>
{{/if}}
{{#if createCategory}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_category.name"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.name
property="name"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="key,value"
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_category.slug"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.slug
property="slug"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_category.color"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.color
property="color"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_category.text_color"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.text_color
property="text_color"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection=true
wizardFieldSelection=true
userFieldSelection="key,value"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_category.parent_category"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.parent_category_id
property="parent_category_id"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="key,value"
wizardFieldSelection=true
userFieldSelection="key,value"
categorySelection="output"
context="action"
)}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_category.permissions"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.permissions
property="permissions"
onUpdate=(action "mappedFieldUpdated")
options=(hash
inputTypes="association"
textSelection=true
wizardFieldSelection=true
wizardActionSelection="key"
userFieldSelection=true
groupSelection="key"
context="action"
)}}
</div>
</div>
{{/if}}
{{#if showAdvanced}}
{{wizard-advanced-toggle showAdvanced=action.showAdvanced}}
{{#if action.showAdvanced}}
<div class="advanced-settings">
{{#if hasCustomFields}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.custom_fields.label"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.custom_fields
property="custom_fields"
onUpdate=(action "mappedFieldUpdated")
options=(hash
inputTypes="association"
customFieldSelection="key"
wizardFieldSelection="value"
wizardActionSelection="value"
userFieldSelection="value"
keyPlaceholder="admin.wizard.action.custom_fields.key"
context=customFieldsContext
)}}
</div>
</div>
{{/if}}
{{#if sendMessage}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.required"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.required
property="required"
onUpdate=(action "mappedFieldUpdated")
options=(hash
textSelection="value"
wizardFieldSelection=true
userFieldSelection=true
groupSelection=true
context="action"
)}}
</div>
</div>
{{/if}}
{{#if showPostAdvanced}}
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.skip_redirect.label"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.skip_redirect}}
<span>
{{i18n "admin.wizard.action.skip_redirect.description" type="topic"}}
</span>
</div>
</div>
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.suppress_notifications.label"}}</label>
</div>
<div class="setting-value">
{{input type="checkbox" checked=action.suppress_notifications}}
<span>
{{i18n "admin.wizard.action.suppress_notifications.description" type="topic"}}
</span>
</div>
</div>
{{/if}}
{{#if routeTo}}
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.route_to.code"}}</label>
</div>
<div class="setting-value">
{{input value=action.code}}
</div>
</div>
{{/if}}
</div>
{{/if}}
{{/if}}