diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 20d6a8e87a0dd047cfe5c2fa804b9c8d20b1d401..ed7160f09eafa5d26431fd08374379a70b6dd2f9 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -191,8 +191,13 @@ abstract class AbstractBuildForm { // element-update: with 'value' $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_ZERO); $md5 = $this->buildRecordHashMd5($this->formSpec[F_TABLE_NAME], $recordId); + + // Via 'element-update' $json[][API_ELEMENT_UPDATE][DIRTY_RECORD_HASH_MD5][API_ELEMENT_ATTRIBUTE]['value'] = $md5; + // Via 'form-update' +// $json[] = [API_FORM_UPDATE_FORM_ELEMENT => DIRTY_RECORD_HASH_MD5, API_FORM_UPDATE_VALUE => $md5, +// API_FORM_UPDATE_DISABLED => false, API_FORM_UPDATE_REQUIRED => false ]; } } @@ -303,15 +308,13 @@ abstract class AbstractBuildForm { * @throws \qfq\CodeException * @throws \qfq\DbException */ - public function buildInputRecordHashMd5($flagWithSpan = true) { + public function buildInputRecordHashMd5() { $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP . STORE_ZERO); $md5 = $this->buildRecordHashMd5($this->formSpec[F_TABLE_NAME], $recordId); $data = ""; - if ($flagWithSpan) { - $data = Support::wrapTag('', $data); - } +// $data = ""; return $data; } @@ -768,7 +771,7 @@ abstract class AbstractBuildForm { $json = $this->getJsonFeMode($formElement[FE_MODE]); // disabled, required - $json['form-element'] = $htmlFormElementName; + $json[API_FORM_UPDATE_FORM_ELEMENT] = $htmlFormElementName; if (isset($formElement[FE_FLAG_ROW_OPEN_TAG]) && isset($formElement[FE_FLAG_ROW_CLOSE_TAG])) { $flagRowUpdate = ($formElement[FE_FLAG_ROW_OPEN_TAG] && $formElement[FE_FLAG_ROW_CLOSE_TAG]); @@ -776,9 +779,9 @@ abstract class AbstractBuildForm { $flagRowUpdate = true; } - // 'value' update via 'form-update' on the full row: only if there is no other FE that row + // 'value' update via 'form-update' on the full row: only if there is no other FE in that row if ($flagRowUpdate) { - $json['value'] = $value; + $json[API_FORM_UPDATE_VALUE] = $value; } if (isset($formElement[FE_LABEL])) { @@ -838,7 +841,7 @@ abstract class AbstractBuildForm { $this->getFeMode($feMode, $dummy, $disabled, $required); - return [API_JSON_DISABLED => $disabled === 'yes', API_JSON_REQUIRED => $required === 'yes']; + return [API_FORM_UPDATE_DISABLED => $disabled === 'yes', API_FORM_UPDATE_REQUIRED => $required === 'yes']; } /** diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 6fd804a1bff42eda1a0f6362fdfb99105b37c6e0..ac74e64eea73a7338b054470ea6ae8d71a37b9d6 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -587,6 +587,12 @@ const API_LOCK_TIMEOUT = 'lock_timeout'; const API_FIELD_NAME = 'field-name'; const API_FIELD_MESSAGE = 'field-message'; const API_FORM_UPDATE = 'form-update'; +const API_FORM_UPDATE_FORM_ELEMENT = 'form-element'; +const API_FORM_UPDATE_VALUE = 'value'; +const API_FORM_UPDATE_HIDDEN = 'hidden'; +const API_FORM_UPDATE_DISABLED = 'disabled'; +const API_FORM_UPDATE_REQUIRED = 'required'; + const API_ELEMENT_UPDATE = 'element-update'; const API_ELEMENT_ATTRIBUTE = 'attr'; const API_ELEMENT_CONTENT = 'content'; @@ -594,15 +600,10 @@ const API_SUBMIT_REASON = 'submit_reason'; const API_SUBMIT_REASON_SAVE = 'save'; const API_SUBMIT_REASON_SAVE_CLOSE = 'save,close'; - const API_LOCK_ACTION_LOCK = 'lock'; const API_LOCK_ACTION_EXTEND = 'extend'; const API_LOCK_ACTION_RELEASE = 'release'; -const API_JSON_HIDDEN = 'hidden'; -const API_JSON_DISABLED = 'disabled'; -const API_JSON_REQUIRED = 'required'; - const API_ANSWER_STATUS_SUCCESS = 'success'; const API_ANSWER_STATUS_CONFLICT = 'conflict'; const API_ANSWER_STATUS_CONFLICT_ALLOW_FORCE = 'conflict_allow_force'; diff --git a/extension/qfq/qfq/form/Dirty.php b/extension/qfq/qfq/form/Dirty.php index ee378b14b9c9113b0179804ab6c2e81c05cea018..33d27b35c747f881589a48701afdd7420ead234b 100644 --- a/extension/qfq/qfq/form/Dirty.php +++ b/extension/qfq/qfq/form/Dirty.php @@ -249,6 +249,7 @@ class Dirty { $record = $this->db->sql("SELECT * FROM $tableName WHERE id=?", ROW_EXPECT_1, [$recordId], "Record to lock not found."); $rcMd5 = OnArray::getMd5($record); + return ($recordHashMd5 != $rcMd5); } diff --git a/javascript/src/ElementUpdate.js b/javascript/src/ElementUpdate.js index 177199fdef1c4e274e838b597fd560659ea4ca5a..3ec47bd9f41d009380bf24524673e71693682a7c 100644 --- a/javascript/src/ElementUpdate.js +++ b/javascript/src/ElementUpdate.js @@ -78,6 +78,9 @@ var QfqNS = QfqNS || {}; n.ElementUpdate.setAttribute = function ($element, attributeName, attributeValue) { $element.attr(attributeName, attributeValue); + if (attributeName.toLowerCase() === "value") { + $element.val(attributeValue); + } }; n.ElementUpdate.deleteAttribute = function ($element, attributeName) { diff --git a/javascript/src/QfqForm.js b/javascript/src/QfqForm.js index 57a768e7724fac4f7683e748fd988bb9431183b9..dd510f8f82c6ef29eab73e34e73d26bb93514dfa 100644 --- a/javascript/src/QfqForm.js +++ b/javascript/src/QfqForm.js @@ -895,6 +895,9 @@ var QfqNS = QfqNS || {}; // do we have to update the HTML Form? if (data['form-update']) { this.applyFormConfiguration(data['form-update']); + } + + if (data['element-update']) { this.applyElementConfiguration(data['element-update']); } diff --git a/mockup/elementupdate.html b/mockup/elementupdate.html index 2e770e4cf8b7657517d52ea3ce3466ef205d3e61..dff1fe92958e9122ee0ec95b4df9f6191ef950aa 100644 --- a/mockup/elementupdate.html +++ b/mockup/elementupdate.html @@ -168,6 +168,7 @@ +