Add unique class to custom field wrappers (#8193)

This commit is contained in:
Kris 2019-10-21 12:22:55 -04:00 committed by GitHub
parent 56862f61c0
commit b41b12ad71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

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