Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#145 ignore empty questions inserting editing intents #161

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/src/components/ToolbarName.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,21 @@ export default class ToolbarName extends Component {
}

handleClick() {
this.props.saveData(this.props.item);
let realContent = [];
let newIntent = this.props.item;

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);
}

handleDelete() {
Expand Down
9 changes: 9 additions & 0 deletions app/src/ducks/intents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions app/src/ducks/utters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down
18 changes: 14 additions & 4 deletions app/src/pages/IntentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/url_routes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const BASE = process.env.REACT_APP_URL_API + 'api/v1/';
export const BASE = 'http://localhost:8000/api/v1/';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change it back to the env variable, with it we can set the API endpoint on production environments

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gabibguedes are you using the dev environment or the docker?
Until the docker problem is solved, using the docker is not possible cause it doesnt reflect changes we made to the code.
Also, as the docker doesnt work properly, we need this variable set this way as described on #157

export const ITEMS_BASE = BASE + 'projects/1/';

export const UTTER_URL = ITEMS_BASE + "utters/";
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down