PHRAS-2808-2806_disable-cterms_mask-writable-fields_4.1

new : checkbox in admin/field to allow gui (prod) editing, default=checked.
rename "publish_cterms" to "generate_cterms"
todo : implement "gui_editable" in edit ux (hide field when =false)
todo : 2 new strings (ckbox labels) to trans
This commit is contained in:
Jean-Yves Gaulier
2019-10-31 19:31:12 +01:00
parent ce13112105
commit b4e848a5e9
13 changed files with 88 additions and 34 deletions

View File

@@ -462,7 +462,8 @@ class databox extends base implements ThumbnailedElement
->set_aggregable((isset($field['aggregable']) ? (string) $field['aggregable'] : 0))
->set_type($type)
->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
->set_publish_cterms((isset($field['publish_cterms']) && (string) $field['publish_cterms'] == 1))
->set_generate_cterms((isset($field['generate_cterms']) && (string) $field['generate_cterms'] == 1))
->set_gui_editable((isset($field['gui_editable']) && (string) $field['gui_editable'] == 1))
->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
->set_report(isset($field['report']) ? (string) $field['report'] : '1')
->save();

View File

@@ -43,7 +43,8 @@ class databox_field implements cache_cacheableInterface
protected $report;
protected $type;
protected $tbranch;
protected $publish_cterms;
protected $generate_cterms;
protected $gui_editable;
protected $separator;
protected $thumbtitle;
@@ -167,7 +168,8 @@ class databox_field implements cache_cacheableInterface
$this->position = (int)$row['sorter'];
$this->type = $row['type'] ?: self::TYPE_STRING;
$this->tbranch = $row['tbranch'];
$this->publish_cterms = (bool)$row['publish_cterms'];
$this->generate_cterms = (bool)$row['generate_cterms'];
$this->gui_editable = (bool)$row['gui_editable'];
$this->VocabularyType = $row['VocabularyControlType'];
$this->VocabularyRestriction = (bool)$row['RestrictToVocabularyControl'];
@@ -308,7 +310,8 @@ class databox_field implements cache_cacheableInterface
`report` = :report,
`type` = :type,
`tbranch` = :tbranch,
`publish_cterms` = :publish_cterms,
`generate_cterms` = :generate_cterms,
`gui_editable` = :gui_editable,
`sorter` = :position,
`thumbtitle` = :thumbtitle,
`VocabularyControlType` = :VocabularyControlType,
@@ -332,7 +335,8 @@ class databox_field implements cache_cacheableInterface
':report' => $this->report ? '1' : '0',
':type' => $this->type,
':tbranch' => $this->tbranch,
':publish_cterms' => $this->publish_cterms ? '1' : '0',
':generate_cterms' => $this->generate_cterms ? '1' : '0',
':gui_editable' => $this->gui_editable ? '1' : '0',
':position' => $this->position,
':thumbtitle' => $this->thumbtitle,
':VocabularyControlType' => $this->getVocabularyControl() ? $this->getVocabularyControl()->getType() : null,
@@ -384,7 +388,8 @@ class databox_field implements cache_cacheableInterface
$meta->setAttribute('aggregable', $this->aggregable);
$meta->setAttribute('type', $this->type);
$meta->setAttribute('tbranch', $this->tbranch);
$meta->setAttribute('publish_cterms', $this->publish_cterms ? '1' : '0');
$meta->setAttribute('generate_cterms', $this->generate_cterms ? '1' : '0');
$meta->setAttribute('gui_editable', $this->gui_editable ? '1' : '0');
if ($this->multi) {
$meta->setAttribute('separator', $this->separator);
}
@@ -717,12 +722,23 @@ class databox_field implements cache_cacheableInterface
}
/**
* @param boolean $publish_cterms
* @param boolean $generate_cterms
* @return databox_field
*/
public function set_publish_cterms($publish_cterms)
public function set_generate_cterms($generate_cterms)
{
$this->publish_cterms = $publish_cterms;
$this->generate_cterms = $generate_cterms;
return $this;
}
/**
* @param boolean $gui_editable
* @return databox_field
*/
public function set_gui_editable($gui_editable)
{
$this->gui_editable = $gui_editable;
return $this;
}
@@ -815,9 +831,18 @@ class databox_field implements cache_cacheableInterface
*
* @return boolean
*/
public function get_publish_cterms()
public function get_generate_cterms()
{
return $this->publish_cterms;
return $this->generate_cterms;
}
/**
*
* @return boolean
*/
public function get_gui_editable()
{
return $this->gui_editable;
}
/**
@@ -930,7 +955,8 @@ class databox_field implements cache_cacheableInterface
'sorter' => $this->position,
'thumbtitle' => $this->thumbtitle,
'tbranch' => $this->tbranch,
'publish_cterms' => $this->publish_cterms,
'generate_cterms' => $this->generate_cterms,
'gui_editable' => $this->gui_editable,
'separator' => $this->separator,
'required' => $this->required,
'report' => $this->report,
@@ -969,10 +995,10 @@ class databox_field implements cache_cacheableInterface
}
$sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `required`, `indexable`, `type`, `tbranch`, `publish_cterms`,
(`id`, `name`, `src`, `readonly`, `gui_editable`, `required`, `indexable`, `type`, `tbranch`, `generate_cterms`,
`thumbtitle`, `multi`, `business`, `aggregable`,
`report`, `sorter`, `separator`)
VALUES (null, :name, '', 0, 0, 1, 'string', '', 1,
VALUES (null, :name, '', 0, 1, 0, 1, 'string', '', 1,
null, 0, 0, 0,
1, :sorter, '')";

View File

@@ -57,7 +57,9 @@ class patch_410alpha17a implements patchInterface
public function apply(base $databox, Application $app)
{
// -- done by xml schema --
// $sql = "ALTER TABLE `metadatas_structure` ADD `publish_cterms` INT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `tbranch`";
// $sql = "ALTER TABLE `metadatas_structure` ADD `generate_cterms` INT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `tbranch`";
// $databox->get_connection()->executeQuery($sql);
// $sql = "ALTER TABLE `metadatas_structure` ADD `gui_editable` INT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `readonly`";
// $databox->get_connection()->executeQuery($sql);
return true;