removeColumn.js 777 B

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