04242a0cf8fd585b50212eea8a13ec475a30d03fd0e795966af279427c8aca7084b631f61a7fd1a83d0b8b74aca9131bb52d1d12831e4b23e1611f200c258d 902 B

12345678910111213141516171819202122232425262728293031
  1. import {checkSelectionConsistency, markLabelAsSelected} from './../utils';
  2. export const KEY = 'make_read_only';
  3. export default function readOnlyItem() {
  4. return {
  5. key: KEY,
  6. name() {
  7. let label = 'Read only';
  8. let atLeastOneReadOnly = checkSelectionConsistency(this.getSelectedRange(), (row, col) => this.getCellMeta(row, col).readOnly);
  9. if (atLeastOneReadOnly) {
  10. label = markLabelAsSelected(label);
  11. }
  12. return label;
  13. },
  14. callback() {
  15. let range = this.getSelectedRange();
  16. let atLeastOneReadOnly = checkSelectionConsistency(range, (row, col) => this.getCellMeta(row, col).readOnly);
  17. range.forAll((row, col) => {
  18. this.setCellMeta(row, col, 'readOnly', !atLeastOneReadOnly);
  19. });
  20. this.render();
  21. },
  22. disabled() {
  23. return !(this.getSelectedRange() && !this.selection.selectedHeader.corner);
  24. }
  25. };
  26. }