Jelajahi Sumber

fixed inline edit form value, added restrictions

Piotr Labudda 10 tahun lalu
induk
melakukan
23bb8a5dcf

+ 6 - 1
SE/schema/gui/Schema_TableBase.php

@@ -5,13 +5,15 @@ class Schema_TableBase {
 
 	public function __construct() {
 		$this->_types = array();
+		$this->_restrictions = array();
 		$this->initTypes();
 	}
 
 	public function initTypes() {// TODO: override
 		// parent::initTypes();// always call parent method
 		// example: $this->_types['WWW'] = 'p5:www_link';
-		// TODO: $this->_types['WWW'] = new Type_Link($params = array('maxLength' => 255, ...));
+		// example: $this->_restrictions['WWW'] = ['maxLength' => 255]
+		// TODO:? $this->_types['WWW'] = new Type_Link($params = ['maxLength' => 255, ...]);
 	}
 
 	public function fixTypes($types) {
@@ -20,6 +22,9 @@ class Schema_TableBase {
 			if (array_key_exists($fldName, $this->_types)) {
 				$types[$fldName]['simpleType'] = $this->_types[$fldName];
 			}
+			if (array_key_exists($fldName, $this->_restrictions)) {
+				$types[$fldName]['restrictions'] = $this->_restrictions[$fldName];
+			}
 		}
 		return $types;
 	}

+ 2 - 0
SE/schema/gui/company/biuro_biall_net_pl/default_db.test_perms.php

@@ -5,7 +5,9 @@ class Schema__biuro_biall_net_pl__default_db__test_perms extends Schema__Core__d
 	public function initTypes() {
 		parent::initTypes();
 		//$this->_types['WWW'] = 'p5:www_link';
+		//$this->_restrictions['WWW'] = array('maxLength' => 255);
 		$this->_types['KATALOG_LINK'] = 'p5:www_link';
+		$this->_restrictions['KATALOG_LINK'] = array('maxLength' => 255);
 	}
 
 }

+ 1 - 0
SE/schema/gui/core/default_db.test_perms.php

@@ -5,6 +5,7 @@ class Schema__Core__default_db__test_perms extends Schema_TableBase {
 	public function initTypes() {
 		parent::initTypes();
 		$this->_types['WWW'] = 'p5:www_link';
+		$this->_restrictions['WWW'] = array('maxLength' => 255);
 	}
 
 }

+ 11 - 8
SE/se-lib/TableAcl.php

@@ -44,7 +44,7 @@ class TableAcl {
 	public function setName($name) {
 		$this->_name = $name;
 	}
-	
+
 	public function setNameByTableId($tableID) {
 		//used for init without knowing table name
 		$db = DB::getDB();
@@ -231,7 +231,7 @@ class TableAcl {
 	}
 
 	/**
-	 * 
+	 *
 	 */
 	public function canWriteRecord($record) {
 
@@ -369,6 +369,9 @@ class TableAcl {
 
 		$item = array();
 		$item['htmlType'] = '';
+		$item['value'] = $fValue;
+		$item['canRead']  = $this->isAllowed($fieldID, 'R', $record);
+		$item['canWrite'] = $this->isAllowed($fieldID, 'W', $record);
 		$item['rawColType'] = $colType;
 		return $item;
 
@@ -389,7 +392,7 @@ class TableAcl {
 		}
 		$maxGrid = V::get('maxGrid', 10, $params);
 
-		if (substr($colType['type'], 0, 3) == 'int' 
+		if (substr($colType['type'], 0, 3) == 'int'
 				|| substr($colType['type'], 0, 7) == 'tinyint'
 				|| substr($colType['type'], 0, 8) == 'smallint'
 				|| substr($colType['type'], 0, 6) == 'bigint'
@@ -636,7 +639,7 @@ class TableAcl {
 		}
 		$maxGrid = V::get('maxGrid', 10, $params);
 
-		if (substr($colType['type'], 0, 3) == 'int' 
+		if (substr($colType['type'], 0, 3) == 'int'
 				|| substr($colType['type'], 0, 7) == 'tinyint'
 				|| substr($colType['type'], 0, 8) == 'smallint'
 				|| substr($colType['type'], 0, 6) == 'bigint'
@@ -836,7 +839,7 @@ class TableAcl {
 
 	/**
 	* List table ids by database
-	* 
+	*
 	*
 	*/
 	public static function GetTablesByDbId($db) {
@@ -848,20 +851,20 @@ class TableAcl {
 	    		foreach($_SESSION['TableAcl_cache'] as $tableID=>$obj) {
 		    		//if($obj->db==$db)
 		    		 $return[$obj['name']]=$tableID;
-		    		
+
 	    		}
 	    		return $return;
 	    	}
 	    	return null;
 	}
 
-	
+
 
 
 	/**
 	 * Get column object. Not initialize
 	 * @returns object - column instance if exists else null
-	 * 
+	 *
 	 * static
 	 */
 	public static function getInstance($idTable) {

+ 10 - 3
SE/se-lib/TableAjax.php

@@ -856,7 +856,7 @@ class TableAjax extends ViewAjax {
 					case "string":
 						cellCnt.html(format.f(val));
 						break;
-					case "p5:www_link":
+					case "p5:www_link":// TODO: P5Type('www_link', columnProps.restrictions).renderTableCell(val)
 						if (val.length > 0) {
 							var linkPrefix = '';
 							if ('http' == val.substr(0, 4)) linkPrefix = '';
@@ -2874,7 +2874,13 @@ class TableAjax extends ViewAjax {
 							inlineEditBox$Node.find('.inlineEditBox-cnt').append(label);
 							var inLabel = jQuery('<strong title="[' + data.idZasob + '] ' + data.fieldLabel + '">' + data.fieldLabel + '</strong>');
 							label.append(inLabel);
-							var frmItem = jQuery('<input id="' + data.htmlFieldName + '" name="' + data.htmlFieldName + '" type="text" value="biall.com.pl" maxlength="255" style="width:98%;" class="form-control" />');
+							var frmItem = jQuery('<input>');
+							frmItem.attr('type', 'text');
+							frmItem.attr('name', data.htmlFieldName);
+							frmItem.attr('value', data.formItem.value);
+							frmItem.attr('maxlength', _.get(data, 'restrictions.maxLength', 255));
+							frmItem.attr('style', 'width:98%');
+							frmItem.attr('class', 'form-control');
 							frmItem.insertAfter(label);
 						} else {
 							if (data && data.legacy_html) {
@@ -2890,7 +2896,7 @@ class TableAjax extends ViewAjax {
 
 						inlineEditBox$Node.find('textarea').autosize();
 
-						var fld = inlineEditBox$Node.find('input[id^="f"]');
+						var fld = inlineEditBox$Node.find('input[name^="f"]');
 						if (fld.length > 0 && !fld.hasClass('se_type-date')) {
 							fld.keydown(function(event) {
 								if (event.which == 13) {
@@ -3905,6 +3911,7 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 				$item = $this->_acl->getFormItem('W', $fieldID, "f{$fieldID}", $fieldVal, $fieldParams, $row);
 				$response['formItem'] = $item;
 				if (!empty($item['rawColType']['simpleType'])) $response['simpleType'] = $item['rawColType']['simpleType'];
+				if (!empty($item['rawColType']['restrictions'])) $response['restrictions'] = $item['rawColType']['restrictions'];
 				echo '<div style="display:none">';
 				DBG::_(true, true, "item", $item, __CLASS__, __FUNCTION__, __LINE__);
 				echo '</div>';

File diff ditekan karena terlalu besar
+ 111 - 53
SE/stuff/lodash.min.js


Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini