Просмотр исходного кода

added p5:string with format by value param - Zaliczka.status

Piotr Labudda 9 лет назад
Родитель
Сommit
b2630b7c3f

+ 9 - 0
SE/schema/gui/core/default_db.zaliczka_wniosek_info_view.php

@@ -5,6 +5,15 @@ class Schema__Core__default_db__zaliczka_wniosek_info_view extends Schema_TableB
 	public function initTypes() {
 		parent::initTypes();
 		$this->_types['KWOTA'] = 'p5:price';
+		$this->_types['status'] = 'p5:string';
+		$this->_params['status'] = [
+			'formatByValue' => [
+				'Oczekuje zatwierdzenia' => '<div class="cell-A_STATUS-WAITING" style="padding:0 6px; overflow:hidden">{0}</div>',
+				'Zatwierdzony' => '<div class="cell-A_STATUS-NORMAL" style="padding:0 6px; overflow:hidden">{0}</div>',
+				'Anulowany' => '<div class="cell-A_STATUS-DELETED" style="padding:0 6px; overflow:hidden">{0}</div>',
+				'Odrzucony' => '<div class="cell-A_STATUS-OFF_HARD" style="padding:0 6px; overflow:hidden">{0}</div>',
+			]
+		];
 	}
 
   public function getPrimaryKeyField() {

+ 22 - 0
SE/se-lib/TableAjax.php

@@ -963,6 +963,19 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 						}
 					}(fldName, fieldProps));
 					break;
+				case "p5:string":// @return String
+					fieldWidget = (function(fldName, fieldProps) {
+						var _fieldName = fldName,
+								_fieldProps = fieldProps,
+								_formatByValue = _.get(_fieldProps, 'formatByValue', null);
+						return function(val, fieldPK, row) {
+							if (_formatByValue && val in _formatByValue) {
+								return _formatByValue[val].f(val)
+							}
+							return val;
+						}
+					}(fldName, fieldProps));
+					break;
 				case "p5:www_link":// @return Element
 					fieldWidget = (function(fldName, fieldProps) {
 						var _fieldName = fldName,
@@ -1676,6 +1689,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 								break;
 						case "p5:price":
 						case "p5:www_link":
+						case "p5:string":
 						case "string":
 								if (placeHolder == undefined) placeHolder = priv.options.types.string.placeHolder;
 								placeHolder = (placeHolder === true || placeHolder == undefined) ? '%' : placeHolder === false ? '' : placeHolder;
@@ -6059,6 +6073,14 @@ jQuery(document).ready(function(){
 							case 'ind': $columnConfig->type = 'number'; break;// TODO: bug 'ind'?
 						}
 						break;
+					case 'p5':
+						switch ($ex[1]) {
+							case 'string': {
+								$columnConfig->type = 'p5:string';
+								$columnConfig->formatByValue = $acl->getXsdFieldParam($col, 'formatByValue');
+							} break;
+						}
+						break;
 				}
 			}