-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3775132
commit abdf257
Showing
18 changed files
with
435 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
plugins/test-management-resources/src/components/test-result/NextButton.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<!-- | ||
// Copyright © 2024 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 { onMount, onDestroy } from 'svelte' | ||
import { Button, Loading, Location, navigate } from '@hcengineering/ui' | ||
import { initializeIterator, testResultIteratorProvider, testIteratorStore } from './store/testIteratorStore' | ||
import testManagement, { TestResult } from '@hcengineering/test-management' | ||
import { Doc, type DocumentQuery, WithLookup } from '@hcengineering/core' | ||
import { getClient } from '@hcengineering/presentation' | ||
import { getObjectLinkFragment } from '@hcengineering/view-resources' | ||
import view from '@hcengineering/view' | ||
export let object: WithLookup<TestResult> | undefined | ||
let isLoading = true | ||
let hasNext = false | ||
const client = getClient() | ||
const hierarchy = client.getHierarchy() | ||
const unsubscribe = testIteratorStore.subscribe(() => { | ||
hasNext = testResultIteratorProvider.getIterator()?.hasNext() ?? false | ||
}) | ||
onMount(async () => { | ||
const query: DocumentQuery<TestResult> = { attachedTo: object?.attachedTo } as any | ||
await initializeIterator(query, object?._id) | ||
hasNext = testResultIteratorProvider.getIterator()?.hasNext() ?? false | ||
isLoading = false | ||
}) | ||
onDestroy(() => { | ||
testResultIteratorProvider.reset() | ||
unsubscribe() | ||
}) | ||
async function goToNextItem (): Promise<void> { | ||
const iterator = testResultIteratorProvider.getIterator() | ||
if (iterator !== undefined) { | ||
const nextItem = iterator.next() | ||
if (nextItem === undefined) { | ||
console.error('No next item') | ||
return | ||
} | ||
const link = await getLink(nextItem) | ||
if (link !== undefined) { | ||
navigate(link) | ||
} | ||
console.log('Next item:', nextItem) | ||
} | ||
} | ||
async function getLink (object: Doc): Promise<Location> { | ||
const { component } = hierarchy.classHierarchyMixin(testManagement.class.TestResult, view.mixin.ObjectPanel) as any | ||
return await getObjectLinkFragment(hierarchy, object, {}, component) | ||
} | ||
</script> | ||
|
||
{#if isLoading} | ||
<Loading /> | ||
{:else} | ||
<Button | ||
label={testManagement.string.GoToNextTest} | ||
kind={'primary'} | ||
icon={view.icon.ArrowRight} | ||
disabled={!hasNext} | ||
on:click={goToNextItem} | ||
showTooltip={{ label: testManagement.string.GoToNextTestTooltip }} | ||
/> | ||
{/if} |
51 changes: 51 additions & 0 deletions
51
plugins/test-management-resources/src/components/test-result/store/testIteratorStore.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// Copyright © 2024 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. | ||
// | ||
|
||
import { writable, get } from 'svelte/store' | ||
import { | ||
type IteratorState, | ||
type StoreAdapter, | ||
ObjectIteratorProvider, | ||
getDefaultIteratorState | ||
} from '@hcengineering/view-resources' | ||
import testManagement, { type TestResult } from '@hcengineering/test-management' | ||
import type { DocumentQuery, Ref } from '@hcengineering/core' | ||
|
||
export const testIteratorStore = writable<IteratorState<TestResult>>(getDefaultIteratorState<TestResult>({})) | ||
|
||
const adapter: StoreAdapter<TestResult> = { | ||
set (value: IteratorState<TestResult>) { | ||
testIteratorStore.set(value) | ||
}, | ||
update (updater: (value: IteratorState<TestResult>) => IteratorState<TestResult>) { | ||
testIteratorStore.update(updater) | ||
}, | ||
get () { | ||
return get(testIteratorStore) | ||
} | ||
} | ||
|
||
export const testResultIteratorProvider = new ObjectIteratorProvider<TestResult>(adapter) | ||
|
||
export async function initializeIterator ( | ||
query: DocumentQuery<TestResult>, | ||
currentObject: Ref<TestResult> | undefined | ||
): Promise<void> { | ||
await testResultIteratorProvider.initialize(testManagement.class.TestResult, query, currentObject) | ||
} | ||
|
||
export function resetTestObjectIterator (): void { | ||
testResultIteratorProvider.reset() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.