Skip to content

Commit 6cbc571

Browse files
committed
fixes #956 story builder: story creation regression - not allowed to update the story
Signed-off-by: Julien Buret <jburet@voyages-sncf.com>
1 parent 9ec93d6 commit 6cbc571

6 files changed

+28
-30
lines changed

bot/admin/web/src/app/bot/story/story-dialog.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class StoryDialogComponent implements OnInit {
112112
this.dialogRef.close({
113113
name: this.name.trim(),
114114
label: !this.label || this.label.trim().length === 0 ? this.name.trim() : this.label.trim(),
115-
tag: this.tag.trim(),
115+
tag: this.tag ? this.tag.trim() : null,
116116
intent: this.intent.trim(),
117117
description: !this.description || this.description.trim().length === 0 ? "" : this.description.trim(),
118118
category: !this.category || this.category.trim().length === 0 ? "default" : this.category.trim(),

bot/admin/web/src/app/bot/story/story-tag.component.css

+3
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@
1717
.story-tag {
1818
margin-top: 15px;
1919
}
20+
.story-select {
21+
min-width: 300px;
22+
}

bot/admin/web/src/app/bot/story/story-tag.component.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
<div class="story-tag">
1818
<mat-form-field>
1919
<mat-label>Tag :</mat-label>
20-
<mat-select [(ngModel)]="selectedTag" (ngModelChange)="selectedTagChange.emit($event)" name="storyTag" disableRipple>
20+
<mat-select [(ngModel)]="selectedTag" (ngModelChange)="selectedTagChange.emit($event)" name="storyTag" disableRipple panelClass="story-select">
21+
<mat-option value="">None</mat-option>
2122
<mat-option *ngFor="let tag of tags" [value]="tag.value">
2223
{{tag.viewValue}}
2324
</mat-option>

bot/admin/web/src/app/bot/story/story-tag.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export class StoryTagComponent {
3535
selectedTagChange: EventEmitter<String> = new EventEmitter<String>();
3636

3737
tags: Tag[] = [
38-
{value: 'ENABLE', viewValue: 'Enable'},
39-
{value: 'DISABLE', viewValue: 'Disable'}
38+
{value: 'ENABLE', viewValue: 'Enable Tag (triggers a bot activation)'},
39+
{value: 'DISABLE', viewValue: 'Disable Tag (triggers a bot deactivation)'}
4040
];
4141

4242
}

bot/admin/web/src/app/bot/story/story.component.html

+17-23
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,26 @@
6161
<div class="content">
6262

6363
<!-- Settings card -->
64-
<mat-card class="answer-card">
65-
<mat-card-header>
66-
<mat-card-title>Settings</mat-card-title>
67-
<mat-card-subtitle>
68-
<span class="intent" matTooltip="Main Intent">{{story.intent.name}}</span>
69-
<span class="category" matTooltip="Story category">&nbsp;[{{story.category}}]</span>
70-
</mat-card-subtitle>
71-
</mat-card-header>
72-
73-
<mat-card-content class="answer-card-content">
74-
<!-- Story description -->
75-
<div *ngif="story.description">
76-
Description : {{story.description}}
77-
</div>
78-
79-
<!-- Story node -->
80-
<ul *ngIf="storyNode">
81-
<li *ngIf="storyNode.intent">Intent: <b>{{storyNode.intent}}</b></li>
82-
<li *ngIf="storyNode.step">Step: <b>{{storyNode.step}}</b></li>
83-
<li *ngIf="storyNode.entities.length !==0">Entities: <b>{{storyNode.entities}}</b></li>
84-
</ul>
64+
<mat-expansion-panel class="answer-card">
65+
<mat-expansion-panel-header>
66+
<mat-panel-title><span class="intent" matTooltip="Main Intent">{{story.intent.name}}</span><span class="category" matTooltip="Story category">&nbsp;[{{story.category}}]</span></mat-panel-title>
67+
<mat-panel-description>
68+
<!-- Story description -->
69+
<span *ngIf="story.description">
70+
{{story.description}}
71+
</span>
8572

73+
<!-- Story node -->
74+
<ul *ngIf="storyNode">
75+
<li *ngIf="storyNode.intent">Intent: <b>{{storyNode.intent}}</b></li>
76+
<li *ngIf="storyNode.step">Step: <b>{{storyNode.step}}</b></li>
77+
<li *ngIf="storyNode.entities.length !==0">Entities: <b>{{storyNode.entities}}</b></li>
78+
</ul>
79+
</mat-panel-description>
80+
</mat-expansion-panel-header>
8681
<!-- Story tag -->
8782
<tock-story-tag class="story-tag" [(selectedTag)]="storyTag"></tock-story-tag>
88-
</mat-card-content>
89-
</mat-card>
83+
</mat-expansion-panel>
9084

9185
<div *ngIf="!story.hideDetails && !story.isBuiltIn()">
9286
<!-- Mandatory entities -->

bot/admin/web/src/app/bot/story/story.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
StoryStep
2525
} from "../model/story";
2626
import {BotService} from "../bot-service";
27-
import { MatDialog } from "@angular/material/dialog";
27+
import {MatDialog} from "@angular/material/dialog";
2828
import {StateService} from "../../core-nlp/state.service";
2929
import {ConfirmDialogComponent} from "../../shared-nlp/confirm-dialog/confirm-dialog.component";
3030
import {StoryDialogComponent} from "./story-dialog.component";
@@ -160,7 +160,7 @@ export class StoryComponent implements OnInit, OnChanges {
160160
if (result && result.name) {
161161
this.story.storyId = result.name;
162162
this.story.name = result.label;
163-
this.story.tags = [result.tag];
163+
this.storyTag = result.tag;
164164
this.story.intent.name = result.intent;
165165
this.story.category = result.category;
166166
this.story.description = result.description;
@@ -173,7 +173,7 @@ export class StoryComponent implements OnInit, OnChanges {
173173

174174
private saveStory(selectStoryAfterSave: boolean) {
175175
this.story.steps = StoryStep.filterNew(this.story.steps);
176-
this.story.tags = [this.storyTag];
176+
this.story.tags = !this.storyTag || this.storyTag.length === 0 ? [] : [this.storyTag];
177177
if (this.story._id) {
178178
this.bot.saveStory(this.story).subscribe(s => {
179179
this.story.selected = selectStoryAfterSave;

0 commit comments

Comments
 (0)