mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 12:26:34 +02:00
* 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>
45 lines
1.1 KiB
JavaScript
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;
|
|
}
|
|
}
|