json-object-editor
Version:
JOE the Json Object Editor | Platform Edition
46 lines (43 loc) • 4.55 kB
JavaScript
var schema = {
title : '${name}',
info:"Use a budget to track your income and expenses.",
menuicon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="-15 -15 80 80"><path d="M18.5 2.6C14.4 2.6 11 5.9 11 10.1 11 11.2 11.3 12.3 11.8 13.3L13.5 12.4C13.2 11.7 13 10.9 13 10.1 13 7 15.4 4.6 18.5 4.6 21.5 4.6 24 7 24 10.1L26 10.1C26 5.9 22.6 2.6 18.5 2.6zM37.2 6.9A1 1 0 0 0 37.1 7 1 1 0 0 0 37 7C34.5 7.6 31.6 9.2 29.7 12.6 28 12.2 26.2 11.9 24.3 11.9 18.6 11.9 14.2 13.7 10.7 16.4 8.9 17.8 7.5 19.7 6.7 22 6.3 21.9 5.9 21.7 5.5 21.4 4.7 20.9 4 20.1 4 18.8 4 17.7 4.5 16.8 5.3 16.4A1 1 0 0 0 4.9 14.5 1 1 0 0 0 4.6 14.6C2.9 15.3 2 17 2 18.8 2 20.9 3.2 22.3 4.3 23.1 5 23.5 5.6 23.8 6.1 23.9 5.7 25.4 5.6 27 5.7 28.8 5.8 33.2 8.9 36.5 11.1 38.3A1 1 0 0 0 11.2 38.3C11.4 38.5 11.4 38.6 11.4 38.6 11.5 38.6 11.5 38.6 11.4 38.8 11.1 39.8 10.5 41.2 10.5 41.2A1 1 0 0 0 10.5 41.2C10 42.6 10.7 44.2 12.1 44.7A1 1 0 0 0 12.1 44.7L15.3 45.9C16.7 46.4 18.3 45.7 18.8 44.3 18.8 44.3 19.2 43.2 19.6 42.3 19.6 42.1 19.7 42.1 19.7 42.1 19.8 42.1 19.8 42.1 19.8 42.1 20.5 42.2 21.9 42.6 24.3 42.6 26.7 42.6 28 42.4 28.7 42.3 28.8 42.3 28.9 42.3 28.9 42.3 28.9 42.4 28.9 42.4 28.9 42.4 28.9 42.5 28.9 42.5 28.9 42.5 29.3 43.4 29.6 44.3 29.7 44.3 29.7 44.4 29.7 44.4 29.7 44.4 30.2 45.7 31.8 46.4 33.2 45.9L36.4 44.7A1 1 0 0 0 36.4 44.7C37.8 44.2 38.5 42.6 37.9 41.2L37.4 39.8A1 1 0 0 0 37.3 39.7C37.3 39.7 37.4 39.7 37.4 39.7 37.4 39.7 37.2 39.7 37.6 39.6 40 38.2 41.9 36.2 43 33.8 43.1 33.5 43.2 33.4 43.3 33.3 43.4 33.2 43.4 33.2 43.8 33.2L45.4 33.2C46.8 33.2 48 32 48 30.5L48 25.7C48 24.2 46.8 23 45.4 23L43.8 23C43.5 23 43.4 23 43.4 23 42.9 20.1 41 16.5 36.7 14.7 36.7 12.6 37.2 11 38.2 8.3A1 1 0 0 0 37.2 6.9zM35.6 9.8C35 11.6 34.6 13.3 34.6 15.3A1 1 0 0 0 35.3 16.2C39.5 17.7 41 20.9 41.4 23.4 41.6 24.4 42.6 25 43.8 25L45.4 25C45.7 25 46 25.3 46 25.7L46 30.5C46 30.9 45.7 31.2 45.4 31.2L43.8 31.2C43 31.2 42.4 31.4 41.9 31.8 41.5 32.2 41.3 32.6 41.2 32.9 40.2 35 38.7 36.7 36.6 37.8 35.8 38.2 35.4 39 35.4 39.6 35.4 40.1 35.5 40.4 35.6 40.5L35.6 40.5 35.6 40.7 36.1 41.9C36.2 42.3 36 42.7 35.7 42.8L32.4 44.1C32.1 44.2 31.6 44 31.5 43.6A1 1 0 0 0 31.5 43.6C31.5 43.6 31.1 42.7 30.8 41.8 30.7 41.4 30.5 40.9 30 40.6 29.5 40.3 29 40.3 28.6 40.3 27.7 40.4 26.5 40.6 24.3 40.6 22.1 40.6 21 40.3 20.2 40.1 19.8 40 19.2 40 18.7 40.3 18.1 40.6 17.9 41.1 17.8 41.6 17.4 42.5 17 43.6 17 43.6 16.8 44 16.4 44.2 16 44.1L12.8 42.8C12.4 42.7 12.3 42.3 12.4 41.9 12.4 41.9 13 40.5 13.3 39.5 13.5 38.8 13.4 38 13.2 37.6 12.9 37.1 12.5 36.8 12.4 36.8 10.4 35.1 7.8 32.3 7.7 28.7 7.4 23.6 9.2 20.1 11.9 18 15.1 15.5 19 13.9 24.3 13.9 26.3 13.9 28.2 14.2 30 14.6A1 1 0 0 0 31.1 14.1C32.2 11.6 33.9 10.5 35.6 9.8zM36.5 23.1C35.4 23.1 34.6 23.9 34.6 25 34.6 26.1 35.4 26.9 36.5 26.9 37.5 26.9 38.4 26.1 38.4 25 38.4 23.9 37.5 23.1 36.5 23.1z"/></svg>',
listView:{
title:
'<joe-title class="joe-fright">-$${amount}</joe-title>'+
'<joe-title>${name}</joe-title>' +
'<joe-subtitle>${info}</joe-subtitle>'+
'<joe-subtext>${RUN[_joe.getDataItemProp;${tags};\'tag\']}</joe-subtext>',
listWindowTitle: 'Budgets'
},
fields:[
'name',
'info',
'additive:boolean',
{name:'amount',type:'number',comment:'the default amount'},
'tags',
{sidebar_start:'right'},
{section_start:'spending'},
{name:'history',label:false,type:'content',run:function(budget){
var ledgers = _joe.Data.ledger.where({tags:{$in:budget.tags}}).sortBy('!start_date');
var html = '<joe-title>Spending History ['+ledgers.length+' ledgers]</joe-title>';
ledgers.map(ledg=>{
console.log(budget._id)
var budgetReference = ledg.budgets[budget._id];
var cls = (budget.amount >= Math.abs(budgetReference.amount))?'green-text':'red-text';
html+='<div class="'+cls+'">'+ledg.start_date+':<b>$'+Math.abs(budgetReference.amount)+'</b></div>';
})
return html;
}},
{section_end:'spending'},
{sidebar_end:'right'},
{section_start:'system',collapsed:true},
'_id','created','itemtype',
{section_end:'system'},
],
filters:function(){
return _joe.Filter.Options.tags({group:true,untagged:true,collapsed:false});
},
idprop : "_id"
};
module.exports = schema;