Skip to content

Commit

Permalink
Feat: add checkbox to accept conditions on create bot ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentlaine committed Jan 14, 2021
1 parent 397e140 commit 9b9ac20
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion back/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabrique-chatbot-back",
"version": "1.1.9",
"version": "1.1.10",
"description": "",
"author": "",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion back/src/chatbot/chatbot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class ChatbotService {
}

async create(chatbot: ChatbotModel, file?: FileModel, icon?: FileModel): Promise<ChatbotModel> {
let chatbotSaved: Chatbot = await this._chatbotsRepository.save(chatbot);
const chatbotSaved: Chatbot = await this._chatbotsRepository.save(chatbot);
if (!file || !icon) {
return chatbotSaved;
}
Expand Down
4 changes: 4 additions & 0 deletions back/src/core/dto/create-chatbot.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class CreateChatbotDto {
@MaxLength(50)
domainName: string;

@IsString()
@IsNotEmpty()
acceptConditions: boolean = false;

@IsString()
@IsNotEmpty()
@MaxLength(200)
Expand Down
3 changes: 3 additions & 0 deletions back/src/core/entities/chatbot.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export class Chatbot {
@Column( { default: false })
intra_def: boolean;

@Column( { default: false })
accept_conditions: boolean;

@Column('enum', { name: 'status', enum: ChatbotStatus, default: ChatbotStatus.pending, nullable: false})
status: ChatbotStatus;

Expand Down
4 changes: 4 additions & 0 deletions back/src/core/models/chatbot.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class ChatbotModel {
@IsNotEmpty()
intra_def: boolean = false;

@IsString()
@IsNotEmpty()
accept_conditions: boolean = false;

@IsString()
@IsOptional()
status: ChatbotStatus;
Expand Down
2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabrique-chatbot-front",
"version": "1.1.9",
"version": "1.1.10",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
1 change: 1 addition & 0 deletions front/src/app/core/models/chatbot-configuration.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export class ChatbotConfiguration {
primaryColor: string;
secondaryColor: string;
domainName: string;
acceptConditions: boolean;
}
1 change: 1 addition & 0 deletions front/src/app/core/services/chatbot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class ChatbotService {
formData.append('audience', botConfig.audience);
formData.append('domainName', botConfig.domainName);
formData.append('intraDef', botConfig.intraDef.toString());
formData.append('acceptConditions', botConfig.acceptConditions.toString());
formData.append('users', JSON.stringify(botConfig.users));

const headers = new HttpHeaders();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export class CreateBotFormComponent implements OnInit {
primaryColor: ['#6e91f0', [Validators.required, Validators.maxLength(20)]],
secondaryColor: ['#eef2fd', [Validators.required, Validators.maxLength(20)]],
}),
this._fb.group({
acceptConditions: [false, Validators.requiredTrue],
}),
])
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ <h4>Personnalisation</h4>
<div [ngStyle]="{'background-color': formArray.at(2).value.secondaryColor}"></div>
</div>
</div>

<div class="info-block">
<mat-checkbox [formControl]="conditionControl" data-cy="ConditionCheckbox">
Je m'engage à mettre à disposition du projet une personne afin de garantir la mise à jour du chatbot.
</mat-checkbox>
</div>
</div>

<div class="success-tab" *ngIf="chatbotGenerated">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class ResumeStepComponent implements OnInit {
return <FormControl> (<FormGroup> this.formArray.at(2)).controls.icon;
}

get conditionControl(): FormControl {
return <FormControl> (<FormGroup> this.formArray.at(3)).controls.acceptConditions;
}

ngOnInit(): void {
this.iconControl.valueChanges.subscribe(() => {
this._generateIconPreview();
Expand Down

0 comments on commit 9b9ac20

Please sign in to comment.