mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-03 07:38:45 +02:00
Support for rating system (#10124)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -22,7 +22,13 @@
|
||||
import notification from '@hcengineering/notification'
|
||||
import { Panel } from '@hcengineering/panel'
|
||||
import { getResource, setPlatformStatus, unknownError } from '@hcengineering/platform'
|
||||
import { IconWithEmoji, copyTextToClipboard, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
ComponentExtensions,
|
||||
IconWithEmoji,
|
||||
copyTextToClipboard,
|
||||
createQuery,
|
||||
getClient
|
||||
} from '@hcengineering/presentation'
|
||||
import tags from '@hcengineering/tags'
|
||||
import { Heading } from '@hcengineering/text-editor'
|
||||
import { TableOfContents } from '@hcengineering/text-editor-resources'
|
||||
@@ -52,7 +58,7 @@
|
||||
} from '@hcengineering/view-resources'
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
|
||||
|
||||
import { starDocument, unlockContent, unstarDocument } from '..'
|
||||
import { unlockContent } from '..'
|
||||
import document from '../plugin'
|
||||
import { getDocumentUrl } from '../utils'
|
||||
import DocumentEditor from './DocumentEditor.svelte'
|
||||
@@ -108,17 +114,6 @@
|
||||
clearTimeout(copyTimeout)
|
||||
})
|
||||
|
||||
const starredQuery = createQuery()
|
||||
let isStarred = false
|
||||
$: starredQuery.query(
|
||||
document.class.SavedDocument,
|
||||
{ attachedTo: _id },
|
||||
(res) => {
|
||||
isStarred = res.length !== 0
|
||||
},
|
||||
{ limit: 1 }
|
||||
)
|
||||
|
||||
async function createEmbedding (file: File): Promise<{ file: Ref<Blob>, type: string } | undefined> {
|
||||
if (doc === undefined) {
|
||||
return undefined
|
||||
@@ -221,18 +216,6 @@
|
||||
]
|
||||
let selectedAside: string | boolean = false
|
||||
|
||||
$: starAction = isStarred
|
||||
? {
|
||||
icon: document.icon.Starred,
|
||||
label: document.string.Unstar,
|
||||
action: () => doc !== undefined && unstarDocument(doc)
|
||||
}
|
||||
: {
|
||||
icon: document.icon.Star,
|
||||
label: document.string.Star,
|
||||
action: () => doc !== undefined && starDocument(doc)
|
||||
}
|
||||
|
||||
$: actions = [
|
||||
{
|
||||
icon: view.icon.CopyId,
|
||||
@@ -249,8 +232,7 @@
|
||||
}, 2000)
|
||||
}
|
||||
}
|
||||
},
|
||||
starAction
|
||||
}
|
||||
]
|
||||
|
||||
let editor: DocumentEditor
|
||||
@@ -323,6 +305,12 @@
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="utils">
|
||||
{#if doc}
|
||||
<ComponentExtensions
|
||||
extension={view.extensions.EditDocTitleExtension}
|
||||
props={{ size: 'medium', kind: 'ghost', _id: doc._id, _class: doc._class, value: doc, readonly }}
|
||||
/>
|
||||
{/if}
|
||||
{#if !$restrictionStore.disableActions}
|
||||
<Button
|
||||
id="btn-doc-title-open-more"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import core, {
|
||||
import {
|
||||
generateId,
|
||||
getCurrentAccount,
|
||||
type Class,
|
||||
@@ -31,8 +31,8 @@ import { openDoc } from '@hcengineering/view-resources'
|
||||
|
||||
import CreateDocument from './components/CreateDocument.svelte'
|
||||
import DocumentIcon from './components/DocumentIcon.svelte'
|
||||
import DocumentItem from './components/DocumentItem.svelte'
|
||||
import DocumentInlineEditor from './components/DocumentInlineEditor.svelte'
|
||||
import DocumentItem from './components/DocumentItem.svelte'
|
||||
import DocumentPresenter from './components/DocumentPresenter.svelte'
|
||||
import DocumentSearchIcon from './components/DocumentSearchIcon.svelte'
|
||||
import DocumentToDoPresenter from './components/DocumentToDoPresenter.svelte'
|
||||
@@ -113,23 +113,6 @@ async function editTeamspace (teamspace: Teamspace | undefined): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function starDocument (doc: Document): Promise<void> {
|
||||
const client = getClient()
|
||||
|
||||
await client.createDoc(document.class.SavedDocument, core.space.Workspace, {
|
||||
attachedTo: doc._id
|
||||
})
|
||||
}
|
||||
|
||||
export async function unstarDocument (doc: Document): Promise<void> {
|
||||
const client = getClient()
|
||||
|
||||
const current = await client.findOne(document.class.SavedDocument, { attachedTo: doc._id })
|
||||
if (current !== undefined) {
|
||||
await client.remove(current)
|
||||
}
|
||||
}
|
||||
|
||||
export async function lockContent (doc: Document | Document[]): Promise<void> {
|
||||
const client = getClient()
|
||||
const me = getCurrentAccount()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
//
|
||||
|
||||
import { type Client, type Doc, type Ref } from '@hcengineering/core'
|
||||
import document, { type Document, documentId } from '@hcengineering/document'
|
||||
import document, { documentId, type Document } from '@hcengineering/document'
|
||||
import { mergeIds, type IntlString, type Resource } from '@hcengineering/platform'
|
||||
import { type AnyComponent, type Location } from '@hcengineering/ui/src/types'
|
||||
|
||||
@@ -50,7 +50,6 @@ export default mergeIds(documentId, document, {
|
||||
Authors: '' as IntlString,
|
||||
Backlinks: '' as IntlString,
|
||||
History: '' as IntlString,
|
||||
SavedDocuments: '' as IntlString,
|
||||
AddLabel: '' as IntlString,
|
||||
NewTeamspace: '' as IntlString,
|
||||
CreateTeamspace: '' as IntlString,
|
||||
|
||||
Reference in New Issue
Block a user