Passed
Pull Request — master (#23)
by
unknown
09:10 queued 04:58
created

src/app/fragments/select-sprite/select-sprite.component.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 60
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 1
mnd 0
bc 0
fnc 1
bpm 0
cpm 1
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A SelectSpriteComponent.spriteListTrackBy 0 3 1
1
import { Sprite } from './../../../assets/data/sprites.d';
2
import { GameDataService } from './../../data/gameData.service';
3
import { ValueAccessorBase } from './../abstract/ValueAccessorBase';
4
/**
5
   Copyright 2018 June Hanabi
6
7
   Licensed under the Apache License, Version 2.0 (the "License");
8
   you may not use this file except in compliance with the License.
9
   You may obtain a copy of the License at
10
11
       http://www.apache.org/licenses/LICENSE-2.0
12
13
   Unless required by applicable law or agreed to in writing, software
14
   distributed under the License is distributed on an "AS IS" BASIS,
15
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
   See the License for the specific language governing permissions and
17
   limitations under the License.
18
 */
19
20
import { Component, Input } from '@angular/core';
21
22
//@ts-ignore
23
const _ = window.require("lodash");
24
25
import {
26
    NG_VALUE_ACCESSOR,
27
} from '@angular/forms';
28
29
@Component({
30
    selector: 'select-sprite',
31
    templateUrl: './select-sprite.component.pug',
32
    styleUrls: ['./select-sprite.component.scss'],
33
    providers: [
34
        { provide: NG_VALUE_ACCESSOR, useExisting: SelectSpriteComponent, multi: true }
35
    ],
36
})
37
export class SelectSpriteComponent extends ValueAccessorBase<string> {
38
39
    constructor(
40
        public gd: GameDataService
41
    ) {
42
        super();
43
    }
44
45
    @Input()
46
    public disabled: boolean = false;
47
48
    @Input()
49
    public label: string = "Sprite";
50
51
    get spriteList() {
52
        const sprites: Sprite[] = _.sortBy(this.gd.file("sprites").data, ["ind"]);
53
        return sprites;
54
    }
55
56
    spriteListTrackBy(index: number) {
57
        return index;
58
    }
59
}
60