mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 21:15:06 +02:00
Cherry Pick of recent changes in qms (#8498)
Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
@@ -13,6 +13,13 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import documents, {
|
||||
ControlledDocument,
|
||||
ControlledDocumentState,
|
||||
DocumentRequest,
|
||||
DocumentState,
|
||||
Project
|
||||
} from '@hcengineering/controlled-documents'
|
||||
import { Class, Doc, Ref } from '@hcengineering/core'
|
||||
import notification from '@hcengineering/notification'
|
||||
import { Panel } from '@hcengineering/panel'
|
||||
@@ -23,25 +30,19 @@
|
||||
Button,
|
||||
Chevron,
|
||||
DropdownLabelsIntl,
|
||||
IconMoreV,
|
||||
Tab,
|
||||
Tabs,
|
||||
eventToHTMLElement,
|
||||
IconMoreV,
|
||||
navigate,
|
||||
resolvedLocationStore,
|
||||
showPopup
|
||||
showPopup,
|
||||
Tab,
|
||||
Tabs
|
||||
} from '@hcengineering/ui'
|
||||
import { showMenu } from '@hcengineering/view-resources'
|
||||
import documents, {
|
||||
ControlledDocument,
|
||||
ControlledDocumentState,
|
||||
DocumentRequest,
|
||||
DocumentState,
|
||||
Project
|
||||
} from '@hcengineering/controlled-documents'
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
|
||||
|
||||
import { createDocumentSnapshotAndEdit, createNewDraftForControlledDoc, getDocReference } from '../docutils'
|
||||
import { getProjectDocumentLink } from '../navigation'
|
||||
import documentRes from '../plugin'
|
||||
import {
|
||||
$activeRightPanelTab as activeRightPanelTab,
|
||||
@@ -49,20 +50,21 @@
|
||||
$availableRightPanelTabs as availableRightPanelTabs,
|
||||
$canCreateNewDraft as canCreateNewDraft,
|
||||
$canCreateNewSnapshot as canCreateNewSnapshot,
|
||||
$canRestoreDraft as canRestoreDraft,
|
||||
$canSendForApproval as canSendForApproval,
|
||||
$canSendForReview as canSendForReview,
|
||||
$controlledDocument as controlledDocument,
|
||||
controlledDocumentClosed,
|
||||
controlledDocumentOpened,
|
||||
$controlledDocumentTemplate as controlledDocumentTemplate,
|
||||
$documentLatestVersion as documentLatestVersion,
|
||||
$documentApprovalIsActive as documentApprovalIsActive,
|
||||
$documentLatestVersion as documentLatestVersion,
|
||||
$documentReviewIsActive as documentReviewIsActive,
|
||||
$documentState as documentState,
|
||||
$editorMode as editorMode,
|
||||
editorModeUpdated,
|
||||
$isDocumentOwner as isDocumentOwner,
|
||||
$isProjectEditable as isProjectEditable,
|
||||
controlledDocumentClosed,
|
||||
controlledDocumentOpened,
|
||||
editorModeUpdated,
|
||||
rightPanelTabChanged
|
||||
} from '../stores/editors/document'
|
||||
import { completeRequest, getDocumentVersionString, getLatestProjectId, rejectRequest, TeamPopupData } from '../utils'
|
||||
@@ -77,12 +79,11 @@
|
||||
import DocumentRightPanel from './document/right-panel/DocumentRightPanel.svelte'
|
||||
import { scrollIntoSection } from './document/store'
|
||||
import DocumentVersionsPopup from './DocumentVersionsPopup.svelte'
|
||||
import DocumentTemplateFooter from './print/DocumentTemplateFooter.svelte'
|
||||
import DocumentTemplateHeader from './print/DocumentTemplateHeader.svelte'
|
||||
import ProjectSelector from './project/ProjectSelector.svelte'
|
||||
import SignatureDialog from './SignatureDialog.svelte'
|
||||
import TeamPopup from './TeamPopup.svelte'
|
||||
import ProjectSelector from './project/ProjectSelector.svelte'
|
||||
import DocumentTemplateHeader from './print/DocumentTemplateHeader.svelte'
|
||||
import DocumentTemplateFooter from './print/DocumentTemplateFooter.svelte'
|
||||
import { getProjectDocumentLink } from '../navigation'
|
||||
|
||||
export let _id: Ref<ControlledDocument>
|
||||
export let _class: Ref<Class<ControlledDocument>>
|
||||
@@ -220,39 +221,43 @@
|
||||
}
|
||||
|
||||
async function onCreateNewDraft (): Promise<void> {
|
||||
if (creating) {
|
||||
return
|
||||
}
|
||||
if (creating) return
|
||||
|
||||
creating = true
|
||||
try {
|
||||
if ($controlledDocument != null && $canCreateNewDraft && $documentLatestVersion != null) {
|
||||
const latest = $documentLatestVersion
|
||||
const version = { major: latest.major, minor: latest.minor + 1 }
|
||||
const project = await getLatestProjectId($controlledDocument.space)
|
||||
|
||||
if (project !== undefined) {
|
||||
try {
|
||||
const { id, success } = await createNewDraftForControlledDoc(
|
||||
client,
|
||||
$controlledDocument,
|
||||
$controlledDocument.space,
|
||||
version,
|
||||
project
|
||||
)
|
||||
if (success) {
|
||||
const loc = getProjectDocumentLink(id, project)
|
||||
navigate(loc)
|
||||
}
|
||||
} catch (err) {
|
||||
await setPlatformStatus(unknownError(err))
|
||||
}
|
||||
} else {
|
||||
console.warn('No document project found for space', $controlledDocument.space)
|
||||
}
|
||||
} else {
|
||||
if (!$controlledDocument || !$canCreateNewDraft || !$documentLatestVersion) {
|
||||
console.warn('Unexpected document state', $documentState)
|
||||
return
|
||||
}
|
||||
|
||||
const latest = $documentLatestVersion
|
||||
const version = { major: latest.major, minor: latest.minor + 1 }
|
||||
const project = await getLatestProjectId($controlledDocument.space)
|
||||
|
||||
if (project === undefined) {
|
||||
console.warn('No document project found for space', $controlledDocument.space)
|
||||
return
|
||||
}
|
||||
|
||||
if ($canRestoreDraft) {
|
||||
await client.update(latest, { state: DocumentState.Draft })
|
||||
const loc = getProjectDocumentLink(latest, project)
|
||||
navigate(loc)
|
||||
} else {
|
||||
const { id, success } = await createNewDraftForControlledDoc(
|
||||
client,
|
||||
$controlledDocument,
|
||||
$controlledDocument.space,
|
||||
version,
|
||||
project
|
||||
)
|
||||
if (success) {
|
||||
const loc = getProjectDocumentLink(id, project)
|
||||
navigate(loc)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
await setPlatformStatus(unknownError(err))
|
||||
} finally {
|
||||
creating = false
|
||||
}
|
||||
@@ -371,7 +376,7 @@
|
||||
|
||||
{#if $canCreateNewDraft}
|
||||
<Button
|
||||
label={documentRes.string.CreateNewDraft}
|
||||
label={$canRestoreDraft ? documentRes.string.RestoreDraft : documentRes.string.CreateNewDraft}
|
||||
kind="regular"
|
||||
loading={creating}
|
||||
disabled={creating}
|
||||
|
||||
+6
@@ -137,11 +137,16 @@
|
||||
|
||||
$: space = $locationStep.space
|
||||
|
||||
let submitted = false
|
||||
|
||||
async function handleSubmit (): Promise<void> {
|
||||
if ($locationStep.space === undefined || $locationStep.project === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
if (submitted) return
|
||||
submitted = true
|
||||
|
||||
const newDocId = generateId<ControlledDocument>()
|
||||
const _space = $locationStep.space
|
||||
|
||||
@@ -198,6 +203,7 @@
|
||||
loading={isLoading}
|
||||
label={documents.string.NewDocument}
|
||||
submitLabel={documents.string.CreateDraft}
|
||||
canSubmit={!submitted}
|
||||
{canProceed}
|
||||
{steps}
|
||||
selectedStep={$currentStep}
|
||||
|
||||
+6
@@ -130,11 +130,16 @@
|
||||
currentStepUpdated(e.detail)
|
||||
}
|
||||
|
||||
let submitted = false
|
||||
|
||||
async function handleSubmit (): Promise<void> {
|
||||
if ($locationStep.space === undefined || $locationStep.project === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
if (submitted) return
|
||||
submitted = true
|
||||
|
||||
const { category } = docObject
|
||||
if (category === undefined || category === null) return
|
||||
|
||||
@@ -206,6 +211,7 @@
|
||||
submitLabel={documents.string.CreateDraft}
|
||||
{canProceed}
|
||||
{steps}
|
||||
canSubmit={!submitted}
|
||||
selectedStep={currentTemplateStep}
|
||||
on:stepChanged={handleStepChanged}
|
||||
on:submit={handleSubmit}
|
||||
|
||||
@@ -380,6 +380,10 @@
|
||||
padding-top: 20rem;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
|
||||
@media print {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.watermark {
|
||||
|
||||
+6
-4
@@ -14,7 +14,7 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import documents, { type Document, type DocumentTemplate } from '@hcengineering/controlled-documents'
|
||||
import documents, { DocumentState, type Document, type DocumentTemplate } from '@hcengineering/controlled-documents'
|
||||
import { PersonPresenter } from '@hcengineering/contact-resources'
|
||||
import { DateRangeMode } from '@hcengineering/core'
|
||||
import { DatePresenter, Label, Scroller, eventToHTMLElement, showPopup } from '@hcengineering/ui'
|
||||
@@ -73,7 +73,9 @@
|
||||
)
|
||||
}
|
||||
|
||||
$: isEditableDraft = $isEditable && $controlledDocument != null && $documentAllVersions.length === 1
|
||||
$: isEditableDraft = $isEditable && $controlledDocument != null && $controlledDocument.state === DocumentState.Draft
|
||||
$: isInitialEditableDraft = isEditableDraft && $documentAllVersions.length === 1
|
||||
|
||||
$: isTemplate =
|
||||
$controlledDocument != null && hierarchy.hasMixin($controlledDocument, documents.mixin.DocumentTemplate)
|
||||
|
||||
@@ -94,7 +96,7 @@
|
||||
value={$controlledDocument}
|
||||
isRegular
|
||||
disableLink
|
||||
editable={isEditableDraft}
|
||||
editable={isInitialEditableDraft}
|
||||
on:edit={(e) => {
|
||||
handleCodeEdit(e.detail)
|
||||
}}
|
||||
@@ -119,7 +121,7 @@
|
||||
|
||||
{#if isTemplate}
|
||||
<DocumentInfo label={documentsRes.string.DocumentPrefix}>
|
||||
<DocumentPrefixPresenter value={asTemplate} editable={isEditableDraft} />
|
||||
<DocumentPrefixPresenter value={asTemplate} editable={isInitialEditableDraft} />
|
||||
</DocumentInfo>
|
||||
{/if}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user