Commit dea7c8c4 authored by Carsten  Rose's avatar Carsten Rose
Browse files

AbstractBuildForm.php: add variant to update md5 via form-update. Remove test...

AbstractBuildForm.php: add variant to update md5 via form-update. Remove test 'span' wrap around 'recordHashMd5'. Introduce constants API_FORM_UPDATE_*.
parent cf2f200e
......@@ -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 = "<input id='" . DIRTY_RECORD_HASH_MD5 . "' name='" . DIRTY_RECORD_HASH_MD5 . "' type='hidden' value='$md5'>";
if ($flagWithSpan) {
$data = Support::wrapTag('<span id="' . DIRTY_RECORD_HASH_MD5_SPAN . '">', $data);
}
// $data = "<input id='" . DIRTY_RECORD_HASH_MD5 . "' name='" . DIRTY_RECORD_HASH_MD5 . "' type='text' value='$md5'>";
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'];
}
/**
......
......@@ -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';
......
......@@ -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);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment