Browse Source

A fix to make editinplace working better

Laurent Destailleur 9 years ago
parent
commit
00118610bb

+ 2 - 2
htdocs/comm/propal/card.php

@@ -1836,9 +1836,9 @@ if ($action == 'create')
 	// Delivery date
 	$langs->load('deliveries');
 	print '<tr><td>';
-	print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer);
+	print $form->editfieldkey($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'datepicker');
 	print '</td><td colspan="5">';
-	print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'day');
+	print $form->editfieldval($langs->trans('DeliveryDate'), 'date_livraison', $object->date_livraison, $object, $user->rights->propal->creer, 'datepicker');
 	print '</td>';
 	print '</tr>';
 

+ 6 - 6
htdocs/core/class/html.form.class.php

@@ -74,10 +74,10 @@ class Form
      *
      * @param   string	$text			Text of label or key to translate
      * @param   string	$htmlname		Name of select field ('edit' prefix will be added)
-     * @param   string	$preselected            Value to show/edit (not used in this function)
+     * @param   string	$preselected    Value to show/edit (not used in this function)
      * @param	object	$object			Object
      * @param	boolean	$perm			Permission to allow button to edit parameter. Set it to 0 to have a not edited field.
-     * @param	string	$typeofdata		Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
+     * @param	string	$typeofdata		Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...)
      * @param	string	$moreparam		More param to add on a href URL*
      * @param   int     $fieldrequired  1 if we want to show field as mandatory using the fieldrequired CSS.
      * @return	string					HTML edit field
@@ -129,7 +129,7 @@ class Form
      * @param	string	$value			Value to show/edit
      * @param	object	$object			Object
      * @param	boolean	$perm			Permission to allow button to edit parameter
-     * @param	string	$typeofdata		Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'day' or 'datepicker', 'dayhour' or 'datepickerhour', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...)
+     * @param	string	$typeofdata		Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datepickerhour', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select:xxx'...)
      * @param	string	$editvalue		When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of value). Use '' to use same than $value
      * @param	object	$extObject		External object
      * @param	mixed	$custommsg		String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
@@ -254,7 +254,7 @@ class Form
      * @param	string	$value			Value to show/edit
      * @param	string	$htmlname		DIV ID (field name)
      * @param	int		$condition		Condition to edit
