(core) Showing censored values as a grey cell

Test Plan: Block read access to column A based on the condition rec.B == 1. Then setting B = 1 in a row makes the cell under A grey.

Reviewers: dsagal

Reviewed By: dsagal

Subscribers: paulfitz, dsagal

Differential Revision: https://phab.getgrist.com/D2828
This commit is contained in:
Alex Hall
2021-06-03 17:01:31 +02:00
parent 2feef7f780
commit 2f3a0e0c7f
5 changed files with 67 additions and 3 deletions

View File

@@ -78,6 +78,27 @@
background-color: unset;
}
.field_clip.invalid.field-error-C {
background-color: unset;
color: var(--grist-color-dark-grey);
padding-left: 18px;
}
.field_clip.invalid.field-error-C::before {
/* based on standard icon styles */
content: "";
position: absolute;
top: 4px;
left: 2px;
width: 14px;
height: 14px;
background-color: var(--grist-color-dark-grey);
-webkit-mask-repeat: no-repeat;
-webkit-mask-position: center;
-webkit-mask-size: contain;
-webkit-mask-image: var(--icon-Lock);
}
.field_clip.field-error-U {
color: #6363a2;
background-color: unset;

View File

@@ -152,7 +152,19 @@ export class FieldEditor extends Disposable {
const column = this._field.column();
const cellCurrentValue = this._editRow.cells[this._field.colId()].peek();
const cellValue = column.isFormula() ? column.formula() : cellCurrentValue;
let cellValue: CellValue;
if (column.isFormula()) {
cellValue = column.formula();
} else if (Array.isArray(cellCurrentValue) && cellCurrentValue[0] === 'C') {
// This cell value is censored by access control rules
// Really the rules should also block editing, but in case they don't, show a blank value
// rather than a 'C'. However if the user tries to edit the cell and then clicks away
// without typing anything the empty string is saved, deleting what was there.
// We should probably just automatically block updates where reading is not allowed.
cellValue = '';
} else {
cellValue = cellCurrentValue;
}
// Enter formula-editing mode (e.g. click-on-column inserts its ID) only if we are opening the
// editor by typing into it (and overriding previous formula). In other cases (e.g. double-click),