Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aboudard's full-sized avatar
🎯
Focusing

Alain Boudard aboudard

🎯
Focusing
View GitHub Profile
import { EntityMetadataMap } from '@ngrx/data';
/**
* Compare function for Entities sort
* @param {string} a
* @param {string} b
* @returns {number}
*/
export function sortByTitle(
a: { title: string },
import { PropsFilterFnFactory, EntityMetadataMap } from '@ngrx/data';
/**
* Filter for entities whose name matches the case-insensitive pattern
* The filter works on ALL properties
* @param {T[]} entities
* @param {string} pattern
* @return {any[]}
*/
export function textFilter<T extends { title: string; description: string }>(
@aboudard
aboudard / todo.selectors.ts
Created November 30, 2021 15:08
NgRx Custom selector for Todo entity
import { EntitySelectorsFactory } from "@ngrx/data";
import { createSelector } from "@ngrx/store";
import { Todo } from "../dto/todo";
export const todoSelectors = new EntitySelectorsFactory().create<Todo>('Todo');
export const selectTodoByCategory = (category: string) => createSelector(
todoSelectors.selectEntities,
(data) => data.filter(c => c.category === category)
);
@aboudard
aboudard / entity-metadata.ts
Created November 30, 2021 13:59
NgRx Data filter function
import { EntityMetadataMap } from '@ngrx/data';
export function activeFilter(entities: { active: boolean }[], search: boolean) {
return entities.filter(e => e.active === search);
}
const entityMetadata: EntityMetadataMap = {
Todo: {
filterFn: activeFilter
}
language: node_js
node_js:
- "10"
dist: trusty
sudo: required
addons:
chrome: stable
sonarcloud:
organization: "aboudard"
branches:
@aboudard
aboudard / app.component.ts
Last active June 26, 2018 12:53 — forked from nrobinaubertin/app.component.ts
Exemple of ngb-date-parser-formatter implementation (ng-bootstrap)
import { NgbDatepickerConfig, NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
import { NgbDateFRParserFormatter } from "./ngb-date-fr-parser-formatter"
@Component({
providers: [{provide: NgbDateParserFormatter, useClass: NgbDateFRParserFormatter}]
})
export class AppComponent {}
@aboudard
aboudard / dabblet.css
Created January 21, 2014 08:54
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
p { color: red; }
@aboudard
aboudard / dabblet.css
Created May 16, 2013 11:46
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(90deg, #ccc, yellow);
min-height: 100%;
a { color: white; font-weight: bold;
padding: 10px; background: red;
text-decoration: none;
transition-property: background;
transition-duration: 1000ms;}
a:hover { background: blue; }