Merge branch 'master' into add_group_field
Dieser Commit ist enthalten in:
Commit
9a489f3b9b
10 geänderte Dateien mit 48 neuen und 17 gelöschten Zeilen
|
@ -16,7 +16,7 @@ export default Ember.Component.extend({
|
|||
categoryPropertyTypes: generateSelectKitContent(['id', 'slug']),
|
||||
|
||||
@computed('field.type')
|
||||
isInput: (type) => type === 'text' || type === 'textarea',
|
||||
isInput: (type) => type === 'text' || type === 'textarea' || type === 'url',
|
||||
|
||||
@computed('field.type')
|
||||
isCategoryOrTag: (type) => type === 'tag' || type === 'category',
|
||||
|
|
|
@ -4,6 +4,4 @@ Wizard.SiteSettings = {};
|
|||
Wizard.RAW_TEMPLATES = {};
|
||||
Discourse.__widget_helpers = {};
|
||||
Discourse.RAW_TEMPLATES = {};
|
||||
Discourse.SiteSettings = Wizard.SiteSettings;
|
||||
Discourse.Model = Ember.Object.extend();
|
||||
Discourse.Site = Ember.Object.extend();
|
||||
Discourse.SiteSettings = Wizard.SiteSettings;
|
|
@ -31,9 +31,12 @@
|
|||
//= require discourse/lib/key-value-store
|
||||
//= require discourse/lib/settings
|
||||
//= require discourse/lib/user-presence
|
||||
//= require discourse/lib/hash
|
||||
|
||||
//= require discourse/mixins/singleton
|
||||
|
||||
//= require discourse/adapters/rest
|
||||
|
||||
//= require discourse/models/login-method
|
||||
//= require discourse/models/permission-type
|
||||
//= require discourse/models/archetype
|
||||
|
|
|
@ -5,7 +5,8 @@ export default {
|
|||
|
||||
initialize(app) {
|
||||
if (window.location.pathname.indexOf('/w/') < 0) return;
|
||||
|
||||
|
||||
const EmberObject = requirejs('@ember/object').default;
|
||||
const Router = requirejs('wizard/router').default;
|
||||
const ApplicationRoute = requirejs('wizard/routes/application').default;
|
||||
const ajax = requirejs('wizard/lib/ajax').ajax;
|
||||
|
@ -22,7 +23,10 @@ export default {
|
|||
const Store = requirejs("discourse/models/store").default;
|
||||
const registerRawHelpers = requirejs("discourse-common/lib/raw-handlebars-helpers").registerRawHelpers;
|
||||
const RawHandlebars = requirejs("discourse-common/lib/raw-handlebars").default;
|
||||
const Site = requirejs("discourse/models/site").default;
|
||||
const RestAdapter = requirejs("discourse/adapters/rest").default;
|
||||
|
||||
Discourse.Model = EmberObject.extend();
|
||||
Discourse.__container__ = app.__container__;
|
||||
Discourse.getURLWithCDN = getUrl;
|
||||
Discourse.getURL = getUrl;
|
||||
|
@ -51,16 +55,16 @@ export default {
|
|||
|
||||
app.register("service:store", Store);
|
||||
targets.forEach(t => app.inject(t, "store", "service:store"));
|
||||
|
||||
const site = Discourse.Site;
|
||||
app.register("site:main", site);
|
||||
targets.forEach(t => app.inject(t, "site", "site:main"));
|
||||
|
||||
targets.forEach(t => app.inject(t, "appEvents", "service:app-events"));
|
||||
|
||||
site.reopenClass(Singleton);
|
||||
site.currentProp('can_create_tag', false);
|
||||
app.register("adapter:rest", RestAdapter);
|
||||
|
||||
const site = Site.current();
|
||||
app.register("site:main", site, { instantiate: false });
|
||||
targets.forEach(t => app.inject(t, "site", "site:main"));
|
||||
|
||||
site.set('can_create_tag', false);
|
||||
|
||||
Router.reopen({
|
||||
rootURL: getUrl('/w/')
|
||||
});
|
||||
|
@ -214,13 +218,14 @@ export default {
|
|||
inputComponentName: function() {
|
||||
const type = this.get('field.type');
|
||||
const id = this.get('field.id');
|
||||
if (type === 'text-only') return false;
|
||||
if (['text-only'].includes(type)) return false;
|
||||
return (type === 'component') ? Ember.String.dasherize(id) : `wizard-field-${type}`;
|
||||
}.property('field.type', 'field.id')
|
||||
});
|
||||
|
||||
const StandardFieldValidation = [
|
||||
'text',
|
||||
'number',
|
||||
'textarea',
|
||||
'dropdown',
|
||||
'tag',
|
||||
|
@ -253,15 +258,15 @@ export default {
|
|||
} else {
|
||||
const val = this.get('value');
|
||||
const type = this.get('type');
|
||||
|
||||
console.log(val, type)
|
||||
|
||||
|
||||
if (type === 'checkbox') {
|
||||
valid = val;
|
||||
} else if (type === 'upload') {
|
||||
valid = val && val.id > 0;
|
||||
} else if (StandardFieldValidation.indexOf(type) > -1) {
|
||||
valid = val && val.toString().length > 0;
|
||||
} else if (type === 'url') {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{{input type='number' step='0.01' id=field.id value=field.value}}
|
|
@ -0,0 +1 @@
|
|||
{{input type='text' id=field.id value=field.value}}
|
|
@ -181,6 +181,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
.url-field input {
|
||||
width: 100%;
|
||||
font-size: 1.1487em;
|
||||
padding: 6px;
|
||||
border: 1px solid #ccc;
|
||||
transition: border-color 0.5s;
|
||||
}
|
||||
|
||||
.control-group {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
|
|
|
@ -9,6 +9,7 @@ en:
|
|||
field:
|
||||
too_short: "%{label} must be at least %{min} characters"
|
||||
required: "%{label} is required."
|
||||
not_url: "%{label} must be a valid url"
|
||||
none: "We couldn't find a wizard at that address."
|
||||
no_skip: "Wizard can't be skipped"
|
||||
export:
|
||||
|
|
|
@ -300,6 +300,12 @@ class CustomWizard::Builder
|
|||
)
|
||||
end
|
||||
|
||||
if is_url_type(field)
|
||||
if !check_if_url(value)
|
||||
updater.errors.add(field['id'].to_s, I18n.t('wizard.field.not_url', label: label))
|
||||
end
|
||||
end
|
||||
|
||||
## ensure all checkboxes are booleans
|
||||
if field['type'] === 'checkbox'
|
||||
updater.fields[field['id']] = standardise_boolean(value)
|
||||
|
@ -316,6 +322,14 @@ class CustomWizard::Builder
|
|||
['text', 'textarea'].include? field['type']
|
||||
end
|
||||
|
||||
def is_url_type(field)
|
||||
['url'].include? field['type']
|
||||
end
|
||||
|
||||
def check_if_url(value)
|
||||
value =~ URI::regexp
|
||||
end
|
||||
|
||||
def standardise_boolean(value)
|
||||
ActiveRecord::Type::Boolean.new.cast(value)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class CustomWizard::Field
|
||||
def self.types
|
||||
@types ||= ['checkbox', 'composer', 'dropdown', 'tag', 'category', 'group', 'image', 'text', 'textarea', 'text-only', 'upload', 'user-selector']
|
||||
@types ||= ['checkbox', 'composer', 'dropdown', 'tag', 'category', 'group', 'image', 'text', 'textarea', 'text-only', 'number', 'upload', 'user-selector', 'url']
|
||||
end
|
||||
|
||||
def self.require_assets
|
||||
|
|
Laden …
In neuem Issue referenzieren