Skip to content

Commit

Permalink
Merge branch 'hcengineering:main' into vacancies-explicit-hide-archiv…
Browse files Browse the repository at this point in the history
…ed-viewoptions-hcengineering#4003
  • Loading branch information
Syarg authored Dec 19, 2023
2 parents 38a3ff1 + 20fda19 commit 1b38e1d
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 91 deletions.
5 changes: 1 addition & 4 deletions models/tracker/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { type Doc, type Ref } from '@hcengineering/core'
import { type ObjectSearchCategory, type ObjectSearchFactory } from '@hcengineering/model-presentation'
import { type NotificationGroup, type NotificationType } from '@hcengineering/notification'
import { mergeIds, type IntlString, type Resource } from '@hcengineering/platform'
import { type ProjectType, type TaskTypeDescriptor } from '@hcengineering/task'
import { type ProjectType } from '@hcengineering/task'
import { trackerId } from '@hcengineering/tracker'
import tracker from '@hcengineering/tracker-resources/src/plugin'
import type { AnyComponent } from '@hcengineering/ui/src/types'
Expand Down Expand Up @@ -109,8 +109,5 @@ export default mergeIds(trackerId, tracker, {
DeleteProject: '' as Ref<Action<Doc, Record<string, any>>>,
DeleteProjectClean: '' as Ref<Action<Doc, Record<string, any>>>,
DeleteIssue: '' as Ref<Action<Doc, Record<string, any>>>
},
descriptors: {
Issue: '' as Ref<TaskTypeDescriptor>
}
})
6 changes: 3 additions & 3 deletions packages/presentation/src/components/DocPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import type { Class, Doc, Ref } from '@hcengineering/core'
import { getObjectValue, type Class, type Doc, type Ref } from '@hcengineering/core'
import type { IntlString } from '@hcengineering/platform'
import {
Button,
Expand Down Expand Up @@ -68,7 +68,7 @@
$: showCategories =
created.length > 0 ||
objects.map((it) => (it as any)[groupBy]).filter((it, index, arr) => arr.indexOf(it) === index).length > 1
objects.map((it) => getObjectValue(groupBy, it)).filter((it, index, arr) => arr.indexOf(it) === index).length > 1
const checkSelected = (item: Doc): void => {
if (selectedElements.has(item._id)) {
Expand Down Expand Up @@ -148,7 +148,7 @@
if (created.find((it) => it._id === doc._id) !== undefined) {
return '_created'
}
return toAny(doc)[groupBy]
return getObjectValue(groupBy, toAny(doc))
}
</script>

Expand Down
13 changes: 10 additions & 3 deletions packages/presentation/src/components/ObjectPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
// limitations under the License.
-->
<script lang="ts">
import type { Class, Doc, DocumentQuery, FindOptions, Ref } from '@hcengineering/core'
import {
getObjectValue,
type Class,
type Doc,
type DocumentQuery,
type FindOptions,
type Ref
} from '@hcengineering/core'
import type { IntlString } from '@hcengineering/platform'
import { Label } from '@hcengineering/ui'
import { createEventDispatcher } from 'svelte'
Expand Down Expand Up @@ -77,8 +84,8 @@
},
(result) => {
result.sort((a, b) => {
const aval: string = `${(a as any)[groupBy]}`
const bval: string = `${(b as any)[groupBy]}`
const aval: string = `${getObjectValue(groupBy, a as any)}`
const bval: string = `${getObjectValue(groupBy, b as any)}`
return aval.localeCompare(bval)
})
if (created.length > 0) {
Expand Down
15 changes: 11 additions & 4 deletions plugins/recruit-resources/src/components/CreateVacancy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
space: Ref<Project>,
template: IssueTemplateData,
parent: Ref<Issue> = tracker.ids.NoParent
): Promise<Ref<Issue>> {
): Promise<Ref<Issue> | undefined> {
const lastOne = await client.findOne<Issue>(
tracker.class.Issue,
{ space },
Expand All @@ -114,6 +114,10 @@
)
const project = await client.findOne(tracker.class.Project, { _id: space })
const rank = calcRank(lastOne, undefined)
const taskType = await client.findOne(task.class.TaskType, { ofClass: tracker.class.Issue })
if (taskType === undefined) {
return
}
const resId = await client.addCollection(tracker.class.Issue, space, parent, tracker.class.Issue, 'subIssues', {
title: template.title + ` (${name})`,
description: template.description,
Expand All @@ -133,7 +137,8 @@
estimation: template.estimation,
reports: 0,
relations: [{ _id: id, _class: recruit.class.Vacancy }],
childInfo: []
childInfo: [],
kind: taskType._id
})
if ((template.labels?.length ?? 0) > 0) {
const tagElements = await client.findAll(tags.class.TagElement, { _id: { $in: template.labels } })
Expand Down Expand Up @@ -181,8 +186,10 @@
if (issueTemplates.length > 0) {
for (const issueTemplate of issueTemplates) {
const issue = await saveIssue(id, issueTemplate.space, issueTemplate)
for (const sub of issueTemplate.children) {
await saveIssue(id, issueTemplate.space, sub, issue)
if (issue !== undefined) {
for (const sub of issueTemplate.children) {
await saveIssue(id, issueTemplate.space, sub, issue)
}
}
}
}
Expand Down
21 changes: 16 additions & 5 deletions plugins/task-resources/src/components/StatusFilter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import core, { Doc, FindResult, IdMap, Ref, RefTo, Space, Status, toIdMap } from '@hcengineering/core'
import { translate } from '@hcengineering/platform'
import presentation, { getClient } from '@hcengineering/presentation'
import { TaskType } from '@hcengineering/task'
import { ProjectType, TaskType } from '@hcengineering/task'
import ui, {
EditWithIcon,
Icon,
Expand All @@ -39,7 +39,7 @@
import view from '@hcengineering/view-resources/src/plugin'
import { buildConfigLookup, getPresenter } from '@hcengineering/view-resources/src/utils'
import { createEventDispatcher } from 'svelte'
import { selectedTaskTypeStore, taskTypeStore } from '..'
import { selectedTaskTypeStore, selectedTypeStore, taskTypeStore, typeStore } from '..'
export let filter: Filter
export let space: Ref<Space> | undefined = undefined
Expand Down Expand Up @@ -67,7 +67,9 @@
search: string,
selectedType: Ref<TaskType> | undefined,
typeStore: IdMap<TaskType>,
statusStore: IdMap<Status>
statusStore: IdMap<Status>,
selectedProjectType: Ref<ProjectType> | undefined,
projectTypeStore: IdMap<ProjectType>
): Promise<void> {
await objectsPromise
targets.clear()
Expand All @@ -85,13 +87,22 @@
values = values.filter((p) => p?.name.includes(search))
}
} else {
const statuses: Status[] = []
let statuses: Status[] = []
const prjStatuses = new Map(
(
(selectedProjectType !== undefined ? projectTypeStore.get(selectedProjectType) : undefined)?.statuses ?? []
).map((p) => [p._id, p])
)
for (const status of statusStore.values()) {
if (hierarchy.isDerived(status._class, targetClass) && status.ofAttribute === filter.key.attribute._id) {
if (prjStatuses.size > 0 && !prjStatuses.has(status._id)) {
continue
}
statuses.push(status)
targets.add(status._id)
}
}
statuses = statuses.filter((it, idx, arr) => arr.findIndex((q) => q._id === it._id) === idx)
values = await sort(statuses)
}
if (targets.has(undefined)) {
Expand Down Expand Up @@ -164,7 +175,7 @@
const dispatch = createEventDispatcher()
$: if (targetClass != null) {
void getValues(search, $selectedTaskTypeStore, $taskTypeStore, $statusStore.byId)
void getValues(search, $selectedTaskTypeStore, $taskTypeStore, $statusStore.byId, $selectedTypeStore, $typeStore)
}
</script>

Expand Down
Loading

0 comments on commit 1b38e1d

Please sign in to comment.