mirror of
https://github.com/discourse/discourse.git
synced 2024-12-20 02:01:28 +08:00
88af23e1ca
This PR modernizes the user fields area of the admin UI. It is largely based on the work on the emoji section.
37 lines
795 B
JavaScript
37 lines
795 B
JavaScript
import { tracked } from "@glimmer/tracking";
|
|
import { sort } from "@ember/object/computed";
|
|
import Service, { service } from "@ember/service";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
export default class AdminUserFields extends Service {
|
|
@service store;
|
|
|
|
@tracked userFields = [];
|
|
|
|
@sort("userFields", "fieldSortOrder") sortedUserFields;
|
|
|
|
fieldSortOrder = ["position"];
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
|
|
this.#fetchUserFields();
|
|
}
|
|
|
|
async #fetchUserFields() {
|
|
try {
|
|
this.userFields = await this.store.findAll("user-field");
|
|
} catch (err) {
|
|
popupAjaxError(err);
|
|
}
|
|
}
|
|
|
|
get firstField() {
|
|
return this.sortedUserFields[0];
|
|
}
|
|
|
|
get lastField() {
|
|
return this.sortedUserFields[this.sortedUserFields.length - 1];
|
|
}
|
|
}
|