migrate ldap list wrapper fields (#3162)

This commit is contained in:
Dharini committed 2026-06-03 16:36:29 -07:00
1 parent 71ec7b465a
commit 4e2b779d96
12 files changed
+163 -136

No files matched your search

@@ -5,6 +5,7 @@
import Component from '@glimmer/component';
import { assert } from '@ember/debug';
import { action } from '@ember/object';
import oidc from './oidc';
import ldap from './ldap';
import password from './password';
@@ -24,4 +25,47 @@ export default class FormAuthMethodIndex extends Component {
);
return component;
}
/**
* Adds a new empty row to the specified field
* @param {string} field - The field name to add a row to
* @param {Array<string>} properties - Array of property names for the empty row (e.g., ['value'] or ['key', 'value'])
*/
@action
addRow(field, properties) {
const emptyRow = Object.fromEntries(properties.map((prop) => [prop, '']));
this.args.model[field] = [...this.args.model[field], emptyRow];
}
/**
* Removes a row from the specified field
* @param {string} field - The field name to remove a row from
* @param {object} rowData - The row data to remove
*/
@action
removeRow(field, rowData) {
let rows = this.args.model[field].filter((item) => item !== rowData);
// Ensure at least one empty row exists for editing
if (rows.length === 0) {
const emptyRow = Object.fromEntries(
Object.keys(rowData).map((key) => [key, '']),
);
rows = [emptyRow];
}
this.args.model[field] = rows;
}
/**
* Updates a specific property in a row
* @param {string} field - The field name containing the row
* @param {object} rowData - The row object to update
* @param {string} property - The property name to update
* @param {object} event - The DOM event containing the new value
*/
@action
updateRow(field, rowData, property, { target: { value } }) {
rowData[property] = value;
this.args.model[field] = [...this.args.model[field]];
}
}