UNPKG

json-object-editor

Version:

JOE the Json Object Editor | Platform Edition

131 lines (124 loc) 6.24 kB
var schema = { title : '${name}', info:"Choose status options to track the progress of different panels throughout your dashboard in a workflow (ex: new member flow). Build a report to easily check the status of a workflow.", default_schema:true, // Curated summary for agents summary:{ description:'Workflow state used by multiple schemas (e.g., task, project).', purpose:'Statuses represent workflow stages. Records (like tasks/projects) reference a single status; statuses can be scoped to specific schemas via datasets. Use status to show state labels and colors and to filter pipelines.', labelField:'name', defaultSort:{ field:'index', dir:'asc' }, searchableFields:['name','info','code','_id'], allowedSorts:['index','name','joeUpdated','created'], relationships:{ outbound:[ { field:'datasets', targetSchema:'<schemaName>', cardinality:'many' } ], inbound:{ graphRef:'server/relationships.graph.json' } }, joeManagedFields:['created','joeUpdated'], fields:[ { name:'_id', type:'string', required:true }, { name:'itemtype', type:'string', required:true, const:'status' }, { name:'name', type:'string', required:true }, { name:'info', type:'string' }, { name:'description', type:'string' }, { name:'color', type:'string' }, { name:'index', type:'number' }, { name:'code', type:'string' }, { name:'default', type:'boolean' }, { name:'terminal', type:'boolean' }, { name:'active', type:'boolean' }, { name:'inactive', type:'boolean' }, { name:'datasets', type:'string', isArray:true }, { name:'joeUpdated', type:'string', format:'date-time', required:true }, { name:'created', type:'string', format:'date-time', required:true } ] }, listView:{ title: '<joe-full-right><joe-subtext>${this.index}</joe-subtext></joe-full-right>'+ '<joe-title>${name}</joe-title><joe-subtitle>${info}</joe-subtitle>'+ '<joe-subtext>${ENUM[${datasets}]}</joe-subtext>', listWindowTitle: 'Statuses' }, menuicon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-40 -40 180 180"><path d="M95 65H15V35H95ZM85 45H25V55H85Z"/><rect x="15" y="75" width="60" height="10"/><rect x="15" y="15" width="60" height="10"/><rect x="5.7" width="2" height="100"/><rect x="7" y="49" width="6" height="2"/></svg>', bgColor:function(item){ return item.color; }, stripeColor:function(item){ if(item.default){ //return 'limegreen'; return {color:'limegreen',name:'default workflow start'}; } if(item.active){ return {color:'#90c0c0',name:'active status'}; } if(item.inactive){ //return 'limegreen'; return {color:'#bbb',name:'inactive status'}; } if(item.terminal){ //return 'crimson'; return {color:'crimson',name:'possible workflow end'}; } return false; }, subsets:function(){ var schemas = []; var subs = []; _joe.current.list.map(function(status){ schemas = schemas.concat(status.datasets||[]); }); (new Set(schemas)).map(function(schema){ subs.push({name:schema,filter:{datasets:{$in:[schema]}}}) }); return subs; }, sorter:['index'], fields:[ 'name', 'info', 'description', 'color:color', { name: "index", type: "number", display: "Ordering Index", comment: "Optional manual ordering index for lists and workflows. Lower values appear first.", width:'50%' }, { name: "code", type: "text", display: "System Code", comment: "Machine-usable, human-readable identifier for database/API use. Use lowercase with underscores.", width:'50%' }, {section_start:'categorization',collapsed:true}, {label:'workflow'}, {name:'default',type:'boolean',display:'default',label:'default status for new items', width:'50%'}, {name:'terminal',type:'boolean',display:'end state', label:'this is a workflow end state', width:'50%'}, {name:'active',type:'boolean',display:'active',label:'being edited right now', width:'50%'}, {name:'inactive',type:'boolean',display:'inactive',label:'objects in this status are not to being actively edited', width:'50%'}, 'datasets', {section_end:'categorization'}, {sidebar_start:'right'}, {section_start:'usage',collapsed:false}, {name:'usages',label:false,type:'content', run:function(item){ var usages = _joe.search({status:item._id}) var html = '<joe-title>'+usages.length+' objects are in this status</joe-title>'; usages.sortBy('itemtype,name').map(function(usage){ html += _joe.renderFieldListItem(usage,function(item){ var html = '<joe-full-right>' +'<joe-subtext>updated</joe-subtext>' +'<joe-subtitle>'+_joe.Utils.toDateString(item.joeUpdated)+'</joe-subtitle>' +'</joe-full-right>' +(_joe.schemas[usage.itemtype].menuicon && '<joe-icon class="icon-50 icon-grey fleft">' +_joe.schemas[usage.itemtype].menuicon+'</joe-icon>' || '') +'<joe-subtext>${itemtype}</joe-subtext>' +'<joe-subtitle>${name}</joe-subtitle><joe-subtext>${info}</joe-subtext>'; return html; },usage.itemtype); }); return html; }}, {section_end:'usage'}, {sidebar_end:'right'}, {section_start:'system',collapsed:true}, '_id','created','itemtype', {section_end:'system'} ], idprop : "_id" }; module.exports = schema;