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

axelor.$eval compatible with fields(containing dot characters), often used in conditional expressions #107

Open
cabbage89 opened this issue Nov 16, 2021 · 1 comment

Comments

@cabbage89
Copy link

https://github.com/axelor/axelor-open-platform/blob/dev/axelor-web/src/main/webapp/js/axelor.app.js#L184

When there are dotted fields in the context object, AngularJS cannot use the $eval expression

axelor.$eval(this.scope, "user.name=='tom'", {"user.name":"tom"});

fix

Object.keys(context).filter(x=>x.includes('.')).forEach(a=>a.split('.').reduce((x,y,i,arr)=>x[y]=(i==arr.length-1?context[a]:(x[y]||{})),context));
{"user.name":"tom"}

Convert the above context object into

{"user":{"name":"tom"}}
@cabbage89 cabbage89 changed the title axelor.$eval compatible with dotted objects, often used in conditional expressions axelor.$eval compatible with fields(containing dot characters), often used in conditional expressions Nov 16, 2021
@cabbage89
Copy link
Author

https://github.com/axelor/axelor-open-platform/blob/dev/axelor-web/src/main/webapp/js/form/form.relational.single.js#L176

_.each(relativeFields, function (field) {
        try{
          record[field] = eval(`value.${field}`);
        }catch (e){}
      });
      Object.keys(record).filter(x=>x.includes('.')).forEach(a=>a.split('.').reduce((x,y,i,arr)=>x[y]=(i==arr.length-1?record[a]:(x[y]||{})),record));
      

axeloradmin pushed a commit that referenced this issue Sep 14, 2023
Consider json field as field in form widget processing.

Fixes #107
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