Skip to content

Commit

Permalink
feat: add default pipe line
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 11, 2020
1 parent 33091fe commit 3d2e1f1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { PatternComponent } from './presentation/pattern/pattern.component';
import { DesignComponent } from './presentation/design/design.component';
import { PractiseComponent } from './presentation/practise/practise.component';
import { ManualComponent } from './presentation/manual/manual.component';
import { MarkdownModule } from 'ngx-markdown';
import { PathComponent } from './features/path/path.component';
import {FormsModule} from '@angular/forms';

@NgModule({
declarations: [
Expand All @@ -48,6 +48,7 @@ import { PathComponent } from './features/path/path.component';
AppRoutingModule,
HttpClientModule,
BrowserAnimationsModule,
FormsModule,
CustomMaterialModule,
],
providers: [Title],
Expand Down
12 changes: 10 additions & 2 deletions src/app/features/path/path.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ <h2>Path to Production</h2>
<div class="page">
<div class="path">
<div id="pipe-header">
<div class="pipe-header" *ngFor="let pipe of pipeData;let i = index" id="{{i}}_header" [ngStyle]="getHeaderHeight()">
<div class="pipe-header" *ngFor="let pipe of pipeData;let i = index" id="{{i}}_header"
[ngStyle]="getHeaderHeight()">
<h2>{{pipe.title}}</h2>
</div>
</div>
Expand All @@ -27,7 +28,14 @@ <h2>{{pipe.title}}</h2>
id="{{i}}_pipe"
[ngStyle]="getContainerStyle(pipe)">

<div class="editable" [ngStyle]="getEditableStyle()" *ngFor="let item of pipe.items;let j = index" id="{{i}}_pipe_child{{j}}">
<div
class="editable"
contenteditable="true"
[ngStyle]="getEditableStyle()"
(change)="changeItem()"
[ngModel]="pipeData[i][j]"
ngDefaultControl
*ngFor="let item of pipe.items;let j = index" id="{{i}}_pipe_child{{j}}">
{{item}}
</div>
</div>
Expand Down
32 changes: 31 additions & 1 deletion src/app/features/path/path.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,32 @@ export class PathComponent implements OnInit {

ngOnInit(): void {
this.maxLength = this.getMaxLength(this.pipeData);
this.storage.get('ledge.path').subscribe((value: Item[]) => {
if (!!value) {
this.pipeData = value;
this.fillDefaultValue();
}
});

this.fillDefaultValue();
}

private fillDefaultValue() {
this.pipeData = this.fillArrayWithEmpty(this.pipeData);
}

fillArrayWithEmpty(items: Item[]) {
// tslint:disable-next-line:prefer-for-of
for (let i = 0; i < items.length; i++) {
const itemLength = items[i].items.length;
for (let j = 0; j <= this.maxLength; j++) {
if (j > itemLength) {
items[i].items[j - 1] = '';
}
}
}

return items;
}

addColumn() {
Expand Down Expand Up @@ -116,7 +142,6 @@ export class PathComponent implements OnInit {
};
}


getHeaderHeight() {
return {
height: this.getContainerHeightWidth().itemWidth + 20 + 12 + 'px'
Expand All @@ -135,4 +160,9 @@ export class PathComponent implements OnInit {

return maxLength;
}

changeItem() {
this.storage.set('ledge.path', this.pipeData).subscribe(() => {
});
}
}

0 comments on commit 3d2e1f1

Please sign in to comment.