1
0
Fork 0

Merge branch 'master' into pr/125

Dieser Commit ist enthalten in:
angusmcleod 2021-07-12 14:05:02 +08:00
Commit 20c8ec1202
11 geänderte Dateien mit 61 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -111,6 +111,18 @@
checked=field.char_counter}} checked=field.char_counter}}
</div> </div>
</div> </div>
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.field.field_placeholder"}}</label>
</div>
<div class="setting-value">
{{textarea
name="field_placeholder"
value=field.placeholder}}
</div>
</div>
{{/if}} {{/if}}
{{#if isUpload}} {{#if isUpload}}

Datei anzeigen

@ -26,7 +26,11 @@ export default {
const setDefaultOwner = requirejs("discourse-common/lib/get-owner") const setDefaultOwner = requirejs("discourse-common/lib/get-owner")
.setDefaultOwner; .setDefaultOwner;
const messageBus = requirejs("message-bus-client").default; const messageBus = requirejs("message-bus-client").default;
const getToken = requirejs("wizard/lib/ajax").getToken;
const setEnvironment = requirejs("discourse-common/config/environment")
.setEnvironment;
const isDevelopment = requirejs("discourse-common/config/environment")
.isDevelopment;
const container = app.__container__; const container = app.__container__;
Discourse.Model = EmberObject.extend(); Discourse.Model = EmberObject.extend();
Discourse.__container__ = container; Discourse.__container__ = container;
@ -89,6 +93,7 @@ export default {
const session = container.lookup("session:main"); const session = container.lookup("session:main");
const setupData = document.getElementById("data-discourse-setup").dataset; const setupData = document.getElementById("data-discourse-setup").dataset;
session.set("highlightJsPath", setupData.highlightJsPath); session.set("highlightJsPath", setupData.highlightJsPath);
setEnvironment(setupData.environment);
Router.reopen({ Router.reopen({
rootURL: getUrl("/w/"), rootURL: getUrl("/w/"),
@ -107,5 +112,11 @@ export default {
}, },
model() {}, model() {},
}); });
$.ajaxPrefilter(function (_, __, jqXHR) {
if (isDevelopment()) {
jqXHR.setRequestHeader("X-CSRF-Token", getToken());
}
});
}, },
}; };

Datei anzeigen

@ -1,7 +1,7 @@
{{d-editor {{d-editor
tabindex=field.tabindex tabindex=field.tabindex
value=composer.reply value=composer.reply
placeholder=replyPlaceholder placeholderTranslated=replyPlaceholder
previewUpdated=(action "previewUpdated") previewUpdated=(action "previewUpdated")
markdownOptions=markdownOptions markdownOptions=markdownOptions
extraButtons=(action "extraButtons") extraButtons=(action "extraButtons")

Datei anzeigen

@ -162,4 +162,15 @@
.text-field input { .text-field input {
margin-bottom: 0; margin-bottom: 0;
} }
.text-field,
.textarea-field,
.composer-field {
input[type="text"],
textarea {
&:focus::placeholder {
color: transparent;
}
}
}
} }

Datei anzeigen

@ -173,6 +173,7 @@ en:
max_length_placeholder: "Maximum length in characters" max_length_placeholder: "Maximum length in characters"
char_counter: "Character Counter" char_counter: "Character Counter"
char_counter_placeholder: "Display Character Counter" char_counter_placeholder: "Display Character Counter"
field_placeholder: "Field Placeholder"
file_types: "File Types" file_types: "File Types"
limit: "Limit" limit: "Limit"
property: "Property" property: "Property"

Datei anzeigen

@ -109,6 +109,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
:format, :format,
:limit, :limit,
:property, :property,
:placeholder,
prefill: mapped_params, prefill: mapped_params,
content: mapped_params, content: mapped_params,
condition: mapped_params, condition: mapped_params,

Datei anzeigen

@ -186,6 +186,16 @@ class CustomWizard::Builder
) )
end end
if field_template['placeholder'].present?
params[:placeholder] = mapper.interpolate(
field_template['placeholder'],
user: true,
value: true,
wizard: true,
template: true
)
end
field = step.add_field(params) field = step.add_field(params)
end end

Datei anzeigen

@ -20,7 +20,8 @@ class CustomWizard::Field
:format, :format,
:limit, :limit,
:property, :property,
:content :content,
:placeholder
attr_accessor :index, attr_accessor :index,
:step :step
@ -44,6 +45,7 @@ class CustomWizard::Field
@limit = attrs[:limit] @limit = attrs[:limit]
@property = attrs[:property] @property = attrs[:property]
@content = attrs[:content] @content = attrs[:content]
@placeholder = attrs[:placeholder]
end end
def label def label
@ -63,18 +65,21 @@ class CustomWizard::Field
max_length: nil, max_length: nil,
prefill: nil, prefill: nil,
char_counter: nil, char_counter: nil,
validations: nil validations: nil,
placeholder: nil
}, },
textarea: { textarea: {
min_length: nil, min_length: nil,
max_length: nil, max_length: nil,
prefill: nil, prefill: nil,
char_counter: nil char_counter: nil,
placeholder: nil
}, },
composer: { composer: {
min_length: nil, min_length: nil,
max_length: nil, max_length: nil,
char_counter: nil char_counter: nil,
placeholder: nil
}, },
text_only: {}, text_only: {},
date: { date: {

Datei anzeigen

@ -32,11 +32,11 @@ class ::CustomWizard::UpdateValidator
@updater.errors.add(field_id, I18n.t('wizard.field.required', label: label)) @updater.errors.add(field_id, I18n.t('wizard.field.required', label: label))
end end
if min_length && value.is_a?(String) && value.strip.length < min_length.to_i if min_length.present? && value.is_a?(String) && value.strip.length < min_length.to_i
@updater.errors.add(field_id, I18n.t('wizard.field.too_short', label: label, min: min_length.to_i)) @updater.errors.add(field_id, I18n.t('wizard.field.too_short', label: label, min: min_length.to_i))
end end
if max_length && value.is_a?(String) && value.strip.length > max_length.to_i if max_length.present? && value.is_a?(String) && value.strip.length > max_length.to_i
@updater.errors.add(field_id, I18n.t('wizard.field.too_long', label: label, max: max_length.to_i)) @updater.errors.add(field_id, I18n.t('wizard.field.too_long', label: label, max: max_length.to_i))
end end

Datei anzeigen

@ -71,6 +71,7 @@ class CustomWizard::FieldSerializer < ::ApplicationSerializer
end end
def placeholder def placeholder
return object.placeholder if object.placeholder.present?
I18n.t("#{object.key || i18n_key}.placeholder", default: '') I18n.t("#{object.key || i18n_key}.placeholder", default: '')
end end

Datei anzeigen

@ -199,6 +199,7 @@ describe CustomWizard::Wizard do
end end
it "lists the site categories" do it "lists the site categories" do
Site.clear_cache
expect(@wizard.categories.length).to eq(1) expect(@wizard.categories.length).to eq(1)
end end