chg: [analyst-data:edit] Added support of editable fields

pull/9583/head
Sami Mokaddem 2024-02-22 08:32:47 +01:00
parent 76e61d3e26
commit 224415c3b4
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
6 changed files with 33 additions and 6 deletions

View File

@ -80,6 +80,7 @@ class AnalystDataController extends AppController
$this->set('id', $id);
$conditions = $this->AnalystData->buildConditions($this->Auth->user());
$params = [
'fields' => $this->AnalystData->getEditableFields(),
'conditions' => $conditions,
'afterFind' => function(array $analystData): array {
$canEdit = $this->ACL->canEditAnalystData($this->Auth->user(), $analystData, $this->modelSelection);

View File

@ -36,6 +36,15 @@ class AnalystData extends AppModel
'Relationship',
];
protected const BASE_EDITABLE_FIELDS = [
'language',
'authors',
'modified',
'distribution',
'sharing_group_id',
];
protected $EDITABLE_FIELDS = [];
/** @var object|null */
protected $Note;
/** @var object|null */
@ -156,6 +165,11 @@ class AnalystData extends AppModel
return true;
}
public function getEditableFields(): array
{
return array_merge(self::BASE_EDITABLE_FIELDS, $this->EDITABLE_FIELDS);
}
/**
* Checks if user can modify given analyst data
*

View File

@ -15,8 +15,11 @@ class Note extends AnalystData
public $current_type = 'Note';
public $current_type_id = 0;
public $validate = array(
);
public const EDITABLE_FIELDS = [
'note',
];
public $validate = [];
public function beforeValidate($options = array())
{

View File

@ -15,8 +15,12 @@ class Opinion extends AnalystData
public $current_type = 'Opinion';
public $current_type_id = 1;
public $validate = array(
);
public const EDITABLE_FIELDS = [
'opinion',
'comment',
];
public $validate = [];
public function beforeValidate($options = array())
{

View File

@ -15,8 +15,11 @@ class Relationship extends AnalystData
public $current_type = 'Relationship';
public $current_type_id = 2;
public $validate = array(
);
protected $EDITABLE_FIELDS = [
'relationship_type',
];
public $validate = [];
/** @var object|null */
protected $Event;

View File

@ -89,10 +89,12 @@ if ($modelSelection === 'Note') {
'options' => $dropdownData['valid_targets'],
'type' => 'dropdown',
'stayInLine' => 1,
'disabled' => !empty($this->data[$modelSelection]['related_object_type']),
],
[
'field' => 'related_object_uuid',
'class' => 'span4',
'disabled' => !empty($this->data[$modelSelection]['related_object_uuid']),
],
sprintf('<div style="max-width: 960px;"><label>%s:</label><div id="related-object-container">%s</div></div>', __('Related Object'), __('- No UUID provided -'))
]