diff --git a/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte b/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte index 0e96819db1..06c49aff50 100644 --- a/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte +++ b/plugins/tracker-resources/src/components/SetParentIssueActionPopup.svelte @@ -68,6 +68,9 @@ $: selected = !Array.isArray(value) ? ('attachedTo' in value ? value.attachedTo : undefined) : undefined $: ignoreObjects = !Array.isArray(value) ? ('_id' in value ? [value._id] : []) : undefined $: docQuery = { + '$lookup.status.category': { + $nin: [tracker.issueStatusCategory.Completed, tracker.issueStatusCategory.Canceled] + }, 'parents.parentId': { $nin: [ ...new Set( diff --git a/server/mongo/src/storage.ts b/server/mongo/src/storage.ts index b6631c5255..d37d64047a 100644 --- a/server/mongo/src/storage.ts +++ b/server/mongo/src/storage.ts @@ -96,7 +96,7 @@ abstract class MongoAdapterBase extends TxProcessor { for (const key in query) { const value = (query as any)[key] - const tkey = this.checkMixinKey(key, clazz) + const tkey = this.translateKey(key, clazz) if (value !== null && typeof value === 'object') { const keys = Object.keys(value) if (keys[0] === '$like') { @@ -321,25 +321,7 @@ abstract class MongoAdapterBase extends TxProcessor { if (options.sort !== undefined) { const sort = {} as any for (const _key in options.sort) { - let key: string = _key - const arr = key.split('.').filter((p) => p) - key = '' - for (let i = 0; i < arr.length; i++) { - const element = arr[i] - if (element === '$lookup') { - key += arr[++i] + '_lookup' - } else { - if (!key.endsWith('.') && i > 0) { - key += '.' - } - key += arr[i] - if (i !== arr.length - 1) { - key += '.' - } - } - // Check if key is belong to mixin class, we need to add prefix. - key = this.checkMixinKey(key, clazz) - } + const key: string = this.translateKey(_key, clazz) sort[key] = options.sort[_key] === SortingOrder.Ascending ? 1 : -1 } pipeline.push({ $sort: sort }) @@ -378,6 +360,30 @@ abstract class MongoAdapterBase extends TxProcessor { return toFindResult(result, total) } + private translateKey(key: string, clazz: Ref>): string { + const arr = key.split('.').filter((p) => p) + let tKey = '' + + for (let i = 0; i < arr.length; i++) { + const element = arr[i] + if (element === '$lookup') { + tKey += arr[++i] + '_lookup' + } else { + if (!tKey.endsWith('.') && i > 0) { + tKey += '.' + } + tKey += arr[i] + if (i !== arr.length - 1) { + tKey += '.' + } + } + // Check if key is belong to mixin class, we need to add prefix. + tKey = this.checkMixinKey(tKey, clazz) + } + + return tKey + } + private clearExtraLookups (row: any): void { for (const key in row) { if (key.endsWith('_lookup')) {