Dev_Work
(Aleksandr)
1
create-account.hbs
{{#if userFields}}
<div class='user-fields'>
{{#each userFields as |f|}}
{{user-field field=f.field value=f.value}}
{{/each}}
</div>
{{/if}}
js
var siteSettings = Discourse.SiteSettings;
console.log(siteSettings.forum_name);
complete = $(".user-field-" + siteSettings.forum_name);
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/controllers/create-account.js.es6#L239-L245
How to check the field?
{{#if f.field.name == complete }} {{! doesn't work }}
OK
{{/if}}
1 « J'aime »
Dev_Work
(Aleksandr)
2
set input for create-account.hbs
var siteSettings = Discourse.SiteSettings;
$('.control-label').each( function () {
if($(this).text().trim() === siteSettings.forum_name) {
const uuid ='lp'+(()=>([1e7]+-1e11).replace(/[018]/g,c=>(c^crypto.getRandomValues(new Uint8Array(1))[0]&15 >> c/4).toString(16)))();
var id = "user-" + $(this).parent().attr('id');
var input = $('#' + id);
input.val(uuid);
// $(this).parent().hide()
}
})
It looks like this

Rails.logger.warn("#{params }")
It looks like this
"user_fields"=><ActionController::Parameters {"1"=>"true", "2"=>""}
“2”=>""
where is the second field ?
1 « J'aime »
merefield
(Robert)
3
This doesn’t work because you can’t perform the actual logic calculation in a Template. This needs to be handled in the corresponding js by a Computed Property. Be sure to read the official Ember guides (making sure you select the same version that Discourse uses) and look at the code in one of the many popular plugin on here to provide you with examples.
Dev_Work
(Aleksandr)
4
thanks for the answer, I’m interested in examples from plugins
merefield
(Robert)
5
3 « J'aime »
Dev_Work
(Aleksandr)
6
Bonjour, j’ai trouvé comment remplacer l’action dans les contrôleurs.
exemple
import CreateAccount from 'discourse/controllers/create-account';
export default {
name: 'Create-Account-Popup',
initialize: function () {
CreateAccount.reopen({
actions: {
createAccount() {
// mon code
}
}
});
}
Comment ajouter votre @discourseComputed ?
Je fais comme dans l’exemple mais cela ne fonctionne pas
export default {
name: 'Create-Account-Popup',
@discourseComputed()
ldapForgotPassword() {
console.log('oublié !!');
return this.siteSettings.forum_login_popup_use_ldap;
},
Dev_Work
(Aleksandr)
7
C’est arrivé via @computed
PreferencesAccount.reopen({
@computed
ldapForgotPassword() {
console.log('oublié !!');
return this.siteSettings.forum_login_popup_use_ldap;
},
1 « J'aime »
Vous devriez utiliser ceci pour éviter un avertissement du navigateur.
Il s’agit simplement d’une importation différente :
import discourseComputed from "discourse-common/utils/decorators";
2 « J'aime »