[Git][noosfero/noosfero][master-1.x] 2 commits: custom-forms: avoid crash on migration due to empty string value
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Sep 3 15:48:36 BRT 2018
Rodrigo Souto pushed to branch master-1.x at Noosfero / noosfero
Commits:
bde41aaa by Rodrigo Souto at 2018-09-03T18:47:37Z
custom-forms: avoid crash on migration due to empty string value
- - - - -
ed402b36 by Rodrigo Souto at 2018-09-03T18:48:24Z
custom-forms: fix graph script to EC5
- - - - -
2 changed files:
- plugins/custom_forms/db/migrate/20180815152844_add_form_answers_on_old_answers.rb
- plugins/custom_forms/public/javascripts/graph.js
Changes:
=====================================
plugins/custom_forms/db/migrate/20180815152844_add_form_answers_on_old_answers.rb
=====================================
@@ -9,7 +9,7 @@ class AddFormAnswersOnOldAnswers < ActiveRecord::Migration
INNER JOIN custom_forms_plugin_fields AS f ON a.field_id = f.id
LEFT JOIN custom_forms_plugin_form_answers AS fa ON fa.answer_id = a.id
INNER JOIN custom_forms_plugin_alternatives AS al ON al.id IN
- (SELECT regexp_split_to_table(a.value, ',')::int) WHERE fa.id IS NULL
+ (SELECT regexp_split_to_table(nullif(a.value, ''), ',')::int) WHERE fa.id IS NULL
AND f.type = 'CustomFormsPlugin::SelectField';"
)
=====================================
plugins/custom_forms/public/javascripts/graph.js
=====================================
@@ -20,9 +20,9 @@
function legend(chart, chartIndex) {
var legendItems = chart.chart.legend.legendItems;
- let html = ``;
+ var html = '';
for (item in legendItems) {
- var legend_text = `<div style="display: flex; margin: unset; margin-right: 5px; margin-bottom: 5px;"><div style="width: 10px; height: 10px; background: ${legendItems[item].fillStyle}; margin-right: 5px;"></div><span style="width: 130px; display: inline-block; font-size: 11px;">${legendItems[item].text} </span></div>`
+ var legend_text = '<div style="display: flex; margin: unset; margin-right: 5px; margin-bottom: 5px;"><div style="width: 10px; height: 10px; background: ${legendItems[item].fillStyle}; margin-right: 5px;"></div><span style="width: 130px; display: inline-block; font-size: 11px;">' + legendItems[item].text + '</span></div>'
html += legend_text;
}
document.getElementById("legend-" + chartIndex).innerHTML = html;
@@ -38,24 +38,24 @@
total += context.dataset.data[i];
}
var tooltipPercentage = Math.round((value / total) * 100);
-
- return `${tooltipPercentage}%`;
+
+ return tooltipPercentage + '%';
};
-
+
Chart.defaults.global.plugins.datalabels.display = function (context) {
- return context.dataset.data[context.dataIndex] !== 0;
+ return context.dataset.data[context.dataIndex] !== 0;
}
-
+
const charts = Chartkick.charts;
const chartPrefix = "chart-";
var chartIndex = 1;
-
+
while (true){
var chart = charts[chartPrefix + chartIndex];
legend(chart, chartIndex);
if (typeof chart == "undefined")
break;
-
+
var graph = chart.getChartObject();
if (graph.config.type == 'pie' || graph.config.type == 'bar') {
chart.redraw();
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/217db470cc80505f7cf6f297937e559dbfa13e84...ed402b36c0b18813085efde1baa4c03613ff690a
--
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/217db470cc80505f7cf6f297937e559dbfa13e84...ed402b36c0b18813085efde1baa4c03613ff690a
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180903/58f39599/attachment-0001.html>
More information about the Noosfero-dev
mailing list