;"use strict"; (function($) { let numFieldForName; // -------------------------- bbpmentity --------------------------- // bbpm.bbpmentity = function(data) { bbpm.entity.call(this, data); this.id = 'bbpmentity'; this.name = 'bbpmentity'; this.tenant = 'Browsway'; } bbpm.bbpmentity.prototype.methods = { "dummy": ""}; bbpm.bbpmentity.prototype = $.extend(true, {}, new bbpm.entity(), bbpm.bbpmentity.prototype); bbpm.tables['bbpmentity'] = new bbpm.bbpmentity({ "name": "bbpmentity", "path": "admin/bbpmentity", "table": "bbpmentities", "fields": [ {"name": "tenant" , "column": "tenant" , "type": "S"}, {"name": "title" , "column": "title" , "type": "S", "multilang": true}, {"name": "json" , "column": "json" , "type": "S"}, {"name": "js_shared" , "column": "js_shared" , "type": "S"}, {"name": "js_backend" , "column": "js_backend" , "type": "S"}, {"name": "js_frontend", "column": "js_frontend", "type": "S"} ], "formulars": { "list" : [ {"field": "json", "cols": "", "sort": "asc"} ], "display": [ {"field": "title" , "type": "text", "length": 128}, {"field": "json" , "type": "code", "height": 400, "mode": "json"}, {"field": "js_shared" , "type": "code", "height": 200, "mode": "javascript"}, {"field": "js_backend" , "type": "code", "height": 200, "mode": "javascript"}, {"field": "js_frontend", "type": "code", "height": 200, "mode": "javascript"} ], "add" : [ {"field": "tenant" , "type": "backend", "set": "javascriptBackend: bbpm.bbpmentity.prototype.methods.tenant"}, {"field": "title" , "type": "text", "length": 128}, {"field": "json" , "type": "code" , "height": 400, "mode": "json"}, {"field": "js_shared" , "type": "code" , "height": 200, "mode": "javascript"}, {"field": "js_backend" , "type": "code" , "height": 200, "mode": "javascript"}, {"field": "js_frontend", "type": "code" , "height": 200, "mode": "javascript"} ] }, "display": { "US": { "title": "Entities", "descriptions": "All BBPM tenant entities", "fields": [ {"name": "Tenant" , "description": "Entity owner"}, {"name": "Title" , "description": "Entity title"}, {"name": "Json" , "description": "Json definition of the entity fields, forms, etc." }, {"name": "Shared Javascript" , "description": "Javascript method shared between frontend and backend"}, {"name": "Backend Javascript" , "description": "Javascript method for backend"}, {"name": "Frontend Javascript", "description": "Javascript method for frontend"} ] } } } ); numFieldForName = []; for (const field in bbpm.tables['bbpmentity']['fields']) { numFieldForName[bbpm.tables['bbpmentity']['fields'][field].name] = field; } for (const form in bbpm.tables['bbpmentity']['formulars']) { for (const field in bbpm.tables['bbpmentity']['formulars'][form]) { if (numFieldForName[bbpm.tables['bbpmentity']['formulars'][form][field].field]) { bbpm.tables['bbpmentity']['formulars'][form][field].field = numFieldForName[bbpm.tables['bbpmentity']['formulars'][form][field].field]; } } } // -------------------------- role --------------------------- // bbpm.role = function(data) { bbpm.entity.call(this, data); this.id = 'role'; this.name = 'role'; this.tenant = 'Browsway'; } bbpm.role.prototype.methods = { "getAllPrivileges": function() { // TODO: Where should it be placed ? var arrayUnique = function(a) { return a.filter(function (value, index, self) { return self.indexOf(value) === index; }); }; var allPrivileges = []; for (var table in bbpm.tables) { for (var step in bbpm.tables[table].steps) { for (var permission in bbpm.tables[table].steps[step].permissions) { for (var i in bbpm.tables[table].steps[step].permissions[permission]) { var privilege = bbpm.tables[table].steps[step].permissions[permission][i]; allPrivileges.push(privilege); } } } } allPrivileges = arrayUnique(allPrivileges).sort(); var allOptions = []; for (var privilege in allPrivileges) { var aPrivilege = {}; aPrivilege[allPrivileges[privilege]] = allPrivileges[privilege]; allOptions.push(aPrivilege); } return allOptions; } }; bbpm.role.prototype = $.extend(true, {}, new bbpm.entity(), bbpm.role.prototype); bbpm.tables['role'] = new bbpm.role({ "name": "role", "path": "admin/role", "table": "roles", "fields": [ {"name": "name" , "column": "name" , "type": "S"}, {"name": "tenant" , "column": "tenant" , "type": "S"}, {"name": "privileges", "column": "privileges", "type": "S", "options": bbpm.role.prototype.methods.getAllPrivileges} ], "formulars": { "list" : [ {"field": "name" , "cols": "col-12 col-sm-6", "sort": "asc"}, {"field": "privileges", "cols": "col-12 col-sm-6", "sort": "asc"} ], "display": [ {"field": "name" , "type": "text", "length": 512}, {"field": "privileges" , "type": "select", "multiple": true} ], "add" : [ {"field": "tenant" , "type": "backend", "set": "javascriptBackend: bbpm.role.prototype.methods.tenant"}, {"field": "name" , "type": "text" , "length": 512, "mandatory": true}, {"field": "privileges", "type": "select", "multiple": true} ] }, "display": { "US": { "title": "Roles", "description": "Worflows use roles to allow users to participate to the different steps and to access data.", "fields": [ {"name": "Name" , "description": "Role name"}, {"name": "Tenant" , "description": "Tenant of the role"}, {"name": "Privileges", "description": "List of privileges of the role"} ] } } }); numFieldForName = []; for (const field in bbpm.tables['role']['fields']) { numFieldForName[bbpm.tables['role']['fields'][field].name] = field; } for (const form in bbpm.tables['role']['formulars']) { for (const field in bbpm.tables['role']['formulars'][form]) { if (numFieldForName[bbpm.tables['role']['formulars'][form][field].field]) { bbpm.tables['role']['formulars'][form][field].field = numFieldForName[bbpm.tables['role']['formulars'][form][field].field]; } } } // -------------------------- user --------------------------- // bbpm.user = function(data) { bbpm.entity.call(this, data); this.id = 'user'; this.name = 'user'; this.tenant = 'Browsway'; } bbpm.user.prototype.methods = { "dummy": ""}; bbpm.user.prototype = $.extend(true, {}, new bbpm.entity(), bbpm.user.prototype); bbpm.tables['user'] = new bbpm.user({ "name": "user", "path": "admin/user", "table": "users", "fields": [ {"name": "email" , "column": "email" , "type": "S"}, {"name": "firstname", "column": "firstname", "type": "S"}, {"name": "lastname" , "column": "lastname" , "type": "S"}, {"name": "pseudo" , "column": "pseudo" , "type": "S"}, {"name": "password" , "column": "password" , "type": "S"} ], "formulars": { "list" : [ {"field": "email" , "cols": "", "sort": "asc"}, {"field": "firstname", "cols": ""}, {"field": "lastname" , "cols": ""}, {"field": "pseudo" , "cols": ""} ], "display": [ {"field": "email" , "type": "text", "length": 512, "disabled": true}, {"field": "pseudo" , "type": "text", "length": 32 , "disabled": true}, {"field": "firstname", "type": "text", "length": 64}, {"field": "lastname" , "type": "text", "length": 64} ], "add" : [ {"field": "email" , "type": "text" , "length": 512, "mandatory": true}, {"field": "pseudo" , "type": "text" , "length": 32 , "mandatory": true}, {"field": "password" , "type": "password", "length": 64 , "mandatory": true}, {"field": "firstname", "type": "text" , "length": 64}, {"field": "lastname" , "type": "text" , "length": 64} ] }, "display": { "US": { "title": "Users", "description": "All BBPM users.", "fields": [ {"name": "Email" , "description": "Email" }, {"name": "Firstname" , "description": "Firstname"}, {"name": "Lastname" , "description": "Lastname" }, {"name": "Pseudo" , "description": "Pseudo" }, {"name": "Password" , "description": "Password" } ] } } }); numFieldForName = []; for (const field in bbpm.tables['user']['fields']) { numFieldForName[bbpm.tables['user']['fields'][field].name] = field; } for (const form in bbpm.tables['user']['formulars']) { for (const field in bbpm.tables['user']['formulars'][form]) { if (numFieldForName[bbpm.tables['user']['formulars'][form][field].field]) { bbpm.tables['user']['formulars'][form][field].field = numFieldForName[bbpm.tables['user']['formulars'][form][field].field]; } } } // -------------------------- test1entity --------------------------- // bbpm.test1entity = function(data) { bbpm.entity.call(this, data); this.id = 'test1entity'; this.name = 'test1entity'; this.tenant = 'Browsway'; } bbpm.test1entity.prototype.methods = { "updateType": function() { // alert("Type has changed"); } }; bbpm.test1entity.prototype = $.extend(true, {}, new bbpm.entity(), bbpm.test1entity.prototype); bbpm.tables['test1entity'] = new bbpm.test1entity({ "name": "test1entity", "path": "test/test1entity", "table": "test1_entities", "fields": [ {"name": "name" , "column": "entity_name" , "type": "S"}, {"name": "password" , "column": "password" , "type": "S"}, {"name": "date" , "column": "entity_date" , "type": "S"}, {"name": "description", "column": "description" , "type": "S"}, {"name": "code" , "column": "code" , "type": "S"}, {"name": "type" , "column": "entity_type" , "type": "S", "options": [{"1": "Type 1"}, {"2": "Type 2"}]}, {"name": "type_mult" , "column": "entity_type_mult", "type": "S", "options": [{"1": "Type 1"}, {"2": "Type 2"}, {"3": "Type 3"}]}, {"name": "workflow" , "column": "workflow" , "type": "S"} ], "formulars": { "list" : [ {"field": "name" , "cols": "", "sort": "asc"}, {"field": "date" , "cols": ""}, {"field": "description", "cols": ""}, {"field": "workflow" , "cols": "", "sortable": false} ], "display": [ {"field": "name" , "type": "text" , "disabled": true}, {"field": "password" , "type": "password"}, {"field": "date" , "type": "date" , "mandatory": true, "minDate": 0}, {"field": "description", "type": "textarea", "length": 512}, {"field": "type" , "type": "select" , "mandatory": true, "change": bbpm.test1entity.prototype.methods.updateType}, {"field": "type_mult" , "type": "select" , "mandatory": true, "multiple": true}, {"field": "workflow" , "type": "workflow"} ], "display3": [ {"field": "name" , "type": "text" , "disabled": true}, {"field": "description", "type": "textarea", "length": 512}, {"field": "workflow" , "type": "workflow"} ], "validate": [ {"field": "name" , "type": "text" , "disabled": true}, {"field": "date" , "type": "date" , "mandatory": true, "minDate": 0}, {"field": "workflow" , "type": "workflow"} ], "add" : [ {"field": "name" , "type": "text"}, {"field": "password" , "type": "password"}, {"field": "date" , "type": "date" , "mandatory": true, "minDate": 0}, {"field": "description", "type": "textarea", "length": 512}, {"field": "code" , "type": "code" , "length": 512, "mode": "javascript"}, {"field": "type" , "type": "select" , "mandatory": true, "change": bbpm.test1entity.prototype.methods.updateType}, {"field": "type_mult" , "type": "select" , "mandatory": true, "multiple": true} ] }, "steps": { "create": { "previous_steps": [], "formular" : "add", "permissions" : {"read": [], "write": []} }, "edit": { "previous_steps": ["create","validate"], "formular" : "display", "permissions" : {"read": [], "write": ["administration"]}, "reset_steps" : ["validate", "edit2", "edit3", "email", "notify_ifttt", "close", "end"] }, "email": { "previous_steps": ["edit"], "email" : "email" }, "notify_ifttt": { "previous_steps": ["edit2"], "script" : "Notify_IFTTT" }, "edit2": { "previous_steps": ["edit"], "formular" : "display", "permissions" : {"read": [], "write": ["test_edition", "administration"]} }, "edit3": { "previous_steps": ["edit"], "formular" : "display3", "permissions" : {"read": [], "write": ["test_edition", "administration"]} }, "validate": { "previous_steps": ["edit2"], "formular" : "validate", "permissions" : {"read": [], "write": ["test_edition"]} }, "close": { "previous_steps": ["notify_ifttt", "edit3"], "formular" : "display", "permissions" : {"read": ["alarm_edition"], "write": ["unknown_permission"]} }, "end": { "previous_steps": ["close"], "formular" : "display", "permissions" : {"read": [], "write": ["none"]} } }, "display": { "US": { "title": "Test1 Entities", "description": "A 'hardcoded' entity used for BBPM tests.", "fields": [ {"name": "Name" , "description": "Name" }, {"name": "Password" , "description": "Password" }, {"name": "Date" , "description": "Date" }, {"name": "Description" , "description": "Description" }, {"name": "Code" , "description": "Code Javascript"}, {"name": "Type" , "description": "Type" }, {"name": "Type multiple" , "description": "Type multiple" }, {"name": "Current step(s)", "description": "Current step(s) where the instance is."} ], "steps": [ {"name": "Create" , "description": ""}, {"name": "Edit" , "description": ""}, {"name": "Mail" , "description": ""}, {"name": "Notify IFTTT", "description": ""}, {"name": "Edit2" , "description": ""}, {"name": "Edit3" , "description": ""}, {"name": "Validate" , "description": ""}, {"name": "Close" , "description": ""}, {"name": "End" , "description": ""} ] } }, "emails": { "email": { "to": "christophe.meresse@gadz.org", "cc": "christophe.meresse@gadz.org", "subject": "[BBPM] {{'field': 'name', 'type': 'text'}}", "content": [ "
Hello,
", "Please find below the content of mail...
", "Hello,
", "Please find below the content of mail2...
", "Hello,
", "Please find below the content of mail...
", "Hello,
", "Please find below the content of mail2...
", "