Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker: parent issues name #2136

Merged
merged 8 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ Tracker:

- Remember view options
- My issues
- Names of parent issues
- Roadmap
- Remember view options
- Context menus (Priority/Status/Assignee)
-

Chunter:

Expand Down
2 changes: 1 addition & 1 deletion models/server-tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ import serverTracker from '@anticrm/server-tracker'

export function createModel (builder: Builder): void {
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
trigger: serverTracker.trigger.OnIssueProjectUpdate
trigger: serverTracker.trigger.OnIssueUpdate
})
}
3 changes: 3 additions & 0 deletions models/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import task from '@anticrm/task'
import {
Document,
Issue,
IssueParentInfo,
IssuePriority,
IssueStatus,
IssueStatusCategory,
Expand Down Expand Up @@ -180,6 +181,8 @@ export class TIssue extends TAttachedDoc implements Issue {
@Prop(ArrOf(TypeRef(tracker.class.Issue)), tracker.string.RelatedTo)
relatedIssue!: Ref<Issue>[]

parents!: IssueParentInfo[]

@Prop(Collection(chunter.class.Comment), tracker.string.Comments)
comments!: number

Expand Down
31 changes: 31 additions & 0 deletions models/tracker/src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,36 @@ async function migrateParentIssues (client: MigrationClient): Promise<void> {
}
}

async function updateIssueParentInfo (client: MigrationClient, parentIssue: Issue | null): Promise<void> {
const parents =
parentIssue === null ? [] : [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents]
const migrationResult = await client.update<Issue>(
DOMAIN_TRACKER,
{
_class: tracker.class.Issue,
attachedTo: parentIssue?._id ?? tracker.ids.NoParent,
parents: { $exists: false }
},
{ parents }
)

if (migrationResult.matched > 0) {
const subIssues = await client.find<Issue>(DOMAIN_TRACKER, {
_class: tracker.class.Issue,
attachedTo: parentIssue?._id ?? tracker.ids.NoParent,
subIssues: { $gt: 0 }
})

for (const issue of subIssues) {
await updateIssueParentInfo(client, issue)
}
}
}

async function migrateIssueParentInfo (client: MigrationClient): Promise<void> {
await updateIssueParentInfo(client, null)
}

async function migrateIssueProjects (client: MigrationClient): Promise<void> {
const issues = await client.find(DOMAIN_TRACKER, { _class: tracker.class.Issue, project: { $exists: false } })

Expand Down Expand Up @@ -288,6 +318,7 @@ async function upgradeProjects (tx: TxOperations): Promise<void> {
export const trackerOperation: MigrateOperation = {
async migrate (client: MigrationClient): Promise<void> {
await Promise.all([migrateIssueProjects(client), migrateParentIssues(client)])
await migrateIssueParentInfo(client)
},
async upgrade (client: MigrationUpgradeClient): Promise<void> {
const tx = new TxOperations(client, core.account.System)
Expand Down
8 changes: 6 additions & 2 deletions plugins/tracker-resources/src/components/CreateIssue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
priority: priority,
dueDate: null,
comments: 0,
subIssues: 0
subIssues: 0,
parents: []
}

const dispatch = createEventDispatcher()
Expand Down Expand Up @@ -143,7 +144,10 @@
rank: calcRank(lastOne, undefined),
comments: 0,
subIssues: 0,
dueDate: object.dueDate
dueDate: object.dueDate,
parents: parentIssue
? [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents]
: []
}

await client.addCollection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { AttachedData, FindOptions, SortingOrder } from '@anticrm/core'
import { AttachedData, FindOptions, Ref, SortingOrder } from '@anticrm/core'
import { getClient, ObjectPopup } from '@anticrm/presentation'
import { calcRank, Issue, IssueStatusCategory } from '@anticrm/tracker'
import { Icon } from '@anticrm/ui'
Expand All @@ -25,7 +25,6 @@
export let width: 'medium' | 'large' | 'full' = 'large'

const client = getClient()

const dispatch = createEventDispatcher()
const options: FindOptions<Issue> = {
lookup: { status: tracker.class.IssueStatus, space: tracker.class.Team },
Expand All @@ -43,7 +42,12 @@
async function onClose ({ detail: parentIssue }: CustomEvent<Issue | undefined | null>) {
const vv = Array.isArray(value) ? value : [value]
for (const docValue of vv) {
if ('_id' in docValue && parentIssue !== undefined && parentIssue?._id !== docValue.attachedTo) {
if (
'_id' in docValue &&
parentIssue !== undefined &&
parentIssue?._id !== docValue.attachedTo &&
parentIssue?._id !== docValue._id
) {
let rank: string | null = null

if (parentIssue) {
Expand All @@ -68,12 +72,24 @@

$: selected = !Array.isArray(value) ? ('attachedTo' in value ? value.attachedTo : undefined) : undefined
$: ignoreObjects = !Array.isArray(value) ? ('_id' in value ? [value._id] : []) : undefined
$: docQuery = {
'parents.parentId': {
$nin: [
...new Set(
(Array.isArray(value) ? value : [value])
.map((issue) => ('_id' in issue ? issue._id : null))
.filter((x): x is Ref<Issue> => x !== null)
)
]
}
}
$: updateIssueStatusCategories()
</script>

<ObjectPopup
_class={tracker.class.Issue}
{options}
{docQuery}
{selected}
multiSelect={false}
allowDeselect={true}
Expand Down
12 changes: 10 additions & 2 deletions plugins/tracker-resources/src/components/issues/KanbanView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import AssigneePresenter from './AssigneePresenter.svelte'
import SubIssuesSelector from './edit/SubIssuesSelector.svelte'
import IssuePresenter from './IssuePresenter.svelte'
import ParentNamesPresenter from './ParentNamesPresenter.svelte'
import PriorityEditor from './PriorityEditor.svelte'

export let currentSpace: Ref<Team> = tracker.team.DefaultTeam
Expand Down Expand Up @@ -172,8 +173,11 @@
showPanel(tracker.component.EditIssue, object._id, object._class, 'content')
}}
>
<div class="flex-col mr-6">
<IssuePresenter value={issue} />
<div class="flex-col mr-8">
<div class="flex clear-mins names">
<IssuePresenter value={issue} />
<ParentNamesPresenter value={issue} />
</div>
<span class="fs-bold caption-color mt-1 lines-limit-2">
{object.title}
</span>
Expand Down Expand Up @@ -210,6 +214,10 @@
{/await}

<style lang="scss">
.names {
font-size: 0.8125rem;
}

.header {
padding-bottom: 0.75rem;
border-bottom: 1px solid var(--divider-color);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!--
// Copyright © 2022 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import type { Issue } from '@anticrm/tracker'

export let value: Issue | undefined
</script>

{#if value}
<div class="root">
<span class="names">
{#each value.parents as parentInfo}
<span class="name">{parentInfo.parentTitle}</span>
{/each}
</span>
</div>
{/if}

<style lang="scss">
.root {
display: flex;
min-width: 0;

.names {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--content-color);
}

.name::before {
content: '›';
padding: 0 0.25rem;
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,29 @@
-->
<script lang="ts">
import type { Issue } from '@anticrm/tracker'
import ParentNamesPresenter from './ParentNamesPresenter.svelte'

export let value: Issue
export let shouldUseMargin: boolean = false
</script>

{#if value}
<span class="titleLabel flex-grow" class:mTitleLabelWithMargin={shouldUseMargin} title={value.title}
>{value.title}</span
>
<span class="root" class:with-margin={shouldUseMargin} title={value.title}>
<span class="name">{value.title}</span>
<ParentNamesPresenter {value} />
</span>
{/if}

<style lang="scss">
.titleLabel {
flex-shrink: 10;
overflow: hidden;
.root {
display: flex;
flex-grow: 1;
min-width: 0;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
flex-shrink: 10;

&.mTitleLabelWithMargin {
&.with-margin {
margin-left: 0.5rem;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
priority: IssuePriority.NoPriority,
dueDate: null,
comments: 0,
subIssues: 0
subIssues: 0,
parents: []
}
}

Expand Down Expand Up @@ -94,7 +95,8 @@
...newIssue,
title: getTitle(newIssue.title),
number: (incResult as any).object.sequence,
rank: calcRank(lastOne, undefined)
rank: calcRank(lastOne, undefined),
parents: [{ parentId: parentIssue._id, parentTitle: parentIssue.title }, ...parentIssue.parents]
}

const objectId = await client.addCollection(
Expand Down
9 changes: 9 additions & 0 deletions plugins/tracker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export interface Issue extends AttachedDoc {
subIssues: number
blockedBy?: Ref<Issue>[]
relatedIssue?: Ref<Issue>[]
parents: IssueParentInfo[]

comments: number
attachments?: number
Expand All @@ -124,6 +125,14 @@ export interface Issue extends AttachedDoc {
rank: string
}

/**
* @public
*/
export interface IssueParentInfo {
parentId: Ref<Issue>
parentTitle: string
}

/**
* @public
*/
Expand Down
Loading