<div cdsCol
[columnNumbers]="{sm:1}"
class="cds-p-0 cds-pt-3">
- <button cdsButton="ghost"
- size="sm"
- id="cell-inline-save-btn"
- type="button"
- (click)="saveCellItem(row, column?.prop)">
+ <div cdsRow>
+ <cds-icon-button kind="tertiary"
+ size="sm"
+ id="cell-inline-save-btn"
+ type="button"
+ (click)="saveCellItem(row, column?.prop)">
<cd-icon type="check"></cd-icon>
- </button>
+ </cds-icon-button>
+ <cds-icon-button kind="ghost"
+ size="sm"
+ id="cell-inline-cancel-btn"
+ type="button"
+ (click)="cancelCellEdit(row[identifier], column?.prop)">
+ <cd-icon type="destroy"></cd-icon>
+ </cds-icon-button>
+ </div>
</div>
</div>
</form>
<div cdsCol
[columnNumbers]="{lg: 5}"
class="edit-btn">
- <button cdsButton="ghost"
- size="sm"
- id="cell-inline-edit-btn"
- (click)="editCellItem(row[identifier], column, value)">
+ <cds-icon-button kind="ghost"
+ size="sm"
+ id="cell-inline-edit-btn"
+ (click)="editCellItem(row[identifier], column, value)">
<cd-icon type="edit"></cd-icon>
- </button>
+ </cds-icon-button>
</div>
</div>
}
row: any;
}>();
+ @Output()
+ isCellEditingEvent = new EventEmitter<boolean>();
+
/**
* Use this variable to access the selected row(s).
*/
}
this.formGroup?.get(key).setValue(value);
this.editStates[rowId][column.prop] = value;
+ this.isCellEditingEvent.emit(true);
}
saveCellItem(row: any, colProp: string) {
valueChange(rowId: string, colProp: string, value: string) {
this.editStates[rowId][colProp] = value;
}
+
+ cancelCellEdit(rowId: string, colProp: string, event?: Event) {
+ if (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ const key = `${rowId}-${colProp}`;
+ if (!this.formGroup.controls[key]) {
+ return;
+ }
+
+ if (this.editStates[rowId]) {
+ delete this.editStates[rowId][colProp];
+ }
+ this.editingCells.clear();
+ this.isCellEditingEvent.emit(false);
+
+ setTimeout(() => {
+ if (this.formGroup.controls[key]) {
+ this.formGroup.removeControl(key);
+ }
+ }, 0);
+ }
}
checkMarkOutline: 'checkmark--outline',
arrowUpRight: ' arrow--up-right',
inProgress: 'in-progress',
- arrowDown: 'arrow--down'
+ arrowDown: 'arrow--down',
+ destroy: 'close'
} as const;
export const EMPTY_STATE_IMAGE = {