mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) updates from grist-core
This commit is contained in:
commit
69ac8fb4b3
@ -31,45 +31,49 @@ export function createPinnedDocs(home: HomeModel) {
|
|||||||
*/
|
*/
|
||||||
export function buildPinnedDoc(home: HomeModel, doc: Document, example?: IExampleInfo): HTMLElement {
|
export function buildPinnedDoc(home: HomeModel, doc: Document, example?: IExampleInfo): HTMLElement {
|
||||||
const renaming = observable<Document|null>(null);
|
const renaming = observable<Document|null>(null);
|
||||||
const isRenaming = computed((use) => use(renaming) === doc);
|
const isRenamingDoc = computed((use) => use(renaming) === doc);
|
||||||
const docTitle = example?.title || doc.name;
|
const docTitle = example?.title || doc.name;
|
||||||
return pinnedDocWrapper(
|
return pinnedDocWrapper(
|
||||||
dom.autoDispose(isRenaming),
|
dom.autoDispose(isRenamingDoc),
|
||||||
pinnedDoc(
|
dom.domComputed(isRenamingDoc, (isRenaming) =>
|
||||||
urlState().setLinkUrl(docUrl(doc)),
|
pinnedDoc(
|
||||||
pinnedDoc.cls('-no-access', !roles.canView(doc.access)),
|
isRenaming ? null : urlState().setLinkUrl(docUrl(doc)),
|
||||||
pinnedDocPreview(
|
pinnedDoc.cls('-no-access', !roles.canView(doc.access)),
|
||||||
example?.bgColor ? dom.style('background-color', example.bgColor) : null,
|
pinnedDocPreview(
|
||||||
(example?.imgUrl ?
|
example?.bgColor ? dom.style('background-color', example.bgColor) : null,
|
||||||
cssImage({src: example.imgUrl}) :
|
(example?.imgUrl ?
|
||||||
[docInitials(docTitle), pinnedDocThumbnail()]
|
cssImage({src: example.imgUrl}) :
|
||||||
),
|
[docInitials(docTitle), pinnedDocThumbnail()]
|
||||||
(doc.public && !example ? cssPublicIcon('PublicFilled', testId('public')) : null),
|
|
||||||
),
|
|
||||||
pinnedDocFooter(
|
|
||||||
dom.domComputed(isRenaming, (yesNo) => yesNo ?
|
|
||||||
pinnedDocEditorInput({
|
|
||||||
initialValue: doc.name || '',
|
|
||||||
save: async (val) => (val !== doc.name) ? home.renameDoc(doc.id, val) : undefined,
|
|
||||||
close: () => renaming.set(null),
|
|
||||||
}, testId('doc-name-editor'))
|
|
||||||
:
|
|
||||||
pinnedDocTitle(
|
|
||||||
dom.text(docTitle),
|
|
||||||
testId('pinned-doc-name'),
|
|
||||||
// Mostly for the sake of tests, allow .test-dm-pinned-doc-name to find documents in
|
|
||||||
// either 'list' or 'icons' views.
|
|
||||||
testId('doc-name')
|
|
||||||
),
|
),
|
||||||
|
(doc.public && !example ? cssPublicIcon('PublicFilled', testId('public')) : null),
|
||||||
),
|
),
|
||||||
cssPinnedDocDesc(
|
pinnedDocFooter(
|
||||||
example?.desc || capitalizeFirst(getTimeFromNow(doc.updatedAt)),
|
(isRenaming ?
|
||||||
testId('pinned-doc-desc')
|
pinnedDocEditorInput({
|
||||||
|
initialValue: doc.name || '',
|
||||||
|
save: async (val) => (val !== doc.name) ? home.renameDoc(doc.id, val) : undefined,
|
||||||
|
close: () => renaming.set(null),
|
||||||
|
}, testId('doc-name-editor'))
|
||||||
|
:
|
||||||
|
pinnedDocTitle(
|
||||||
|
dom.text(docTitle),
|
||||||
|
testId('pinned-doc-name'),
|
||||||
|
// Mostly for the sake of tests, allow .test-dm-pinned-doc-name to find documents in
|
||||||
|
// either 'list' or 'icons' views.
|
||||||
|
testId('doc-name')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
cssPinnedDocDesc(
|
||||||
|
example?.desc || capitalizeFirst(getTimeFromNow(doc.updatedAt)),
|
||||||
|
testId('pinned-doc-desc')
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
example ? null : pinnedDocOptions(icon('Dots'),
|
example ? null : pinnedDocOptions(icon('Dots'),
|
||||||
menu(() => makeDocOptionsMenu(home, doc, renaming), {placement: 'bottom-start'}),
|
menu(() => makeDocOptionsMenu(home, doc, renaming), {placement: 'bottom-start'}),
|
||||||
|
// Clicks on the menu trigger shouldn't follow the link that it's contained in.
|
||||||
|
dom.on('click', (ev) => { ev.stopPropagation(); ev.preventDefault(); }),
|
||||||
testId('pinned-doc-options')
|
testId('pinned-doc-options')
|
||||||
),
|
),
|
||||||
testId('pinned-doc')
|
testId('pinned-doc')
|
||||||
|
Loading…
Reference in New Issue
Block a user