Skip to content

Instantly share code, notes, and snippets.

Christian Lüdemann lydemann

Block or report user

Report or block lydemann

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View RenderingTranslationService.ts
@Injectable() export class RenderingTranslationService {
constructor() {}
private renderingTranslationRules: RenderingTranslationRule[] = [RenderingTranslationRule.freetextRenderingRule, RenderingTranslationRule.radioRenderingRule, RenderingTranslationRule.checkboxRenderingRule, RenderingTranslationRule.comboboxRenderingRule];
getRenderingForQuestion(question: Question): Rendering {
let renderingToReturn;
for (const renderingTranslationRule of this.renderingTranslationRules) {
if (renderingTranslationRule.booleanExp(question)) {
renderingToReturn = renderingTranslationRule.rendering;
break;
}
View ValidationRule.ts
export class ValidationRule {
private static _validationRulesMap: Map < string, ValidationRule > ;
public static get validationRulesMap() {
if (!ValidationRule._validationRulesMap) {
ValidationRule._validationRulesMap = new Map < string, ValidationRule > ();
}
return ValidationRule._validationRulesMap;
}
public static required = new ValidationRule('REQUIRED', Validators.required);
private constructor(private name: string, public validationFn: (control: AbstractControl) => ValidationErrors | null) {
View QuestionFormGeneratorService.ts
export class QuestionFormGeneratorService {
constructor() {}
getQuestionsFormGroup(quesitons: Question[]): FormGroup {
const group: {
[key: string]: AbstractControl
} = {};
quesitons.forEach(question => {
const validatiors = this.getValidationFunctions(question.validationRules);
group[question.externalQuestionId] = question.answerType.toUpperCase() === selectMulti ? new FormGroup(this.getAnswerOptionsControlsObj(question.answerOptions), validatiors) : new FormControl(question.answer || '', validatiors);
@lydemann
lydemann / shared-ui-elements.module.ts
Created Oct 20, 2019
shared-ui-elements.module.ts
View shared-ui-elements.module.ts
const IMPORTS = [
SpinnerModule,
SpinnerOverlayWrapperModule,
CheckboxModule,
IconModule,
ButtonsModule,
AccordionModule,
TextareaModule,
ToggleModule,
TooltipModule,
@lydemann
lydemann / shared-ui-elements.module.ts
Created Oct 20, 2019
shared-ui-elements.module.ts
View shared-ui-elements.module.ts
const IMPORTS = [
SpinnerModule,
SpinnerOverlayWrapperModule,
CheckboxModule,
IconModule,
ButtonsModule,
AccordionModule,
TextareaModule,
ToggleModule,
TooltipModule,
View todo-list.service.spec
import { TestBed } from '@angular/core/testing';
import { Store } from '@ngrx/store';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { first } from 'rxjs/operators';
import { TodoListService } from '@app/core/todo-list/todo-list.service';
import { TODOItem } from '@app/shared/models/todo-item';
import { TodoListState } from './redux-api/todo-list.model';
describe('Service: TodoList', () => {
View .lintstagedrc
{
"*.{ts,json,md,scss,html}": [
"prettier --write",
"git add"
],
"*.ts": [
"tslint --fix",
"git add"
],
"*.scss": [
View commitlint.config.js
module.exports = {
extends: ["@commitlint/config-conventional"]
};
View angular.json
{
"glob": "**/*",
"input": "src/assets",
"output": "assets"
}
View app.module.ts
LoadableModule.forRoot({ fileMappings: lazyLoadingConfig }),
You can’t perform that action at this time.