Search:
Template:MindTouch > ToBeDeveloped > Task/To Do Lists > Template:ToDoRollup

Template:ToDoRollup

    Table of contents
    No headers
    Dekiapi();
    
    var onlymine = ($OnlyMine ?? $0 ?? true);
    var onlyopen = ($OnlyOpen ?? $1 ?? false);
    
     tstable{options:{zebra:true}};
    //datatable('#TaskItems');
    
    // Required Variables
    var percentmap = {1:'0%',2:'25%',3:'50%',4:'75%',5:'100%',default:'0%'};
    var prioritymap = {1:'1',2:'2',3:'3',default:'Unk'};
    var tasksubpage = '';
    
    // List of pageIDs to not include.
    var DoNotInclude = [1075];
    var CurProgress = 0;
    var ProgressPossible=0;
    var OverAllProgress=0;
    
    // Find all the pages with the todomaster template
    var todopageids = cpidekidb.list("SELECT page_id  FROM pages WHERE page_text LIKE '%todomaster(%);%' OR page_text LIKE '%todomaster{%};%'");
    
    foreach(var d in DoNotInclude) {
        let todopageids = list.select(todopageids, '$ != ' ..d);
    }
    
    <div id="progressParent"><a style="float:right" href="#" ctor="when($this.click) {return false;}; when($this.mouseover){ $('div#projectProgress').show()}; when($this.mouseout) {$('div#projectProgress').hide()}">'Total Progress'</a></div>
    
    <table id="TaskItems" border="1" width="100%">
        <tr>
            <th>
                'Task ID'
            </th>
            <th>
                'Description'
            </th>
            <th>
                'Assignee(s)'
            </th>
            <th>
                'Priority'
            </th>
            <th>
                'Due Date'
            </th>
            <th>
                'Progress'
            </th>
            <th>
                'On Hold'
            </th>
            <th>
                'Complete Date'
            </th>
            <th>
                'Notes'
            </th>
        </tr>
    // Flip thru the pages and gather the required task info
    foreach(var pgid in todopageids) {
        var pg = wiki.getpage(pgid);
        
        // Find out if we actually have any tasks on the list
        if(wiki.pageexists(pg.path ..'/tasks')) {
            let tasksubpage = wiki.getpage(pg.path ..'/tasks');
        } else {
            let tasksubpage = nil;
        }
    
        if(#tasksubpage.subpages > 0) {
    
    
    
        foreach(var taskitem in tasksubpage.subpages) {
    
                var taskdetail = json.parse(taskitem.properties['todo-item'].text ?? "") ?? [];
    
    foreach(var a in taskdetail.assignee) {
    
    //Assume we are not going to show this item
    var ShowResultMine=false;
    var ShowResultOpen=false;
    
    if(onlymine==true && a == user.name) {
        let ShowResultMine = true;
        // This will just count a particular users progress
        let ProgressPossible = ProgressPossible + 4;
        let curprogress = (curprogress + taskdetail.percent -1);
    } else if(onlymine==false){
        let ShowResultMine = true;
        // This means Count it all
        let ProgressPossible = ProgressPossible + 4;
        let curprogress = (curprogress + taskdetail.percent -1);
    }
    
    if(onlyopen==true && taskdetail.done==false) {
        let ShowResultOpen = true;
    } else if(onlyopen==false) {
        let ShowResultOpen = true;
    }
    
    
    if(ShowResultMine==true && ShowResultOpen==true){
            <tr>
                <td>
                    web.link(taskitem.uri, taskitem.id);
                </td>
                <td>
                    taskdetail.desc;
                </td>
                <td>
                    a;
                </td>
                <td>
                    prioritymap[((taskdetail.priority==nil || taskdetail.priority == '') ? 'default' : taskdetail.priority)];
                </td>
                <td>
                    taskdetail.duedate;
                </td>
                <td>
                    percentmap[((taskdetail.percent==nil || taskdetail.percent=='') ? 'default' : taskdetail.percent)];
                </td>
                <td>
                    (taskdetail.hold==true);
                </td>
                <td>
                    (date.isvalid(taskdetail.donedate) ? date.format(taskdetail.donedate,'MM/dd/yyyy') : 'N/A');
                </td>
                <td>
                    <a href="#" id=(taskitem.id ..'-'..__index) taskid=(taskitem.id) ctor="when($this.click){ ShowMyDetails($this.attr('taskid')); return false; };" >'view'</a>
                </td>
            </tr>
    }
    }
        }
    
    
    
        }
    
    }
    </table> 
    
    let OverAllProgress = ( num.round( ((curprogress / progresspossible) * 100), 0) );
    <div id="projectProgress">
    //    GoogleStatusIndicator{value: OverAllProgress, text: 'Over All Progress: ' ..OverAllProgress ..'%', height: '200', width: '120'};
    var text = 'Over All Progress: ' ..OverAllProgress ..'%';
    web.image('http://chart.apis.google.com/chart?chs=250x150&cht=gom&chd=t:' ..OverAllProgress ..'&chl=' ..web.uriencode(text));
    </div>
    
    
    <html><head>
    <script type="text/javascript">"
        $(document).ready(function() {
            $('div#projectProgress').hide();
            $('div#projectProgress').appendTo('#progressParent');
    
            $('div#TaskDetailViewer').hide();
            $('div#TaskDetailViewer').click(function(){$(this).hide()});
            $(document).click(function(){$('div#TaskDetailViewer').hide()});
    
        });
    
    function ShowMyDetails(pid) {
    
        $('div#TaskDetailViewer').hide();
    
        Deki.$.ajax({
                    type: 'GET',
                    url: 'http://cpideki.changeparts.com/@api/deki/pages/' + pid + '/contents?section=1&include=true',
                    dataType: 'xml',
                    success: function(data){
                            $('#TaskDetailViewer').html( '<p style=\"text-align:center;\">Click to Close</p>' + $(data).find('content').text() );
                    }    
         });
    
          centerIt($('div#TaskDetailViewer'));
    
         $('div#TaskDetailViewer').show();
    }
    
    function centerIt($el) {
    	var frm = $('iframe',top.document.body);
    	var iframeXOffset = 0, iframeYOffset = 0, windowHeight = 0, windowWidth = 0;
    	var i=frm.length;
    	while (i--) {
    		if (frm[i].contentDocument) {
    			doc = frm[i].contentDocument;
    		} else {
    			doc = frm[i].contentWindow.document;
    		}
    		if (doc === document) {
    			//located our iframe!
    			iframeXOffset = $(frm[i]).offset().left;
    			iframeYOffset = $(frm[i]).offset().top;
    			break;
    		}
    	};
    	if (jQuery.browser.msie) {
    		windowWidth = top.window.document.documentElement.clientWidth;
    		windowHeight = top.window.document.documentElement.clientHeight;
    	} else {
    		windowWidth = top.window.innerWidth;
    		windowHeight = top.window.innerHeight;
    	}
    	var elHeight = $el.height();
    	var newTop = ((windowHeight/2) - (elHeight/2)) - iframeYOffset + $(parent.document.documentElement).scrollTop();
    	if ((newTop + elHeight) > $(document).height()) {
    		newTop = $(document).height() - elHeight;
    	}
    	$el.css ({
    		left: ((windowWidth/2) - ($el.width()/2)) - iframeXOffset + $(parent.document.documentElement).scrollLeft(),
    		top: newTop
    	});
    }
    
    "</script>
    
    <style type="text/css">"
        div#projectProgress {
                width:155px;
                float: right;
            }
        div#progressParent {
                width:155px;
                margin-bottom: 5px;
                float: right;
            }
        div#TaskDetailViewer{
                    position:absolute;
                    z-index:100;
                    border:1px solid #000000;
                    margin: auto;
                    overflow: auto;
                    background-color:#FFFFCC;
                    height: 400px;
                    width: 600px;
                    padding: 5px;
                }
    
    "</style>
    </head></html>
    
    <div id="TaskDetailViewer" height="30%"></div>

    Files (0)

     

    Comments (0)

    You must login to post a comment.