lwc-utils icon indicating copy to clipboard operation
lwc-utils copied to clipboard

SOQL Datatable - enter "all" for sortable or editable fields

Open solo-1234 opened this issue 5 years ago • 2 comments

It would be nice to have the option to choose "all" for sortable/editable fields, instead of typing each one manually.

solo-1234 avatar Oct 28 '20 14:10 solo-1234

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__c notation is used.

Due to those complexities, this is on hold for a bit

tsalb avatar Feb 21 '21 21:02 tsalb

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;
        });
      }
    }
  }

tsalb avatar Feb 21 '21 21:02 tsalb