|
@@ -66,6 +66,12 @@ function p5Utils__objectToQueryWithKeyPrefix(obj, prefix, callback) {
|
|
|
.join('&')
|
|
.join('&')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function p5Utils__multiReplaceValues(input, row) {
|
|
|
|
|
+ return Object.keys(row).reduce(function (ret, fieldName) {
|
|
|
|
|
+ return ret.replace(new RegExp('\{' + fieldName + '\}', 'g'), row[fieldName])
|
|
|
|
|
+ }, input)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
|
|
|
global['P5UI__TableAjaxSpecialFilter'] = createReactClass({
|
|
global['P5UI__TableAjaxSpecialFilter'] = createReactClass({
|
|
|
// props.store: Redux store with state: { isLoading bool, selected array of strings }
|
|
// props.store: Redux store with state: { isLoading bool, selected array of strings }
|
|
@@ -1326,8 +1332,8 @@ var TableAjax = function() {
|
|
|
break;
|
|
break;
|
|
|
case "p5:www_link":// @return Element
|
|
case "p5:www_link":// @return Element
|
|
|
fieldWidget = (function(fldName, fieldProps) {
|
|
fieldWidget = (function(fldName, fieldProps) {
|
|
|
- var _fieldName = fldName,
|
|
|
|
|
- _fieldProps = fieldProps;
|
|
|
|
|
|
|
+ var _fieldName = fldName;
|
|
|
|
|
+ var _fieldProps = fieldProps;
|
|
|
// console.log('FieldWidget: generate function to render field('+_fieldName+') ', fieldProps);
|
|
// console.log('FieldWidget: generate function to render field('+_fieldName+') ', fieldProps);
|
|
|
return function(val, fieldPK, row) {
|
|
return function(val, fieldPK, row) {
|
|
|
// console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value('+val+') ', fieldProps);
|
|
// console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value('+val+') ', fieldProps);
|
|
@@ -1358,6 +1364,45 @@ var TableAjax = function() {
|
|
|
}
|
|
}
|
|
|
}(fldName, fieldProps));
|
|
}(fldName, fieldProps));
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case "p5:link":// @return Element
|
|
|
|
|
+ fieldWidget = (function(fldName, fieldProps) {
|
|
|
|
|
+ var _fieldName = fldName;
|
|
|
|
|
+ var _fieldProps = fieldProps;
|
|
|
|
|
+ DBG && console.log('FieldWidget: generate function to render field('+_fieldName+') ', fieldProps);
|
|
|
|
|
+ return function(val, fieldPK, row) {
|
|
|
|
|
+ DBG && console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value('+val+') ', fieldProps);
|
|
|
|
|
+ // fieldProps._appInfo.simpleLink: {
|
|
|
|
|
+ // @href: "index.php?MENU_INIT=POKAZ_OFERTY_AKTUALNE_FUNC&task=activate_deal&id_deal={ID}"
|
|
|
|
|
+ // @label: "Aktywuj umowę {ID}"
|
|
|
|
|
+ // @target: "_blank"
|
|
|
|
|
+ if (!_fieldProps._appInfo.simpleLink) return 'BUG: missing _appInfo.simpleLink!';
|
|
|
|
|
+ if (!_fieldProps._appInfo.simpleLink['@label']) return 'BUG: missing _appInfo.simpleLink[@label]!';
|
|
|
|
|
+ var label = p5Utils__multiReplaceValues(_fieldProps._appInfo.simpleLink['@label'], row);
|
|
|
|
|
+ var relativeLink = p5Utils__multiReplaceValues(_fieldProps._appInfo.simpleLink['@href'], row);
|
|
|
|
|
+ if ('index.php' == relativeLink.substr(0, 9) || 'procesy5.php' == relativeLink.substr(0, 12)) {
|
|
|
|
|
+ link = window.location.protocol + '//' + window.location.hostname
|
|
|
|
|
+ link += window.location.pathname.split('/').slice(0, -1).join('/')
|
|
|
|
|
+ link += '/' + relativeLink
|
|
|
|
|
+ } else if ('http' == relativeLink.substr(0, 4)) {
|
|
|
|
|
+ link = relativeLink
|
|
|
|
|
+ // else if ('ftp' == val.substr(0, 3))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ link = 'http://' + relativeLink
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ var linkErrors = validate({www_link: link}, {www_link: {url: true}});
|
|
|
|
|
+ if (linkErrors) {
|
|
|
|
|
+ DBG && console.log('DBG:linkErrors (' + _fieldName + ': ' + link + ')', linkErrors);
|
|
|
|
|
+ return label;
|
|
|
|
|
+ }
|
|
|
|
|
+ fldNode = document.createElement('a');
|
|
|
|
|
+ fldNode.setAttribute('href', link);
|
|
|
|
|
+ if (_fieldProps._appInfo.simpleLink['@target']) fldNode.setAttribute('target', _fieldProps._appInfo.simpleLink['@target']);
|
|
|
|
|
+ fldNode.appendChild(document.createTextNode(label));
|
|
|
|
|
+ return fldNode;
|
|
|
|
|
+ }
|
|
|
|
|
+ }(fldName, fieldProps));
|
|
|
|
|
+ break;
|
|
|
case "special":
|
|
case "special":
|
|
|
fieldWidget = (function(fldName, fieldProps) {
|
|
fieldWidget = (function(fldName, fieldProps) {
|
|
|
var _fieldName = fldName;
|
|
var _fieldName = fldName;
|
|
@@ -1651,7 +1696,7 @@ var TableAjax = function() {
|
|
|
// TODO: support for ui-function in rowFunctions
|
|
// TODO: support for ui-function in rowFunctions
|
|
|
// var funObj = rowFunctions[key];
|
|
// var funObj = rowFunctions[key];
|
|
|
// var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false});
|
|
// var funcNode = p5UI_TableAjax_generateFunctionNode(funObj, rowPK, {ico: true, label: false});
|
|
|
- // DBG1 && console.log('TableAjax::renderCellRowFunctions: rowFunction[' + key + ']', { funObj: funObj, uiFunc: funObj['ui-function'], uiFuncExists: global[funObj['ui-function']] });
|
|
|
|
|
|
|
+ // DBG && console.log('TableAjax::renderCellRowFunctions: rowFunction[' + key + ']', { funObj: funObj, uiFunc: funObj['ui-function'], uiFuncExists: global[funObj['ui-function']] });
|
|
|
// if (funObj['ui-function'] && global[funObj['ui-function']]) {
|
|
// if (funObj['ui-function'] && global[funObj['ui-function']]) {
|
|
|
// funcNode.on('click', function (event) { event.preventDefault(); global[funObj['ui-function']](rowPK); });
|
|
// funcNode.on('click', function (event) { event.preventDefault(); global[funObj['ui-function']](rowPK); });
|
|
|
// }
|
|
// }
|