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

FIX: properly account for custom tag fields

Dieser Commit ist enthalten in:
Angus McLeod 2019-10-15 16:34:43 +11:00
Ursprung 9880bd780e
Commit 7792d2365b
4 geänderte Dateien mit 31 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -59,9 +59,13 @@ export default Ember.Component.extend({
@computed('availableFields') @computed('availableFields')
categoryFields(fields) { categoryFields(fields) {
console.log(fields);
return fields.filter(f => f.type == 'category'); return fields.filter(f => f.type == 'category');
}, },
@computed('availableFields')
tagFields(fields) {
return fields.filter(f => f.type == 'tag');
},
@computed() @computed()
builderUserFields() { builderUserFields() {

Datei anzeigen

@ -114,7 +114,19 @@
{{tag-chooser tags=action.tags {{tag-chooser tags=action.tags
filterable=true filterable=true
allowCreate=true allowCreate=true
isDisabled=action.custom_category_enabled}} isDisabled=action.custom_tag_enabled}}
<div class="setting-gutter">
{{input type='checkbox' checked=action.custom_tag_enabled}}
<span>{{i18n 'admin.wizard.action.custom_tag.label'}}</span>
{{#if action.custom_tag_enabled}}
<div class="custom-tag">
{{combo-box value=action.custom_tag_field
content=tagFields
nameProperty="label"
none='admin.wizard.select_field'}}
</div>
{{/if}}
</div>
</div> </div>
</div> </div>
{{/if}} {{/if}}

Datei anzeigen

@ -158,6 +158,8 @@ en:
label: "Custom Category" label: "Custom Category"
wizard_field: "Wizard Field" wizard_field: "Wizard Field"
user_field: "User Field" user_field: "User Field"
custom_tag:
label: "Custom Tag"
send_to_api: send_to_api:
label: "Send to API" label: "Send to API"
api: "API" api: "API"

Datei anzeigen

@ -558,8 +558,8 @@ class CustomWizard::Builder
end end
end end
if action['tags'].present? if tags = action_tags(action, data)
url += "&tags=#{action['tags'].join(',')}" url += "&tags=#{tags.join(',')}"
end end
data['redirect_on_complete'] = Discourse.base_uri + URI.encode(url) data['redirect_on_complete'] = Discourse.base_uri + URI.encode(url)
@ -603,7 +603,7 @@ class CustomWizard::Builder
def action_category_id(action, data) def action_category_id(action, data)
if action['custom_category_enabled'] if action['custom_category_enabled']
if action['custom_category_wizard_field'] if action['custom_category_wizard_field']
category_id = data[action['category_id']] data[action['category_id']]
elsif action['custom_category_user_field_key'] elsif action['custom_category_user_field_key']
if action['custom_category_user_field_key'].include?('custom_fields') if action['custom_category_user_field_key'].include?('custom_fields')
field = action['custom_category_user_field_key'].split('.').last field = action['custom_category_user_field_key'].split('.').last
@ -616,4 +616,12 @@ class CustomWizard::Builder
action['category_id'] action['category_id']
end end
end end
def action_tags(action, data)
if action['custom_tag_enabled']
data[action['custom_tag_field']]
else
action['tags']
end
end
end end