-     * @param	string	$inputType		Type of input ('string', 'numeric', 'datepicker', 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx')
+     * @param	string	$inputType		Type of input ('string', 'numeric', 'datepicker' ('day' do not work, don't know why), 'textarea:rows:cols', 'ckeditor:dolibarr_zzz:width:height:?:1:rows:cols', 'select:xxx')
      * @param	string	$editvalue		When in edit mode, use this value as $value instead of value
      * @param	object	$extObject		External object
      * @param	mixed	$custommsg		String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
@@ -269,7 +269,7 @@ class Form
         // Check parameters
         if ($inputType == 'textarea') $value = dol_nl2br($value);
         else if (preg_match('/^numeric/',$inputType)) $value = price($value);
-        else if ($inputType == 'datepicker') $value = dol_print_date($value, 'day');
+        else if ($inputType == 'day' || $inputType == 'datepicker') $value = dol_print_date($value, 'day');
 
         if ($condition)
         {
@@ -302,7 +302,7 @@ class Form
                 if (! empty($tmp[2])) $savemethod=$tmp[2];
 				$out.= '<input id="width_'.$htmlname.'" value="'.$inputOption.'" type="hidden"/>'."\n";
             }
-            else if ((preg_match('/^datepicker/',$inputType)) || (preg_match('/^datehourpicker/',$inputType)))
+            else if ((preg_match('/^day$/',$inputType)) || (preg_match('/^datepicker/',$inputType)) || (preg_match('/^datehourpicker/',$inputType)))
             {
                 $tmp=explode(':',$inputType);
                 $inputType=$tmp[0];

+ 13 - 0
htdocs/core/js/editinplace.js

@@ -53,9 +53,11 @@ $(document).ready(function() {
 		});
 		$('.editkey_textarea').hover(
 				function () {
+					console.log("We are hover (entry) an editkey_textarea");
 					$('#viewval_' + $(this).attr('id')).addClass("viewval_hover");
 				},
 				function () {
+					console.log("We are no more hover (exit) an editkey_textarea");
 					$('#viewval_' + $(this).attr('id')).removeClass("viewval_hover");
 				}
 		);
@@ -104,9 +106,11 @@ $(document).ready(function() {
 		});
 		$('.editkey_ckeditor').hover(
 				function () {
+					console.log("We are hover (entry) an editkey_ckeditor");
 					$('#viewval_' + $(this).attr('id')).addClass("viewval_hover");
 				},
 				function () {
+					console.log("We are no more hover (exit) an editkey_ckeditor");
 					$('#viewval_' + $(this).attr('id')).removeClass("viewval_hover");
 				}
 		);
@@ -145,9 +149,11 @@ $(document).ready(function() {
 		});
 		$('.editkey_string').hover(
 				function () {
+					console.log("We are hover (entry) an editkey_string");
 					$('#viewval_' + $(this).attr('id')).addClass("viewval_hover");
 				},
 				function () {
+					console.log("We are no more hover an editkey_string");
 					$('#viewval_' + $(this).attr('id')).removeClass("viewval_hover");
 				}
 		);
@@ -186,9 +192,11 @@ $(document).ready(function() {
 		});
 		$('.editkey_numeric').hover(
 				function () {
+					console.log("We are hover an editkey_numeric");
 					$( '#viewval_' + $(this).attr('id') ).addClass("viewval_hover");
 				},
 				function () {
+					console.log("We are no more hover (exit) an editkey_textarea");
 					$( '#viewval_' + $(this).attr('id') ).removeClass("viewval_hover");
 				}
 		);
@@ -227,9 +235,11 @@ $(document).ready(function() {
 		});
 		$('.editkey_datepicker').hover(
 				function () {
+					console.log("We are hover (entry) editkey_datepicker");
 					$('#viewval_' + $(this).attr('id')).addClass("viewval_hover");
 				},
 				function () {
+					console.log("We are no more hover (exit) an editkey_datepicker");
 					$('#viewval_' + $(this).attr('id')).removeClass("viewval_hover");
 				}
 		);
@@ -270,9 +280,11 @@ $(document).ready(function() {
 		});
 		$('.editkey_select').hover(
 				function () {
+					console.log("We are hover (entry) an editkey_select");
 					$('#viewval_' + $(this).attr('id')).addClass("viewval_hover");
 				},
 				function () {
+					console.log("We are no more hover (exit) an editkey_select");
 					$('#viewval_' + $(this).attr('id')).removeClass("viewval_hover");
 				}
 		);
@@ -316,6 +328,7 @@ $(document).ready(function() {
 		});
 		$('.editkey_autocomplete').hover(
 				function () {
+					console.log("We are no more hover (exit) an editkey_autocomplete");
 					$('#viewval_' + $(this).attr('id')).addClass("viewval_hover");
 				},
 				function () {

+ 9 - 4
htdocs/core/tpl/objectline_create.tpl.php

@@ -51,8 +51,11 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','fac
 ?>
 
 <!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->
-<?php $nolinesbefore=(count($this->lines) == 0); ?>
-<tr class="liste_titre<?php echo ($nolinesbefore?'':' liste_titre_add') ?> nodrag nodrop">
+<?php 
+$nolinesbefore=(count($this->lines) == 0);
+if ($nolinesbefore) {
+?>
+<tr class="liste_titre nodrag nodrop">
 	<td class="linecoldescription" <?php echo (! empty($conf->global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
 	<div id="add"></div><span class="hideonsmartphone"><?php echo $langs->trans('AddNewLine'); ?></span><?php // echo $langs->trans("FreeZone"); ?>
 	</td>
@@ -100,8 +103,10 @@ if (in_array($object->element,array('propal', 'supplier_proposal','facture','fac
 	?>
 	<td class="linecoledit" colspan="<?php echo $colspan; ?>">&nbsp;</td>
 </tr>
-
-<tr <?php echo $bcnd[$var]; ?>>
+<?php 
+}
+?>
+<tr class="pair nodrag nodrop nohoverpair<?php echo $nolinesbefore?'':' liste_titre_add'; ?>">
 <?php
 if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
 	$coldisplay=2; }