Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Lüdemann lydemann

View GitHub Profile
@lydemann
lydemann / todo-list-sandbox.service.ts
Created Jun 20, 2020
todo-list-sandbox.service.ts
View todo-list-sandbox.service.ts
public todoListChanged(affectedIds: string[]) {
this.store.dispatch(
TodoListActions.todoListChanged({
affectedIds,
}),
);
}
@lydemann
lydemann / todo-list-sandbox.service.ts
Created Jun 20, 2020
todo-list-sandbox.service.ts
View todo-list-sandbox.service.ts
public todoListChanged(affectedIds: string[]) {
this.store.dispatch(
TodoListActions.todoListChanged({
affectedIds: []
}),
);
}
@lydemann
lydemann / todo-list-sandbox.service.ts
Created Jun 20, 2020
todo-list-sandbox.service.ts
View todo-list-sandbox.service.ts
TodoListActions.todoFormSubmited({
todoItem: {
...todoItem,
},
}),
@lydemann
lydemann / todo-list-sandbox.service.ts
Created Jun 20, 2020
todo-list-sandbox.service.ts
View todo-list-sandbox.service.ts
public loadTodoList() {
this.store.dispatch(TodoListActions.getTodoListRequest());
}
View todo-list.component.html
<app-crud-item
*ngFor="let todo of todos"
[todoItem]="todo"
data-test="todo-item"
(todoDelete)="deleteTodo($event)"
(todoEdit)="selectTodoForEdit($event)"
(todoCompleteToggled)="todoCompleteToggled($event)"
></app-crud-item>
View todo.po.ts
public static checkForTodos() {
cy.get('[data-test=todo-item]').should('have.length', 5);
}
View todo.spec.ts
import { TodoPage } from '../support/todo.po';
describe('TodoList', () => {
beforeEach(() => {
cy.setupAppGlobalRoutes();
TodoPage.goToPage();
});
it('should should show todo items', () => {
TodoPage.checkForTodos();
View todo.po.ts
export class TodoPage {
public static goToPage() {
cy.visit('/');
}
public static createTodoItem() {
cy.get('[data-test=todo-title]').type('Some name');
cy.get('[data-test=todo-description]').type('Some description');
cy.get('[data-test=todo-duedate]').type('2019-10-10');
View element-component.ts
import { HostListener, ɵmarkDirty as markDirty } from '@angular/core';
export abstract class ElementComponent {
@HostListener('click', ['$event'])
@HostListener('change', ['$event'])
public runCD() {
markDirty(this);
}
}
View cd-input.directive.ts
import {
Directive,
HostListener,
OnChanges,
SimpleChanges,
ɵmarkDirty as markDirty,
} from '@angular/core';
@Directive({ selector: '[appCDTrigger]' })
export class CDInputDirective implements OnChanges {
You can’t perform that action at this time.