Skip to content

Commit

Permalink
feat(render): make single pass parameter works
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed May 8, 2020
1 parent 9660a5b commit a2f86b6
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<span>{{item.name}}</span>
<span>{{item.displayName}} : {{item.chartValue}}</span>
<mat-slider
min="1" max="5" step="1"
*ngIf="isParent"
[(ngModel)]="item.chartValue"
(change)="updateValue($event)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { MatSliderChange } from '@angular/material/slider';
import { RatingModel } from '../model/rating.model';
import { RatingItemModel } from '../model/rating.model';

@Component({
selector: 'component-rating-item',
Expand All @@ -23,8 +23,7 @@ import { RatingModel } from '../model/rating.model';
],
})
export class ComponentRatingItemComponent implements OnInit {
@Input() item: RatingModel;
@Input() isParent: boolean;
@Input() item: RatingItemModel;
@Output() itemChange = new EventEmitter();

disabled = false;
Expand All @@ -34,7 +33,13 @@ export class ComponentRatingItemComponent implements OnInit {
onTouched(_) {}

ngOnInit() {

const nameValuesSplit = this.item.name.split(': ');
this.item.displayName = nameValuesSplit[0];
if (nameValuesSplit.length > 1) {
this.item.chartValue = parseInt(nameValuesSplit[1], 10);
} else {
this.item.chartValue = 3;
}
}

registerOnChange(fn: any): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<ul id="markdown-rating">
<li *ngFor="let task of data">
<component-rating-item
[isParent]="isParent"
[item]="task"
(itemChange)="changeForm($event, task)">
</component-rating-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ export class ComponentRatingComponent implements OnInit, ControlValueAccessor {
}

changeForm($event: any, item: any) {

console.log($event, item);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="ledge-maturity">
<div class="left">
<ledge-radar [data]="data" [config]="config"></ledge-radar>
<div class="left" *ngIf="chartData">
<ledge-radar [data]="chartData" [config]="config"></ledge-radar>
</div>

<div class="right" *ngIf="data">
<component-rating [data]="data[0].children"></component-rating>
<component-rating [data]="ratingData"></component-rating>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { LedgeListItem } from '../model/ledge-chart.model';
import { RatingItemModel, RatingListModel } from '../model/rating.model';

@Component({
selector: 'ledge-maturity',
Expand All @@ -9,6 +10,8 @@ import { LedgeListItem } from '../model/ledge-chart.model';
export class LedgeMaturityComponent implements OnInit, OnChanges {
@Input()
data: LedgeListItem[];
chartData: LedgeListItem[];
ratingData: RatingListModel;

@Input()
config: any;
Expand All @@ -19,10 +22,10 @@ export class LedgeMaturityComponent implements OnInit, OnChanges {
}

ngOnChanges(changes: SimpleChanges): void {
this.renderData();
}

private renderData() {

if (changes.data) {
this.data = changes.data.currentValue;
this.chartData = this.data;
this.ratingData = this.data[0].children as any;
}
}
}
10 changes: 8 additions & 2 deletions projects/ledge-render/src/lib/components/model/rating.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
export interface RatingModel {
id: string;
export interface RatingItemModel {
id?: string;
name: string;
displayName?: string;
chartValue?: number;
}

export interface RatingListModel {
name?: string;
children?: RatingItemModel;
}
6 changes: 3 additions & 3 deletions src/assets/docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

```maturity
- 业务
- 业务远景
- 业务远景: 3
- 电梯演讲
- 商业画布
- 业务需求
- 业务需求: 1
- 需求列表
- 需求管理
- 业务是如何进行变更的?
- 跨功能需求
- 跨功能需求: 2
- 运行质量
- 演进质量
```
Expand Down

0 comments on commit a2f86b6

Please sign in to comment.