<commit_before>import { Component, EventEmitter, Input, Output, Renderer } from '@angular/core';
import { TodoItem } from './shared/todoItem';

@Component({
    selector: 'todo-list',
    template: `
        <li *ngIf="item" class={{item.state}}>
            <div class="view">
                <input
                    (click)="stateToggle($event)" 
                    class="toggle" 
                    type="checkbox"
                    [checked]="setCheckedState()"
                >
                <label>{{item.name}}</label>
                <button 
                    (click)="destroyItem()"
                    class="destroy"
                >
                </button>
            </div>
            <input class="edit" value="Create a TodoMVC template">
        </li>
    `,
})

export class TodoListComponent {
    @Input() item: TodoItem;
    @Input() allItems: TodoItem[];

    @Input() activeCount: number;
    @Output() onCountChange = new EventEmitter<number>();

    stateToggle(event: any): void {
        if (this.item.state === 'active') {
            this.item.state = 'completed';
            this.activeCount--;
        } else {
            this.item.state = 'active';
            this.activeCount++;
        }

        this.onCountChange.emit(this.activeCount);
    }

    destroyItem(): void {
        this.allItems.splice(this.allItems.indexOf(this.item), 1);
        if (this.item.state === 'active') {
            this.activeCount--;
            this.onCountChange.emit(this.activeCount);
        }
    }

    setCheckedState(): boolean {
        if (this.item.state === 'completed') return true;
        else if (this.item.state === 'active') return false;
    }
}
<commit_msg>can now edit item values<commit_after>import { Component, EventEmitter, Input, Output, Renderer } from '@angular/core';
import { TodoItem } from './shared/todoItem';

@Component({
    selector: 'todo-list',
    template: `
        <li *ngIf="item" class={{item.state}}>
            <div class="view">
                <input
                    (click)="stateToggle($event)" 
                    class="toggle" 
                    type="checkbox"
                    [checked]="setCheckedState()"
                >
                <label *ngIf="!isEdit"
                    (click)="isEdit=true"
                >
                    {{item.name}}
                </label>
                <input *ngIf="isEdit"
                    #editItemInput 
                    (keydown.enter)="editItem(editItemInput.value)"
                    class="new-todo"
                    placeholder="Edit This Item"
                >
                <button 
                    (click)="destroyItem()"
                    class="destroy"
                >
                </button>
            </div>
            <input class="edit" value="Create a TodoMVC template">
        </li>
    `,
})

export class TodoListComponent {
    @Input() item: TodoItem;
    @Input() allItems: TodoItem[];

    @Input() activeCount: number;
    @Output() onCountChange = new EventEmitter<number>();

    isEdit = false;

    stateToggle(event: any): void {
        if (this.item.state === 'active') {
            this.item.state = 'completed';
            this.activeCount--;
        } else {
            this.item.state = 'active';
            this.activeCount++;
        }

        this.onCountChange.emit(this.activeCount);
    }

    destroyItem(): void {
        this.allItems.splice(this.allItems.indexOf(this.item), 1);
        if (this.item.state === 'active') {
            this.activeCount--;
            this.onCountChange.emit(this.activeCount);
        }
    }

    setCheckedState(): boolean {
        if (this.item.state === 'completed') return true;
        else if (this.item.state === 'active') return false;
    }

    editItem(newItemName: any) {
        console.log(newItemName);
        this.item.name = newItemName;
        this.isEdit = false;
    }
}

{'fraction_non_alphanumeric': 0.1393939393939394, 'fraction_numerical': 0.000505050505050505, 'mean_word_length': 1.580456026058632, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7294428', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1071, 'n_words': 207}