add event delegation to update after task, descriptive tip, other fixes related to empty fields

This commit is contained in:
i-break-codes 2016-11-21 22:37:36 +05:30
parent 640355c696
commit 5c53b11a26
5 changed files with 103 additions and 9 deletions

View File

@ -1,3 +1,14 @@
<!--
/**
* logerr
*
* @category scrum-board
* @author Vaibhav Mehta <vaibhav@decodingweb.com>
* @copyright Copyright (c) 2016 Vaibhav Mehta <https://github.com/i-break-codes>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0 Beta
*/
-->
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@ -87,7 +98,7 @@
</div> </div>
<div class="hide" id="tips"> <div class="hide" id="tips">
Double click on the task text to edit it Double click on the task text to edit it <br> <span>(Task titles are not editable for now)</span>
</div> </div>
<script id="task-card-template" type="text/x-handlebars-template"> <script id="task-card-template" type="text/x-handlebars-template">
@ -97,8 +108,12 @@
<h5>{{title}}</h5> <h5>{{title}}</h5>
<div class="card-details"> <div class="card-details">
<p data-field="description">{{description}}</p> <p data-field="description">{{description}}</p>
<p data-field="remote_url"><a href="{{#checkForBlank remote_url}}{{/checkForBlank}}" target="_blank">{{#checkForBlank remote_url}}{{/checkForBlank}}</a></p> <p data-field="remote_url">
<p data-field="assigned_to">{{#checkForBlank assigned_to}}{{/checkForBlank}}</p> {{#checkIfEmptyRemoteURL remote_url}}{{/checkIfEmptyRemoteURL}}
</p>
<p data-field="assigned_to">
{{#checkIfEmptyAssigned assigned_to}}{{/checkIfEmptyAssigned}}
</p>
</div> </div>
</div> </div>
{{/each}} {{/each}}

View File

@ -1,3 +1,13 @@
/**
* logerr
*
* @category scrum-board
* @author Vaibhav Mehta <vaibhav@decodingweb.com>
* @copyright Copyright (c) 2016 Vaibhav Mehta <https://github.com/i-break-codes>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0 Beta
*/
var App = function() { var App = function() {
function init() { function init() {
tips(); tips();
@ -51,7 +61,7 @@ var App = function() {
var keyVal = splitParams[i].split('='); var keyVal = splitParams[i].split('=');
obj[keyVal[0]] = unescape(keyVal[1]); obj[keyVal[0]] = unescape(keyVal[1]);
} }
// TODO: Add validations // TODO: Add validations
if(obj.description === '' || obj.title === '') { if(obj.description === '' || obj.title === '') {
return; return;
@ -82,7 +92,7 @@ var App = function() {
$(this).attr('contenteditable','true').parents('.card').addClass('edit-mode'); $(this).attr('contenteditable','true').parents('.card').addClass('edit-mode');
}); });
$('.card').find('p').on('input', function() { $(document).on('input', '.card p', function() {
var taskId = $(this).parents('.card').data('task-id'); var taskId = $(this).parents('.card').data('task-id');
var fieldToEdit = $(this).data('field'); var fieldToEdit = $(this).data('field');
var getTaskData = JSON.parse(LocalStorage.get('task-' + taskId)); var getTaskData = JSON.parse(LocalStorage.get('task-' + taskId));

View File

@ -1,3 +1,45 @@
Handlebars.registerHelper('checkForBlank', function(val, options) { /**
return (val !== '') ? val : '-'; * logerr
}); *
* @category scrum-board
* @author Vaibhav Mehta <vaibhav@decodingweb.com>
* @copyright Copyright (c) 2016 Vaibhav Mehta <https://github.com/i-break-codes>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0 Beta
*/
// TODO: Clearup this mess later and find a better way to handle blank fields
var Helper = function() {
function init() {
checkIfEmptyRemoteURL();
checkForEmptyAssign();
}
function checkIfEmptyRemoteURL() {
Handlebars.registerHelper('checkIfEmptyRemoteURL', function(val, options) {
if(val) {
return '<a href="' + val + '" target="_blank">' + val + '</a>';
} else {
return '-';
}
});
}
function checkForEmptyAssign() {
Handlebars.registerHelper('checkIfEmptyAssigned', function(val, options) {
if(val) {
return val;
} else {
return '-';
}
});
}
return {
init: init
}
}();
Helper.init();

View File

@ -1,3 +1,14 @@
/**
* logerr
*
* @category scrum-board
* @author Vaibhav Mehta <vaibhav@decodingweb.com>
* @copyright Copyright (c) 2016 Vaibhav Mehta <https://github.com/i-break-codes>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0 Beta
*/
var LocalStorage = function() { var LocalStorage = function() {
function set(key, val) { function set(key, val) {
localStorage.setItem(key, val); localStorage.setItem(key, val);

View File

@ -1,3 +1,14 @@
/**
* logerr
*
* @category scrum-board
* @author Vaibhav Mehta <vaibhav@decodingweb.com>
* @copyright Copyright (c) 2016 Vaibhav Mehta <https://github.com/i-break-codes>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0 Beta
*/
@import 'https://fonts.googleapis.com/css?family=Hind+Vadodara:300,400'; @import 'https://fonts.googleapis.com/css?family=Hind+Vadodara:300,400';
//Colors //Colors
@ -565,10 +576,15 @@ footer {
cursor: pointer; cursor: pointer;
background: { background: {
image: url('../images/info.svg'); image: url('../images/info.svg');
position: 4px center; position: 4px 12px;
size: 16px; size: 16px;
repeat: no-repeat; repeat: no-repeat;
} }
span {
font-size: 10px;
font-style: italic;
}
} }
@keyframes showTips { @keyframes showTips {