forked from Wavyzz/dolibarr
Fix: move jnotify options in separate file
Fix: move nl2br treatment New: add error message for edit in place
This commit is contained in:
@@ -361,7 +361,7 @@ else if ($id)
|
||||
|
||||
// Km/Price
|
||||
print '<tr><td>'.$langs->trans("FeesKilometersOrAmout").'</td>';
|
||||
print '<td>'.$form->editInPlace(price($object->km), 'km', $user->rights->deplacement->creer, 'numeric').'</td></tr>';
|
||||
print '<td>'.$form->editInPlace($object->km, 'km', $user->rights->deplacement->creer, 'numeric').'</td></tr>';
|
||||
|
||||
// Where
|
||||
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
|
||||
@@ -405,9 +405,7 @@ else if ($id)
|
||||
// Public note
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
// FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
|
||||
// by editInPlace if necessary according to type (4rd parameter)
|
||||
print $form->editInPlace(dol_nl2br($object->note_public), 'note_public', $user->rights->deplacement->creer, 'area');
|
||||
print $form->editInPlace($object->note_public, 'note_public', $user->rights->deplacement->creer, 'area');
|
||||
print "</td></tr>";
|
||||
|
||||
// Private note
|
||||
@@ -415,9 +413,7 @@ else if ($id)
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
// FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
|
||||
// by editInPlace if necessary according to type (4rd parameter)
|
||||
print $form->editInPlace(dol_nl2br($object->note_private), 'note', $user->rights->deplacement->creer, 'area');
|
||||
print $form->editInPlace($object->note_private, 'note', $user->rights->deplacement->creer, 'area');
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/genericobject.class.php");
|
||||
top_httphead();
|
||||
|
||||
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||
//var_dump($_POST);
|
||||
//print_r($_POST);
|
||||
|
||||
// Load original field value
|
||||
if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||
@@ -52,6 +52,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||
$value = GETPOST('value');
|
||||
$type = GETPOST('type');
|
||||
|
||||
$return=array();
|
||||
$error=0;
|
||||
|
||||
if ($element == 'fichinter') $element = 'ficheinter';
|
||||
@@ -70,6 +71,7 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||
if (! is_numeric($value))
|
||||
{
|
||||
$error++;
|
||||
$return['error'] = $langs->trans('ErrorBadValue');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +81,13 @@ if((isset($_POST['field']) && ! empty($_POST['field']))
|
||||
if ($ret > 0)
|
||||
{
|
||||
if ($type == 'numeric') $value = price($value);
|
||||
else $value = (! empty($value) ? dol_nl2br($value) : ' ');
|
||||
else if ($type == 'textarea') $value = dol_nl2br($value);
|
||||
|
||||
echo $value;
|
||||
$return['value'] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -153,10 +153,13 @@ class Form
|
||||
*/
|
||||
function editInPlace($value, $htmlname, $condition, $type='area')
|
||||
{
|
||||
global $conf,$user;
|
||||
global $conf;
|
||||
|
||||
$out='';
|
||||
$value = ($value ? $value : " ");
|
||||
|
||||
// Check parameters
|
||||
if ($type == 'area') $value = dol_nl2br($value);
|
||||
else if ($type == 'numeric') $value = price($value);
|
||||
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && $condition)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
// \brief File that include javascript functions for edit in place
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
var element = $('#element').html();
|
||||
var table_element = $('#table_element').html();
|
||||
@@ -17,6 +16,7 @@ $(document).ready(function() {
|
||||
rows : 4,
|
||||
id : 'field',
|
||||
tooltip : tooltipInPlace,
|
||||
placeholder : placeholderInPlace,
|
||||
cancel : cancelInPlace,
|
||||
submit : submitInPlace,
|
||||
indicator : indicatorInPlace,
|
||||
@@ -32,6 +32,16 @@ $(document).ready(function() {
|
||||
element: element,
|
||||
table_element: table_element,
|
||||
fk_element: fk_element
|
||||
},
|
||||
callback : function(result, settings) {
|
||||
var obj = $.parseJSON(result);
|
||||
|
||||
if (obj.error) {
|
||||
$(this).html(this.revert);
|
||||
$.jnotify(obj.error, "error", true);
|
||||
} else {
|
||||
$(this).html(obj.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.edit_text').editable(urlSaveInPlace, {
|
||||
@@ -39,6 +49,7 @@ $(document).ready(function() {
|
||||
id : 'field',
|
||||
width : 300,
|
||||
tooltip : tooltipInPlace,
|
||||
placeholder : placeholderInPlace,
|
||||
cancel : cancelInPlace,
|
||||
submit : submitInPlace,
|
||||
indicator : indicatorInPlace,
|
||||
@@ -47,6 +58,16 @@ $(document).ready(function() {
|
||||
element: element,
|
||||
table_element: table_element,
|
||||
fk_element: fk_element
|
||||
},
|
||||
callback : function(result, settings) {
|
||||
var obj = $.parseJSON(result);
|
||||
|
||||
if (obj.error) {
|
||||
$(this).html(this.revert);
|
||||
$.jnotify(obj.error, "error", true);
|
||||
} else {
|
||||
$(this).html(obj.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.edit_numeric').editable(urlSaveInPlace, {
|
||||
@@ -54,6 +75,7 @@ $(document).ready(function() {
|
||||
id : 'field',
|
||||
width : 100,
|
||||
tooltip : tooltipInPlace,
|
||||
placeholder : placeholderInPlace,
|
||||
cancel : cancelInPlace,
|
||||
submit : submitInPlace,
|
||||
indicator : indicatorInPlace,
|
||||
@@ -62,7 +84,16 @@ $(document).ready(function() {
|
||||
element: element,
|
||||
table_element: table_element,
|
||||
fk_element: fk_element
|
||||
},
|
||||
callback : function(result, settings) {
|
||||
var obj = $.parseJSON(result);
|
||||
|
||||
if (obj.error) {
|
||||
$(this).html(this.revert);
|
||||
$.jnotify(obj.error, "error", true);
|
||||
} else {
|
||||
$(this).html(obj.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
26
htdocs/core/js/jnotify.js
Normal file
26
htdocs/core/js/jnotify.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2011 Regis Houssin <regis@dolibarr.fr>
|
||||
//
|
||||
// Script javascript that contains functions for jnotify default options
|
||||
//
|
||||
// \file htdocs/core/js/jnotify.js
|
||||
// \brief File that include javascript functions for jnotify default options
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
$.jnotify.setup({
|
||||
delay: 3000 // the default time to show each notification (in milliseconds)
|
||||
, sticky: false // determines if the message should be considered "sticky" (user must manually close notification)
|
||||
, closeLabel: "×" // the HTML to use for the "Close" link
|
||||
, showClose: true // determines if the "Close" link should be shown if notification is also sticky
|
||||
, fadeSpeed: 1000 // the speed to fade messages out (in milliseconds)
|
||||
, slideSpeed: 250 // the speed used to slide messages out (in milliseconds)
|
||||
, classContainer: "jnotify-container"
|
||||
, classNotification: "jnotify-notification"
|
||||
, classBackground: "jnotify-background"
|
||||
, classClose: "jnotify-close"
|
||||
, classMessage: "jnotify-message"
|
||||
, init: null // callback that occurs when the main jnotify container is created
|
||||
, create: null // callback that occurs when when the note is created (occurs just before appearing in DOM)
|
||||
, beforeRemove: null // callback that occurs when before the notification starts to fade away
|
||||
});
|
||||
});
|
||||
@@ -3963,21 +3963,6 @@ function get_htmloutput_mesg($mesgstring='',$mesgarray='', $style='ok', $keepemb
|
||||
jQuery.jnotify("'.dol_escape_js($out).'",
|
||||
"'.($style=="ok" ? 3000 : $style).'",
|
||||
'.($style=="ok" ? "false" : "true").',
|
||||
{
|
||||
closeLabel: "×" // the HTML to use for the "Close" link
|
||||
, showClose: true // determines if the "Close" link should be shown if notification is also sticky
|
||||
, fadeSpeed: 1000 // the speed to fade messages out (in milliseconds)
|
||||
, slideSpeed: 250 // the speed used to slide messages out (in milliseconds)
|
||||
, classContainer: "jnotify-container"
|
||||
, classNotification: "jnotify-notification"
|
||||
, classBackground: "jnotify-background"
|
||||
, classClose: "jnotify-close"
|
||||
, classMessage: "jnotify-message"
|
||||
, init: null // callback that occurs when the main jnotify container is created
|
||||
, create: null // callback that occurs when when the note is created (occurs just before
|
||||
// appearing in DOM)
|
||||
, beforeRemove: null // callback that occurs when before the notification starts to fade away
|
||||
},
|
||||
{ remove: function (){} } );
|
||||
});
|
||||
</script>';
|
||||
|
||||
@@ -807,9 +807,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
print $langs->trans('Description');
|
||||
print '</td><td colspan="3">';
|
||||
// FIXME parameter note_private must not be denatured with a format function to be propagated. dol_nl2br must be used
|
||||
// by editInPlace if necessary according to type (4rd parameter)
|
||||
print $form->editInPlace(dol_nl2br($object->description), 'description', $user->rights->ficheinter->creer && $object->statut == 0, 'area');
|
||||
print $form->editInPlace($object->description, 'description', $user->rights->ficheinter->creer && $object->statut == 0, 'area');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -872,9 +870,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
// Public note
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
// FIXME parameter note_public must not be denatured with a format function to be propagated. dol_nl2br must be used
|
||||
// by editInPlace if necessary according to type (4rd parameter)
|
||||
print $form->editInPlace(dol_nl2br($object->note_public), 'note_public', $user->rights->ficheinter->creer, 'area');
|
||||
print $form->editInPlace($object->note_public, 'note_public', $user->rights->ficheinter->creer, 'area');
|
||||
print "</td></tr>";
|
||||
|
||||
// Private note
|
||||
@@ -882,7 +878,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td valign="top" colspan="3">';
|
||||
print $form->editInPlace(dol_nl2br($object->note_private), 'note_private', $user->rights->ficheinter->creer);
|
||||
print $form->editInPlace($object->note_private, 'note_private', $user->rights->ficheinter->creer);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
@@ -601,6 +601,7 @@ AttributeCode=Attribute code
|
||||
OptionalFieldsSetup=Extra attributes setup
|
||||
URLPhoto=Url of photo/logo
|
||||
CreateDraft=Create draft
|
||||
ClickToEdit=Click to edit
|
||||
|
||||
# Week day
|
||||
Monday=Monday
|
||||
|
||||
@@ -601,6 +601,7 @@ AttributeCode=Code de l'attribut
|
||||
OptionalFieldsSetup=Configuration des attributs complémentaires
|
||||
URLPhoto=Url vers photo/logo
|
||||
CreateDraft=Créer brouillon
|
||||
ClickToEdit=Cliquer ici pour éditer
|
||||
|
||||
# Week day
|
||||
Monday=Lundi
|
||||
|
||||
@@ -922,7 +922,11 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout-latest'.$ext.'"></script>'."\n";
|
||||
}
|
||||
// jQuery jnotify
|
||||
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY)) print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>'."\n";
|
||||
if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY))
|
||||
{
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js"></script>'."\n";
|
||||
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/jnotify.js"></script>'."\n";
|
||||
}
|
||||
// jQuery jeditable
|
||||
if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE))
|
||||
{
|
||||
@@ -930,7 +934,8 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
|
||||
print '<script type="text/javascript">'."\n";
|
||||
print 'var urlSaveInPlace = \''.DOL_URL_ROOT.'/core/ajax/saveinplace.php\';'."\n";
|
||||
print 'var urlLoadInPlace = \''.DOL_URL_ROOT.'/core/ajax/loadinplace.php\';'."\n";
|
||||
print 'var tooltipInPlace = \''.$langs->trans('ClickToEdit').'\';'."\n";
|
||||
print 'var tooltipInPlace = \''.$langs->transnoentities('ClickToEdit').'\';'."\n";
|
||||
print 'var placeholderInPlace = \''.$langs->trans('ClickToEdit').'\';'."\n";
|
||||
print 'var cancelInPlace = \''.$langs->trans('Cancel').'\';'."\n";
|
||||
print 'var submitInPlace = \''.$langs->trans('Ok').'\';'."\n";
|
||||
print 'var indicatorInPlace = \'<img src="'.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'">\';'."\n";
|
||||
|
||||
Reference in New Issue
Block a user