mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
19 lines
472 B
JavaScript
19 lines
472 B
JavaScript
import { get } from "@ember/object";
|
|
export function formatCurrency([reviewable, fieldId]) {
|
|
// The field `category_id` corresponds to `category`
|
|
if (fieldId === "category_id") {
|
|
fieldId = "category.id";
|
|
}
|
|
|
|
let value = get(reviewable, fieldId);
|
|
|
|
// If it's an array, say tags, make a copy so we aren't mutating the original
|
|
if (Array.isArray(value)) {
|
|
value = value.slice(0);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
export default Ember.Helper.helper(formatCurrency);
|