lwc-utils
lwc-utils copied to clipboard
SOQL Datatable - enter "all" for sortable or editable fields
It would be nice to have the option to choose "all" for sortable/editable fields, instead of typing each one manually.
A couple more considerations came out of office hours:
- Extra logic to consider for compound name fields.
- Extra security check for parent relationship fields if
Lookup__r.Parent_Field__cnotation is used.
Due to those complexities, this is on hold for a bit
Leaving some thoughts for now:
set editableFields(value = '') {
this._isAllInlineEdit = value === INLINE_EDIT_KEY;
this._editableFields = createFlattenedSetFromDelimitedString(value, ',');
}
...
// For future enhancements
@wire(getObjectInfo, { objectApiName: '$_objectApiName' })
objectInfoWire({ error, data }) {
if (error) {
this._notifySingleError('getObjectInfo error', error);
} else if (data) {
this._objectInfo = data;
if (this._isAllInlineEdit) {
// Rely on FLS given by this wire adapter
this._allUpdateableFields = new Set(
Object.values(this._objectInfo.fields)
.filter(field => field.updateable)
.map(field => field.apiName)
);
// TODO deal with compound names
// Re-establish editable fields and the table column definition outside of _setTableColumns
this._editableFields = new Set(
this.tableColumns.filter(col => this._allUpdateableFields.has(col.fieldName)).map(col => col.fieldName)
);
// TODO figure out best way to get FLS for n parent(s)
// Finally, repaint the columns for the pencil icon
this.tableColumns = this.tableColumns.map(col => {
col.editable = this._editableFields.has(col.fieldName);
return col;
});
}
}
}