From 5b210c41d414c545b913e40eaf2d10dedfee30ee Mon Sep 17 00:00:00 2001 From: Robert Barrow Date: Sun, 10 Nov 2019 22:48:06 +0000 Subject: [PATCH] REMOVE: all national flags logic that will be moved to national flags plugin --- .../components/wizard-custom-field.js.es6 | 7 +---- .../wizard/initializers/custom.js.es6 | 13 -------- .../components/wizard-field-dropdown.hbs | 5 +-- config/locales/client.en.yml | 1 - config/locales/server.en.yml | 3 +- config/settings.yml | 5 +-- lib/builder.rb | 4 --- lib/flags.rb | 31 ------------------- plugin.rb | 1 - 9 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 lib/flags.rb diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 1afb1683..484b501a 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -32,12 +32,7 @@ export default Ember.Component.extend({ 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; }, diff --git a/assets/javascripts/wizard/initializers/custom.js.es6 b/assets/javascripts/wizard/initializers/custom.js.es6 index 7e9d2b69..8dc7893e 100644 --- a/assets/javascripts/wizard/initializers/custom.js.es6 +++ b/assets/javascripts/wizard/initializers/custom.js.es6 @@ -20,19 +20,6 @@ export default { const Singleton = requirejs("discourse/mixins/singleton").default; const WizardFieldDropdown = requirejs('wizard/components/wizard-field-dropdown').default; - 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 if (!Object.entries) Object.entries = function( obj ){ diff --git a/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs b/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs index 011a2e3f..4f411ce3 100644 --- a/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs +++ b/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs @@ -4,7 +4,4 @@ content=field.choices none=(hash id="__none__" label=field.dropdown_none) nameProperty="label" - tabindex="9"}} -{{#if isFlagSelector}} - -{{/if}} + tabindex="9"}} \ No newline at end of file diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index c2c4ee6a..e5cd67a5 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -101,7 +101,6 @@ en: categories: "Categories" groups: "Groups" tags: "Tags" - flags: "Flags" filter: "Preset Filter" choice: value: "Value" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index dd36b72f..a0063e3b 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -22,5 +22,4 @@ en: site_settings: 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_national_flags_label_cue: "The characters that must appear in the dropdown field label for it to show a flag" \ No newline at end of file + wizard_recognised_image_upload_formats: "File types which will result in upload displaying an image preview" \ No newline at end of file diff --git a/config/settings.yml b/config/settings.yml index e99f28bd..552f0ce8 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -11,7 +11,4 @@ plugins: default: "jpg|jpeg|png|gif" refresh: true type: list - list_type: compact - wizard_national_flags_label_cue: - client: true - default: "National" + list_type: compact \ No newline at end of file diff --git a/lib/builder.rb b/lib/builder.rb index 1e2c08a6..60ef4861 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -291,10 +291,6 @@ class CustomWizard::Builder objects = Tag.top_tags(guardian: guardian).map { |tag| TagStruct.new(tag,tag) } end - if field_template['choices_preset'] === 'flags' - objects = CustomWizard::Flags.list - end - if field_template['choices_filters'] && field_template['choices_filters'].length > 0 field_template['choices_filters'].each do |f| objects.reject! do |o| diff --git a/lib/flags.rb b/lib/flags.rb deleted file mode 100644 index 00f29866..00000000 --- a/lib/flags.rb +++ /dev/null @@ -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 diff --git a/plugin.rb b/plugin.rb index 4ce2932e..02c96da8 100644 --- a/plugin.rb +++ b/plugin.rb @@ -85,7 +85,6 @@ after_initialize do load File.expand_path('../jobs/set_after_time_wizard.rb', __FILE__) load File.expand_path('../lib/builder.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/template.rb', __FILE__) load File.expand_path('../lib/wizard.rb', __FILE__)