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

@@ -314,7 +314,8 @@ class FieldsController extends Controller
->set_readonly($data['readonly'])
->set_type($data['type'])
->set_tbranch($data['tbranch'])
->set_publish_cterms($data['publish_cterms'])
->set_generate_cterms($data['generate_cterms'])
->set_gui_editable($data['gui_editable'])
->set_report($data['report'])
->setVocabularyControl(null)
->setVocabularyRestricted(false);
@@ -350,7 +351,7 @@ class FieldsController extends Controller
{
return [
'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'aggregable',
'required', 'separator', 'readonly', 'type', 'tbranch', 'publish_cterms', 'report',
'required', 'separator', 'readonly', 'gui_editable', 'type', 'tbranch', 'generate_cterms', 'report',
'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels'
];
}

View File

@@ -594,7 +594,8 @@ class V1Controller extends Controller
],
'separator' => $databox_field->get_separator(),
'thesaurus_branch' => $databox_field->get_tbranch(),
'publish_cterms' => $databox_field->get_publish_cterms(),
'generate_cterms' => $databox_field->get_generate_cterms(),
'gui_editable' => $databox_field->get_gui_editable(),
'type' => $databox_field->get_type(),
'indexable' => $databox_field->is_indexable(),
'multivalue' => $databox_field->is_multi(),

View File

@@ -75,7 +75,8 @@ class EditController extends Controller
'format' => '',
'explain' => '',
'tbranch' => $meta->get_tbranch(),
'publish_cterms' => $meta->get_publish_cterms(),
'generate_cterms' => $meta->get_generate_cterms(),
'gui_editable' => $meta->get_gui_editable(),
'maxLength' => $meta->get_tag()
->getMaxLength(),
'minLength' => $meta->get_tag()

View File

@@ -36,7 +36,8 @@ final class DbalDataboxFieldRepository implements DataboxFieldRepository
'label_fr',
'label_de',
'label_nl',
'publish_cterms',
'generate_cterms',
'gui_editable',
];
/** @var DataboxFieldFactory */

View File

@@ -98,7 +98,7 @@ class ThesaurusHydrator implements HydratorInterface
}
}
else {
if(($fields[$name])->get_publish_cterms()) {
if(($fields[$name])->get_generate_cterms()) {
$this->candidate_terms->insert($field_names[$offset], $values[$offset]);
}
}

View File

@@ -43,7 +43,7 @@ class Field implements Typed
private $thesaurus_roots;
private $publish_cterms;
private $generate_cterms;
private $used_by_collections;
@@ -77,7 +77,7 @@ class Field implements Typed
'private' => $field->isBusiness(),
'facet' => $facet,
'thesaurus_roots' => $roots,
'publish_cterms' => $field->get_publish_cterms(),
'generate_cterms' => $field->get_generate_cterms(),
'used_by_collections' => $databox->get_collection_unique_ids()
]);
}
@@ -106,7 +106,7 @@ class Field implements Typed
$this->is_private = \igorw\get_in($options, ['private'], false);
$this->facet = \igorw\get_in($options, ['facet']);
$this->thesaurus_roots = \igorw\get_in($options, ['thesaurus_roots'], null);
$this->publish_cterms = \igorw\get_in($options, ['publish_cterms'], false);
$this->generate_cterms = \igorw\get_in($options, ['generate_cterms'], false);
$this->used_by_collections = \igorw\get_in($options, ['used_by_collections'], []);
Assertion::boolean($this->is_searchable);
@@ -130,7 +130,7 @@ class Field implements Typed
'private' => $this->is_private,
'facet' => $this->facet,
'thesaurus_roots' => $this->thesaurus_roots,
'publish_cterms' => $this->publish_cterms,
'generate_cterms' => $this->generate_cterms,
'used_by_collections' => $this->used_by_collections
]);
}
@@ -195,9 +195,9 @@ class Field implements Typed
return $this->thesaurus_roots;
}
public function get_publish_cterms()
public function get_generate_cterms()
{
return $this->publish_cterms;
return $this->generate_cterms;
}
/**

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;

View File

@@ -2034,11 +2034,19 @@
<comment></comment>
</field>
<field>
<name>publish_cterms</name>
<name>generate_cterms</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default></default>
<default>1</default>
<comment></comment>
</field>
<field>
<name>gui_editable</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields>

View File

@@ -189,6 +189,14 @@
</label>
</td>
</tr>
<tr>
<td>
<label for="gui_editable" class="checkbox">
<input id="gui_editable" type="checkbox" <%= field.gui_editable ? "checked='checked'" : "" %> />
{% trans %}gui_editable{% endtrans %}
</label>
</td>
</tr>
<tr>
<td colspan="2">
<label for="business" class="checkbox">
@@ -248,8 +256,8 @@
<td><input id="tbranch" type="text" value="<%= field.tbranch %>"/></td>
</tr>
<tr>
<td><label for="publish_cterms" class="checkbox">{% trans %}publish_cterms{% endtrans %}</label></td>
<td><input id="publish_cterms" type="checkbox" <%= field.publish_cterms ? "checked='checked'" : "" %> /></td>
<td><label for="generate_cterms" class="checkbox">{% trans %}generate_cterms{% endtrans %}</label></td>
<td><input id="generate_cterms" type="checkbox" <%= field.generate_cterms ? "checked='checked'" : "" %> /></td>
</tr>
</table>
</div>

View File

@@ -26,7 +26,8 @@ define([
"type": "string",
"thumbtitle": "0",
"tbranch": "",
"publish_cterms": false,
"generate_cterms": false,
"gui_editable": true,
"separator": "",
"required": false,
"report": true,

View File

@@ -44,8 +44,12 @@ define([
this.field.get('tbranch').should.equal("");
});
it("should default publish_cterms property to '0'", function () {
this.field.get('publish_cterms').should.equal("0");
it("should default generate_cterms property to '1'", function () {
this.field.get('generate_cterms').should.equal("1");
});
it("should default gui_editable property to '1'", function () {
this.field.get('gui_editable').should.equal("1");
});
it("should default separator property to 'empty'", function () {