diff --git a/.travis.yml b/.travis.yml index 2de36029c..b604be88a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ branches: only: - master - /quarter\d*/ + - develop + - /2.\d*.\d*/ env: - TEST_SUITE=rspec - TEST_SUITE=cucumber diff --git a/app/assets/javascripts/transam_core/flyout.js b/app/assets/javascripts/transam_core/flyout.js new file mode 100644 index 000000000..49e438fbb --- /dev/null +++ b/app/assets/javascripts/transam_core/flyout.js @@ -0,0 +1,24 @@ +// function closeFlyout() { +// for(var elem of document.getElementsByClassName("closeFlyout")){ +// elem.addEventListener("click", function(){ +// this.form.reset(); +// }); +// } +// } + + +function createFlyout(elem, before, append) { + $(document).ready(function(){ + before; + $(elem + ":empty").append(append); + }); +} + +function toggleExtend(trigger, elem, isRight) { + if (isRight) { + $(trigger).on('click', function() {$(elem).toggleClass( "extend-right" )}); + } else { + $(trigger).on('click', function() {$(elem).toggleClass( "extend-left" )}); + elem.scrollLeft = window.innerWidth; + } +} \ No newline at end of file diff --git a/app/assets/javascripts/transam_core/table-library/export.js b/app/assets/javascripts/transam_core/table-library/export.js new file mode 100644 index 000000000..bac5eabc9 --- /dev/null +++ b/app/assets/javascripts/transam_core/table-library/export.js @@ -0,0 +1,86 @@ +$(document).on('click', ".export_option", function(event){ + event.stopPropagation(); + const id = $(this).closest(".library-table").find("table").eq(0).attr('id'); + if($(this).text().trim() === "csv") { + $(this).attr({ 'download': "output.csv", 'href': export_table(id, $(this).text().trim()), 'target': '_blank' }); + } else if($(this).text().trim() === "txt") { + $(this).attr({ 'download': "output.txt", 'href': export_table(id, $(this).text().trim()), 'target': '_blank' }); + } else if($(this).text().trim() === "excel") { + $(this).attr({ 'download': "output.xls", 'href': export_table(id, $(this).text().trim()), 'target': '_blank' }); + } + $(this).closest('.export').eq(0).removeClass("open"); +}); + + + + + +function export_table(id, type) { + const table = $('#'+id); + const header = table.find("tr:has(th)").eq(0).find(".header-item:not(.header-checkbox)"); + let rows = []; + if($('#' + id + '_export_checkbox').is(':checked')) { + rows = table.find(".row-checked:has(td)"); + } else { + rows = table.find("tr:has(td)"); + } + let csv = ""; + for(let cell of header){ + csv = csv + $(cell).find(".header-text").text().replace(/,/g, '') + ","; + } + csv = csv + '\n'; + for(let row of rows){ + for(let c of $(row).find(".row-item")) { + if($(c).hasClass("action-column")) { + continue; + } else if($(c).hasClass("checkmark-column")) { + csv = csv + (($(c).find(".cell-text i").css("visibility") == "visible")? "Yes,": "No,"); + } else { + csv = csv + $(c).find(".cell-text").text().replace(/,/g, '') + ","; + } + } + csv = csv + '\n'; + } + if(type === "csv") { + csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv); + return csvData; + } else if(type === "txt") { + csvData = 'data:application/txt;charset=utf-8,' + encodeURIComponent(csv); + return csvData; + } else if(type === "excel") { + csvData = 'data:application/xls;charset=utf-8,' + encodeURIComponent(csv); + return csvData; + } + +} + +function init_export(id, types) { + const table = $('#'+id); + $(document).ready(function(){ + let wrapper = $('