Skip to content

Commit c2adcd5

Browse files
authored
Checkbox to Button for Expand with AI (#54)
1 parent 9cd6428 commit c2adcd5

7 files changed

+203
-195
lines changed

.changeset/chubby-candies-clean.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"specif-ai": patch
3+
---
4+
5+
Checkbox to Button for Enhance with AI for Root Requirements, User Stories and Tasks

ui/src/app/pages/edit-solution/edit-solution.component.html

+9-10
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ <h1 class="font-semibold">
6767

6868
<div class="flex items-center justify-between mt-4">
6969
<div class="flex-col">
70-
<div class="flex items-center mb-4">
71-
<input
72-
type="checkbox"
73-
id="expandAI"
74-
formControlName="expandAI"
75-
class="w-4 h-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500 cursor-pointer"
76-
/>
77-
<label for="expandAI" class="ml-2 block text-sm text-gray-900"
78-
>Expand with AI</label
79-
>
70+
<div class="flex items-center">
71+
<app-button
72+
buttonContent="Enhance with AI"
73+
icon="heroSparklesSolid"
74+
theme="secondary"
75+
size="sm"
76+
rounded="lg"
77+
(click)="updateRequirementWithAI()"
78+
></app-button>
8079
</div>
8180
<app-multi-upload
8281
*ngIf="mode === 'add'"

ui/src/app/pages/edit-solution/edit-solution.component.ts

+82-84
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { TextareaFieldComponent } from '../../components/core/textarea-field/tex
3232
import { ButtonComponent } from '../../components/core/button/button.component';
3333
import { AiChatComponent } from '../../components/ai-chat/ai-chat.component';
3434
import { MultiUploadComponent } from '../../components/multi-upload/multi-upload.component';
35-
import { NgIconComponent } from '@ng-icons/core';
35+
import { NgIconComponent, provideIcons } from '@ng-icons/core';
3636
import { ErrorMessageComponent } from '../../components/core/error-message/error-message.component';
3737
import { ConfirmationDialogComponent } from '../../components/confirmation-dialog/confirmation-dialog.component';
3838
import {
@@ -44,6 +44,7 @@ import {
4444
import { ToasterService } from 'src/app/services/toaster/toaster.service';
4545
import { catchError, switchMap, take } from 'rxjs';
4646
import { RequirementTypeEnum } from 'src/app/model/enum/requirement-type.enum';
47+
import { heroSparklesSolid } from '@ng-icons/heroicons/solid';
4748

4849
@Component({
4950
selector: 'app-edit-solution',
@@ -64,6 +65,11 @@ import { RequirementTypeEnum } from 'src/app/model/enum/requirement-type.enum';
6465
ErrorMessageComponent,
6566
MatTooltipModule,
6667
],
68+
providers: [
69+
provideIcons({
70+
heroSparklesSolid
71+
})
72+
]
6773
})
6874
export class EditSolutionComponent {
6975
projectId: string = '';
@@ -133,92 +139,84 @@ export class EditSolutionComponent {
133139
this.createRequirementForm();
134140
}
135141

136-
updateRequirement() {
137-
if (this.requirementForm.getRawValue().expandAI) {
138-
const body: IUpdateRequirementRequest = {
139-
updatedReqt: this.requirementForm.getRawValue().title,
140-
addReqtType: this.folderName,
141-
fileContent: this.uploadedFileContent,
142-
contentType: this.uploadedFileContent ? 'fileContent' : 'userContent',
143-
id: this.initialData.id,
144-
reqId: this.fileName.replace(/\-base.json$/, ''),
145-
reqDesc: this.requirementForm.getRawValue().content,
146-
name: this.initialData.name,
147-
description: this.initialData.description,
148-
useGenAI: true,
149-
};
150-
this.featureService.updateRequirement(body).subscribe(
151-
(data) => {
152-
data.updated.requirement = data.updated.requirement.replace(
153-
PRD_HEADINGS.SCREENS,
154-
PRD_HEADINGS.SCREENS_FORMATTED,
155-
).replace(
156-
PRD_HEADINGS.PERSONAS,
157-
PRD_HEADINGS.PERSONAS_FORMATTED,
158-
);
159-
this.store.dispatch(
160-
new UpdateFile(this.absoluteFilePath, {
161-
requirement: data.updated.requirement,
162-
title: data.updated.title,
163-
chatHistory: this.chatHistory,
164-
epicTicketId: this.initialData.epicTicketId,
165-
}),
166-
);
167-
this.allowFreeRedirection = true;
168-
this.store.dispatch(new ReadFile(`${this.folderName}/${this.fileName}`));
169-
this.selectedFileContent$.subscribe((res: any) => {
170-
this.oldContent = res.requirement;
171-
this.requirementForm.patchValue({
172-
title: res.title,
173-
content: res.requirement,
174-
epicticketid: res.epicTicketId,
175-
});
176-
this.chatHistory = res.chatHistory || [];
142+
updateRequirementWithAI() {
143+
const body: IUpdateRequirementRequest = {
144+
updatedReqt: this.requirementForm.getRawValue().title,
145+
addReqtType: this.folderName,
146+
fileContent: this.uploadedFileContent,
147+
contentType: this.uploadedFileContent ? 'fileContent' : 'userContent',
148+
id: this.initialData.id,
149+
reqId: this.fileName.replace(/\-base.json$/, ''),
150+
reqDesc: this.requirementForm.getRawValue().content,
151+
name: this.initialData.name,
152+
description: this.initialData.description,
153+
useGenAI: true,
154+
};
155+
this.featureService.updateRequirement(body).subscribe(
156+
(data) => {
157+
data.updated.requirement = data.updated.requirement
158+
.replace(PRD_HEADINGS.SCREENS, PRD_HEADINGS.SCREENS_FORMATTED)
159+
.replace(PRD_HEADINGS.PERSONAS, PRD_HEADINGS.PERSONAS_FORMATTED);
160+
this.store.dispatch(
161+
new UpdateFile(this.absoluteFilePath, {
162+
requirement: data.updated.requirement,
163+
title: data.updated.title,
164+
chatHistory: this.chatHistory,
165+
epicTicketId: this.initialData.epicTicketId,
166+
}),
167+
);
168+
this.allowFreeRedirection = true;
169+
this.store.dispatch(
170+
new ReadFile(`${this.folderName}/${this.fileName}`),
171+
);
172+
this.selectedFileContent$.subscribe((res: any) => {
173+
this.oldContent = res.requirement;
174+
this.requirementForm.patchValue({
175+
title: res.title,
176+
content: res.requirement,
177+
epicticketid: res.epicTicketId,
177178
});
178-
this.toastService.showSuccess(
179-
TOASTER_MESSAGES.ENTITY.UPDATE.SUCCESS(
180-
body.addReqtType,
181-
data.reqId,
182-
),
183-
);
184-
},
185-
(error) => {
186-
console.error('Error updating requirement:', error); // Handle any errors
187-
this.toastService.showError(
188-
TOASTER_MESSAGES.ENTITY.UPDATE.FAILURE(
189-
this.folderName,
190-
body.reqId,
191-
),
192-
);
193-
},
194-
);
195-
} else {
196-
this.store.dispatch(
197-
new UpdateFile(this.absoluteFilePath, {
198-
requirement: this.requirementForm.getRawValue().content,
199-
title: this.requirementForm.getRawValue().title,
200-
chatHistory: this.chatHistory,
201-
epicTicketId: this.initialData.epicTicketId,
202-
}),
203-
);
204-
this.allowFreeRedirection = true;
205-
this.store.dispatch(new ReadFile(`${this.folderName}/${this.fileName}`));
206-
this.selectedFileContent$.subscribe((res: any) => {
207-
this.oldContent = res.requirement;
208-
this.requirementForm.patchValue({
209-
title: res.title,
210-
content: res.requirement,
211-
epicticketid: res.epicTicketId,
179+
this.chatHistory = res.chatHistory || [];
212180
});
213-
this.chatHistory = res.chatHistory || [];
181+
this.toastService.showSuccess(
182+
TOASTER_MESSAGES.ENTITY.UPDATE.SUCCESS(body.addReqtType, data.reqId),
183+
);
184+
},
185+
(error) => {
186+
console.error('Error updating requirement:', error); // Handle any errors
187+
this.toastService.showError(
188+
TOASTER_MESSAGES.ENTITY.UPDATE.FAILURE(this.folderName, body.reqId),
189+
);
190+
},
191+
);
192+
}
193+
194+
updateRequirement() {
195+
this.store.dispatch(
196+
new UpdateFile(this.absoluteFilePath, {
197+
requirement: this.requirementForm.getRawValue().content,
198+
title: this.requirementForm.getRawValue().title,
199+
chatHistory: this.chatHistory,
200+
epicTicketId: this.initialData.epicTicketId,
201+
}),
202+
);
203+
this.allowFreeRedirection = true;
204+
this.store.dispatch(new ReadFile(`${this.folderName}/${this.fileName}`));
205+
this.selectedFileContent$.subscribe((res: any) => {
206+
this.oldContent = res.requirement;
207+
this.requirementForm.patchValue({
208+
title: res.title,
209+
content: res.requirement,
210+
epicticketid: res.epicTicketId,
214211
});
215-
this.toastService.showSuccess(
216-
TOASTER_MESSAGES.ENTITY.UPDATE.SUCCESS(
217-
this.folderName,
218-
this.fileName.replace(/\-base.json$/, ''),
219-
),
220-
);
221-
}
212+
this.chatHistory = res.chatHistory || [];
213+
});
214+
this.toastService.showSuccess(
215+
TOASTER_MESSAGES.ENTITY.UPDATE.SUCCESS(
216+
this.folderName,
217+
this.fileName.replace(/\-base.json$/, ''),
218+
),
219+
);
222220
}
223221

224222
navigateBackToDocumentList(data: any) {

ui/src/app/pages/edit-user-stories/edit-user-stories.component.html

+9-10
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,15 @@ <h1 class="text-normal font-semibold mb-4">
8181
</div>
8282
<div class="flex items-center justify-between mt-4">
8383
<div class="flex-col">
84-
<div class="flex items-center mb-4">
85-
<input
86-
type="checkbox"
87-
id="expandAI"
88-
formControlName="expandAI"
89-
class="w-4 h-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500"
90-
/>
91-
<label for="expandAI" class="ml-2 block text-sm text-gray-900"
92-
>Expand story with AI</label
93-
>
84+
<div class="flex items-center">
85+
<app-button
86+
buttonContent="Enhance with AI"
87+
icon="heroSparklesSolid"
88+
theme="secondary"
89+
size="sm"
90+
rounded="lg"
91+
(click)="updateUserStoryWithAI()"
92+
></app-button>
9493
</div>
9594

9695
<app-multi-upload

0 commit comments

Comments
 (0)