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
Showing
11 changed files
with
92 additions
and
33 deletions.
There are no files selected for viewing
23 changes: 6 additions & 17 deletions
23
src/app/components/editors/conditions/select-conditions/select-conditions.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 |
---|---|---|
@@ -1,34 +1,23 @@ | ||
import { Component, } from '@angular/core'; | ||
|
||
import { DTCFG } from '../../../../config/datatable.config'; | ||
import { ConditionsSearchService } from '../../../../services/search/conditions-search.service'; | ||
import { CONDITION_SOURCE_TYPES, CONDITION_SOURCE_TYPES_KEYS } from '../../../../types/conditions.type'; | ||
import { WIKI_BASE_URL } from '../../../../constants/general'; | ||
import { CONDITION_SOURCE_TYPES, CONDITION_SOURCE_TYPES_KEYS, Conditions } from '../../../../types/conditions.type'; | ||
import { ConditionsHandlerService } from '../../../../services/handlers/conditions-handler.service'; | ||
import { SelectComplexKeyComponent } from '../../shared/select-complex-key.component'; | ||
|
||
@Component({ | ||
selector: 'app-select-creature', | ||
templateUrl: './select-conditions.component.html', | ||
styleUrls: ['./select-conditions.component.scss'] | ||
}) | ||
export class SelectConditionsComponent { | ||
public readonly DTCFG = DTCFG; | ||
public readonly WIKI_BASE_URL = WIKI_BASE_URL; | ||
export class SelectConditionsComponent extends SelectComplexKeyComponent<Conditions> { | ||
public readonly CONDITION_SOURCE_TYPES = CONDITION_SOURCE_TYPES; | ||
public readonly CONDITION_SOURCE_TYPES_KEYS = CONDITION_SOURCE_TYPES_KEYS; | ||
|
||
constructor( | ||
public selectService: ConditionsSearchService, | ||
private handlerService: ConditionsHandlerService, | ||
) {} | ||
|
||
onSelect(event) { | ||
this.handlerService.select(false, event.selected[0]); | ||
console.log(this.handlerService.selected); | ||
} | ||
|
||
onCreateNew() { | ||
this.handlerService.select(true, this.selectService.fields.getRawValue()); | ||
console.log(this.handlerService.selected); | ||
protected handlerService: ConditionsHandlerService, | ||
) { | ||
super(selectService, handlerService); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/app/components/editors/shared/select-complex-key.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 { SearchService } from '../../../services/search/search.service'; | ||
import { ComplexKeyHandlerService } from '../../../services/handlers/complex-key.handler.service'; | ||
import { TableRow } from '../../../types/general'; | ||
import { DTCFG } from '../../../config/datatable.config'; | ||
import { WIKI_BASE_URL } from '../../../constants/general'; | ||
|
||
export class SelectComplexKeyComponent<T extends TableRow> { | ||
public readonly DTCFG = DTCFG; | ||
public readonly WIKI_BASE_URL = WIKI_BASE_URL; | ||
|
||
constructor( | ||
public selectService: SearchService<T>, | ||
protected handlerService: ComplexKeyHandlerService<T>, | ||
) {} | ||
|
||
onSelect(event) { | ||
this.handlerService.select(false, event.selected[0]); | ||
} | ||
|
||
onCreateNew() { | ||
this.handlerService.select(true, this.selectService.fields.getRawValue()); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Router } from '@angular/router'; | ||
|
||
import { HandlerService } from './handler.service'; | ||
import { getPartial } from '../../utils/helpers'; | ||
import { TableRow } from '../../types/general'; | ||
|
||
export abstract class ComplexKeyHandlerService<T extends TableRow> extends HandlerService<T> { | ||
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690 | ||
constructor( | ||
protected mainEditorRoutePath: string, | ||
protected router: Router, | ||
protected idFields: string[], | ||
) { | ||
super( | ||
mainEditorRoutePath, | ||
router, | ||
); | ||
} | ||
|
||
select(isNew: boolean, id: Partial<T>) { | ||
super.select(isNew, this.getIdObject(id)); | ||
} | ||
|
||
private getIdObject(input: Partial<T> | T): Partial<T> { | ||
return getPartial<T>(input, this.idFields); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Router } from '@angular/router'; | ||
|
||
import { ComplexKeyHandlerService } from './complex-key.handler.service'; | ||
import { SAI_ID_FIELDS, SmartScripts } from '../../types/smart-scripts.type'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SaiHandlerService extends ComplexKeyHandlerService<SmartScripts> { | ||
/* istanbul ignore next */ // because of: https://github.com/gotwarlost/istanbul/issues/690 | ||
constructor( | ||
protected router: Router, | ||
) { | ||
super( | ||
'smart-ai/editor', | ||
router, | ||
SAI_ID_FIELDS, | ||
); | ||
} | ||
} |
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