diff --git a/dev/generator/src/issues.ts b/dev/generator/src/issues.ts index a6cb28e3c8..7b3689587c 100644 --- a/dev/generator/src/issues.ts +++ b/dev/generator/src/issues.ts @@ -35,7 +35,8 @@ const object: AttachedData = { reportedTime: 0, estimation: 0, reports: 0, - childInfo: [] + childInfo: [], + createOn: Date.now() } export interface IssueOptions { @@ -97,7 +98,8 @@ async function genIssue (client: TxOperations, statuses: Ref[]): Pr estimation: object.estimation, reports: 0, relations: [], - childInfo: [] + childInfo: [], + createOn: Date.now() } await client.addCollection( tracker.class.Issue, diff --git a/models/chunter/src/index.ts b/models/chunter/src/index.ts index 77e652b95e..7be1cf5ec6 100644 --- a/models/chunter/src/index.ts +++ b/models/chunter/src/index.ts @@ -37,6 +37,7 @@ import { Index, Model, Prop, + ReadOnly, TypeMarkup, TypeRef, TypeString, @@ -88,6 +89,7 @@ export class TChunterMessage extends TAttachedDoc implements ChunterMessage { createBy!: Ref @Prop(TypeTimestamp(), chunter.string.Create) + @ReadOnly() createOn!: Timestamp @Prop(TypeTimestamp(), chunter.string.Edit) diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 2e0b92cf3e..3256493456 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -273,6 +273,10 @@ export class TIssue extends TAttachedDoc implements Issue { @Prop(Collection(tracker.class.TimeSpendReport), tracker.string.TimeSpendReports) reports!: number + @Prop(TypeTimestamp(), tracker.string.CreatedOn) + @ReadOnly() + createOn!: Timestamp + declare childInfo: IssueChildInfo[] } diff --git a/models/tracker/src/migration.ts b/models/tracker/src/migration.ts index 5d614bf1f2..dac14faf94 100644 --- a/models/tracker/src/migration.ts +++ b/models/tracker/src/migration.ts @@ -21,6 +21,7 @@ import core, { generateId, Ref, SortingOrder, + TxCollectionCUD, TxCreateDoc, TxOperations, TxResult, @@ -710,6 +711,59 @@ async function renameProject (client: MigrationClient): Promise { ) } +async function setCreate (client: MigrationClient): Promise { + while (true) { + const docs = await client.find( + DOMAIN_TRACKER, + { + _class: tracker.class.Issue, + createOn: { $exists: false } + }, + { limit: 500 } + ) + if (docs.length === 0) { + break + } + const creates = await client.find>(DOMAIN_TX, { + 'tx.objectId': { $in: docs.map((it) => it._id) }, + 'tx._class': core.class.TxCreateDoc + }) + for (const doc of docs) { + const tx = creates.find((it) => it.tx.objectId === doc._id) + if (tx !== undefined) { + await client.update( + DOMAIN_TRACKER, + { + _id: doc._id + }, + { + createOn: tx.modifiedOn + } + ) + await client.update( + DOMAIN_TX, + { + _id: tx._id + }, + { + 'tx.attributes.createOn': tx.modifiedOn + } + ) + } else { + await client.update( + DOMAIN_TRACKER, + { + _id: doc._id + }, + { + createOn: doc.modifiedOn + } + ) + } + } + } +} + export const trackerOperation: MigrateOperation = { async migrate (client: MigrationClient): Promise { await client.update( @@ -725,6 +779,7 @@ export const trackerOperation: MigrateOperation = { await migrateIssueParentInfo(client) await fillRank(client) await renameProject(client) + await setCreate(client) }, async upgrade (client: MigrationUpgradeClient): Promise { const tx = new TxOperations(client, core.account.System) diff --git a/models/tracker/src/plugin.ts b/models/tracker/src/plugin.ts index 7a4f3024c5..1a7d5a6754 100644 --- a/models/tracker/src/plugin.ts +++ b/models/tracker/src/plugin.ts @@ -34,7 +34,8 @@ export default mergeIds(trackerId, tracker, { GotoComponents: '' as IntlString, GotoTrackerApplication: '' as IntlString, SearchIssue: '' as IntlString, - Parent: '' as IntlString + Parent: '' as IntlString, + CreatedOn: '' as IntlString }, component: { // Required to pass build without errorsF diff --git a/plugins/tracker-assets/lang/en.json b/plugins/tracker-assets/lang/en.json index 1f8e6df288..0233ac81e6 100644 --- a/plugins/tracker-assets/lang/en.json +++ b/plugins/tracker-assets/lang/en.json @@ -282,7 +282,8 @@ "WorkDayLength": "Select length of working day", "SevenHoursLength": "Seven Hours", - "EightHoursLength": "Eight Hours" + "EightHoursLength": "Eight Hours", + "CreatedOn": "Created on" }, "status": {} } diff --git a/plugins/tracker-assets/lang/ru.json b/plugins/tracker-assets/lang/ru.json index 8126522882..556ba0bbf0 100644 --- a/plugins/tracker-assets/lang/ru.json +++ b/plugins/tracker-assets/lang/ru.json @@ -282,7 +282,8 @@ "WorkDayLength": "Выберите длину рабочего дня", "SevenHoursLength": "Семь Часов", - "EightHoursLength": "Восемь Часов" + "EightHoursLength": "Восемь Часов", + "CreatedOn": "Создана" }, "status": {} } diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index a4058b8a60..00d8656fa6 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -115,7 +115,7 @@ const defaultIssue = { title: '', description: '', - assignee: '' as Ref, + assignee, component, sprint, number: 0, @@ -130,7 +130,8 @@ reportedTime: 0, estimation: 0, reports: 0, - childInfo: [] + childInfo: [], + createOn: Date.now() } let object = originalIssue @@ -166,7 +167,7 @@ $: if (templateId !== undefined) { templateQuery.query(tracker.class.IssueTemplate, { _id: templateId }, (res) => { - template = res.shift() + template = res[0] }) } else { template = undefined @@ -455,7 +456,8 @@ estimation: object.estimation, reports: 0, relations: relatedTo !== undefined ? [{ _id: relatedTo._id, _class: relatedTo._class }] : [], - childInfo: [] + childInfo: [], + createOn: Date.now() } await client.addCollection( diff --git a/plugins/tracker-resources/src/components/SubIssues.svelte b/plugins/tracker-resources/src/components/SubIssues.svelte index e8bf21a1c1..96cc30a9fe 100644 --- a/plugins/tracker-resources/src/components/SubIssues.svelte +++ b/plugins/tracker-resources/src/components/SubIssues.svelte @@ -93,7 +93,8 @@ estimation: subIssue.estimation, reports: 0, relations: [], - childInfo: [] + childInfo: [], + createOn: Date.now() } await client.addCollection( diff --git a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte index 95901f5f64..e391553919 100644 --- a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte @@ -65,7 +65,8 @@ estimation: 0, reportedTime: 0, reports: 0, - childInfo: [] + childInfo: [], + createOn: Date.now() } } diff --git a/plugins/tracker-resources/src/components/templates/CreateIssueTemplate.svelte b/plugins/tracker-resources/src/components/templates/CreateIssueTemplate.svelte index 31d481aba6..40f4bab019 100644 --- a/plugins/tracker-resources/src/components/templates/CreateIssueTemplate.svelte +++ b/plugins/tracker-resources/src/components/templates/CreateIssueTemplate.svelte @@ -66,7 +66,6 @@ } $: _space = space - let spaceRef: Project | undefined $: canSave = getTitle(object.title ?? '').length > 0 @@ -136,14 +135,7 @@ createMore={false} > - { - spaceRef = evt.detail - }} - /> +