Skip to content

Commit

Permalink
Fixer Not Show Country on Profie
Browse files Browse the repository at this point in the history
  • Loading branch information
Litalino committed Jan 8, 2024
1 parent b6444b6 commit f35b948
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js/dist/forum.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions js/src/forum/components/AddCountryCodeField.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import Component from 'flarum/Component';
export default class AddCountryCodeField extends Component {
oninit(vnode) {
super.oninit(vnode);
//const user = app.session.user;
//console.log(user);
this.countryCode = app.session.user.countryCode();
//console.log(this.countryCode);
}

view(vnode) {
//onblur to onchange
view(vnode) {
return (
<fieldset className="Settings-theme">
<legend>{app.translator.trans('justoverclock-country-flags.forum.inputCountryCode')}</legend>
<select className="FormControl countryCode" id="country" name="country" value={this.countryCode} onchange={this.saveValue.bind(this)}>
<select className="FormControl countryCode" id="country" name="country" value={this.countryCode} onblur={this.saveValue.bind(this)}>
<option value="" disabled selected>{app.translator.trans('justoverclock-country-flags.forum.clickToSelectCountry')}</option>
<option value="AF">Afghanistan</option>
<option value="AX">Aland Islands</option>
Expand Down
3 changes: 3 additions & 0 deletions js/src/forum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ app.initializers.add('litalino/user-country-info', () => {
});
extend(UserCard.prototype, 'infoItems', function (items) {
const user = this.attrs.user;
//const user = app.session.user.countryCode();
//const user = this.attrs.user.countryCode();
//console.log(user);
let countryFlag = user.countryCode();
//console.log(countryFlag);
if (countryFlag === '') return;
Expand Down
4 changes: 2 additions & 2 deletions src/Listeners/AddCountryFlagAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public function __invoke(UserSerializer $serializer, User $user, array $attribut
{
$actor = $serializer->getActor();

if ($actor->can('edit', $user)) {
//if ($actor->can('edit', $user)) {
$attributes['countryCode'] = $user->countryCode;

Check failure on line 15 in src/Listeners/AddCountryFlagAttributes.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.3

Access to an undefined property Flarum\User\User::$countryCode.

Check failure on line 15 in src/Listeners/AddCountryFlagAttributes.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.4

Access to an undefined property Flarum\User\User::$countryCode.

Check failure on line 15 in src/Listeners/AddCountryFlagAttributes.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.1

Access to an undefined property Flarum\User\User::$countryCode.

Check failure on line 15 in src/Listeners/AddCountryFlagAttributes.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 8.2

Access to an undefined property Flarum\User\User::$countryCode.

Check failure on line 15 in src/Listeners/AddCountryFlagAttributes.php

View workflow job for this annotation

GitHub Actions / run / PHPStan PHP 7.3

Access to an undefined property Flarum\User\User::$countryCode.
//$attributes['canEditOwnBirthday'] = $actor->id === $user->id && $actor->can('editOwnBirthday', $user);
}
//}

//$attributes['countryCode'] = $user->countryCode;

Expand Down

0 comments on commit f35b948

Please sign in to comment.