From 227c472c36476dd885996aa5e9fcc627ab031457 Mon Sep 17 00:00:00 2001 From: Evangelos Vlachogiannis Date: Tue, 12 Aug 2014 15:34:54 +0200 Subject: [PATCH 1/4] tests-run page: Showing 51 of ... test cases, #64 --- js/testunit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/testunit.js b/js/testunit.js index d334bae..e1837b9 100644 --- a/js/testunit.js +++ b/js/testunit.js @@ -601,9 +601,9 @@ TestUnit.loadTestsTree = function (){ } $(".testsOnPage").html(countTests); TestUnit.viewTestUnitIdList(); - accessdb.API.TEST.countAll(function(error, data, status){ - if(data) - $(".tests_count_all").html(data); + accessdb.API.TEST.countAll(function(res){ + if(res) + $(".tests_count_all").html(res); }); $.treevue(data.children, filter.page+"-teststree", {useAria: false}).appendTo('#thetestsTreeDiv'); Utils.loadingEnd(".webTechTreeDiv"); From b6d856b197beb35b7b7e12737f4cc9d6ddc0abf0 Mon Sep 17 00:00:00 2001 From: Evangelos Vlachogiannis Date: Tue, 12 Aug 2014 15:39:43 +0200 Subject: [PATCH 2/4] tests-run page: Showing 51 of ... test cases, #64 --- js/testunit.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/testunit.js b/js/testunit.js index e1837b9..d334bae 100644 --- a/js/testunit.js +++ b/js/testunit.js @@ -601,9 +601,9 @@ TestUnit.loadTestsTree = function (){ } $(".testsOnPage").html(countTests); TestUnit.viewTestUnitIdList(); - accessdb.API.TEST.countAll(function(res){ - if(res) - $(".tests_count_all").html(res); + accessdb.API.TEST.countAll(function(error, data, status){ + if(data) + $(".tests_count_all").html(data); }); $.treevue(data.children, filter.page+"-teststree", {useAria: false}).appendTo('#thetestsTreeDiv'); Utils.loadingEnd(".webTechTreeDiv"); From d712a6a1a53ba9d7a85d9622455d615f9f85cfb6 Mon Sep 17 00:00:00 2001 From: Evangelos Vlachogiannis Date: Tue, 12 Aug 2014 15:41:36 +0200 Subject: [PATCH 3/4] lib add --- js/lib/jquery.multiFieldExtender-2.0.js | 197 ++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 js/lib/jquery.multiFieldExtender-2.0.js diff --git a/js/lib/jquery.multiFieldExtender-2.0.js b/js/lib/jquery.multiFieldExtender-2.0.js new file mode 100644 index 0000000..6f7243e --- /dev/null +++ b/js/lib/jquery.multiFieldExtender-2.0.js @@ -0,0 +1,197 @@ +/* + jQuery plugin to add functionality to your forms to add multiple records on single click on the fly using client side javascript + author: Vipul Limbachiya + http://vipulilmbachiya.com + */ + +/* + * This program is free software. It comes without any warranty, to the extent permitted by applicable law. + * You can redistribute it and/or modify it without any terms. + * Save developers, use Firefox http://firefox.com + */ + +(function ($) { + $.fn.EnableMultiField = function (options) { + options = $.extend({ + linkText: 'Add more', + linkClass: 'addMoreFields', + enableRemove: true, + removeLinkText: 'Remove', + removeLinkClass: 'removeFields', + confirmOnRemove: true, + confirmationMsgOnRemove: 'Are you sure you wish to remove selected field(s)?', + beforeAddEventCallback: null, + addEventCallback: null, + removeEventCallback: null, + maxItemsAllowedToAdd: null, + maxItemReachedCallback: null, + data: [] + }, + options); + + return this.each(function () { + var self = $(this); + + $(self).attr("TotalFieldsAdded", "0"); + + $(self).attr("maxCountReached", "false"); + + $(self).attr("FieldCount", "0"); + + $(self).attr("uniqueId", options.linkClass + Math.random()); + + $(self).find("." + options.linkClass).remove(); + + $(self).find("." + options.removeLinkClass).remove(); + + $(self).append(" " + options.linkText + ""); + + $(self).find("." + options.linkClass).unbind("click").click(function () { + return handleAdd($(this)); + }); + + var myClone = $(self).clone(); + + if (options.data.length > 0) { + var $curElem = $(self); + for (var i = 0; i < options.data.length; i++) { + $curElem.find("input,select,textarea").each(function () { + var itemName = $(this).attr("recName"); + $(this).val(options.data[i][itemName]); + }); + $curElem.find("." + options.linkClass).trigger("click"); + $curElem = $curElem.next(); + } + } + + function handleAdd(elem) { + if (options.beforeAddEventCallback !== null) { + if (!options.beforeAddEventCallback(self)) { + return false; + } + } + var totalCount = parseInt($(self).attr("TotalFieldsAdded"), 10); + var fieldCount = parseInt($(self).attr("FieldCount"), 10); + if (options.maxItemsAllowedToAdd === null || totalCount < options.maxItemsAllowedToAdd) { + var newElem = myClone.clone(); + + $(newElem).find("*[id!=''][name!='']").each(function () { + if ($(this).attr("id")) { + var strid = $(this).attr("id"); + var strname = ""; + + if ($(this).attr("name")) { + strname = $(this).attr("name"); + } + + $(this).attr("id", strid + "_" + fieldCount); + $(this).attr("name", strname + "$" + fieldCount); + } + }); + + totalCount++; + fieldCount++; + + $(self).attr("TotalFieldsAdded", totalCount); + $(self).attr("FieldCount", fieldCount); + + $(newElem).removeAttr("uniqueId"); + + if (options.enableRemove && $(self).attr("uniqueId") != $(elem).parent().attr("uniqueId")) { + if ($(elem).parent().find("." + options.removeLinkClass).length === 0) { + $(elem).parent().append(" " + options.removeLinkText + ""); + } + $(elem).parent().find("." + options.removeLinkClass).unbind("click").click(function () { + return handleRemove($(this)); + }); + } + + $(newElem).attr("uniqueId", options.linkClass + Math.random()); + + $(elem).parent().after(newElem); + + $(elem).parent().find("." + options.linkClass).remove(); + + $(newElem).find("." + options.linkClass).remove(); + $(newElem).find("." + options.removeLinkClass).remove(); + + if (options.enableRemove) { + if ($(newElem).find("." + options.removeLinkClass).length === 0) { + $(newElem).append(" " + options.removeLinkText + ""); + } + $(newElem).find("." + options.removeLinkClass).unbind("click").click(function () { + return handleRemove($(this)); + }); + } + + $(self).attr("maxCountReached", "false"); + + $(newElem).append(" " + options.linkText + ""); + + newElem.find("." + options.linkClass).unbind("click").click(function () { + return handleAdd($(this)); + }); + + if (options.addEventCallback !== null) { + options.addEventCallback($(newElem), self); + } + } + + if (options.maxItemsAllowedToAdd !== null && totalCount >= options.maxItemsAllowedToAdd) { + newElem.find("." + options.linkClass).hide(); + + if (options.maxItemReachedCallback !== null) { + options.maxItemReachedCallback($(newElem), self); + } + } + + return false; + } + + function handleRemove(elem) { + var cnt = true; + + if (options.confirmOnRemove) { + cnt = confirm(options.confirmationMsgOnRemove); + } + if (cnt) { + var prevParent = $(elem).parent().prev(); + + var totalCount = parseInt($(self).attr("TotalFieldsAdded"), 10); + totalCount--; + + $(self).attr("TotalFieldsAdded", totalCount); + + if ($(elem).parent().find("." + options.linkClass).length > 0) { + if (options.enableRemove && $(self).attr("uniqueId") != $(prevParent).attr("uniqueId")) { + if ($(prevParent).find("." + options.removeLinkClass).length === 0) { + $(prevParent).append(" " + options.removeLinkText + ""); + } + + $(prevParent).find("." + options.removeLinkClass).unbind("click").click(function () { + return handleRemove($(this)); + }); + } + + $(prevParent).append(" " + options.linkText + ""); + + prevParent.find("." + options.linkClass).unbind("click").click(function () { + return handleAdd($(this)); + }); + } + + if (options.maxItemsAllowedToAdd !== null && totalCount < options.maxItemsAllowedToAdd) { + $(self).siblings().find("." + options.linkClass).show(); + } + + $(elem).parent().remove(); + + if (options.removeEventCallback !== null) { + options.removeEventCallback($(prevParent), self); + } + } + return false; + } + }); + }; +})(jQuery); \ No newline at end of file From 7a09c304f8f9e26e65255df5b6784cda8f102090 Mon Sep 17 00:00:00 2001 From: Evangelos Vlachogiannis Date: Tue, 12 Aug 2014 16:09:03 +0200 Subject: [PATCH 4/4] Change test ID to be more brief, could also be not first in reading order #59 --- js/router.js | 2 +- templates.html | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/router.js b/js/router.js index cb2c852..8c803be 100644 --- a/js/router.js +++ b/js/router.js @@ -74,7 +74,7 @@ window.accessdb.appRouter.on('route:results-technique', function (id) { }); window.accessdb.appRouter.on('route:results-test', function (id) { TestUnit.prototype.loadById(id, function(test){ - $(".results-test-id").html(test.testUnitId); + $(".results-test-id").html(Utils.stripTestID(test.testUnitId)); $(".results-test-title").html(test.title); }); this.params.testUnitId = id; diff --git a/templates.html b/templates.html index 8372cfa..3a08dee 100644 --- a/templates.html +++ b/templates.html @@ -1,5 +1,5 @@