1
0
Fork 0

NEW FEATURE: ability to request national flag update in wizard

Dieser Commit ist enthalten in:
Robert Barrow 2019-09-11 09:30:38 +01:00
Ursprung 961ad8cc27
Commit 1670ed4b67
8 geänderte Dateien mit 873 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,7 @@ export default Ember.Component.extend({
@computed()
presetChoices() {
return [
let presets = [
{
id: 'categories',
name: I18n.t('admin.wizard.field.choices_preset.categories')
@ -32,6 +32,13 @@ 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;
},
@on('didInsertElement')

Datei anzeigen

@ -1,3 +1,5 @@
import { default as computed } from 'ember-addons/ember-computed-decorators';
export default {
name: 'custom-routes',
@ -16,6 +18,20 @@ export default {
const autocomplete = requirejs('discourse/lib/autocomplete').default;
const cook = requirejs('discourse/plugins/discourse-custom-wizard/wizard/lib/text-lite').cook;
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 (field.label.includes('Nation')) ? true : false;
}
});
// IE11 Polyfill - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill
if (!Object.entries)

Datei anzeigen

@ -5,3 +5,6 @@
none=(hash id="__none__" label=field.dropdown_none)
nameProperty="label"
tabindex="9"}}
{{#if isFlagSelector}}
<img class="nationalflag-usersummary" src="/plugins/discourse-nationalflags/images/nationalflags/{{field.value}}.png" />
{{/if}}

Datei anzeigen

@ -229,8 +229,27 @@
margin: 20px 0;
}
.wizard-image-row .wizard-btn-upload {
margin: 0;
.wizard-image-row {
.wizard-btn-upload {
margin: 0;
}
}
.wizard-image-preview {
max-width: 200px;
max-height: 200px;
overflow: hidden;
img {
max-width:100%;
max-height:100%;
}
}
.wizard-select-value img {
vertical-align: middle;
}
.wizard-field-upload {

Datei anzeigen

@ -101,6 +101,7 @@ en:
categories: "Categories"
groups: "Groups"
tags: "Tags"
flags: "Flags"
filter: "Preset Filter"
choice:
value: "Value"

Datei anzeigen

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

819
lib/flags.rb Normale Datei
Datei anzeigen

@ -0,0 +1,819 @@
class CustomWizard::Flag
def initialize(id, name, value)
@id = id
@name = name
@value = value
end
def id
@id
end
def name
@name
end
def value
@value
end
end
class CustomWizard::Flags
def self.list
flags = [
{ "id" => 0,
"name"=> "none",
"value"=> "none.png"
}, {
"id"=> 1,
"name"=> "ad",
"value"=> "ad.png"
}, {
"id"=> 2,
"name"=> "ae",
"value"=> "ae.png"
}, {
"name"=> "af",
"value"=> "af.png"
}, {
"name"=> "ag",
"value"=> "ag.png"
}, {
"name"=> "ai",
"value"=> "ai.png"
}, {
"name"=> "al",
"value"=> "al.png"
}, {
"name"=> "am",
"value"=> "am.png"
}, {
"name"=> "ao",
"value"=> "ao.png"
}, {
"name"=> "aq",
"value"=> "aq.png"
}, {
"name"=> "ar",
"value"=> "ar.png"
}, {
"name"=> "as",
"value"=> "as.png"
}, {
"name"=> "at",
"value"=> "at.png"
}, {
"name"=> "au",
"value"=> "au.png"
}, {
"name"=> "aw",
"value"=> "aw.png"
}, {
"name"=> "ax",
"value"=> "ax.png"
}, {
"name"=> "az",
"value"=> "az.png"
}, {
"name"=> "ba",
"value"=> "ba.png"
}, {
"name"=> "bb",
"value"=> "bb.png"
}, {
"name"=> "bd",
"value"=> "bd.png"
}, {
"name"=> "be",
"value"=> "be.png"
}, {
"name"=> "bf",
"value"=> "bf.png"
}, {
"name"=> "bg",
"value"=> "bg.png"
}, {
"name"=> "bh",
"value"=> "bh.png"
}, {
"name"=> "bi",
"value"=> "bi.png"
}, {
"name"=> "bj",
"value"=> "bj.png"
}, {
"name"=> "bl",
"value"=> "bl.png"
}, {
"name"=> "bm",
"value"=> "bm.png"
}, {
"name"=> "bn",
"value"=> "bn.png"
}, {
"name"=> "bo",
"value"=> "bo.png"
}, {
"name"=> "bq",
"value"=> "bq.png"
}, {
"name"=> "br",
"value"=> "br.png"
}, {
"name"=> "bs",
"value"=> "bs.png"
}, {
"name"=> "bt",
"value"=> "bt.png"
}, {
"name"=> "bv",
"value"=> "bv.png"
}, {
"name"=> "bw",
"value"=> "bw.png"
}, {
"name"=> "by",
"value"=> "by.png"
}, {
"name"=> "bz",
"value"=> "bz.png"
}, {
"name"=> "ca",
"value"=> "ca.png"
}, {
"name"=> "cc",
"value"=> "cc.png"
}, {
"name"=> "cd",
"value"=> "cd.png"
}, {
"name"=> "cf",
"value"=> "cf.png"
}, {
"name"=> "cg",
"value"=> "cg.png"
}, {
"name"=> "ch",
"value"=> "ch.png"
}, {
"name"=> "ci",
"value"=> "ci.png"
}, {
"name"=> "ck",
"value"=> "ck.png"
}, {
"name"=> "cl",
"value"=> "cl.png"
}, {
"name"=> "cm",
"value"=> "cm.png"
}, {
"name"=> "cn",
"value"=> "cn.png"
}, {
"name"=> "co",
"value"=> "co.png"
}, {
"name"=> "cr",
"value"=> "cr.png"
}, {
"name"=> "cu",
"value"=> "cu.png"
}, {
"name"=> "cv",
"value"=> "cv.png"
}, {
"name"=> "cw",
"value"=> "cw.png"
}, {
"name"=> "cx",
"value"=> "cx.png"
}, {
"name"=> "cy",
"value"=> "cy.png"
}, {
"name"=> "cz",
"value"=> "cz.png"
}, {
"name"=> "de",
"value"=> "de.png"
}, {
"name"=> "de-at",
"value"=> "de-at.png"
}, {
"name"=> "dj",
"value"=> "dj.png"
}, {
"name"=> "dk",
"value"=> "dk.png"
}, {
"name"=> "dm",
"value"=> "dm.png"
}, {
"name"=> "do",
"value"=> "do.png"
}, {
"name"=> "dz",
"value"=> "dz.png"
}, {
"name"=> "ec",
"value"=> "ec.png"
}, {
"name"=> "ee",
"value"=> "ee.png"
}, {
"name"=> "eg",
"value"=> "eg.png"
}, {
"name"=> "eh",
"value"=> "eh.png"
}, {
"name"=> "er",
"value"=> "er.png"
}, {
"name"=> "es",
"value"=> "es.png"
}, {
"name"=> "et",
"value"=> "et.png"
}, {
"name"=> "eu",
"value"=> "eu.png"
}, {
"name"=> "fi",
"value"=> "fi.png"
}, {
"name"=> "fj",
"value"=> "fj.png"
}, {
"name"=> "fk",
"value"=> "fk.png"
}, {
"name"=> "fm",
"value"=> "fm.png"
}, {
"name"=> "fo",
"value"=> "fo.png"
}, {
"name"=> "fr",
"value"=> "fr.png"
}, {
"name"=> "fr-br",
"value"=> "fr-br.png"
}, {
"name"=> "ga",
"value"=> "ga.png"
}, {
"name"=> "gb-eng",
"value"=> "gb-eng.png"
}, {
"name"=> "gb-nir",
"value"=> "gb-nir.png"
}, {
"name"=> "gb-sct",
"value"=> "gb-sct.png"
}, {
"name"=> "gb-wls",
"value"=> "gb-wls.png"
}, {
"name"=> "gb",
"value"=> "gb.png"
}, {
"name"=> "gd",
"value"=> "gd.png"
}, {
"name"=> "ge",
"value"=> "ge.png"
}, {
"name"=> "gf",
"value"=> "gf.png"
}, {
"name"=> "gg",
"value"=> "gg.png"
}, {
"name"=> "gh",
"value"=> "gh.png"
}, {
"name"=> "gi",
"value"=> "gi.png"
}, {
"name"=> "gl",
"value"=> "gl.png"
}, {
"name"=> "gm",
"value"=> "gm.png"
}, {
"name"=> "gn",
"value"=> "gn.png"
}, {
"name"=> "gp",
"value"=> "gp.png"
}, {
"name"=> "gq",
"value"=> "gq.png"
}, {
"name"=> "gr",
"value"=> "gr.png"
}, {
"name"=> "gs",
"value"=> "gs.png"
}, {
"name"=> "gt",
"value"=> "gt.png"
}, {
"name"=> "gu",
"value"=> "gu.png"
}, {
"name"=> "gw",
"value"=> "gw.png"
}, {
"name"=> "gy",
"value"=> "gy.png"
}, {
"name"=> "hk",
"value"=> "hk.png"
}, {
"name"=> "hm",
"value"=> "hm.png"
}, {
"name"=> "hn",
"value"=> "hn.png"
}, {
"name"=> "hr",
"value"=> "hr.png"
}, {
"name"=> "ht",
"value"=> "ht.png"
}, {
"name"=> "hu",
"value"=> "hu.png"
}, {
"name"=> "id",
"value"=> "id.png"
}, {
"name"=> "ie",
"value"=> "ie.png"
}, {
"name"=> "il",
"value"=> "il.png"
}, {
"name"=> "im",
"value"=> "im.png"
}, {
"name"=> "in",
"value"=> "in.png"
}, {
"name"=> "io",
"value"=> "io.png"
}, {
"name"=> "iq",
"value"=> "iq.png"
}, {
"name"=> "ir",
"value"=> "ir.png"
}, {
"name"=> "is",
"value"=> "is.png"
}, {
"name"=> "it",
"value"=> "it.png"
}, {
"name"=> "je",
"value"=> "je.png"
}, {
"name"=> "jm",
"value"=> "jm.png"
}, {
"name"=> "jo",
"value"=> "jo.png"
}, {
"name"=> "jp",
"value"=> "jp.png"
}, {
"name"=> "ke",
"value"=> "ke.png"
}, {
"name"=> "kg",
"value"=> "kg.png"
}, {
"name"=> "kh",
"value"=> "kh.png"
}, {
"name"=> "ki",
"value"=> "ki.png"
}, {
"name"=> "km",
"value"=> "km.png"
}, {
"name"=> "kn",
"value"=> "kn.png"
}, {
"name"=> "kp",
"value"=> "kp.png"
}, {
"name"=> "kr",
"value"=> "kr.png"
}, {
"name"=> "kw",
"value"=> "kw.png"
}, {
"name"=> "ky",
"value"=> "ky.png"
}, {
"name"=> "kz",
"value"=> "kz.png"
}, {
"name"=> "la",
"value"=> "la.png"
}, {
"name"=> "lb",
"value"=> "lb.png"
}, {
"name"=> "lc",
"value"=> "lc.png"
}, {
"name"=> "li",
"value"=> "li.png"
}, {
"name"=> "lk",
"value"=> "lk.png"
}, {
"name"=> "lr",
"value"=> "lr.png"
}, {
"name"=> "ls",
"value"=> "ls.png"
}, {
"name"=> "lt",
"value"=> "lt.png"
}, {
"name"=> "lu",
"value"=> "lu.png"
}, {
"name"=> "lv",
"value"=> "lv.png"
}, {
"name"=> "ly",
"value"=> "ly.png"
}, {
"name"=> "ma",
"value"=> "ma.png"
}, {
"name"=> "mc",
"value"=> "mc.png"
}, {
"name"=> "md",
"value"=> "md.png"
}, {
"name"=> "me",
"value"=> "me.png"
}, {
"name"=> "mf",
"value"=> "mf.png"
}, {
"name"=> "mg",
"value"=> "mg.png"
}, {
"name"=> "mh",
"value"=> "mh.png"
}, {
"name"=> "mk",
"value"=> "mk.png"
}, {
"name"=> "ml",
"value"=> "ml.png"
}, {
"name"=> "mm",
"value"=> "mm.png"
}, {
"name"=> "mn",
"value"=> "mn.png"
}, {
"name"=> "mo",
"value"=> "mo.png"
}, {
"name"=> "mp",
"value"=> "mp.png"
}, {
"name"=> "mq",
"value"=> "mq.png"
}, {
"name"=> "mr",
"value"=> "mr.png"
}, {
"name"=> "ms",
"value"=> "ms.png"
}, {
"name"=> "mt",
"value"=> "mt.png"
}, {
"name"=> "mu",
"value"=> "mu.png"
}, {
"name"=> "mv",
"value"=> "mv.png"
}, {
"name"=> "mw",
"value"=> "mw.png"
}, {
"name"=> "mx",
"value"=> "mx.png"
}, {
"name"=> "my",
"value"=> "my.png"
}, {
"name"=> "mz",
"value"=> "mz.png"
}, {
"name"=> "na",
"value"=> "na.png"
}, {
"name"=> "nc",
"value"=> "nc.png"
}, {
"name"=> "ne",
"value"=> "ne.png"
}, {
"name"=> "nf",
"value"=> "nf.png"
}, {
"name"=> "ng",
"value"=> "ng.png"
}, {
"name"=> "ni",
"value"=> "ni.png"
}, {
"name"=> "nl",
"value"=> "nl.png"
}, {
"name"=> "no",
"value"=> "no.png"
}, {
"name"=> "np",
"value"=> "np.png"
}, {
"name"=> "nr",
"value"=> "nr.png"
}, {
"name"=> "nu",
"value"=> "nu.png"
}, {
"name"=> "nz",
"value"=> "nz.png"
}, {
"name"=> "om",
"value"=> "om.png"
}, {
"name"=> "pa",
"value"=> "pa.png"
}, {
"name"=> "pe",
"value"=> "pe.png"
}, {
"name"=> "pf",
"value"=> "pf.png"
}, {
"name"=> "pg",
"value"=> "pg.png"
}, {
"name"=> "ph",
"value"=> "ph.png"
}, {
"name"=> "pk",
"value"=> "pk.png"
}, {
"name"=> "pl",
"value"=> "pl.png"
}, {
"name"=> "pm",
"value"=> "pm.png"
}, {
"name"=> "pn",
"value"=> "pn.png"
}, {
"name"=> "pr",
"value"=> "pr.png"
}, {
"name"=> "ps",
"value"=> "ps.png"
}, {
"name"=> "pt",
"value"=> "pt.png"
}, {
"name"=> "pw",
"value"=> "pw.png"
}, {
"name"=> "py",
"value"=> "py.png"
}, {
"name"=> "qa",
"value"=> "qa.png"
}, {
"name"=> "re",
"value"=> "re.png"
}, {
"name"=> "ro",
"value"=> "ro.png"
}, {
"name"=> "rs",
"value"=> "rs.png"
}, {
"name"=> "ru",
"value"=> "ru.png"
}, {
"name"=> "rw",
"value"=> "rw.png"
}, {
"name"=> "sa",
"value"=> "sa.png"
}, {
"name"=> "sb",
"value"=> "sb.png"
}, {
"name"=> "sc",
"value"=> "sc.png"
}, {
"name"=> "sd",
"value"=> "sd.png"
}, {
"name"=> "se",
"value"=> "se.png"
}, {
"name"=> "sg",
"value"=> "sg.png"
}, {
"name"=> "sh",
"value"=> "sh.png"
}, {
"name"=> "si",
"value"=> "si.png"
}, {
"name"=> "sj",
"value"=> "sj.png"
}, {
"name"=> "sk",
"value"=> "sk.png"
}, {
"name"=> "sl",
"value"=> "sl.png"
}, {
"name"=> "sm",
"value"=> "sm.png"
}, {
"name"=> "sn",
"value"=> "sn.png"
}, {
"name"=> "so",
"value"=> "so.png"
}, {
"name"=> "sr",
"value"=> "sr.png"
}, {
"name"=> "ss",
"value"=> "ss.png"
}, {
"name"=> "st",
"value"=> "st.png"
}, {
"name"=> "sv",
"value"=> "sv.png"
}, {
"name"=> "sx",
"value"=> "sx.png"
}, {
"name"=> "sy",
"value"=> "sy.png"
}, {
"name"=> "sz",
"value"=> "sz.png"
}, {
"name"=> "tc",
"value"=> "tc.png"
}, {
"name"=> "td",
"value"=> "td.png"
}, {
"name"=> "tf",
"value"=> "tf.png"
}, {
"name"=> "tg",
"value"=> "tg.png"
}, {
"name"=> "th",
"value"=> "th.png"
}, {
"name"=> "tj",
"value"=> "tj.png"
}, {
"name"=> "tk",
"value"=> "tk.png"
}, {
"name"=> "tl",
"value"=> "tl.png"
}, {
"name"=> "tm",
"value"=> "tm.png"
}, {
"name"=> "tn",
"value"=> "tn.png"
}, {
"name"=> "to",
"value"=> "to.png"
}, {
"name"=> "tr",
"value"=> "tr.png"
}, {
"name"=> "tt",
"value"=> "tt.png"
}, {
"name"=> "tv",
"value"=> "tv.png"
}, {
"name"=> "tw",
"value"=> "tw.png"
}, {
"name"=> "tz",
"value"=> "tz.png"
}, {
"name"=> "ua",
"value"=> "ua.png"
}, {
"name"=> "ug",
"value"=> "ug.png"
}, {
"name"=> "um",
"value"=> "um.png"
}, {
"name"=> "un",
"value"=> "un.png"
}, {
"name"=> "us",
"value"=> "us.png"
}, {
"name"=> "us-at",
"value"=> "us-at.png"
}, {
"name"=> "uy",
"value"=> "uy.png"
}, {
"name"=> "uz",
"value"=> "uz.png"
}, {
"name"=> "va",
"value"=> "va.png"
}, {
"name"=> "vc",
"value"=> "vc.png"
}, {
"name"=> "ve",
"value"=> "ve.png"
}, {
"name"=> "vg",
"value"=> "vg.png"
}, {
"name"=> "vi",
"value"=> "vi.png"
}, {
"name"=> "vn",
"value"=> "vn.png"
}, {
"name"=> "vu",
"value"=> "vu.png"
}, {
"name"=> "wf",
"value"=> "wf.png"
}, {
"name"=> "ws",
"value"=> "ws.png"
}, {
"name"=> "ye",
"value"=> "ye.png"
}, {
"name"=> "yt",
"value"=> "yt.png"
}, {
"name"=> "za",
"value"=> "za.png"
}, {
"name"=> "zm",
"value"=> "zm.png"
}, {
"name"=> "zw",
"value"=> "zw.png"
}
]
flagscollection = []
id = 0
flags.each do |f|
flagscollection << CustomWizard::Flag.new(f['name'], f['name'], f['value'])
id += 1
end
return flagscollection
end
end

Datei anzeigen

@ -87,6 +87,7 @@ 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__)