This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/user-field.js
2020-03-12 13:29:55 -04:00

25 lines
722 B
JavaScript

import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component";
import { fmt } from "discourse/lib/computed";
export default Component.extend({
classNameBindings: [":user-field", "field.field_type", "customFieldClass"],
layoutName: fmt("field.field_type", "components/user-fields/%@"),
@discourseComputed
noneLabel() {
return "user_fields.none";
},
@discourseComputed("field.name")
customFieldClass(fieldName) {
if (fieldName) {
fieldName = fieldName
.replace(/\s+/g, "-")
.replace(/[!\"#$%&'\(\)\*\+,\.\/:;<=>\?\@\[\\\]\^`\{\|\}~]/g, "")
.toLowerCase();
return fieldName && `user-field-${fieldName}`;
}
}
});