allow inline editing on document details page

This commit is contained in:
Uwe Steinmann 2020-09-07 16:20:37 +02:00
parent a75257c7c2
commit c6d0a1d345
9 changed files with 77 additions and 1 deletions

View File

@ -3,6 +3,7 @@
--------------------------------------------------------------------------------
- fix import of users
- major rework of scripts in utils, unify reading of settings, use PHP_EOL
- allow inline editing of document name
--------------------------------------------------------------------------------
Changes in version 5.1.19

View File

@ -74,6 +74,8 @@ class Settings { /* {{{ */
var $_apiUserId = 0;
// api allowed origins for restapi
var $_apiOrigin = '';
// allow inline editing of document/folder names
var $_inlineEditing = false;
// Strict form checking
var $_strictFormCheck = false;
// list of form fields which are visible by default but can be explixitly
@ -472,6 +474,7 @@ class Settings { /* {{{ */
$node = $xml->xpath('/configuration/site/edition');
$tab = $node[0]->attributes();
$this->_strictFormCheck = Settings::boolVal($tab["strictFormCheck"]);
$this->_inlineEditing = Settings::boolVal($tab["inlineEditing"]);
if(trim(strval($tab["noDocumentFormFields"])))
$this->_noDocumentFormFields = explode(',',strval($tab["noDocumentFormFields"]));
$this->setViewOnlineFileTypesFromString(strval($tab["viewOnlineFileTypes"]));
@ -835,6 +838,7 @@ class Settings { /* {{{ */
// XML Path: /configuration/site/edition
$node = $this->getXMLNode($xml, '/configuration/site', 'edition');
$this->setXMLAttributValue($node, "strictFormCheck", $this->_strictFormCheck);
$this->setXMLAttributValue($node, "inlineEditing", $this->_inlineEditing);
$this->setXMLAttributValue($node, "noDocumentFormFields", implode(',', $this->_noDocumentFormFields));
$this->setXMLAttributValue($node, "viewOnlineFileTypes", $this->getViewOnlineFileTypesToString());
$this->setXMLAttributValue($node, "editOnlineFileTypes", $this->getEditOnlineFileTypesToString());

View File

@ -600,6 +600,30 @@ switch($command) {
}
break; /* }}} */
case 'setdocumentname': /* {{{ */
if(1||$user) {
$document = $dms->getDocument($_REQUEST['id']);
if($document) {
if ($document->getAccessMode($user) >= M_READWRITE) {
if (!$document->setName($_REQUEST['name'])) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>'Error setting name', 'data'=>''));
} else {
header('Content-Type: application/json');
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_name_changed'), 'data'=>''));
add_log_line();
}
} else {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
}
} else {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
}
}
break; /* }}} */
case 'submittranslation': /* {{{ */
if($settings->_showMissingTranslations) {
if($user && !empty($_POST['phrase'])) {

View File

@ -76,6 +76,7 @@ if ($action == "saveSettings")
// SETTINGS - SITE - EDITION
$settings->_strictFormCheck = getBoolValue("strictFormCheck");
$settings->_inlineEditing = getBoolValue("inlineEditing");
if(empty($_POST["noDocumentFormFields"]))
$settings->_noDocumentFormFields = array();
else

View File

@ -225,6 +225,11 @@ i.in-workflow {color: #11479e;}
i.workflow-action {color: #91479e;}
i.selected {border: 1px solid #d4d4d4;padding:3px;border-radius:3px;background-color:#fafafa;background-image: linear-gradient(to bottom, #ffffff, #f2f2f2);}
span.editable:after {
font: normal normal normal 14px/1 FontAwesome;
content: " \f044";
}
span.openpopupbox {
cursor: pointer;
}

View File

@ -518,6 +518,30 @@ $(document).ready( function() {
$('button.history-back').on('click', function(event) { /* {{{ */
window.history.back();
}); /* }}} */
$("body").on("blur", "span.editable", function(e) { /* {{{ */
console.log($(this).data('document'));
console.log('Hallo'+$(this).text());
e.preventDefault();
$.post( "../op/op.Ajax.php", { command: "setdocumentname", id: $(this).data('document'), name: $(this).text() })
.done(function( data ) {
noty({
text: data.message,
type: data.success ? 'success' : 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
timeout: 1500,
});
});
}); /* }}} */
$("body").on("keypress", "span.editable", function(e) { /* {{{ */
if(e.which == 13) {
$(this).blur();
}
return e.which != 13;
}); /* }}} */
});
function onAddClipboard(ev) { /* {{{ */

View File

@ -2038,6 +2038,22 @@ $(function() {
echo "</div>\n";
} /* }}} */
/**
* Wrap text in inline editing tags
*
* @param string text
*/
function printInlineEdit($text, $object){ /* {{{ */
if(!empty($this->params['settings']->_inlineEditing)) {
echo "<span class=\"editable\" contenteditable=\"true\"";
if($object->isType('document'))
echo " data-document=\"".$object->getId()."\"";
echo ">".$text;
echo "</span>\n";
} else
echo $text;
} /* }}} */
/**
* Print button with link for deleting a document
*

View File

@ -299,6 +299,7 @@ $this->showStartPaneContent('site', (!$currenttab || $currenttab == 'site'));
-->
<?php $this->showConfigHeadline('settings_Edition'); ?>
<?php $this->showConfigCheckbox('settings_strictFormCheck', 'strictFormCheck'); ?>
<?php $this->showConfigCheckbox('settings_inlineEditing', 'inlineEditing'); ?>
<?php $this->showConfigOption('settings_noDocumentFormFields', 'noDocumentFormFields', array('comment', 'keywords', 'categories', 'sequence', 'expires', 'version', 'version_comment', 'notification'), true, true); ?>
<?php $this->showConfigText('settings_viewOnlineFileTypes', 'viewOnlineFileTypes', 'array'); ?>
<?php $this->showConfigText('settings_editOnlineFileTypes', 'editOnlineFileTypes', 'array'); ?>

View File

@ -201,7 +201,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
?>
<tr>
<td><?php printMLText("name");?>:</td>
<td><?php print htmlspecialchars($document->getName());?></td>
<td><?php $this->printInlineEdit(htmlspecialchars($document->getName()), $document);?></td>
</tr>
<tr>
<td><?php printMLText("owner");?>:</td>