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

Insert the Bypass Option in each Calc #1616

Merged
merged 1 commit into from
Jun 13, 2024
Merged
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
5 changes: 4 additions & 1 deletion src/mixins/extensions/ComputedFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ export default {
computedFields(screen, definition, logsEnabled = true) {
// For each computed field defined
definition.computed.forEach((computed) => {
if (computed.byPass) {
// If the computed field has bypass set to true, skip it
return;
}
const formula = JSON.stringify(computed.formula);
const type = JSON.stringify(computed.type);
const name = JSON.stringify(computed.property);
const safeDotName = this.safeDotName(computed.property);
const code = `

const evaluatedExpression = this.evaluateExpression(${formula}, ${type});
// Handle errors if any
if (evaluatedExpression.error) {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/fixtures/byPassFalse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type":"screen_package","version":"2","screens":[{"id":3,"uuid":"9c24bc51-6040-498e-aa3e-9ce061fd1e84","screen_category_id":"1","title":"test","description":"test","type":"FORM","config":[{"name":"test","items":[{"label":"Line Input","config":{"icon":"far fa-square","name":"test","type":"text","label":"New Input","helper":null,"readonly":false,"dataFormat":"string","validation":[],"placeholder":null,"defaultValue":{"mode":"basic","value":"{{calcName}}"}},"component":"FormInput","inspector":[{"type":"FormInput","field":"name","config":{"name":"Variable Name","label":"Variable Name","helper":"A variable name is a symbolic name to reference information.","validation":"regex:\/^([a-zA-Z]([a-zA-Z0-9_]?)+\\.?)+(?<!\\.)$\/|required|not_in:null,break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with,class,const,enum,export,extends,import,super,true,false"}},{"type":"FormInput","field":"label","config":{"label":"Label","helper":"The label describes the field's name"}},{"type":"FormMultiselect","field":"dataFormat","config":{"name":"Data Type","label":"Data Type","helper":"The data type specifies what kind of data is stored in the variable.","options":[{"value":"string","content":"Text"},{"value":"int","content":"Integer"},{"value":"currency","content":"Currency"},{"value":"percentage","content":"Percentage"},{"value":"float","content":"Decimal"},{"value":"datetime","content":"Datetime"},{"value":"date","content":"Date"},{"value":"password","content":"Password"}],"validation":"required"}},{"type":{"extends":{"props":["label","error","options","helper","name","value","selectedControl"],"mixins":[{"name":"ValidationMixin","props":{"config":{"type":null},"validation":{"type":null},"validationData":{"type":null},"validationField":{"type":null},"validationMessages":{"type":null}},"watch":{"validationData":{"deep":true}},"mixins":[{"name":"ProxyDataMixin","methods":[]}],"methods":[],"computed":[]}],"methods":[],"computed":[],"_compiled":true,"components":{"RequiredAsterisk":{"name":"RequiredAsterisk","_Ctor":[],"_compiled":true,"staticRenderFns":[]}},"inheritAttrs":false,"staticRenderFns":[]},"computed":[],"_compiled":true,"staticRenderFns":[]},"field":"dataMask","config":{"name":"Data Format","label":"Data Format","helper":"The data format for the selected type."}},{"type":"ValidationSelect","field":"validation","config":{"label":"Validation Rules","helper":"The validation rules needed for this field"}},{"type":"FormInput","field":"placeholder","config":{"label":"Placeholder Text","helper":"The placeholder is what is shown in the field when no value is provided yet"}},{"type":"FormInput","field":"helper","config":{"label":"Helper Text","helper":"Help text is meant to provide additional guidance on the field's value"}},{"type":"FormCheckbox","field":"readonly","config":{"label":"Read Only","helper":null}},{"type":"ColorSelect","field":"color","config":{"label":"Text Color","helper":"Set the element's text color","options":[{"value":"text-primary","content":"primary"},{"value":"text-secondary","content":"secondary"},{"value":"text-success","content":"success"},{"value":"text-danger","content":"danger"},{"value":"text-warning","content":"warning"},{"value":"text-info","content":"info"},{"value":"text-light","content":"light"},{"value":"text-dark","content":"dark"}]}},{"type":"ColorSelect","field":"bgcolor","config":{"label":"Background Color","helper":"Set the element's background color","options":[{"value":"alert alert-primary","content":"primary"},{"value":"alert alert-secondary","content":"secondary"},{"value":"alert alert-success","content":"success"},{"value":"alert alert-danger","content":"danger"},{"value":"alert alert-warning","content":"warning"},{"value":"alert alert-info","content":"info"},{"value":"alert alert-light","content":"light"},{"value":"alert alert-dark","content":"dark"}]}},{"type":"default-value-editor","field":"defaultValue","config":{"label":"Default Value","helper":"The default value is pre populated using the existing request data. This feature will allow you to modify the value displayed on screen load if needed."}},{"type":"FormInput","field":"conditionalHide","config":{"label":"Visibility Rule","helper":"This control is hidden until this expression is true"}},{"type":"DeviceVisibility","field":"deviceVisibility","config":{"label":"Device Visibility","helper":"This control is hidden until this expression is true"}},{"type":"FormInput","field":"customFormatter","config":{"label":"Custom Format String","helper":"Use the Mask Pattern format <br> Date ##\/##\/#### <br> SSN ###-##-#### <br> Phone (###) ###-####","validation":null}},{"type":"FormInput","field":"customCssSelector","config":{"label":"CSS Selector Name","helper":"Use this in your custom css rules","validation":"regex: [-?[_a-zA-Z]+[_-a-zA-Z0-9]*]"}},{"type":"FormInput","field":"ariaLabel","config":{"label":"Aria Label","helper":"Attribute designed to help assistive technology (e.g. screen readers) attach a label"}},{"type":"FormInput","field":"tabindex","config":{"label":"Tab Order","helper":"Order in which a user will move focus from one control to another by pressing the Tab key","validation":"regex: [0-9]*"}}],"editor-control":"FormInput","editor-component":"FormInput"},{"label":"Submit Button","config":{"icon":"fas fa-share-square","name":null,"event":"submit","label":"New Submit","loading":false,"tooltip":[],"variant":"primary","fieldValue":null,"loadingLabel":"Loading...","defaultSubmit":true},"component":"FormButton","inspector":[{"type":"FormInput","field":"label","config":{"label":"Label","helper":"The label describes the button's text"}},{"type":"FormInput","field":"name","config":{"name":"Variable Name","label":"Variable Name","helper":"A variable name is a symbolic name to reference information.","validation":"regex:\/^(?:[A-Za-z])(?:[0-9A-Z_.a-z])*(?<![.])$\/|not_in:null,break,case,catch,continue,debugger,default,delete,do,else,finally,for,function,if,in,instanceof,new,return,switch,this,throw,try,typeof,var,void,while,with,class,const,enum,export,extends,import,super,true,false"}},{"type":"FormMultiselect","field":"event","config":{"label":"Type","helper":"Choose whether the button should submit the form","options":[{"value":"submit","content":"Submit Button"},{"value":"script","content":"Regular Button"}]}},{"type":"LoadingSubmitButton","field":"loading","config":{"label":"Loading Submit Button","helper":"Loading Submit Button"}},{"type":"LabelSubmitButton","field":"loadingLabel","config":{"label":"Loading Submit Button Label","helper":"Loading Submit Button Label"}},{"type":{"props":["label","value","helper"],"watch":{"value":{"immediate":true}},"methods":[],"computed":[],"_compiled":true,"components":{"FormTextArea":{"name":"FormTextArea","_Ctor":[],"props":{"name":{"type":null},"rows":{"type":null},"error":{"type":null},"label":{"type":null},"value":{"type":null},"helper":{"type":null},"readonly":{"type":null},"richtext":{"type":null},"controlClass":{"type":null}},"watch":{"rows":{"immediate":true}},"mixins":[{"methods":[],"directives":{"uni-id":[],"uni-for":[],"uni-form":[],"uni-aria-owns":[],"uni-aria-flowto":[],"uni-aria-controls":[],"uni-aria-labelledby":[],"uni-aria-describedby":[],"uni-aria-activedescendant":[]}},{"name":"ValidationMixin","props":{"config":{"type":null},"validation":{"type":null},"validationData":{"type":null},"validationField":{"type":null},"validationMessages":{"type":null}},"watch":{"validationData":{"deep":true,"user":true}},"mixins":[{"name":"ProxyDataMixin","methods":[]}],"methods":[],"computed":[]}],"methods":[],"computed":[],"_compiled":true,"components":{"Editor":{"props":{"plugins":[null,null],"toolbar":[null,null],"modelEvents":[null,null]},"watch":[]},"DisplayErrors":{"props":["name","error","validator"],"computed":[],"_compiled":true,"staticRenderFns":[]},"RequiredAsterisk":{"name":"RequiredAsterisk","_Ctor":[],"_compiled":true,"staticRenderFns":[]}},"inheritAttrs":false,"staticRenderFns":[]}},"inheritAttrs":false,"staticRenderFns":[]},"field":"tooltip","config":{"label":"Tooltip","helper":null}},{"type":"FormInput","field":"fieldValue","config":{"label":"Value","helper":"The value being submitted"}},{"type":"FormMultiselect","field":"variant","config":{"label":"Button Variant Style","helper":"The variant determines the appearance of the button","options":[{"value":"primary","content":"Primary"},{"value":"secondary","content":"Secondary"},{"value":"success","content":"Success"},{"value":"danger","content":"Danger"},{"value":"warning","content":"Warning"},{"value":"info","content":"Info"},{"value":"light","content":"Light"},{"value":"dark","content":"Dark"},{"value":"link","content":"Link"}]}},{"type":"FormInput","field":"conditionalHide","config":{"label":"Visibility Rule","helper":"This control is hidden until this expression is true"}},{"type":"DeviceVisibility","field":"deviceVisibility","config":{"label":"Device Visibility","helper":"This control is hidden until this expression is true"}},{"type":"FormInput","field":"customFormatter","config":{"label":"Custom Format String","helper":"Use the Mask Pattern format <br> Date ##\/##\/#### <br> SSN ###-##-#### <br> Phone (###) ###-####","validation":null}},{"type":"FormInput","field":"customCssSelector","config":{"label":"CSS Selector Name","helper":"Use this in your custom css rules","validation":"regex: [-?[_a-zA-Z]+[_-a-zA-Z0-9]*]"}},{"type":"FormInput","field":"ariaLabel","config":{"label":"Aria Label","helper":"Attribute designed to help assistive technology (e.g. screen readers) attach a label"}},{"type":"FormInput","field":"tabindex","config":{"label":"Tab Order","helper":"Order in which a user will move focus from one control to another by pressing the Tab key","validation":"regex: [0-9]*"}}],"editor-control":"FormSubmit","editor-component":"FormButton"}],"order":1}],"computed":[{"id":3,"name":"test","type":"javascript","order":1,"byPass":false,"formula":"return 'Hello World';","property":"calcName"},{"id":4,"name":"dos","type":"javascript","order":2,"byPass":true,"formula":"aaa\nreturn \"dos test\";","property":"calcNameSecod"}],"custom_css":null,"created_at":"2024-05-27T13:18:42+00:00","updated_at":"2024-06-12T14:09:44+00:00","status":"ACTIVE","key":null,"watchers":[],"translations":null,"is_template":0,"asset_type":null,"projects":"[]","categories":[{"id":1,"uuid":"9c1fc1ba-5d2b-4fba-a77c-562a59f28e26","name":"Uncategorized","status":"ACTIVE","is_system":0,"created_at":"2024-05-25T01:54:41+00:00","updated_at":"2024-05-25T01:54:41+00:00","pivot":{"category_type":"ProcessMaker\\Models\\ScreenCategory","assignable_id":3,"category_id":1}}]}],"screen_categories":[],"scripts":[]}
Loading
Loading