From 78380f1593faff14842a2dabda3cb93a53e3fb9c Mon Sep 17 00:00:00 2001 From: Amal Francis Date: Mon, 20 Oct 2014 21:05:00 +0530 Subject: [PATCH 1/7] Catch PDOException & Exceptions in cases like connection to DB failed or DB dir not writeable and return 503 status --- api/api.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/api/api.php b/api/api.php index 83710b7..0f84266 100644 --- a/api/api.php +++ b/api/api.php @@ -15,8 +15,16 @@ $app->response->headers->set('Content-Type', 'application/json'); $jsonResponse = new JsonResponse(); require_once('helpers.php'); // Must come after $jsonResponse exists. -R::setup('sqlite:taskboard.db'); -createInitialUser(); +// Catch Exception if connection to DB failed +try { + R::setup('sqlite:taskboard.db'); + createInitialUser(); +} catch(Exception $e) { + $app->response->setStatus(503); + $jsonResponse->message = 'Connection to Database failed.'; + + $app->response->setBody($jsonResponse->asJson()); +} $app->notFound(function() use ($app, $jsonResponse) { $app->response->setStatus(404); From 7c30e6d275f1c07cb3a24134aed80365686d85aa Mon Sep 17 00:00:00 2001 From: Amal Francis Date: Tue, 21 Oct 2014 00:28:11 +0530 Subject: [PATCH 2/7] Modified the message and userRoutes.php --- api/api.php | 4 ++-- api/userRoutes.php | 41 ++++++++++++++++++----------------------- 2 files changed, 20 insertions(+), 25 deletions(-) mode change 100644 => 100755 api/api.php mode change 100644 => 100755 api/userRoutes.php diff --git a/api/api.php b/api/api.php old mode 100644 new mode 100755 index 0f84266..bc6b688 --- a/api/api.php +++ b/api/api.php @@ -18,10 +18,10 @@ require_once('helpers.php'); // Must come after $jsonResponse exists. // Catch Exception if connection to DB failed try { R::setup('sqlite:taskboard.db'); - createInitialUser(); + createInitialUser(); } catch(Exception $e) { $app->response->setStatus(503); - $jsonResponse->message = 'Connection to Database failed.'; + $jsonResponse->message = 'Connection to Database failed. Ensure api is writable.'; $app->response->setBody($jsonResponse->asJson()); } diff --git a/api/userRoutes.php b/api/userRoutes.php old mode 100644 new mode 100755 index 3f034b8..71d9929 --- a/api/userRoutes.php +++ b/api/userRoutes.php @@ -6,34 +6,29 @@ $app->post('/login', function() use ($app, $jsonResponse) { $expires = ($data->rememberme) ? (2 * 7 * 24 * 60 * 60) /* Two weeks */ : (1.5 * 60 * 60) /* One and a half hours */; - try { - $lookup = R::findOne('user', ' username = ? ', [$data->username]); - $jsonResponse->message = 'Invalid username or password.'; - $app->response->setStatus(401); + $lookup = R::findOne('user', ' username = ? ', [$data->username]); - if (null != $lookup) { - $hash = password_hash($data->password, PASSWORD_BCRYPT, array('salt' => $lookup->salt)); - if ($lookup->password == $hash) { - if ($lookup->logins == 0 && $lookup->username == 'admin') { - $jsonResponse->addAlert('warning', "This is your first login, don't forget to change your password."); - $jsonResponse->addAlert('success', 'Go to Settings to add your first board.'); - } - setUserToken($lookup, $expires); - $lookup->logins = $lookup->logins + 1; - $lookup->lastLogin = time(); - R::store($lookup); + $jsonResponse->message = 'Invalid username or password.'; + $app->response->setStatus(401); - logAction($lookup->username . ' logged in.', null, null); - $jsonResponse->message = 'Login successful.'; - $jsonResponse->data = $lookup->token; - $app->response->setStatus(200); + if (null != $lookup) { + $hash = password_hash($data->password, PASSWORD_BCRYPT, array('salt' => $lookup->salt)); + if ($lookup->password == $hash) { + if ($lookup->logins == 0 && $lookup->username == 'admin') { + $jsonResponse->addAlert('warning', "This is your first login, don't forget to change your password."); + $jsonResponse->addAlert('success', 'Go to Settings to add your first board.'); } + setUserToken($lookup, $expires); + $lookup->logins = $lookup->logins + 1; + $lookup->lastLogin = time(); + R::store($lookup); + + logAction($lookup->username . ' logged in.', null, null); + $jsonResponse->message = 'Login successful.'; + $jsonResponse->data = $lookup->token; + $app->response->setStatus(200); } - } catch (Exception $ex) { - } - if (!is_writable('taskboard.db')) { - $jsonResponse->message = 'The api directory is not writable.'; } $app->response->setBody($jsonResponse->asJson()); }); From d1d4eac9869576020ed12518bed1cba89e5f8afd Mon Sep 17 00:00:00 2001 From: kiswa Date: Mon, 20 Oct 2014 15:09:13 -0400 Subject: [PATCH 3/7] Reset file modes from recent PR. --- api/api.php | 2 +- api/userRoutes.php | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 api/api.php mode change 100755 => 100644 api/userRoutes.php diff --git a/api/api.php b/api/api.php old mode 100755 new mode 100644 index bc6b688..65cc2dd --- a/api/api.php +++ b/api/api.php @@ -21,7 +21,7 @@ try { createInitialUser(); } catch(Exception $e) { $app->response->setStatus(503); - $jsonResponse->message = 'Connection to Database failed. Ensure api is writable.'; + $jsonResponse->message = 'Connection to database failed. Ensure api is writable.'; $app->response->setBody($jsonResponse->asJson()); } diff --git a/api/userRoutes.php b/api/userRoutes.php old mode 100755 new mode 100644 From 8728f624789df4977e279f6f575f10011d944a0b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 20 Oct 2014 17:39:41 -0400 Subject: [PATCH 4/7] Add exception handler for entire API. --- api/api.php | 16 ++++++++-------- js/controllers/login.js | 7 +++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/api/api.php b/api/api.php index 65cc2dd..5a3a27b 100644 --- a/api/api.php +++ b/api/api.php @@ -16,15 +16,15 @@ $jsonResponse = new JsonResponse(); require_once('helpers.php'); // Must come after $jsonResponse exists. // Catch Exception if connection to DB failed -try { - R::setup('sqlite:taskboard.db'); - createInitialUser(); -} catch(Exception $e) { - $app->response->setStatus(503); - $jsonResponse->message = 'Connection to database failed. Ensure api is writable.'; +function exceptionHandler($exception) { + header('Content-Type: application/json'); + http_response_code(503); + echo '{"message": "API Error."}'; +}; +set_exception_handler('exceptionHandler'); - $app->response->setBody($jsonResponse->asJson()); -} +R::setup('sqlite:taskboard.db'); +createInitialUser(); $app->notFound(function() use ($app, $jsonResponse) { $app->response->setStatus(404); diff --git a/js/controllers/login.js b/js/controllers/login.js index 81d88ba..2f2510c 100644 --- a/js/controllers/login.js +++ b/js/controllers/login.js @@ -28,10 +28,9 @@ function ($rootScope, $scope, $location, $window, UserService, AuthenticationSer $location.path('/boards'); }).error(function(data, status) { $scope.isSaving = false; - if (status === 401) { - $scope.errors.push(data.message); - } else { - $scope.errors.push('Something went wrong. Please try again.'); + $scope.errors.push(data.message); + if (status === 503) { + $scope.errors[0] = $scope.errors[0] + ' Ensure api directory is writable.'; } }); }; From 0f3c215a420a4d859244a9e1736e154f1e9769aa Mon Sep 17 00:00:00 2001 From: kiswa Date: Mon, 20 Oct 2014 18:15:50 -0400 Subject: [PATCH 5/7] Modify marked to make links open in new tab. Fixes #18. --- lib/marked.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/marked.min.js b/lib/marked.min.js index 545ef30..3821cac 100644 --- a/lib/marked.min.js +++ b/lib/marked.min.js @@ -3,4 +3,4 @@ * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) * https://github.com/chjj/marked */ -(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script"||cap[1]==="style",text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^/i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"—").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
"+(escaped?code:escape(code,true))+"\n
"}return'
'+(escaped?code:escape(code,true))+"\n
\n"};Renderer.prototype.blockquote=function(quote){return"
\n"+quote+"
\n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
  • "+text+"
  • \n"};Renderer.prototype.paragraph=function(text){return"

    "+text+"

    \n"};Renderer.prototype.table=function(header,body){return'\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
    \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
    ":"
    "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0){return""}}var out='
    ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:

    "+escape(e.message+"",true)+"
    "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); \ No newline at end of file +(function(){var block={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:noop,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:noop,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:noop,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};block.bullet=/(?:[*+-]|\d+\.)/;block.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;block.item=replace(block.item,"gm")(/bull/g,block.bullet)();block.list=replace(block.list)(/bull/g,block.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+block.def.source+")")();block.blockquote=replace(block.blockquote)("def",block.def)();block._tag="(?!(?:"+"a|em|strong|small|s|cite|q|dfn|abbr|data|time|code"+"|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo"+"|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b";block.html=replace(block.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,block._tag)();block.paragraph=replace(block.paragraph)("hr",block.hr)("heading",block.heading)("lheading",block.lheading)("blockquote",block.blockquote)("tag","<"+block._tag)("def",block.def)();block.normal=merge({},block);block.gfm=merge({},block.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/});block.gfm.paragraph=replace(block.paragraph)("(?!","(?!"+block.gfm.fences.source.replace("\\1","\\2")+"|"+block.list.source.replace("\\1","\\3")+"|")();block.tables=merge({},block.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/});function Lexer(options){this.tokens=[];this.tokens.links={};this.options=options||marked.defaults;this.rules=block.normal;if(this.options.gfm){if(this.options.tables){this.rules=block.tables}else{this.rules=block.gfm}}}Lexer.rules=block;Lexer.lex=function(src,options){var lexer=new Lexer(options);return lexer.lex(src)};Lexer.prototype.lex=function(src){src=src.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n");return this.token(src,true)};Lexer.prototype.token=function(src,top,bq){var src=src.replace(/^ +$/gm,""),next,loose,cap,bull,b,item,space,i,l;while(src){if(cap=this.rules.newline.exec(src)){src=src.substring(cap[0].length);if(cap[0].length>1){this.tokens.push({type:"space"})}}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);cap=cap[0].replace(/^ {4}/gm,"");this.tokens.push({type:"code",text:!this.options.pedantic?cap.replace(/\n+$/,""):cap});continue}if(cap=this.rules.fences.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"code",lang:cap[2],text:cap[3]});continue}if(cap=this.rules.heading.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:"heading",depth:cap[1].length,text:cap[2]});continue}if(top&&(cap=this.rules.nptable.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/\n$/,"").split("\n")};for(i=0;i ?/gm,"");this.token(cap,top,true);this.tokens.push({type:"blockquote_end"});continue}if(cap=this.rules.list.exec(src)){src=src.substring(cap[0].length);bull=cap[2];this.tokens.push({type:"list_start",ordered:bull.length>1});cap=cap[0].match(this.rules.item);next=false;l=cap.length;i=0;for(;i1&&b.length>1)){src=cap.slice(i+1).join("\n")+src;i=l-1}}loose=next||/\n\n(?!\s*$)/.test(item);if(i!==l-1){next=item.charAt(item.length-1)==="\n";if(!loose)loose=next}this.tokens.push({type:loose?"loose_item_start":"list_item_start"});this.token(item,false,bq);this.tokens.push({type:"list_item_end"})}this.tokens.push({type:"list_end"});continue}if(cap=this.rules.html.exec(src)){src=src.substring(cap[0].length);this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:cap[1]==="pre"||cap[1]==="script"||cap[1]==="style",text:cap[0]});continue}if(!bq&&top&&(cap=this.rules.def.exec(src))){src=src.substring(cap[0].length);this.tokens.links[cap[1].toLowerCase()]={href:cap[2],title:cap[3]};continue}if(top&&(cap=this.rules.table.exec(src))){src=src.substring(cap[0].length);item={type:"table",header:cap[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:cap[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:cap[3].replace(/(?: *\| *)?\n$/,"").split("\n")};for(i=0;i])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:noop,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:noop,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/;inline.link=replace(inline.link)("inside",inline._inside)("href",inline._href)();inline.reflink=replace(inline.reflink)("inside",inline._inside)();inline.normal=merge({},inline);inline.pedantic=merge({},inline.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/});inline.gfm=merge({},inline.normal,{escape:replace(inline.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:replace(inline.text)("]|","~]|")("|","|https?://|")()});inline.breaks=merge({},inline.gfm,{br:replace(inline.br)("{2,}","*")(),text:replace(inline.gfm.text)("{2,}","*")()});function InlineLexer(links,options){this.options=options||marked.defaults;this.links=links;this.rules=inline.normal;this.renderer=this.options.renderer||new Renderer;this.renderer.options=this.options;if(!this.links){throw new Error("Tokens array requires a `links` property.")}if(this.options.gfm){if(this.options.breaks){this.rules=inline.breaks}else{this.rules=inline.gfm}}else if(this.options.pedantic){this.rules=inline.pedantic}}InlineLexer.rules=inline;InlineLexer.output=function(src,links,options){var inline=new InlineLexer(links,options);return inline.output(src)};InlineLexer.prototype.output=function(src){var out="",link,text,href,cap;while(src){if(cap=this.rules.escape.exec(src)){src=src.substring(cap[0].length);out+=cap[1];continue}if(cap=this.rules.autolink.exec(src)){src=src.substring(cap[0].length);if(cap[2]==="@"){text=cap[1].charAt(6)===":"?this.mangle(cap[1].substring(7)):this.mangle(cap[1]);href=this.mangle("mailto:")+text}else{text=escape(cap[1]);href=text}out+=this.renderer.link(href,null,text);continue}if(!this.inLink&&(cap=this.rules.url.exec(src))){src=src.substring(cap[0].length);text=escape(cap[1]);href=text;out+=this.renderer.link(href,null,text);continue}if(cap=this.rules.tag.exec(src)){if(!this.inLink&&/^
    /i.test(cap[0])){this.inLink=false}src=src.substring(cap[0].length);out+=this.options.sanitize?escape(cap[0]):cap[0];continue}if(cap=this.rules.link.exec(src)){src=src.substring(cap[0].length);this.inLink=true;out+=this.outputLink(cap,{href:cap[2],title:cap[3]});this.inLink=false;continue}if((cap=this.rules.reflink.exec(src))||(cap=this.rules.nolink.exec(src))){src=src.substring(cap[0].length);link=(cap[2]||cap[1]).replace(/\s+/g," ");link=this.links[link.toLowerCase()];if(!link||!link.href){out+=cap[0].charAt(0);src=cap[0].substring(1)+src;continue}this.inLink=true;out+=this.outputLink(cap,link);this.inLink=false;continue}if(cap=this.rules.strong.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.strong(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.em.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.em(this.output(cap[2]||cap[1]));continue}if(cap=this.rules.code.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.codespan(escape(cap[2],true));continue}if(cap=this.rules.br.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.br();continue}if(cap=this.rules.del.exec(src)){src=src.substring(cap[0].length);out+=this.renderer.del(this.output(cap[1]));continue}if(cap=this.rules.text.exec(src)){src=src.substring(cap[0].length);out+=escape(this.smartypants(cap[0]));continue}if(src){throw new Error("Infinite loop on byte: "+src.charCodeAt(0))}}return out};InlineLexer.prototype.outputLink=function(cap,link){var href=escape(link.href),title=link.title?escape(link.title):null;return cap[0].charAt(0)!=="!"?this.renderer.link(href,title,this.output(cap[1])):this.renderer.image(href,title,escape(cap[1]))};InlineLexer.prototype.smartypants=function(text){if(!this.options.smartypants)return text;return text.replace(/--/g,"�").replace(/(^|[-\u2014/(\[{"\s])'/g,"$1�").replace(/'/g,"�").replace(/(^|[-\u2014/(\[{\u2018\s])"/g,"$1�").replace(/"/g,"�").replace(/\.{3}/g,"�")};InlineLexer.prototype.mangle=function(text){var out="",l=text.length,i=0,ch;for(;i.5){ch="x"+ch.toString(16)}out+="&#"+ch+";"}return out};function Renderer(options){this.options=options||{}}Renderer.prototype.code=function(code,lang,escaped){if(this.options.highlight){var out=this.options.highlight(code,lang);if(out!=null&&out!==code){escaped=true;code=out}}if(!lang){return"
    "+(escaped?code:escape(code,true))+"\n
    "}return'
    '+(escaped?code:escape(code,true))+"\n
    \n"};Renderer.prototype.blockquote=function(quote){return"
    \n"+quote+"
    \n"};Renderer.prototype.html=function(html){return html};Renderer.prototype.heading=function(text,level,raw){return"'+text+"\n"};Renderer.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"};Renderer.prototype.list=function(body,ordered){var type=ordered?"ol":"ul";return"<"+type+">\n"+body+"\n"};Renderer.prototype.listitem=function(text){return"
  • "+text+"
  • \n"};Renderer.prototype.paragraph=function(text){return"

    "+text+"

    \n"};Renderer.prototype.table=function(header,body){return'\n"+"\n"+header+"\n"+"\n"+body+"\n"+"
    \n"};Renderer.prototype.tablerow=function(content){return"\n"+content+"\n"};Renderer.prototype.tablecell=function(content,flags){var type=flags.header?"th":"td";var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";return tag+content+"\n"};Renderer.prototype.strong=function(text){return""+text+""};Renderer.prototype.em=function(text){return""+text+""};Renderer.prototype.codespan=function(text){return""+text+""};Renderer.prototype.br=function(){return this.options.xhtml?"
    ":"
    "};Renderer.prototype.del=function(text){return""+text+""};Renderer.prototype.link=function(href,title,text){if(this.options.sanitize){try{var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(prot.indexOf("javascript:")===0){return""}}var out='
    ";return out};Renderer.prototype.image=function(href,title,text){var out=''+text+'":">";return out};function Parser(options){this.tokens=[];this.token=null;this.options=options||marked.defaults;this.options.renderer=this.options.renderer||new Renderer;this.renderer=this.options.renderer;this.renderer.options=this.options}Parser.parse=function(src,options,renderer){var parser=new Parser(options,renderer);return parser.parse(src)};Parser.prototype.parse=function(src){this.inline=new InlineLexer(src.links,this.options,this.renderer);this.tokens=src.reverse();var out="";while(this.next()){out+=this.tok()}return out};Parser.prototype.next=function(){return this.token=this.tokens.pop()};Parser.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0};Parser.prototype.parseText=function(){var body=this.token.text;while(this.peek().type==="text"){body+="\n"+this.next().text}return this.inline.output(body)};Parser.prototype.tok=function(){switch(this.token.type){case"space":{return""}case"hr":{return this.renderer.hr()}case"heading":{return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text)}case"code":{return this.renderer.code(this.token.text,this.token.lang,this.token.escaped)}case"table":{var header="",body="",i,row,cell,flags,j;cell="";for(i=0;i/g,">").replace(/"/g,""").replace(/'/g,"'")}function unescape(html){return html.replace(/&([#\w]+);/g,function(_,n){n=n.toLowerCase();if(n==="colon")return":";if(n.charAt(0)==="#"){return n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1))}return""})}function replace(regex,opt){regex=regex.source;opt=opt||"";return function self(name,val){if(!name)return new RegExp(regex,opt);val=val.source||val;val=val.replace(/(^|[^\[])\^/g,"$1");regex=regex.replace(name,val);return self}}function noop(){}noop.exec=noop;function merge(obj){var i=1,target,key;for(;iAn error occured:

    "+escape(e.message+"",true)+"
    "}throw e}}marked.options=marked.setOptions=function(opt){merge(marked.defaults,opt);return marked};marked.defaults={gfm:true,tables:true,breaks:false,pedantic:false,sanitize:false,smartLists:false,silent:false,highlight:null,langPrefix:"lang-",smartypants:false,headerPrefix:"",renderer:new Renderer,xhtml:false};marked.Parser=Parser;marked.parser=Parser.parse;marked.Renderer=Renderer;marked.Lexer=Lexer;marked.lexer=Lexer.lex;marked.InlineLexer=InlineLexer;marked.inlineLexer=InlineLexer.output;marked.parse=marked;if(typeof module!=="undefined"&&typeof exports==="object"){module.exports=marked}else if(typeof define==="function"&&define.amd){define(function(){return marked})}else{this.marked=marked}}).call(function(){return this||(typeof window!=="undefined"?window:global)}()); From 8e893b22aa4b040293b7f8dab8b11085042231e8 Mon Sep 17 00:00:00 2001 From: kiswa Date: Mon, 20 Oct 2014 18:23:44 -0400 Subject: [PATCH 6/7] Automatic actions allow 'Uncategorized' and 'Unassigned'. Resolves #5. --- VERSION | 12 ++- api/helpers.php | 35 +++---- js/controllers/settingsAutoActions.js | 132 +++++++++++++++----------- partials/settingsAutoActions.html | 4 +- readme.md | 6 +- 5 files changed, 111 insertions(+), 78 deletions(-) diff --git a/VERSION b/VERSION index 1474d00..4f96966 100644 --- a/VERSION +++ b/VERSION @@ -1 +1,11 @@ -v0.2.0 +v0.2.1 + +Changelog + + * Supports nginx (@alex3305) + * Supports use in Docker (Ubuntu Trusty & nginx - @alex3305) + * Build scripts executable by default (@niedzielski) + * Automatic Actions now allow "Unassigned" and "Uncategorized" for changing assignee or category (Issue #5) + * Links in item descriptions open in new tab (Issue #18) + * Lanes are now Columns to match common Kanban terminology (Issue #4) + * Any exception in API is handled and returns a 503 (inspired by @amalfra) diff --git a/api/helpers.php b/api/helpers.php index 55f0f03..30a27d0 100644 --- a/api/helpers.php +++ b/api/helpers.php @@ -1,19 +1,20 @@ $value) { - if (substr($name, 0, 5) == 'HTTP_') { - $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; - } - } - - return $headers; - } -} +if (!function_exists('getallheaders')) { + function getallheaders() { + $headers = ''; + + foreach ($_SERVER as $name => $value) { + if (substr($name, 0, 5) == 'HTTP_') { + $headers[str_replace(' ', '-', ucwords(strtolower( + str_replace('_', ' ', substr($name, 5)) + )))] = $value; + } + } + + return $headers; + } +} // Log an action. If $itemId is set, it is an item action. function logAction($comment, $oldValue, $newValue, $itemId=null) { @@ -344,12 +345,14 @@ function runAutoActions(&$item) { } break; case 1: // Item assigned to user - if ($item->assignee == $action->secondaryId) { + if ($item->assignee == $action->secondaryId || + ($action->secondaryId == 0 && $item->assignee == null)) { updateItemFromAction($item, $action); } break; case 2: // Item assigned to category - if ($item->category == $action->secondaryId) { + if ($item->category == $action->secondaryId || + ($action->secondaryId == 0 && $item->category == null)) { updateItemFromAction($item, $action); } break; diff --git a/js/controllers/settingsAutoActions.js b/js/controllers/settingsAutoActions.js index 33b3cd3..db7a167 100644 --- a/js/controllers/settingsAutoActions.js +++ b/js/controllers/settingsAutoActions.js @@ -4,6 +4,10 @@ function ($scope, $interval, BoardService) { $scope.loadingActions = true; $scope.actions = []; + $scope.secondarySelection = []; + $scope.boardCategories = [{ id: 0, name: 'Uncategorized' }]; + $scope.userList = [{ id: 0, name: 'Unassigned', username: 'Unassigned' }]; + $scope.actionData = { isSaving: false, board: null, @@ -17,58 +21,72 @@ function ($scope, $interval, BoardService) { }; $scope.actionDeleting = []; + $scope.actionTypes = [ + { id: 0, action: 'Set item color' }, + { id: 1, action: 'Set item category'}, + { id: 2, action: 'Set item assignee' }, + { id: 3, action: 'Clear item due date' } + ]; $scope.actionOptions = { triggers: [ { id: 0, - trigger: 'Item moves to lane', - actions: [ - { id: 0, action: 'Set item color' }, - { id: 1, action: 'Set item category'}, - { id: 2, action: 'Set item assignee' }, - { id: 3, action: 'Clear item due date' } - ] + trigger: 'Item moves to lane' }, { id: 1, - trigger: 'Item assigned to user', - actions: [ - { id: 0, action: 'Set item color' }, - { id: 1, action: 'Set item category'}, - { id: 3, action: 'Clear item due date' } - ] + trigger: 'Item assigned to user' }, { id: 2, - trigger: 'Item set to category', - actions: [ - { id: 0, action: 'Set item color' }, - { id: 2, action: 'Set item assignee' }, - { id: 3, action: 'Clear item due date' } - ] + trigger: 'Item set to category' } ] }; var getBoardData = function(boardId) { - if (null === boardId || undefined === boardId) - { - return; - } - - var boardData; - $scope.boards.forEach(function(board) { - if (board.id === boardId) { - boardData = board; + if (null === boardId || undefined === boardId) + { + return; } - }); - return boardData; - }, + var boardData; + $scope.boards.forEach(function(board) { + if (board.id === boardId) { + boardData = board; + } + }); + + return boardData; + }, + + getCategories = function(boardData) { + var categories = [{ id: '0', name: 'Uncategorized' }]; + + if (boardData) { + boardData.ownCategory.forEach(function(category) { + categories.push(category); + }); + } + return categories; + }, + + getUsers = function(boardData) { + var userList = [{ id: '0', name: 'Unassigned', username: 'Unassigned' }]; + + if (boardData) { + boardData.sharedUser.forEach(function(user) { + userList.push({ id: user.id, name: user.username }); + }); + } + return userList; + }, getSecondaryText = function(action) { var text = ': ', - actionBoard = getBoardData(action.board_id); + actionBoard = getBoardData(action.board_id), + boardCategories = getBoardData(actionBoard), + userList = getUsers(actionBoard); switch(parseInt(action.trigger_id)) { case 0: // Lane @@ -79,14 +97,14 @@ function ($scope, $interval, BoardService) { }); break; case 1: // User - actionBoard.sharedUser.forEach(function(user) { + userList.forEach(function(user) { if (user.id === action.secondary_id) { - text += user.username; + text += user.name; } }); break; case 2: // Category - actionBoard.ownCategory.forEach(function(category) { + boardCategories.forEach(function(category) { if (category.id === action.secondary_id) { text += category.name; } @@ -98,41 +116,44 @@ function ($scope, $interval, BoardService) { getActionText = function(action) { var text = '', - actionBoard = getBoardData(action.board_id); + actionBoard = getBoardData(action.board_id), + boardCategories = getCategories(actionBoard), + userList = getUsers(actionBoard); + switch(parseInt(action.action_id)) { case 0: // Color text = ': ' + action.color; break; case 1: // Category - actionBoard.ownCategory.forEach(function(category) { + boardCategories.forEach(function(category) { if (category.id === action.category_id) { text = ': ' + category.name; } }); break; case 2: // Assignee - actionBoard.sharedUser.forEach(function(user) { + userList.forEach(function(user) { if (user.id === action.assignee_id) { - text = ': ' + user.username; + text = ': ' + user.name; } }); break; } return text; - }; + }, - $scope.updateAutoActions = function(actions) { + updateAutoActions = function(actions) { if (!actions) { return; } - var mappedActions = []; + var mappedActions = []; actions.forEach(function(action) { mappedActions.push({ id: action.id, board: $scope.boardLookup[action.board_id], trigger: $scope.actionOptions.triggers[action.trigger_id].trigger + getSecondaryText(action), - action: $scope.actionOptions.triggers[0].actions[action.action_id].action + getActionText(action) + action: $scope.actionTypes[action.action_id].action + getActionText(action) }); }); @@ -142,8 +163,9 @@ function ($scope, $interval, BoardService) { $scope.loadActions = function() { BoardService.getAutoActions() .success(function(data) { - $scope.updateAutoActions(data.data); + updateAutoActions(data.data); $scope.loadingActions = false; + $scope.loadActions(); }); }; @@ -157,8 +179,12 @@ function ($scope, $interval, BoardService) { $scope.addAction = function() { if ($scope.actionData.secondary === null || ($scope.actionData.action !== 3 && - ($scope.actionData.color === null && $scope.actionData.category === null && $scope.actionData.assignee === null))) { - $scope.alerts.showAlert({ type: 'error', text: 'One or more required fields are not entered. Automatic Action not added.' }); + ($scope.actionData.color === null && $scope.actionData.category === null && + $scope.actionData.assignee === null))) { + $scope.alerts.showAlert({ + type: 'error', + text: 'One or more required fields are not entered. Automatic Action not added.' + }); return; } @@ -183,17 +209,14 @@ function ($scope, $interval, BoardService) { }); }; - $scope.secondarySelection = []; $scope.updateSecondary = function() { $scope.secondarySelection = []; $scope.actionData.secondary = null; $scope.actionData.action = 0; var boardData = getBoardData($scope.actionData.board); - if (boardData) { - $scope.boardCategories = boardData.ownCategory; - $scope.userList = boardData.sharedUser; - } + $scope.boardCategories = getCategories(boardData); + $scope.userList = getUsers(boardData); if (boardData) { switch($scope.actionData.trigger) { @@ -201,13 +224,10 @@ function ($scope, $interval, BoardService) { $scope.secondarySelection = boardData.ownLane; break; case 1: - $scope.secondarySelection = boardData.sharedUser; - $scope.secondarySelection.forEach(function(user) { - user.name = user.username; - }); + $scope.secondarySelection = $scope.userList; break; case 2: - $scope.secondarySelection = boardData.ownCategory; + $scope.secondarySelection = $scope.boardCategories; break; } } diff --git a/partials/settingsAutoActions.html b/partials/settingsAutoActions.html index 35ab81a..ff6b37e 100644 --- a/partials/settingsAutoActions.html +++ b/partials/settingsAutoActions.html @@ -60,7 +60,7 @@
    @@ -83,7 +83,7 @@ diff --git a/partials/boardItemViewModal.html b/partials/boardItemViewModal.html index ff5830f..8d7abb0 100644 --- a/partials/boardItemViewModal.html +++ b/partials/boardItemViewModal.html @@ -25,7 +25,7 @@

    Category: {{ categories[viewItem.category] }}

    -

    Current Lane: {{ viewItem.laneName }}

    +

    Current Column: {{ viewItem.laneName }}

    diff --git a/partials/settingsBoardModal.html b/partials/settingsBoardModal.html index bd25605..ccec29a 100644 --- a/partials/settingsBoardModal.html +++ b/partials/settingsBoardModal.html @@ -17,7 +17,7 @@
    -
    Lanes
    +
    Columns
    • @@ -32,7 +32,7 @@
    - diff --git a/partials/settingsBoardTable.html b/partials/settingsBoardTable.html index 6edf8bd..fc1b485 100644 --- a/partials/settingsBoardTable.html +++ b/partials/settingsBoardTable.html @@ -4,7 +4,7 @@ - +
    NameLanesCategoriesUsersActionsNameColumnsCategoriesUsersActions