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

Edit Response results in empty array (that leads to cf-conditional to fail) #421

Open
heri16 opened this issue Dec 3, 2020 · 0 comments

Comments

@heri16
Copy link

heri16 commented Dec 3, 2020

On the first flow, the cf-conditonal works normally because tagValue is [''] (array with emtpy string).

However, if the user edit a response, the cf-condition fails to work and always return false because tagValue is now [] (emtpy array).

We are testing for emtpy string with a RegExp cf-conditional for a tag that might be skipped/hidden due to a previous tag.

/**
* @name editTag
* go back in time and edit a tag.
*/
public editTag(tag: ITag): void {
this.ignoreExistingTags = false;
this.savedStep = this.step - 1;//save step
this.step = this.tags.indexOf(tag); // === this.currentTag
this.validateStepAndUpdate();
if(this.activeConditions && Object.keys(this.activeConditions).length > 0){
this.savedStep = -1;//don't save step, as we wont return
// clear chatlist.
this.cfReference.chatList.clearFrom(this.step + 1);
//reset from active tag, brute force
const editTagIndex: number = this.tags.indexOf(tag);
for(var i = editTagIndex + 1; i < this.tags.length; i++){
const tag: ITag | ITagGroup = this.tags[i];
tag.reset();
}
}
}

for (var i = 0; i < condition.conditionals.length; i++) {
var conditional: string | RegExp = condition.conditionals[i];
if(typeof tagValue !== "string"){
for (var j = 0; j < tagValue.length; j++) {
isValid = testValue(<string>tagValue[j], conditional);
if(isValid) break;
}
}else{
// string comparisson
isValid = testValue((<string[]>tagValue).toString(), conditional);
}
if(isValid) break;
}

@heri16 heri16 changed the title Edit Response casues empty array (that leads to cf-conditional to fail) Edit Response results in empty array (that leads to cf-conditional to fail) Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant