vault/ui/app/models/generated-item.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

45 lines
1.1 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import Model from '@ember-data/model';
import { tracked } from '@glimmer/tracking';
// This model is used for OpenApi-generated models in path-help service's getNewModel method
export default class GeneratedItemModel extends Model {
allFields = [];
@tracked _id;
get mutableId() {
return this._id || this.id;
}
set mutableId(value) {
this._id = value;
}
get fieldGroups() {
const groups = {
default: [],
};
const fieldGroups = [];
this.constructor.eachAttribute((name, attr) => {
// if the attr comes in with a fieldGroup from OpenAPI,
if (attr.options.fieldGroup) {
if (groups[attr.options.fieldGroup]) {
groups[attr.options.fieldGroup].push(attr);
} else {
groups[attr.options.fieldGroup] = [attr];
}
} else {
// otherwise just add that attr to the default group
groups.default.push(attr);
}
});
for (const group in groups) {
fieldGroups.push({ [group]: groups[group] });
}
return fieldGroups;
}
}