c2678aa94d88140936ec383b042a55824cadcf031f6f91b214abd3da75c324b86d1dbbb2e98b63ddeea53ddc57469ecd381246b0f31d3c551e99d94c092ad8 741 B

123456789101112131415161718192021222324252627
  1. import {getValidSelection} from './../utils';
  2. export const KEY = 'remove_col';
  3. export default function removeColumnItem() {
  4. return {
  5. key: KEY,
  6. name: 'Remove column',
  7. callback(key, selection) {
  8. let amount = selection.end.col - selection.start.col + 1;
  9. this.alter('remove_col', selection.start.col, amount, 'ContextMenu.removeColumn');
  10. },
  11. disabled() {
  12. const selected = getValidSelection(this);
  13. const totalColumns = this.countCols();
  14. return !selected || this.selection.selectedHeader.rows || this.selection.selectedHeader.corner ||
  15. !this.isColumnModificationAllowed() || !totalColumns;
  16. },
  17. hidden() {
  18. return !this.getSettings().allowRemoveColumn;
  19. }
  20. };
  21. }