Skip to content

Commit

Permalink
set greyarrow values
Browse files Browse the repository at this point in the history
  • Loading branch information
pfaffman committed Nov 27, 2024
1 parent 5cb36a2 commit 788f68e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion about.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
"maximum_discourse_version": null,
"assets": {},
"modifiers": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import { apiInitializer } from "discourse/lib/api";
import discourseComputed, { on } from "discourse-common/utils/decorators";
import { set } from "@ember/object"; // <-- Import set function here
import EmberObject, { set} from "@ember/object"; // Import EmberObject here
import { dasherize } from "@ember/string";
import EmberObject from "@ember/object"; // Import EmberObject here
import UserCardContents from "discourse/components/user-card-contents";
import { isEmpty } from "@ember/utils";
import { apiInitializer } from "discourse/lib/api";
import discourseComputed from "discourse-common/utils/decorators";

export default apiInitializer("1.8.0", ( api ) => {
console.log("hello world from api initializer!");

export default apiInitializer("1.8.0", (api) => {
const userFieldId = 8;
const userFieldVal = "Bronze";

api.modifyClass("component:user-card-contents", {
pluginId: "discourse-default-user-custom-fields",
@discourseComputed("[email protected]")
publicUserFields() {
// Custom logic here
console.log("hello world from publicUserFields in my theme component!");
const siteUserFields = this.site.get("user_fields");
if (!isEmpty(siteUserFields)) {
console.log("got site user fields!", siteUserFields);
const userFields = this.get("user.user_fields");
// if [userfields[1] is null make it a default strring
if (userFields[1] == null) {
userFields[1] = "I am not important";
if (userFields[userFieldId] == null) {
userFields[userFieldId] = userFieldVal

Check failure on line 20 in javascripts/discourse/api-initializers/default-user-custom-field-value.js

View workflow job for this annotation

GitHub Actions / ci / linting

Missing semicolon
}
console.log("got user fields!", userFields);
return siteUserFields
.filterBy("show_on_user_card", true)
.sortBy("position")
Expand All @@ -35,24 +29,22 @@ export default apiInitializer("1.8.0", ( api ) => {
})
.compact();
}
}
});
},
});

// Modify User controller
// Modify User controller
api.modifyClass("controller:user", {
pluginId: "discourse-default-user-custom-fields",

@discourseComputed("[email protected]")
publicUserFields() {
console.log("Overriding publicUserFields in User controller...");
const siteUserFields = this.site.get("user_fields");

if (!isEmpty(siteUserFields)) {
const userFields = this.get("model.user_fields");
if (userFields[1] == null) {
userFields[1] = "I am not important";
if (userFields[userFieldId] == null) {
userFields[userFieldId] = userFieldVal;
}
console.log("got user fields!", userFields);
return siteUserFields
.filterBy("show_on_profile", true)
.sortBy("position")
Expand All @@ -66,5 +58,5 @@ export default apiInitializer("1.8.0", ( api ) => {
.compact();
}
},
});
});
});

0 comments on commit 788f68e

Please sign in to comment.