chg: [component:CRUD] Cleanup leftovers comments
parent
94fbd74918
commit
50737543a9
|
@ -12,7 +12,6 @@
|
|||
'type' => 'color',
|
||||
),
|
||||
),
|
||||
'metaTemplates' => empty($metaTemplates) ? [] : $metaTemplates,
|
||||
'submit' => array(
|
||||
'action' => $this->request->getParam('action')
|
||||
)
|
||||
|
|
|
@ -134,7 +134,6 @@ class CRUDComponent extends Component
|
|||
});
|
||||
$metaTemplates = $metaQuery->all();
|
||||
}
|
||||
// $this->Controller->set('metaTemplates', $metaTemplates->toArray());
|
||||
return $metaTemplates;
|
||||
}
|
||||
|
||||
|
@ -415,9 +414,7 @@ class CRUDComponent extends Component
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// debug($data['MetaTemplates']);
|
||||
$validationErrors = $data->getErrors();
|
||||
// $validationMessage = $this->prepareValidationMessage($validationErrors);
|
||||
$validationMessage = $this->prepareValidationError($data);
|
||||
$message = __(
|
||||
'{0} could not be modified.{1}',
|
||||
|
|
|
@ -17,7 +17,6 @@ class Individual extends AppModel
|
|||
'uuid' => true,
|
||||
];
|
||||
|
||||
// protected $_virtual = ['full_name', 'meta_fields', 'alternate_emails'];
|
||||
protected $_virtual = ['full_name', 'alternate_emails'];
|
||||
|
||||
protected function _getFullName()
|
||||
|
@ -28,27 +27,6 @@ class Individual extends AppModel
|
|||
return sprintf("%s %s", $this->first_name, $this->last_name);
|
||||
}
|
||||
|
||||
// protected function _getMetaFields()
|
||||
// {
|
||||
// if (!empty($this->metaTemplates)) {
|
||||
// $metaFields = [];
|
||||
// foreach ($this->metaTemplates as $metaTemplate) {
|
||||
// if (!empty($metaTemplate['meta_template_fields'])) {
|
||||
// foreach ($metaTemplate['meta_template_fields'] as $templateMetaFields) {
|
||||
// foreach ($templateMetaFields['meta_fields'] as $metaField) {
|
||||
// $tmpMetaTemplate = $metaTemplate->toArray();
|
||||
// unset($tmpMetaTemplate['meta_template_fields']);
|
||||
// $metaField['metaTemplate'] = $tmpMetaTemplate;
|
||||
// $metaFields[] = $metaField;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return $metaFields;
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
protected function _getAlternateEmails()
|
||||
{
|
||||
$emails = [];
|
||||
|
|
|
@ -44,16 +44,6 @@ class MetaFieldsTable extends AppTable
|
|||
return $validator;
|
||||
}
|
||||
|
||||
// public function buildRules(RulesChecker $rules): RulesChecker
|
||||
// {
|
||||
// $rules->add([$this, 'isValidMetaField'], 'validMetaField', [
|
||||
// // 'errorField' => 'meta_field.value',
|
||||
// 'errorField' => 'value',
|
||||
// 'message' => __('The provided value doesn\'t satisfy the validation defined by the meta-fields\'s meta-template'),
|
||||
// ]);
|
||||
// return $rules;
|
||||
// }
|
||||
|
||||
public function isValidMetaField($value, array $context)
|
||||
{
|
||||
$metaFieldsTable = $context['providers']['table'];
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
'type' => 'tags'
|
||||
),
|
||||
),
|
||||
// 'metaTemplates' => empty($metaTemplates) ? [] : $metaTemplates,
|
||||
'submit' => array(
|
||||
'action' => $this->request->getParam('action')
|
||||
)
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
'field' => 'type'
|
||||
)
|
||||
),
|
||||
'metaTemplates' => empty($metaTemplates) ? [] : $metaTemplates,
|
||||
'submit' => array(
|
||||
'action' => $this->request->getParam('action')
|
||||
)
|
||||
|
|
|
@ -35,14 +35,11 @@
|
|||
if (empty($fieldData['type']) || $fieldData['type'] !== 'checkbox' ) {
|
||||
$params['class'] .= ' form-control';
|
||||
}
|
||||
//$params['class'] = sprintf('form-control %s', $params['class']);
|
||||
foreach ($fieldData as $k => $fd) {
|
||||
if (!isset($simpleFieldWhitelist) || in_array($k, $simpleFieldWhitelist) || strpos($k, 'data-') === 0) {
|
||||
$params[$k] = $fd;
|
||||
}
|
||||
}
|
||||
// debug($fieldData);
|
||||
// debug($params);
|
||||
$temp = $this->element('genericElements/Form/Fields/' . $fieldTemplate, array(
|
||||
'fieldData' => $fieldData,
|
||||
'params' => $params
|
||||
|
@ -51,7 +48,6 @@
|
|||
$temp = '<span class="hidden">' . $temp . '</span>';
|
||||
}
|
||||
echo $temp;
|
||||
// $fieldsArrayForPersistence []= $modelForForm . \Cake\Utility\Inflector::camelize($fieldData['field']);
|
||||
} else {
|
||||
echo $fieldData;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ foreach ($entity->MetaTemplates as $i => $metaTemplate) {
|
|||
];
|
||||
}
|
||||
$fieldsHtml = '';
|
||||
// debug($metaTemplate['meta_template_fields']);
|
||||
foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
||||
$metaTemplateField->label = Inflector::humanize($metaTemplateField->field);
|
||||
if (!empty($metaTemplateField->metaFields)) {
|
||||
|
|
|
@ -3,7 +3,6 @@ $seed = 'mfb-' . mt_rand();
|
|||
?>
|
||||
<div class="d-flex align-items-center">
|
||||
<?php
|
||||
// $content = sprintf('<a class="btn btn-primary btn-xs">%s</a><a class="btn btn-link btn-xs">%s</a>', $this->Bootstrap->icon('plus'), __('Add another {0}', h($fieldData['label'])));
|
||||
$content = sprintf('<a class="btn btn-primary btn-xs">%s</a><a class="btn btn-link btn-xs">%s</a>', $this->Bootstrap->icon('plus'), __('Add another {0}', h($metaTemplateFieldName)));
|
||||
$content = sprintf(
|
||||
'%s%s',
|
||||
|
@ -15,7 +14,6 @@ $seed = 'mfb-' . mt_rand();
|
|||
]),
|
||||
$this->Bootstrap->button([
|
||||
'nodeType' => 'a',
|
||||
// 'text' => __('Add another {0}', h($fieldData['label'])),
|
||||
'text' => __('Add another {0}', h($metaTemplateFieldName)),
|
||||
'variant' => 'link',
|
||||
'class' => ['link-secondary'],
|
||||
|
@ -69,32 +67,5 @@ $seed = 'mfb-' . mt_rand();
|
|||
.val('')
|
||||
.removeClass('is-invalid')
|
||||
}
|
||||
// function addNewField() {
|
||||
// const $clicked = $(this);
|
||||
// const $lastInputContainer = $clicked.closest('.multi-metafields-container').children().not('.template-container').find('input').last().closest('.multi-metafield-container')
|
||||
// const $templateContainer = $clicked.closest('.multi-metafields-container').find('.template-container').children()
|
||||
// const $clonedContainer = $templateContainer.clone()
|
||||
// $clonedContainer.removeClass('d-none', 'template-container')
|
||||
// const $clonedInput = $clonedContainer.find('input, select')
|
||||
// if ($clonedInput.length > 0) {
|
||||
// const injectedTemplateId = $clicked.closest('.multi-metafields-container').find('.new-metafield').length
|
||||
// $clonedInput.addClass('new-metafield')
|
||||
// adjustClonedInputAttr($clonedInput, injectedTemplateId)
|
||||
// $clonedContainer.insertAfter($lastInputContainer)
|
||||
// }
|
||||
// }
|
||||
|
||||
// function adjustClonedInputAttr($input, injectedTemplateId) {
|
||||
// let explodedPath = $input.attr('field').split('.').splice(0, 5)
|
||||
// explodedPath.push('new', injectedTemplateId)
|
||||
// dottedPathStr = explodedPath.join('.')
|
||||
// brackettedPathStr = explodedPath.map((elem, i) => {
|
||||
// return i == 0 ? elem : `[${elem}]`
|
||||
// }).join('')
|
||||
// $input.attr('id', dottedPathStr)
|
||||
// .attr('field', dottedPathStr)
|
||||
// .attr('name', brackettedPathStr)
|
||||
// .val('')
|
||||
// }
|
||||
})()
|
||||
</script>
|
|
@ -11,11 +11,6 @@ $form->setTemplates($default_template);
|
|||
|
||||
$fieldsHtml = '';
|
||||
$labelPrintedOnce = false;
|
||||
$newMetaFields = [];
|
||||
$newFieldIndex = 0;
|
||||
// $newMetaFieldPrinted = false;
|
||||
// debug($entity);
|
||||
// debug($entity->getErrors());
|
||||
if (!empty($metaFieldsEntities)) {
|
||||
foreach ($metaFieldsEntities as $i => $metaFieldsEntity) {
|
||||
$metaFieldsEntity->label = Inflector::humanize($metaFieldsEntity->field);
|
||||
|
@ -36,15 +31,6 @@ if (!empty($metaFieldsEntities)) {
|
|||
$i
|
||||
);
|
||||
$fieldData['class'] = 'new-metafield';
|
||||
// $fieldData['field'] = sprintf(
|
||||
// 'MetaTemplates.%s.meta_template_fields.%s.metaFields.new.%s',
|
||||
// $metaFieldsEntity->meta_template_id,
|
||||
// $metaFieldsEntity->meta_template_field_id,
|
||||
// $newFieldIndex
|
||||
// );
|
||||
// $fieldData['class'] = 'new-metafield';
|
||||
// $newMetaFieldPrinted = true;
|
||||
// $newFieldIndex += 1;
|
||||
}
|
||||
if ($labelPrintedOnce) { // Only the first input can have a label
|
||||
$fieldData['label'] = false;
|
||||
|
@ -62,18 +48,18 @@ if (!empty($metaFieldsEntities)) {
|
|||
if (!empty($metaTemplateField) && !empty($multiple)) { // Add multiple field button
|
||||
$metaTemplateField->label = Inflector::humanize($metaTemplateField->field);
|
||||
$emptyMetaFieldInput = '';
|
||||
if (empty($metaFieldsEntities)) {
|
||||
// $emptyMetaFieldInput = $this->element(
|
||||
// 'genericElements/Form/fieldScaffold',
|
||||
// [
|
||||
// 'fieldData' => [
|
||||
// 'label' => $metaTemplateField->label,
|
||||
// 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new.0', $metaTemplateField->meta_template_id, $metaTemplateField->id),
|
||||
// 'class' => 'new-metafield',
|
||||
// ],
|
||||
// 'form' => $form,
|
||||
// ]
|
||||
// );
|
||||
if (empty($metaFieldsEntities)) { // Include editable field for meta-template not containing a meta-field
|
||||
$emptyMetaFieldInput = $this->element(
|
||||
'genericElements/Form/fieldScaffold',
|
||||
[
|
||||
'fieldData' => [
|
||||
'label' => $metaTemplateField->label,
|
||||
'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new.0', $metaTemplateField->meta_template_id, $metaTemplateField->id),
|
||||
'class' => 'new-metafield',
|
||||
],
|
||||
'form' => $form,
|
||||
]
|
||||
);
|
||||
}
|
||||
$emptyInputForSecurityComponent = $this->element(
|
||||
'genericElements/Form/fieldScaffold',
|
||||
|
@ -86,19 +72,6 @@ if (!empty($metaTemplateField) && !empty($multiple)) { // Add multiple field but
|
|||
'form' => $form,
|
||||
]
|
||||
);
|
||||
// $emptyInputForSecurityComponent = '';
|
||||
// if (!$newMetaFieldPrinted) {
|
||||
// $emptyInputForSecurityComponent = $this->element(
|
||||
// 'genericElements/Form/fieldScaffold',
|
||||
// [
|
||||
// 'fieldData' => [
|
||||
// 'label' => false,
|
||||
// 'field' => sprintf('MetaTemplates.%s.meta_template_fields.%s.metaFields.new[]', $metaTemplateField->meta_template_id, $metaTemplateField->id),
|
||||
// ],
|
||||
// 'form' => $form,
|
||||
// ]
|
||||
// );
|
||||
// }
|
||||
$multiFieldButtonHtml = sprintf(
|
||||
'<div class="row mb-1 multi-metafield-container add-input-container"><div class="col-sm-2 form-label"></div><div class="col-sm-10 multi-metafield-input-container">%s</div></div>',
|
||||
$this->element(
|
||||
|
@ -108,7 +81,7 @@ if (!empty($metaTemplateField) && !empty($multiple)) { // Add multiple field but
|
|||
]
|
||||
)
|
||||
);
|
||||
// $fieldsHtml .= $emptyMetaFieldInput;
|
||||
$fieldsHtml .= $emptyMetaFieldInput;
|
||||
$fieldsHtml .= sprintf('<div class="d-none template-container">%s</div>', $emptyInputForSecurityComponent);
|
||||
$fieldsHtml .= $multiFieldButtonHtml;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ foreach($data['MetaTemplates'] as $metaTemplate) {
|
|||
$fields = [];
|
||||
foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
||||
$labelPrintedOnce = false;
|
||||
if (!empty($metaTemplateField->metaFields)) {
|
||||
foreach ($metaTemplateField->metaFields as $metaField) {
|
||||
$fields[] = [
|
||||
'key' => !$labelPrintedOnce ? $metaField->field : '',
|
||||
|
@ -25,12 +26,19 @@ foreach($data['MetaTemplates'] as $metaTemplate) {
|
|||
$labelPrintedOnce = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$listTable = $this->Bootstrap->listTable([
|
||||
'hover' => false,
|
||||
'elementsRootPath' => '/genericElements/SingleViews/Fields/'
|
||||
],[
|
||||
'item' => false,
|
||||
'fields' => $fields
|
||||
'fields' => $fields,
|
||||
'caption' => __n(
|
||||
'This meta-template contains {0} meta-field',
|
||||
'This meta-template contains {0} meta-fields',
|
||||
count($fields),
|
||||
count($fields)
|
||||
)
|
||||
]);
|
||||
$tabData['content'][] = $listTable;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue