From e338537dbf58b8eb9e1a7ca02b1d96ae1aad5fff Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Thu, 25 Feb 2021 19:52:46 -0300 Subject: [PATCH 1/7] Correcting dev environment configuration problem Co-authored-by: @AmandaMuniz --- app/src/utils/url_routes.js | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/utils/url_routes.js b/app/src/utils/url_routes.js index 03a9634..362e71e 100644 --- a/app/src/utils/url_routes.js +++ b/app/src/utils/url_routes.js @@ -1,4 +1,4 @@ -export const BASE = process.env.REACT_APP_URL_API + 'api/v1/'; +export const BASE = 'http://localhost:8000/api/v1/'; export const ITEMS_BASE = BASE + 'projects/1/'; export const UTTER_URL = ITEMS_BASE + "utters/"; diff --git a/docker-compose.yml b/docker-compose.yml index f323075..bf71d1e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: ports: - 3000:3000 environment: - REACT_APP_URL_API: http://localhost:8000/ # API + REACT_APP_URL_API: http://localhost:8000/ #API stdin_open: true volumes: - ./app:/botflow/ From 2e4ab956f0d3dc9e9b06d1cbf1481ae8ac873d92 Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Tue, 2 Mar 2021 01:14:49 -0300 Subject: [PATCH 2/7] Not saving empty contents and ignoring them on validation --- app/src/components/ToolbarName.js | 12 +++++++++++- app/src/pages/IntentPage.js | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/src/components/ToolbarName.js b/app/src/components/ToolbarName.js index 3ccb835..0506d84 100644 --- a/app/src/components/ToolbarName.js +++ b/app/src/components/ToolbarName.js @@ -69,7 +69,17 @@ export default class ToolbarName extends Component { } handleClick() { - this.props.saveData(this.props.item); + let realContent = []; + let newIntent = this.props.item; + + this.props.item.samples.forEach(content => { + if (content.trim().length !== 0) { + realContent.push(content); + } + }); + newIntent.samples = realContent; + //console.log("Formatado:", newIntent); + this.props.saveData(newIntent); } handleDelete() { diff --git a/app/src/pages/IntentPage.js b/app/src/pages/IntentPage.js index 28517f0..12e61c7 100644 --- a/app/src/pages/IntentPage.js +++ b/app/src/pages/IntentPage.js @@ -46,15 +46,25 @@ class IntentPage extends Component { } checkEmptyFieldsIntent(samples) { - let changed = true; + let status = true; + let emptyField = false; + let fullfilledIntents = 0; if (samples !== undefined) { samples.forEach(sample => { - if (sample.trim().length === 0) { - changed = false; + if (sample.trim().length === 0) { + emptyField = true; + } else { + fullfilledIntents++; } }); + + if (fullfilledIntents === 0 && emptyField) { + status = false; + } else { + status = true; + } } - return changed; + return status; } isButtonEnabled() { From 8fb36d0fb19cff810477f80e9953384dfd26b697 Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Tue, 2 Mar 2021 01:22:44 -0300 Subject: [PATCH 3/7] Not showing empty intent balloongs anymore --- app/src/ducks/intents.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/ducks/intents.js b/app/src/ducks/intents.js index 1eb3ed0..0a3a29a 100644 --- a/app/src/ducks/intents.js +++ b/app/src/ducks/intents.js @@ -59,6 +59,7 @@ export const undoDeleteIntentContent = (state = INITIAL_STATE) => { export const selectIntent = (state = INITIAL_STATE, action) => { let selected_item = action.item; let selected_item_position = action.item_position; + let nonEmptySamples=[]; if (selected_item_position < 0) { state.intents.find((item, index) => { @@ -67,6 +68,14 @@ export const selectIntent = (state = INITIAL_STATE, action) => { }); } + selected_item.samples.forEach(sample => { + if (sample.trim().length !== 0) { + nonEmptySamples.push(sample); + } + }); + + selected_item.samples=nonEmptySamples; + return { ...state, id: selected_item.id, From b1955cb32cbe623bc13c17da8d59c66af038faa5 Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Tue, 2 Mar 2021 02:25:22 -0300 Subject: [PATCH 4/7] Removing empty balloons from utter upon loading --- app/src/components/ToolbarName.js | 18 +++++++++++------- app/src/ducks/utters.js | 10 ++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/components/ToolbarName.js b/app/src/components/ToolbarName.js index 0506d84..bed148a 100644 --- a/app/src/components/ToolbarName.js +++ b/app/src/components/ToolbarName.js @@ -72,14 +72,18 @@ export default class ToolbarName extends Component { let realContent = []; let newIntent = this.props.item; - this.props.item.samples.forEach(content => { - if (content.trim().length !== 0) { - realContent.push(content); - } - }); - newIntent.samples = realContent; + if (this.props.item.samples !== undefined) { + this.props.item.samples.forEach(content => { + if (content.trim().length !== 0) { + realContent.push(content); + } + }); + newIntent.samples = realContent; + this.props.saveData(newIntent); + } else { + this.props.saveData(this.props.item); + } //console.log("Formatado:", newIntent); - this.props.saveData(newIntent); } handleDelete() { diff --git a/app/src/ducks/utters.js b/app/src/ducks/utters.js index 1799a34..d339a78 100644 --- a/app/src/ducks/utters.js +++ b/app/src/ducks/utters.js @@ -82,6 +82,16 @@ export const selectUtter = (state = INITIAL_STATE, action) => { }); } + + for (let i=0; i< selected_item.alternatives[0].length; i++) { + if (selected_item.alternatives[0][i].trim().length === 0){ + selected_item.alternatives[0].splice(i, 1); + console.log("ACERTOU!: ", selected_item.alternatives[0]); + }; + } + + + return { ...state, helper_text: "", From 10c65d0d3bd0b91f1d82e8009d2d84f1dbc4856f Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Tue, 2 Mar 2021 11:18:54 -0300 Subject: [PATCH 5/7] Disabling delete button on single question --- app/src/components/IntentForm.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/components/IntentForm.js b/app/src/components/IntentForm.js index 0affcfd..8ebbb4a 100644 --- a/app/src/components/IntentForm.js +++ b/app/src/components/IntentForm.js @@ -34,6 +34,14 @@ class IntentForm extends Component { this.handleSnackbarClick = this.handleSnackbarClick.bind(this) } + checkFields() { + if(this.props.content.length<=1) { + return true; + } else { + return false; + } + } + handleDelete(intent_index) { if (this.props.content.length > 1) { this.props.deleteIntentContent(intent_index); @@ -79,7 +87,7 @@ class IntentForm extends Component { /> - this.handleDelete(sample_index)}> + this.handleDelete(sample_index)}> From 92f6dcd0bdbd2eb7833d8d3698010fa2592180a3 Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Tue, 2 Mar 2021 11:46:30 -0300 Subject: [PATCH 6/7] Disabling delete button on single utter ballon --- app/src/components/UtterForm.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/components/UtterForm.js b/app/src/components/UtterForm.js index 0d0c842..4928355 100644 --- a/app/src/components/UtterForm.js +++ b/app/src/components/UtterForm.js @@ -31,6 +31,15 @@ class UtterForm extends Component { this.props.setUtterContent(e.target.value, utter_index, text_index) } + checkFields() { + if(this.props.content.length<=1) { + return true; + } else { + return false; + } + } + + handleDelete(utter_index, text_index) { const utters_length = this.props.content.length; const utters_text_length = this.props.content[0].length; @@ -88,6 +97,7 @@ class UtterForm extends Component { this.handleDelete(alternative_index, content_index)}> From 5f5b9f1328224a454c2121f6342e3d6a8a3023bf Mon Sep 17 00:00:00 2001 From: Miguel-Alves Date: Tue, 2 Mar 2021 12:14:38 -0300 Subject: [PATCH 7/7] Making validation applies to both ballons options --- app/src/components/UtterForm.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/components/UtterForm.js b/app/src/components/UtterForm.js index 4928355..98dde98 100644 --- a/app/src/components/UtterForm.js +++ b/app/src/components/UtterForm.js @@ -32,10 +32,11 @@ class UtterForm extends Component { } checkFields() { - if(this.props.content.length<=1) { - return true; - } else { + console.log("teste:", this.props.content); + if(this.props.content.length >1|| this.props.content[0].length > 1) { return false; + } else { + return true; } }