(core) Fix warning bug in Save Copy dialog

Summary:
The warning about workspace write access would still be shown if
a user picked a workspace they had write access to, and cleared the
Name field in the Save Copy dialog. This fixes the condition for
showing the warning to not show it in this case, and adds a placeholder
to the Name field when it is blank.

Test Plan: Browser test.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D3002
This commit is contained in:
George Gevoian 2021-08-27 11:10:30 -07:00
parent 3edb3a6826
commit 3d085ff2d7

View File

@ -163,7 +163,7 @@ class SaveCopyModal extends Disposable {
return [ return [
cssField( cssField(
cssLabel("Name"), cssLabel("Name"),
input(this._destName, {onInput: true}, dom.cls(cssInput.className), input(this._destName, {onInput: true}, {placeholder: 'Enter document name'}, dom.cls(cssInput.className),
// modal dialog grabs focus after 10ms delay; so to focus this input, wait a bit longer // modal dialog grabs focus after 10ms delay; so to focus this input, wait a bit longer
// (see the TODO in app/client/ui2018/modals.ts about weasel.js and focus). // (see the TODO in app/client/ui2018/modals.ts about weasel.js and focus).
(elem) => { setTimeout(() => { elem.focus(); }, 20); }, (elem) => { setTimeout(() => { elem.focus(); }, 20); },
@ -204,10 +204,11 @@ class SaveCopyModal extends Disposable {
), ),
testId('copy-dest-workspace'), testId('copy-dest-workspace'),
), ),
wss ? dom.maybe(this._saveDisabled, () => wss ? dom.domComputed(this._destWS, (destWs) =>
cssWarningText("You do not have write access to the selected workspace", destWs && !roles.canEdit(destWs.access) ?
testId('copy-warning') cssWarningText("You do not have write access to the selected workspace",
) testId('copy-warning')
) : null
) : null ) : null
] ]
), ),