Skip to content
Snippets Groups Projects
Commit a24fa458 authored by Mike Feranda's avatar Mike Feranda
Browse files

Issue #3402526: Improve valueSend and change JS to allow look-ups

parent 521ddb78
Branches
Tags 8.x-1.0-rc11
1 merge request!10Update aggrid.widget.js
/**
* Behavior for 'aggrid_widget_type' widget.
*/
(function ($, Drupal, drupalSettings, once) {
var aggrid = (function (me, $, Drupal, drupalSettings, once) {
me.name = "aggrid";
'use strict';
var aggridFieldName = [];
var aggridDataEdit = [];
......@@ -849,16 +850,18 @@
valueGot = eval(valueGetterItems);
// Update the cell value.
if (gridOptions[item].rowData[params.node.id][params.column.colId] != valueGot) {
gridOptions[item].rowData[params.node.id][params.column.colId] = valueGot;
// If good and needs to be sent, send it.
valueSendFunc(params, valueGot);
makeJson(item); // Make sure the rowData output is updated.
// Return it
return valueGot;
}
else {
}
// else, just return the current value.
return params.data[params.column.colId];
}
}
function valueParserFunc(params) {
let ptName;
......@@ -1079,7 +1082,6 @@
// Used with valueSend JSON item to send values to another aggrid on the same node.
function valueSendFunc(params, cellValue) {
let valueSendItems;
let valueSet;
// Auto value change when needed.
let rscParamsRowId;
let rscParamsColDefField;
......@@ -1111,27 +1113,49 @@
// Look up the other grid and assign the variables.
let t = $('div[data-aggrid-id="' + value['aggrid_id'] + '"]').attr('id');
let i = (value['id'] == 'params.node.id') ? params.node.id : value['id'];
let f = (value['field'] == '[this]') ? params.column.colId : value['field'];
let f = (value['field'] == '[this]') ? params.column.colId : value['field'];
let g = gridOptions[t];
// Check if gridOption exists.
// @todo need to add proper error messages.
// Check if gridOption exists.F
if (typeof g !== 'undefined') {
let rowNode = g.api.getRowNode(i);
// Check if rowNode exists.
if (typeof rowNode !== 'undefined') {
if (f !== '') {
// Found... change the values and refresh.
rowNode['data'][f] = cellValue;
g.api.refreshCells();
rowNode.setDataValue(f, cellValue);
return true;
} else {
console.log(
Drupal.t(
'valueSend function on [' + params.node.id + '][' + params.column.colId + '] missing field name.', {}, {
context: 'aggrid error on valueSend'
}
)
);
}
} else {
console.log(
Drupal.t(
'valueSend function on [' + params.node.id + '][' + params.column.colId + '] row not found.', {}, {
context: 'aggrid error on valueSend'
}
)
);
}
} else {
console.log(
Drupal.t(
'valueSend function on [' + params.node.id + '][' + params.column.colId + '] missing row number.', {}, {
context: 'aggrid error on valueSend'
}
)
);
}
});
return true;
}
else {
// Issue
return false;
}
}
// #######
// ####### Context Menu Items
......@@ -1500,7 +1524,7 @@
}
};
Drupal.behaviors.HtmlIntegration = {
Drupal.behaviors.aggridHtmlIntegration = {
attach: function (context) {
// Make sure to only run once per page for each item.
......@@ -1577,4 +1601,7 @@
// No submit on aggrid with enter (allow enter cell for edit).
if (e.keyCode === 13) { e.preventDefault(); }
});
})(jQuery, Drupal, drupalSettings, once);
me.gridOptions = gridOptions;
return me;
})(aggrid || {}, jQuery, Drupal, drupalSettings, once);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment