arkit
Version:
Visualises JavaScript, TypeScript and Flow codebases as meaningful and committable architecture diagrams
50 lines (37 loc) • 820 B
JavaScript
import { Component, EventEmitter, Output, Input } from '@angular/core';
import template from './todo-item.template.html';
export class TodoItemComponent {
todo;
itemModified = new EventEmitter();
itemRemoved = new EventEmitter();
editing = false;
cancelEditing() {
this.editing = false;
}
stopEditing(editedTitle) {
this.todo.setTitle(editedTitle.value);
this.editing = false;
if (this.todo.title.length === 0) {
this.remove();
} else {
this.update();
}
}
edit() {
this.editing = true;
}
toggleCompletion() {
this.todo.completed = !this.todo.completed;
this.update();
}
remove() {
this.itemRemoved.next(this.todo.uid);
}
update() {
this.itemModified.next(this.todo.uid);
}
}