-
Notifications
You must be signed in to change notification settings - Fork 15
Feature/osmt 38 import directly to collection #436
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
Merged
Corpratespaz
merged 12 commits into
develop
from
feature/OSMT-38-import-directly-to-collection
Jul 21, 2023
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7017c72
Starting working to add the skill import component
jchavez137 58837ec
removing import rsd component, adding batch import logic and custom b…
jchavez137 e290223
reverting maven.yml and api-tests.yml, adding batch import component …
jchavez137 45751ee
adding some unit testing
jchavez137 7b10b1c
removing unnecessary skill import component, adding control to select…
jchavez137 f7a141e
refactoring names and cleaning code
jchavez137 d009613
removing whitespaces
jchavez137 770f08c
addressing import comments
jchavez137 70303b4
setting default value for destination selector
jchavez137 3f1deb6
duplicating buttons
jchavez137 a68c269
refactoring validation for skills to be imported
jchavez137 dafe02f
removing blank line added
jchavez137 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
83 changes: 83 additions & 0 deletions
83
...ction/create-collection/batch-import-collection/batch-import-collection.component.spec.ts
This file contains hidden or 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,83 @@ | ||
| import {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
| import { ActivatedRoute, Router } from "@angular/router"; | ||
| import { ActivatedRouteStubSpec } from "@test/util/activated-route-stub.spec"; | ||
| import { Type } from "@angular/core"; | ||
| import { RouterTestingModule } from "@angular/router/testing"; | ||
| import { HttpClientTestingModule } from "@angular/common/http/testing"; | ||
| import { Location } from "@angular/common"; | ||
| import { Title } from "@angular/platform-browser"; | ||
| import { BatchImportCollectionComponent } from './batch-import-collection.component'; | ||
| import { AppConfig } from "../../../app.config"; | ||
| import { ToastService } from "../../../toast/toast.service"; | ||
| import { EnvironmentService } from "../../../core/environment.service"; | ||
| import { CollectionServiceStub, EnvironmentServiceStub, RouterStub } from "@test/resource/mock-stubs"; | ||
| import { CollectionService } from "../../service/collection.service"; | ||
|
|
||
|
|
||
| let activatedRoute: ActivatedRouteStubSpec | ||
| let component: BatchImportCollectionComponent | ||
| let fixture: ComponentFixture<BatchImportCollectionComponent> | ||
|
|
||
| export function createComponent(T: Type<BatchImportCollectionComponent>): Promise<void> { | ||
| fixture = TestBed.createComponent(T) | ||
| component = fixture.componentInstance | ||
|
|
||
| // 1st change detection triggers ngOnInit which gets a hero | ||
| fixture.detectChanges() | ||
|
|
||
| return fixture.whenStable().then(() => { | ||
| // 2nd change detection displays the async-fetched hero | ||
| fixture.detectChanges() | ||
| }) | ||
| } | ||
|
|
||
| describe('BatchImportCollectionComponent', () => { | ||
| beforeEach(() => { | ||
| activatedRoute = new ActivatedRouteStubSpec() | ||
| }) | ||
|
|
||
| let fixture: ComponentFixture<BatchImportCollectionComponent>; | ||
|
|
||
| beforeEach(async(() => { | ||
| TestBed.configureTestingModule({ | ||
| declarations: [BatchImportCollectionComponent], | ||
| imports: [ | ||
| RouterTestingModule, | ||
| HttpClientTestingModule | ||
| ], | ||
| providers: [ | ||
| AppConfig, | ||
| Location, | ||
| Title, | ||
| ToastService, | ||
| { provide: EnvironmentService, useClass: EnvironmentServiceStub }, | ||
| { provide: CollectionService, useClass: CollectionServiceStub }, | ||
| { provide: ActivatedRoute, useValue: activatedRoute }, | ||
| { provide: Router, useClass: RouterStub }, | ||
| ] | ||
| }) | ||
| .compileComponents() | ||
|
|
||
| const appConfig = TestBed.inject(AppConfig) | ||
| AppConfig.settings = appConfig.defaultConfig() | ||
|
|
||
| const environmentService = TestBed.inject(EnvironmentService) | ||
| environmentService.environment.editableAuthor = true | ||
| AppConfig.settings.editableAuthor = true // Doubly sure | ||
|
|
||
| activatedRoute.setParams({ uuid: "uuid1" }) | ||
| createComponent(BatchImportCollectionComponent) | ||
| })); | ||
|
|
||
| it("should be created", () => { | ||
| expect(component).toBeTruthy() | ||
| }) | ||
|
|
||
| it("nameLabel should return", () => { | ||
| component.collectionUuid = "" | ||
| expect(component.nameLabel).toEqual("New Collection Name") | ||
|
|
||
| component.collectionUuid = "uuid" | ||
| expect(component.nameLabel).toEqual("Collection Name") | ||
| }) | ||
| }); |
54 changes: 54 additions & 0 deletions
54
...collection/create-collection/batch-import-collection/batch-import-collection.component.ts
This file contains hidden or 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,54 @@ | ||
| import { Component } from '@angular/core'; | ||
| import { Title } from "@angular/platform-browser"; | ||
| import { Location } from "@angular/common"; | ||
| import { ActivatedRoute, Router } from "@angular/router"; | ||
| import { CollectionFormComponent } from "../collection-form.component"; | ||
| import { ExtrasSelectedSkillsState } from "../../add-skills-collection.component"; | ||
| import { ApiSearch, ApiSkillListUpdate } from "../../../richskill/service/rich-skill-search.service"; | ||
| import { CollectionService } from "../../service/collection.service"; | ||
| import { ToastService } from "../../../toast/toast.service"; | ||
|
|
||
| @Component({ | ||
| selector: 'app-batch-import-collection', | ||
| templateUrl: "../collection-form.component.html" | ||
| }) | ||
| export class BatchImportCollectionComponent extends CollectionFormComponent { | ||
|
|
||
| state?: ExtrasSelectedSkillsState | ||
|
|
||
| constructor( | ||
| protected collectionService: CollectionService, | ||
| protected loc: Location, | ||
| protected router: Router, | ||
| protected route: ActivatedRoute, | ||
| protected toastService: ToastService, | ||
| protected titleService: Title | ||
| ) { | ||
| super(collectionService, loc, router, route, toastService, titleService) | ||
| this.state = this.router.getCurrentNavigation()?.extras.state as ExtrasSelectedSkillsState | ||
| } | ||
|
|
||
| onSubmit(): void { | ||
| console.log(this.state?.selectedSkills?.length) | ||
| const updateObject = this.updateObject() | ||
| this.collectionSaved = this.collectionService.createCollection(updateObject) | ||
| const update = new ApiSkillListUpdate({ | ||
| add: new ApiSearch({uuids: this.state?.selectedSkills?.map(it => it.uuid) }) | ||
| }) | ||
|
|
||
| if (this.collectionSaved) { | ||
| this.collectionSaved.subscribe(collection => { | ||
| this.collectionForm.markAsPristine() | ||
| this.collectionService.updateSkillsWithResult(collection.uuid, update, undefined).subscribe(result => { | ||
| if (result) { | ||
| const message = `You added ${result.modifiedCount} RSDs to the collection.` | ||
| this.toastService.showToast("Success!", message) | ||
| this.toastService.hideBlockingLoader() | ||
| this.router.navigate([`/collections/${collection.uuid}/manage`]) | ||
| } | ||
| }) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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,5 @@ | ||
| export enum BatchImportOptionsEnum { | ||
| existing = "existing", | ||
| new = "new", | ||
| workspace = "workspace", | ||
| } | ||
This file contains hidden or 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 hidden or 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,3 @@ | ||
| .t-import-margin-bottom { | ||
| margin-bottom: -133px; | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.