Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement quest-selector (#546)
- Loading branch information
1 parent
cfca29c
commit c8c3f37
Showing
14 changed files
with
289 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
src/app/shared/modules/search/quest-search.service.spec.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,19 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { instance } from 'ts-mockito'; | ||
|
||
import { QuestSearchService } from './quest-search.service'; | ||
import { MockedSqliteQueryService } from '../../testing/mocks'; | ||
import { SqliteQueryService } from '@keira-shared/services/sqlite-query.service'; | ||
|
||
describe('QuestSearchService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({ | ||
providers: [ | ||
{ provide: SqliteQueryService, useValue: instance(MockedSqliteQueryService) }, | ||
] | ||
})); | ||
|
||
it('should be created', () => { | ||
const service: QuestSearchService = TestBed.inject(QuestSearchService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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,22 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { SearchService } from './search.service'; | ||
import { MysqlQueryService } from '@keira-shared/services/mysql-query.service'; | ||
import { | ||
QUEST_TEMPLATE_SEARCH_FIELDS, | ||
QUEST_TEMPLATE_TABLE, | ||
QuestTemplate, | ||
} from '../../types/quest-template.type'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class QuestSearchService extends SearchService<QuestTemplate> { | ||
|
||
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690 | ||
constructor( | ||
protected queryService: MysqlQueryService, | ||
) { | ||
super(queryService, QUEST_TEMPLATE_TABLE, QUEST_TEMPLATE_SEARCH_FIELDS); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/app/shared/modules/selectors/quest-selector/quest-selector-btn.component.spec.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,26 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { QuestSelectorBtnComponent } from './quest-selector-btn.component'; | ||
import { QuestSelectorModule } from './quest-selector.module'; | ||
|
||
describe('QuestSelectorBtnComponent', () => { | ||
let component: QuestSelectorBtnComponent; | ||
let fixture: ComponentFixture<QuestSelectorBtnComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ QuestSelectorModule ], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(QuestSelectorBtnComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
src/app/shared/modules/selectors/quest-selector/quest-selector-btn.component.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,23 @@ | ||
import { Component } from '@angular/core'; | ||
import { BsModalService } from 'ngx-bootstrap'; | ||
|
||
import { QuestSelectorModalComponent } from './quest-selector-modal.component'; | ||
import { BaseSelectorBtnComponent } from '../base-selector/base-selector-btn.component'; | ||
|
||
@Component({ | ||
selector: 'keira-quest-selector-btn', | ||
templateUrl: '../base-selector/base-selector-btn.component.html', | ||
styleUrls: ['../base-selector/base-selector-btn.component.scss'] | ||
}) | ||
export class QuestSelectorBtnComponent extends BaseSelectorBtnComponent { | ||
|
||
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690 | ||
constructor( | ||
modalService: BsModalService, | ||
) { | ||
super( | ||
QuestSelectorModalComponent, | ||
modalService, | ||
); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/app/shared/modules/selectors/quest-selector/quest-selector-modal.component.html
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,57 @@ | ||
<div class="modal-body"> | ||
|
||
<p class="lead text-center mb-1">Quest selector</p> | ||
|
||
<form [formGroup]="searchService.queryForm"> | ||
<div class="row"> | ||
<ng-container [formGroup]="searchService.fields"> | ||
<div class="form-group col-3"> | ||
<input [formControlName]="'ID'" type="number" class="form-control form-control-sm" id="ID" placeholder="ID"> | ||
</div> | ||
<div class="form-group col-5"> | ||
<input [formControlName]="'LogTitle'" class="form-control form-control-sm" id="LogTitle" placeholder="Name"> | ||
</div> | ||
</ng-container> | ||
<div class="form-group col-2"> | ||
<input [formControlName]="'limit'" class="form-control form-control-sm" id="limit" placeholder="Unlimited"> | ||
</div> | ||
<div class="col-2"> | ||
<button | ||
id="search-btn" | ||
class="btn btn-primary btn-sm" | ||
[disabled]="searchService.queryForm.invalid" | ||
(click)="searchService.onSearch()" | ||
>Search</button> | ||
</div> | ||
</div> | ||
<code [highlight]="searchService.query"></code> | ||
</form> | ||
|
||
<div *ngIf="searchService.rows"> | ||
|
||
<ngx-datatable | ||
class="bootstrap table table-striped text-center datatable-select highlight-select" | ||
[rows]="searchService.rows" | ||
[headerHeight]="DTCFG.headerHeight" | ||
[footerHeight]="DTCFG.footerHeight" | ||
[columnMode]="DTCFG.columnMode" | ||
[rowHeight]="DTCFG.rowHeight" | ||
[limit]="DTCFG.limit" | ||
[selectionType]="DTCFG.selectionType" | ||
(select)='onSelect($event)' | ||
> | ||
<ngx-datatable-column name="ID" prop="ID" [minWidth]="100"> | ||
<ng-template let-row="row" ngx-datatable-cell-template> | ||
{{ row.ID }} | ||
</ng-template> | ||
</ngx-datatable-column> | ||
<ngx-datatable-column name="Quest Title" prop="LogTitle"></ngx-datatable-column> | ||
</ngx-datatable> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-danger" id="modal-cancel-btn" (click)="onCancel()">Cancel</button> | ||
<button type="button" class="btn btn-success" id="modal-select-btn" (click)="onSave()">Select</button> | ||
</div> |
Empty file.
39 changes: 39 additions & 0 deletions
39
src/app/shared/modules/selectors/quest-selector/quest-selector-modal.component.spec.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,39 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { BsModalRef } from 'ngx-bootstrap'; | ||
import { instance } from 'ts-mockito'; | ||
|
||
import { QuestSelectorModalComponent } from './quest-selector-modal.component'; | ||
import { MysqlQueryService } from '../../../services/mysql-query.service'; | ||
import { MockedMysqlQueryService } from '@keira-testing/mocks'; | ||
import { QuestSearchService } from '../../search/quest-search.service'; | ||
import { QuestSelectorModule } from './quest-selector.module'; | ||
|
||
describe('QuestSelectorModalComponent', () => { | ||
let component: QuestSelectorModalComponent; | ||
let fixture: ComponentFixture<QuestSelectorModalComponent>; | ||
let searchService: QuestSearchService; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ QuestSelectorModule ], | ||
providers: [ | ||
BsModalRef, | ||
{ provide: MysqlQueryService, useValue: instance(MockedMysqlQueryService) }, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
searchService = TestBed.inject(QuestSearchService); | ||
searchService.query = '--mock query'; | ||
|
||
fixture = TestBed.createComponent(QuestSelectorModalComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/app/shared/modules/selectors/quest-selector/quest-selector-modal.component.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,22 @@ | ||
import { Component, } from '@angular/core'; | ||
import { BsModalRef } from 'ngx-bootstrap'; | ||
|
||
import { QuestSearchService } from '../../search/quest-search.service'; | ||
import { QUEST_TEMPLATE_ID } from '@keira-types/quest-template.type'; | ||
import { SearchSelectorModalComponent } from '../base-selector/search-selector-modal.component'; | ||
|
||
@Component({ | ||
selector: 'keira-quest-selector-modal', | ||
templateUrl: './quest-selector-modal.component.html', | ||
styleUrls: ['./quest-selector-modal.component.scss'] | ||
}) | ||
export class QuestSelectorModalComponent extends SearchSelectorModalComponent { | ||
|
||
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690 | ||
constructor( | ||
protected bsModalRef: BsModalRef, | ||
public searchService: QuestSearchService, | ||
) { | ||
super(QUEST_TEMPLATE_ID, bsModalRef); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/app/shared/modules/selectors/quest-selector/quest-selector.module.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,31 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { ReactiveFormsModule } from '@angular/forms'; | ||
|
||
import { QuestSelectorModalComponent } from './quest-selector-modal.component'; | ||
import { QuestSelectorBtnComponent } from './quest-selector-btn.component'; | ||
import { highlightOptions } from '@keira-config/highlight.config'; | ||
import { HighlightModule } from 'ngx-highlightjs'; | ||
import { NgxDatatableModule } from '@swimlane/ngx-datatable'; | ||
import { ModalModule } from 'ngx-bootstrap'; | ||
|
||
@NgModule({ | ||
entryComponents: [ | ||
QuestSelectorModalComponent, | ||
], | ||
declarations: [ | ||
QuestSelectorBtnComponent, | ||
QuestSelectorModalComponent, | ||
], | ||
imports: [ | ||
BrowserModule, | ||
ReactiveFormsModule, | ||
NgxDatatableModule, | ||
ModalModule.forRoot(), | ||
HighlightModule.forRoot(highlightOptions), | ||
], | ||
exports: [ | ||
QuestSelectorBtnComponent, | ||
], | ||
}) | ||
export class QuestSelectorModule {} |