Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Create Brick Block #426 #432

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,34 @@
"tags": []
},
"features-convs-mgr-stories-blocks-library-block-options": "libs/features/convs-mgr/stories/blocks/library/block-options",
"features-convs-mgr-stories-blocks-library-brick-block": {
"projectType": "library",
"root": "libs/features/convs-mgr/stories/blocks/library/brick-block",
"sourceRoot": "libs/features/convs-mgr/stories/blocks/library/brick-block/src",
"prefix": "app",
"targets": {
"test": {
"executor": "@nrwl/jest:jest",
"outputs": [
"coverage/libs/features/convs-mgr/stories/blocks/library/brick-block"
],
"options": {
"jestConfig": "libs/features/convs-mgr/stories/blocks/library/brick-block/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"options": {
"lintFilePatterns": [
"libs/features/convs-mgr/stories/blocks/library/brick-block/**/*.ts",
"libs/features/convs-mgr/stories/blocks/library/brick-block/**/*.html"
]
}
}
},
"tags": []
},
"features-convs-mgr-stories-blocks-library-document-message-block": "libs/features/convs-mgr/stories/blocks/library/document-message-block",
"features-convs-mgr-stories-blocks-library-email-message-block": "libs/features/convs-mgr/stories/blocks/library/email-message-block",
"features-convs-mgr-stories-blocks-library-fail-block": {
Expand Down
1 change: 1 addition & 0 deletions apps/conv-learning-manager/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"FAILBLOCK": "Fail Block",
"JUMP":"Jump",
"EVENT": "Event",
"BRICK":"Brick",
"END-BLOCK":"End Block"
},
"PLACEHOLDER": {
Expand Down
3 changes: 2 additions & 1 deletion apps/conv-learning-manager/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"LOCATION-INPUT":"saisie de position",
"KEYWORD-JUMP": "saut de mots-clés",
"EVENT": "Événement",
"JUMP":"saut"
"JUMP":"saut",
"BRICK":"Brique"
},
"PLACEHOLDER": {
"CAPTION": "Légende",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": ["../../../../../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "app",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "app",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# features-convs-mgr-stories-blocks-library-brick-block

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test features-convs-mgr-stories-blocks-library-brick-block` to execute the unit tests.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* eslint-disable */
export default {
displayName: 'features-convs-mgr-stories-blocks-library-brick-block',
preset: '../../../../../../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
stringifyContentPathRegex: '\\.(html|svg)$',
},
},
coverageDirectory:
'../../../../../../../coverage/libs/features/convs-mgr/stories/blocks/library/brick-block',
transform: {
'^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/convs-mgr-brick-block.module';
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<div [id]="id" *ngIf="brickForm">
<form [formGroup]="brickForm" fxLayout="column" fxLayoutALign="start center">
<textarea [id]="id" formControlName="brick" type="text" rows="3"></textarea>
<button
type="button"
mat-raised-button
style="
background-color: #ffab2d;
color: #fff;
width: max-content;
padding: 8px;
margin: 0.5rem auto 0.25rem auto;
"
>
Edit
</button>
<!-- <app-default-option-field
[jsPlumb]="jsPlumb"
[blockFormGroup]="brickForm"
></app-default-option-field> -->
</form>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { BrickBlockComponent } from './brick-block.component';

describe('BrickBlockComponent', () => {
let component: BrickBlockComponent;
let fixture: ComponentFixture<BrickBlockComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [BrickBlockComponent],
}).compileComponents();

fixture = TestBed.createComponent(BrickBlockComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { StoryBlockTypes } from '@app/model/convs-mgr/stories/blocks/main';
import { BrickBlock } from '@app/model/convs-mgr/stories/blocks/messaging';
import { BrowserJsPlumbInstance } from '@jsplumb/browser-ui';

@Component({
selector: 'app-brick-block',
templateUrl: './brick-block.component.html',
styleUrls: ['./brick-block.component.scss'],
})
export class BrickBlockComponent implements OnInit {
@Input() id: string;
@Input() block: BrickBlock;
@Input() brickForm: FormGroup;
@Input() jsPlumb: BrowserJsPlumbInstance;

@Input() blockFormGroup: FormGroup;

messageInputId: string;
type: StoryBlockTypes;
messagetype = StoryBlockTypes.BrickBlock;

ngOnInit(): void {
this.messageInputId = `brick-${this.id}`;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import {
FlexLayoutModule,
MaterialBricksModule,
MaterialDesignModule,
} from '@iote/bricks-angular';
import { ConvsMgrBlockOptionsModule } from '@app/features/convs-mgr/stories/blocks/library/block-options';
import { BrickBlockComponent } from './components/brick-block/brick-block.component';
@NgModule({
imports: [
CommonModule,
MaterialDesignModule,
FlexLayoutModule,
MaterialBricksModule,

FormsModule,
ReactiveFormsModule,

ConvsMgrBlockOptionsModule,
],
declarations: [BrickBlockComponent],
exports: [BrickBlockComponent],
})
export class ConvsMgrBrickBlockModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"extends": "../../../../../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"target": "es2020",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../../../../dist/out-tsc",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": []
},
"exclude": [
"src/test-setup.ts",
"**/*.spec.ts",
"jest.config.ts",
"**/*.test.ts"
],
"include": ["**/*.ts"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["jest.config.ts", "**/*.test.ts", "**/*.spec.ts", "**/*.d.ts"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { ConvsMgrMultipleInputMessageBlockModule } from '@app/features/convs-mgr
import { ConvsMgrImageInputBlockModule } from '@app/features/convs-mgr/stories/blocks/library/image-input-block';
import { ConvsMgrLocationInputBlockModule } from '@app/features/convs-mgr/stories/blocks/library/location-input-block';
import { ConvsMgrStoriesWebhookBlockModule } from '@app/features/convs-mgr/stories/blocks/library/webhook-block';
import { ConvsMgrBrickBlockModule } from '@app/features/convs-mgr/stories/blocks/library/brick-block';

import { ConvsMgrAnchorBlockModule } from '@app/features/convs-mgr/stories/blocks/library/anchor-block';
import { ConvsMgrOpenEndedQuestionBlockModule } from '@app/features/convs-mgr/stories/blocks/library/open-ended-question-block';
Expand All @@ -40,7 +41,6 @@ import { ConvsMgrMultiContentInputBlockModule } from '@app/features/convs-mgr/st
import { ConvsMgrVideoInputBlockModule } from '@app/features/convs-mgr/stories/blocks/library/video-input-block';
import { ConvsMgrKeywordJumpBlockModule } from '@app/features/convs-mgr/stories/blocks/library/keyword-jump-block';
import { ConvsMgrEventBlockModule } from '@app/features/convs-mgr/stories/blocks/library/event-block';

import { FileStateModule, UploadFileService } from '@app/state/file';

import { BlockInjectorService } from './providers/block-injector.service';
Expand Down Expand Up @@ -80,6 +80,7 @@ import { BlockComponent } from './components/block/block.component';
ConvsMgrAudioInputBlockModule,
ConvsMgrStoriesWebhookBlockModule,
ConvsMgrMultiContentInputBlockModule,
ConvsMgrBrickBlockModule,

ConvsMgrAnchorBlockModule,
ConvsMgrVideoInputBlockModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ <h4 class="block-title"> {{ blockTitle | transloco }}</h4>
<app-webhook-block [id]="id" [block]="block" [webhookForm]="blockFormGroup" [jsPlumb]="jsPlumb" class="block">
</app-webhook-block>
</div>
<div *ngSwitchCase="brickType">
<app-brick-block [id]="id" [block]="block" [brickForm]="blockFormGroup" [jsPlumb]="jsPlumb" class="block">
</app-brick-block>
</div>
<div *ngSwitchCase="openQuestiontype">
<app-open-ended-question-block [id]="id" [block]="block" [openEndedQuestionForm]="blockFormGroup" [jsPlumb]="jsPlumb" class="block">
</app-open-ended-question-block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { _CreateDocumentMessageBlockForm } from '../../model/document-block-form
import { _CreateReplyBlockForm } from '../../model/reply-block-form.model';
import { _CreateMultipleInputMessageBlockForm } from '../../model/multiple-input-message-block-form.model';
import { _CreateImageInputBlockForm } from '../../model/image-input-block-form.model';

import { _CreateBrickBlockForm } from '../../model/brick-block-form.model';
import { iconsAndTitles } from '../../model/icons-and-titles';
import { _CreateJumpBlockForm } from '../../model/jump-block-form.model';
import { _CreateFailBlockForm } from '../../model/fail-block-form.model';
Expand Down Expand Up @@ -79,6 +79,7 @@ export class BlockComponent implements OnInit {
audioInputType = StoryBlockTypes.AudioInput;
videoInputType = StoryBlockTypes.VideoInput;
webhookType = StoryBlockTypes.WebhookBlock;
brickType = StoryBlockTypes.BrickBlock;
endStoryAnchor = StoryBlockTypes.EndStoryAnchorBlock;
openQuestiontype = StoryBlockTypes.OpenEndedQuestion;
multiContentInputType = StoryBlockTypes.MultiContentInput;
Expand Down Expand Up @@ -206,6 +207,10 @@ export class BlockComponent implements OnInit {
this.blockFormGroup = _CreateWebhookBlockForm(this._fb, this.block);
this.blocksGroup.push(this.blockFormGroup);
break;
case StoryBlockTypes.BrickBlock:
this.blockFormGroup = _CreateBrickBlockForm(this._fb, this.block);
this.blocksGroup.push(this.blockFormGroup);
break;
case StoryBlockTypes.EndStoryAnchorBlock:
this.blockFormGroup = _CreateEndStoryAnchorBlockForm(this._fb, this.block);
this.blocksGroup.push(this.blockFormGroup);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { FormGroup, FormBuilder } from '@angular/forms';

import { StoryBlockTypes } from '@app/model/convs-mgr/stories/blocks/main';
import { BrickBlock } from '@app/model/convs-mgr/stories/blocks/messaging';

/**
*
* @param _fb instance of formbuilder that creates formgroups controls etc
* @param blockData the data being patched into the FormGroup
* @returns builds the formgroup with data if available and returns the Formgroup
*/
export function _CreateBrickBlockForm(
_fb: FormBuilder,
blockData: BrickBlock
): FormGroup {
return _fb.group({
id: [blockData?.id! ?? ''],
defaultTarget: [blockData.defaultTarget ?? ''],
message: [blockData?.message! ?? ''],
type: [blockData.type ?? StoryBlockTypes.BrickBlock],
position: [blockData.position ?? { x: 200, y: 50 }],
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export const iconsAndTitles: any = {
title: 'PAGE-CONTENT.BLOCK.TITLES.WEBHOOK',
icon: 'fas fa-link',
},
26: {
title: 'PAGE-CONTENT.BLOCK.TITLES.BRICK',
icon: 'fas fa-cubes'
},
27: {
title: 'PAGE-CONTENT.BLOCK.TITLES.OPEN-ENDED-QUESTION',
icon: 'fas fa-question-circle',
Expand Down
Loading