Browse Source

Beginnings of scrum support

Nathaniel van Diepen 10 years ago
parent
commit
5fc970ae90
7 changed files with 56 additions and 8 deletions
  1. 12 4
      api.php
  2. 11 3
      data/pages/project.template
  3. 7 0
      data/pages/scrum.template
  4. 1 1
      js/index.js
  5. 1 0
      php/include.php
  6. 1 0
      php/project.php
  7. 23 0
      php/scrum.php

+ 12 - 4
api.php

@@ -64,15 +64,23 @@
 				break;
 				case 'scrum':
 					back(true);
-					// TODO - handle scrum requests
-					if(false){
-						// TODO
+					$ret['template'] = array(
+						'type'=>'pages',
+						'name'=>'scrum'
+					);
+					if($context = scrumObj($id)){
+						$context['user'] = userObj($context['user']);
+						if($LOGGEDIN){
+							$context['key'] = true;
+							$context['user'] = userObj($_SESSION['username']);
+						};
+						$ret['context'] = $context;
 					}else{
 						$ret['state'] = array(
 							'url'=>isset($_GET['back'])?$_GET['back']:'page-index'
 						);
 					}
-					retj($ret);
+					retj($ret,'Scrum - '.$context['title']);
 				break;
 				case 'project':
 					back(true);

+ 11 - 3
data/pages/project.template

@@ -4,9 +4,10 @@
 <div style="font-size:large;">
 	{{description}}
 </div>
-<span style="font-size:small;">
+<br/>
+<h3>
 	Comments
-</span>
+</h3>
 <ul>
 	{{#each comments}}
 		<li>
@@ -33,4 +34,11 @@
 		"title": "Comment"
 	}
 </a>
-<a href="#page-scrums">scrums</a>
+<br/>
+<br/>
+<h3>
+	Scrums
+</h3>
+{{#each scrums}}
+	<a class="button" href="#scrum-{{id}}">{{title}}</a>
+{{/each}}

+ 7 - 0
data/pages/scrum.template

@@ -0,0 +1,7 @@
+<h2>
+	{{title}} <a style="font-size:small;color:gray;text-decoration:none;" href="#~{{user.name}}">{{user.name}}</a>
+</h2>
+<div style="font-size:large;">
+	{{description}}
+</div>
+<br/>

+ 1 - 1
js/index.js

@@ -242,7 +242,7 @@
 			getNewState();
 			if(!equal(State.data,Old)){
 				switch(State.data.type){
-					case 'page':case 'user':case 'project':case 'issue':
+					case 'page':case 'user':case 'project':case 'issue':case 'scrum':
 						apiCall(State.data,function(d){
 							if(!exists(d.error)){
 								if(exists(d.context)){

+ 1 - 0
php/include.php

@@ -15,6 +15,7 @@
 	require_once(PATH_PHP.'messages.php');
 	require_once(PATH_PHP.'user.php');
 	require_once(PATH_PHP.'project.php');
+	require_once(PATH_PHP.'scrum.php');
 	require_once(PATH_PHP.'issue.php');
 	require_once(PATH_PHP.'emails.php');
 	authenticate();

+ 1 - 0
php/project.php

@@ -8,6 +8,7 @@
 				$project = $res->fetch_assoc();
 				$project['user'] = userObj($project['user']);
 				$project['comments'] = messages($project['id'],'project');
+				$project['scrums'] = scrums($project['id']);
 				return $project;
 			}
 		}

+ 23 - 0
php/scrum.php

@@ -0,0 +1,23 @@
+<?php
+	require_once(realpath(dirname(__FILE__)).'/config.php');
+	require_once(PATH_PHP.'database.php');
+	function scrums($id){
+		$arr = array();
+		if($res = query("SELECT s.id,s.title,s.description,u.name as user FROM `scrums` s JOIN `users` u ON u.id = s.u_id WHERE s.p_id='%d' ORDER BY s.title DESC",array($id))){
+			while($row = $res->fetch_assoc()){
+				array_push($arr,$row);
+			}
+		}
+		return $arr;
+	}
+	function scrumObj($id){
+		if($res = query("SELECT s.id,s.title,s.description,u.name as user FROM `scrums` s JOIN `users` u ON u.id = s.u_id WHERE s.id='%d'",array($id))){
+			if($res->num_rows == 1){
+				$scrum = $res->fetch_assoc();
+				$scrum['user'] = userObj($scrum['user']);
+				return $scrum;
+			}
+		}
+		return false;
+	}
+?>