0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 02:50:28 +01:00
Dieser Commit ist enthalten in:
Robert Barrow 2019-11-04 18:10:20 +00:00
Commit 2e1926fc8a
8 geänderte Dateien mit 44 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -57,6 +57,16 @@ export default Ember.Component.extend({
return fields.map((f) => ` w{${f.id}}`); return fields.map((f) => ` w{${f.id}}`);
}, },
@computed('availableFields')
categoryFields(fields) {
return fields.filter(f => f.type == 'category');
},
@computed('availableFields')
tagFields(fields) {
return fields.filter(f => f.type == 'tag');
},
@computed() @computed()
builderUserFields() { builderUserFields() {
const noTheme = PROFILE_FIELDS.filter((f) => f !== 'theme_id'); const noTheme = PROFILE_FIELDS.filter((f) => f !== 'theme_id');

Datei anzeigen

@ -63,7 +63,8 @@ export default Ember.Component.extend({
let stepFields = s.fields.map((f) => { let stepFields = s.fields.map((f) => {
return Ember.Object.create({ return Ember.Object.create({
id: f.id, id: f.id,
label: `${f.id} (${s.id})` label: `${f.id} (${s.id})`,
type: f.type
}); });
}); });
fields.push(...stepFields); fields.push(...stepFields);

Datei anzeigen

@ -88,7 +88,7 @@
<span>{{i18n 'admin.wizard.action.custom_category.wizard_field'}}</span> <span>{{i18n 'admin.wizard.action.custom_category.wizard_field'}}</span>
{{#if action.custom_category_wizard_field}} {{#if action.custom_category_wizard_field}}
{{combo-box value=action.category_id {{combo-box value=action.category_id
content=availableFields content=categoryFields
nameProperty="label" nameProperty="label"
none='admin.wizard.select_field'}} none='admin.wizard.select_field'}}
{{/if}} {{/if}}
@ -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}}
@ -264,7 +276,3 @@
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{#if openComposer}}
{{/if}}

Datei anzeigen

@ -1,3 +1,4 @@
(function() { (function () {
window.location.href = "/login"; document.cookie = 'destination_url=' + window.location.href + ';path=/';
})(); window.location.href = '/login'
})()

Datei anzeigen

@ -11,6 +11,7 @@
//= require discourse/lib/page-visible //= require discourse/lib/page-visible
//= require discourse/lib/logout //= require discourse/lib/logout
//= require discourse/lib/render-tag //= require discourse/lib/render-tag
//= require discourse/lib/notification-levels
//= require markdown-it-bundle //= require markdown-it-bundle
//= require pretty-text/engines/discourse-markdown-it //= require pretty-text/engines/discourse-markdown-it

Datei anzeigen

@ -160,6 +160,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

@ -5,12 +5,6 @@ class CustomWizard::WizardController < ::ApplicationController
helper_method :wizard_page_title helper_method :wizard_page_title
helper_method :theme_ids helper_method :theme_ids
before_action :handle_login_redirect, unless: :current_user
def handle_login_redirect
cookies[:destination_url] = "/w/#{params[:wizard_id]}"
end
def wizard def wizard
CustomWizard::Template.new(PluginStore.get('custom_wizard', params[:wizard_id].underscore)) CustomWizard::Template.new(PluginStore.get('custom_wizard', params[:wizard_id].underscore))
end end

Datei anzeigen

@ -560,8 +560,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)
@ -605,7 +605,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
@ -618,4 +618,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