Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Merge pull request #26 from merefield/national_flags_better_integration
REMOVE: all redundant nat flags logic that has been moved to national flags plugin
Dieser Commit ist enthalten in:
Commit
0a79517301
9 geänderte Dateien mit 4 neuen und 66 gelöschten Zeilen
|
@ -32,12 +32,7 @@ export default Ember.Component.extend({
|
||||||
name: I18n.t('admin.wizard.field.choices_preset.tags')
|
name: I18n.t('admin.wizard.field.choices_preset.tags')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
if (Discourse.SiteSettings.nationalflag_enabled) {
|
|
||||||
presets.push({
|
|
||||||
id: 'flags',
|
|
||||||
name: I18n.t('admin.wizard.field.choices_preset.flags')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return presets;
|
return presets;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -29,19 +29,6 @@ export default {
|
||||||
|
|
||||||
registerRawHelpers(RawHandlebars, Handlebars);
|
registerRawHelpers(RawHandlebars, Handlebars);
|
||||||
|
|
||||||
WizardFieldDropdown.reopen({
|
|
||||||
tagName: 'span',
|
|
||||||
classNames: ['wizard-select-value'],
|
|
||||||
|
|
||||||
@computed
|
|
||||||
isFlagSelector() {
|
|
||||||
const field = this.get('field');
|
|
||||||
//TODO improve the way this detects a flag dropdown (currently it relies on the string 'Nation', e.g. 'Nationality' or 'National Flag' appearing in label)
|
|
||||||
return (typeof field.label !== 'undefined') ? (field.label.includes(Discourse.SiteSettings.wizard_national_flags_label_cue)) ? true : false : false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// IE11 Polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill
|
// IE11 Polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill
|
||||||
if (!Object.entries)
|
if (!Object.entries)
|
||||||
Object.entries = function( obj ){
|
Object.entries = function( obj ){
|
||||||
|
|
|
@ -4,7 +4,4 @@
|
||||||
content=field.choices
|
content=field.choices
|
||||||
none=(hash id="__none__" label=field.dropdown_none)
|
none=(hash id="__none__" label=field.dropdown_none)
|
||||||
nameProperty="label"
|
nameProperty="label"
|
||||||
tabindex="9"}}
|
tabindex="9"}}
|
||||||
{{#if isFlagSelector}}
|
|
||||||
<img class="nationalflag-usersummary" src="/plugins/discourse-nationalflags/images/nationalflags/{{field.value}}.png" />
|
|
||||||
{{/if}}
|
|
|
@ -103,7 +103,6 @@ en:
|
||||||
categories: "Categories"
|
categories: "Categories"
|
||||||
groups: "Groups"
|
groups: "Groups"
|
||||||
tags: "Tags"
|
tags: "Tags"
|
||||||
flags: "Flags"
|
|
||||||
filter: "Preset Filter"
|
filter: "Preset Filter"
|
||||||
choice:
|
choice:
|
||||||
value: "Value"
|
value: "Value"
|
||||||
|
|
|
@ -22,5 +22,4 @@ en:
|
||||||
|
|
||||||
site_settings:
|
site_settings:
|
||||||
wizard_redirect_exclude_paths: "Routes excluded from wizard redirects."
|
wizard_redirect_exclude_paths: "Routes excluded from wizard redirects."
|
||||||
wizard_recognised_image_upload_formats: "File types which will result in upload displaying an image preview"
|
wizard_recognised_image_upload_formats: "File types which will result in upload displaying an image preview"
|
||||||
wizard_national_flags_label_cue: "The characters that must appear in the dropdown field label for it to show a flag"
|
|
|
@ -11,7 +11,4 @@ plugins:
|
||||||
default: "jpg|jpeg|png|gif"
|
default: "jpg|jpeg|png|gif"
|
||||||
refresh: true
|
refresh: true
|
||||||
type: list
|
type: list
|
||||||
list_type: compact
|
list_type: compact
|
||||||
wizard_national_flags_label_cue:
|
|
||||||
client: true
|
|
||||||
default: "National"
|
|
|
@ -290,10 +290,6 @@ class CustomWizard::Builder
|
||||||
objects = Tag.top_tags(guardian: guardian).map { |tag| TagStruct.new(tag,tag) }
|
objects = Tag.top_tags(guardian: guardian).map { |tag| TagStruct.new(tag,tag) }
|
||||||
end
|
end
|
||||||
|
|
||||||
if field_template['choices_preset'] === 'flags'
|
|
||||||
objects = CustomWizard::Flags.list
|
|
||||||
end
|
|
||||||
|
|
||||||
if field_template['choices_filters'] && field_template['choices_filters'].length > 0
|
if field_template['choices_filters'] && field_template['choices_filters'].length > 0
|
||||||
field_template['choices_filters'].each do |f|
|
field_template['choices_filters'].each do |f|
|
||||||
objects.reject! do |o|
|
objects.reject! do |o|
|
||||||
|
|
31
lib/flags.rb
31
lib/flags.rb
|
@ -1,31 +0,0 @@
|
||||||
class CustomWizard::Flag
|
|
||||||
def initialize(id, name)
|
|
||||||
@id = id
|
|
||||||
@name = name
|
|
||||||
end
|
|
||||||
|
|
||||||
def id
|
|
||||||
@id
|
|
||||||
end
|
|
||||||
|
|
||||||
def name
|
|
||||||
@name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class CustomWizard::Flags
|
|
||||||
|
|
||||||
def self.list
|
|
||||||
raw_flags = YAML.safe_load(File.read(File.join(Rails.root, 'plugins', 'discourse-custom-wizard', 'config', 'national_flags.yml')))
|
|
||||||
|
|
||||||
flagscollection = []
|
|
||||||
|
|
||||||
raw_flags.map do |name, pic|
|
|
||||||
# This is super hacky. Adding the trailing space actually stops search breaking in the dropdown! (and doesn't compromise the view!)
|
|
||||||
# Feeding just name, name will break search
|
|
||||||
flagscollection << CustomWizard::Flag.new(name, "#{name} ")
|
|
||||||
end
|
|
||||||
|
|
||||||
flagscollection
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -85,7 +85,6 @@ after_initialize do
|
||||||
load File.expand_path('../jobs/set_after_time_wizard.rb', __FILE__)
|
load File.expand_path('../jobs/set_after_time_wizard.rb', __FILE__)
|
||||||
load File.expand_path('../lib/builder.rb', __FILE__)
|
load File.expand_path('../lib/builder.rb', __FILE__)
|
||||||
load File.expand_path('../lib/field.rb', __FILE__)
|
load File.expand_path('../lib/field.rb', __FILE__)
|
||||||
load File.expand_path('../lib/flags.rb', __FILE__)
|
|
||||||
load File.expand_path('../lib/step_updater.rb', __FILE__)
|
load File.expand_path('../lib/step_updater.rb', __FILE__)
|
||||||
load File.expand_path('../lib/template.rb', __FILE__)
|
load File.expand_path('../lib/template.rb', __FILE__)
|
||||||
load File.expand_path('../lib/wizard.rb', __FILE__)
|
load File.expand_path('../lib/wizard.rb', __FILE__)
|
||||||
|
|
Laden …
In neuem Issue referenzieren