Skip to content

Commit

Permalink
PHRAS-3947: Prod - Editing - restrict field content to thesaurus and …
Browse files Browse the repository at this point in the history
…or suggested values (#4426)

* add property input-disabled in field

* fix

* fix
  • Loading branch information
aynsix authored Dec 4, 2023
1 parent 945be4c commit f0baae9
Show file tree
Hide file tree
Showing 27 changed files with 232 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Phraseanet-production-client/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ module.exports = {
setupDir: _root + 'tests/setup/node.js',
karmaConf: _root + 'config/karma.conf.js',
// change this version when you change JS file for lazy loading
assetFileVersion: 98
assetFileVersion: 99
};
2 changes: 1 addition & 1 deletion Phraseanet-production-client/dist/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=98";
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=99";
/******/ var timeout = setTimeout(onScriptComplete, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ function onScriptComplete() {
Expand Down
2 changes: 1 addition & 1 deletion Phraseanet-production-client/dist/authenticate.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=98";
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=99";
/******/ var timeout = setTimeout(onScriptComplete, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ function onScriptComplete() {
Expand Down
2 changes: 1 addition & 1 deletion Phraseanet-production-client/dist/commons.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=98";
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".js?v=99";
/******/ var timeout = setTimeout(onScriptComplete, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ function onScriptComplete() {
Expand Down
2 changes: 1 addition & 1 deletion Phraseanet-production-client/dist/commons.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=98";
/******/ script.src = __webpack_require__.p + "lazy-" + ({}[chunkId]||chunkId) + ".min.js?v=99";
/******/ var timeout = setTimeout(onScriptComplete, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ function onScriptComplete() {
Expand Down
18 changes: 18 additions & 0 deletions Phraseanet-production-client/dist/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -22818,12 +22818,24 @@ var recordEditorService = function recordEditorService(services) {
$editTimeArea.hide();
$editDateArea.css('width', 210);
}

if (field.input_disable) {
$editDateArea.prop('disabled', true);
} else {
$editDateArea.prop('disabled', false);
}
} else {
$editDateArea.hide();
$editTimeArea.hide();
(0, _jquery2.default)('#idEditDateZone', options.$container).hide();
$editTextArea.show();
$editTextArea.css('height', '100%');

if (field.input_disable) {
$editTextArea.prop('disabled', true);
} else {
$editTextArea.prop('disabled', false);
}
}

$ztextStatus.hide();
Expand Down Expand Up @@ -22884,6 +22896,12 @@ var recordEditorService = function recordEditorService(services) {

$editMultiValTextArea.trigger('keyup.maxLength');

if (field.input_disable) {
$editMultiValTextArea.prop('disabled', true);
} else {
$editMultiValTextArea.prop('disabled', false);
}

self.setTimeout(function () {
return $editMultiValTextArea.focus();
}, 50);
Expand Down
18 changes: 18 additions & 0 deletions Phraseanet-production-client/dist/production.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -22818,12 +22818,24 @@ var recordEditorService = function recordEditorService(services) {
$editTimeArea.hide();
$editDateArea.css('width', 210);
}

if (field.input_disable) {
$editDateArea.prop('disabled', true);
} else {
$editDateArea.prop('disabled', false);
}
} else {
$editDateArea.hide();
$editTimeArea.hide();
(0, _jquery2.default)('#idEditDateZone', options.$container).hide();
$editTextArea.show();
$editTextArea.css('height', '100%');

if (field.input_disable) {
$editTextArea.prop('disabled', true);
} else {
$editTextArea.prop('disabled', false);
}
}

$ztextStatus.hide();
Expand Down Expand Up @@ -22884,6 +22896,12 @@ var recordEditorService = function recordEditorService(services) {

$editMultiValTextArea.trigger('keyup.maxLength');

if (field.input_disable) {
$editMultiValTextArea.prop('disabled', true);
} else {
$editMultiValTextArea.prop('disabled', false);
}

self.setTimeout(function () {
return $editMultiValTextArea.focus();
}, 50);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,24 @@ const recordEditorService = services => {
$editTimeArea.hide();
$editDateArea.css('width',210);
}

if (field.input_disable) {
$editDateArea.prop('disabled', true);
} else {
$editDateArea.prop('disabled', false);
}
} else {
$editDateArea.hide();
$editTimeArea.hide();
$('#idEditDateZone', options.$container).hide();
$editTextArea.show();
$editTextArea.css('height', '100%');

if (field.input_disable) {
$editTextArea.prop('disabled', true);
} else {
$editTextArea.prop('disabled', false);
}
}

$ztextStatus.hide();
Expand Down Expand Up @@ -698,6 +710,12 @@ const recordEditorService = services => {

$editMultiValTextArea.trigger('keyup.maxLength');

if (field.input_disable) {
$editMultiValTextArea.prop('disabled', true);
} else {
$editMultiValTextArea.prop('disabled', false);
}

self.setTimeout(() => $editMultiValTextArea.focus(), 50);

// reveal_mval();
Expand Down
3 changes: 2 additions & 1 deletion lib/Alchemy/Phrasea/Controller/Admin/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ private function updateFieldWithData(\databox_field $field, array $data)
->set_gui_editable($data['gui_editable'])
->set_gui_visible($data['gui_visible'])
->set_printable($data['printable'])
->set_input_disable($data['input_disable'])
->set_report($data['report'])
->setVocabularyControl(null)
->setVocabularyRestricted(false);
Expand Down Expand Up @@ -353,7 +354,7 @@ private function getMandatoryFieldProperties()
{
return [
'name', 'multi', 'thumbtitle', 'tag', 'business', 'indexable', 'aggregable',
'required', 'separator', 'readonly', 'gui_editable', 'gui_visible' , 'printable', 'type', 'tbranch', 'generate_cterms', 'report',
'required', 'separator', 'readonly', 'gui_editable', 'gui_visible' , 'printable', 'input_disable', 'type', 'tbranch', 'generate_cterms', 'report',
'vocabulary-type', 'vocabulary-restricted', 'dces-element', 'labels'
];
}
Expand Down
1 change: 1 addition & 0 deletions lib/Alchemy/Phrasea/Controller/Api/V1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ private function listDataboxMetadataFieldProperties(\databox_field $databox_fiel
'gui_editable' => $databox_field->get_gui_editable(),
'gui_visible' => $databox_field->get_gui_visible(),
'printable' => $databox_field->get_printable(),
'input_disable' => $databox_field->get_input_disable(),
'type' => $databox_field->get_type(),
'indexable' => $databox_field->is_indexable(),
'multivalue' => $databox_field->is_multi(),
Expand Down
1 change: 1 addition & 0 deletions lib/Alchemy/Phrasea/Controller/Prod/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function submitAction(Request $request)
'gui_editable' => $meta->get_gui_editable(),
'gui_visible' => $meta->get_gui_visible(),
'printable' => $meta->get_printable(),
'input_disable' => $meta->get_input_disable(),
'maxLength' => $meta->get_tag()
->getMaxLength(),
'minLength' => $meta->get_tag()
Expand Down
2 changes: 1 addition & 1 deletion lib/Alchemy/Phrasea/Core/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Version
* @var string
*/

private $number = '4.1.8-rc7';
private $number = '4.1.8-rc8';

/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class DbalDataboxFieldRepository implements DataboxFieldRepository
'gui_editable',
'gui_visible',
'printable',
'input_disable',
];

/** @var DataboxFieldFactory */
Expand Down
2 changes: 1 addition & 1 deletion lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getGlobals()
{
return [
// change this version when you change JS file to force the navigation to reload js file
'assetFileVersion' => 98
'assetFileVersion' => 99
];

}
Expand Down
1 change: 1 addition & 0 deletions lib/classes/databox.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ public function feed_meta_fields()
->set_gui_editable((!isset($field['gui_editable']) || (isset($field['gui_editable']) && (string) $field['gui_editable'] == 1)))
->set_gui_visible((!isset($field['gui_visible']) || (isset($field['gui_visible']) && (string) $field['gui_visible'] == 1)))
->set_printable((!isset($field['printable']) || (isset($field['printable']) && (string) $field['printable'] == 1)))
->set_input_disable((isset($field['input_disable']) && (string) $field['input_disable'] == 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();
Expand Down
36 changes: 31 additions & 5 deletions lib/classes/databox/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class databox_field implements cache_cacheableInterface
protected $generate_cterms;
protected $gui_editable;
protected $gui_visible;
protected $input_disable;
protected $printable;
protected $separator;
protected $thumbtitle;
Expand Down Expand Up @@ -174,6 +175,7 @@ protected function loadFromRow(array $row)
$this->gui_editable = (bool)$row['gui_editable'];
$this->gui_visible = (bool)$row['gui_visible'];
$this->printable = (bool)$row['printable'];
$this->input_disable = (bool)$row['input_disable'];
$this->VocabularyType = $row['VocabularyControlType'];
$this->VocabularyRestriction = (bool)$row['RestrictToVocabularyControl'];

Expand Down Expand Up @@ -318,6 +320,7 @@ public function save()
`gui_editable` = :gui_editable,
`gui_visible` = :gui_visible,
`printable` = :printable,
`input_disable` = :input_disable,
`sorter` = :position,
`thumbtitle` = :thumbtitle,
`VocabularyControlType` = :VocabularyControlType,
Expand All @@ -341,10 +344,11 @@ public function save()
':report' => $this->report ? '1' : '0',
':type' => $this->type,
':tbranch' => $this->tbranch,
':generate_cterms' => $this->generate_cterms ? '1' : '0',
':generate_cterms' => $this->generate_cterms ? '1' : '0',
':gui_editable' => $this->gui_editable ? '1' : '0',
':gui_visible' => $this->gui_visible ? '1' : '0',
':gui_visible' => $this->gui_visible ? '1' : '0',
':printable' => $this->printable ? '1' : '0',
':input_disable' => $this->input_disable ? '1' : '0',
':position' => $this->position,
':thumbtitle' => $this->thumbtitle,
':VocabularyControlType' => $this->getVocabularyControl() ? $this->getVocabularyControl()->getType() : null,
Expand Down Expand Up @@ -400,6 +404,7 @@ public function save()
$meta->setAttribute('gui_editable', $this->gui_editable ? '1' : '0');
$meta->setAttribute('gui_visible', $this->gui_visible ? '1' : '0');
$meta->setAttribute('printable', $this->printable ? '1' : '0');
$meta->setAttribute('input_disable', $this->input_disable ? '1' : '0');
if ($this->multi) {
$meta->setAttribute('separator', $this->separator);
}
Expand Down Expand Up @@ -775,6 +780,17 @@ public function set_printable($printable)
return $this;
}

/**
* @param boolean $input_disable
* @return databox_field
*/
public function set_input_disable($input_disable)
{
$this->input_disable = $input_disable;

return $this;
}

/**
*
* @param string $separator
Expand Down Expand Up @@ -895,6 +911,15 @@ public function get_printable()
return $this->printable;
}

/**
*
* @return boolean
*/
public function get_input_disable()
{
return $this->input_disable;
}

/**
* @param Boolean $all If set to false, returns a one-char separator to use for serialiation
*
Expand Down Expand Up @@ -1007,8 +1032,9 @@ public function toArray()
'tbranch' => $this->tbranch,
'generate_cterms' => $this->generate_cterms,
'gui_editable' => $this->gui_editable,
'gui_visible' => $this->gui_visible,
'gui_visible' => $this->gui_visible,
'printable' => $this->printable,
'input_disable' => $this->input_disable,
'separator' => $this->separator,
'required' => $this->required,
'report' => $this->report,
Expand Down Expand Up @@ -1047,10 +1073,10 @@ public static function create(Application $app, databox $databox, $name)
}

$sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `gui_editable`,`gui_visible`, `printable`, `required`, `indexable`, `type`, `tbranch`, `generate_cterms`,
(`id`, `name`, `src`, `readonly`, `gui_editable`,`gui_visible`, `printable`, `input_disable`, `required`, `indexable`, `type`, `tbranch`, `generate_cterms`,
`thumbtitle`, `multi`, `business`, `aggregable`,
`report`, `sorter`, `separator`)
VALUES (null, :name, '', 0, 1, 1, 1, 0, 1, 'string', '', 1,
VALUES (null, :name, '', 0, 1, 1, 1, 0, 0, 1, 'string', '', 1,
null, 0, 0, 0,
1, :sorter, '')";

Expand Down
8 changes: 8 additions & 0 deletions lib/conf.d/bases_structure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,14 @@
<default>1</default>
<comment></comment>
</field>
<field>
<name>input_disable</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default>0</default>
<comment></comment>
</field>
</fields>
<indexes>
<index>
Expand Down
Loading

0 comments on commit f0baae9

Please sign in to comment.