mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
[skip ci]
PHRAS-3381_tx-as-classification-plan_MASTER fix : "replace_all" ok back : ok is handled WIP
This commit is contained in:
17
Phraseanet-production-client/dist/production.js
vendored
17
Phraseanet-production-client/dist/production.js
vendored
@@ -11638,23 +11638,6 @@ var thesaurusService = function thesaurusService(services) {
|
|||||||
// title: localeService.t('add data'),
|
// title: localeService.t('add data'),
|
||||||
loading: true
|
loading: true
|
||||||
}, 0);
|
}, 0);
|
||||||
// dlg.setContent("");
|
|
||||||
|
|
||||||
// let parms = {
|
|
||||||
// url: '/thesaurus/drop_records.php',
|
|
||||||
// data: {
|
|
||||||
// 'sbas_id': sbas_id,
|
|
||||||
// 'tx_term_id': tx_term_id,
|
|
||||||
// 'lst': lstRecords
|
|
||||||
// },
|
|
||||||
// async: true,
|
|
||||||
// cache: false,
|
|
||||||
// dataType: 'json',
|
|
||||||
// // timeout: 10 * 60 * 1000, // 10 minutes !
|
|
||||||
// success: function (result, textStatus) {
|
|
||||||
// dlg.setContent(result);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
_jquery2.default.get(url + 'prod/thesaurus/droprecords', {
|
_jquery2.default.get(url + 'prod/thesaurus/droprecords', {
|
||||||
'dlg_level': 0,
|
'dlg_level': 0,
|
||||||
|
@@ -11638,23 +11638,6 @@ var thesaurusService = function thesaurusService(services) {
|
|||||||
// title: localeService.t('add data'),
|
// title: localeService.t('add data'),
|
||||||
loading: true
|
loading: true
|
||||||
}, 0);
|
}, 0);
|
||||||
// dlg.setContent("");
|
|
||||||
|
|
||||||
// let parms = {
|
|
||||||
// url: '/thesaurus/drop_records.php',
|
|
||||||
// data: {
|
|
||||||
// 'sbas_id': sbas_id,
|
|
||||||
// 'tx_term_id': tx_term_id,
|
|
||||||
// 'lst': lstRecords
|
|
||||||
// },
|
|
||||||
// async: true,
|
|
||||||
// cache: false,
|
|
||||||
// dataType: 'json',
|
|
||||||
// // timeout: 10 * 60 * 1000, // 10 minutes !
|
|
||||||
// success: function (result, textStatus) {
|
|
||||||
// dlg.setContent(result);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
_jquery2.default.get(url + 'prod/thesaurus/droprecords', {
|
_jquery2.default.get(url + 'prod/thesaurus/droprecords', {
|
||||||
'dlg_level': 0,
|
'dlg_level': 0,
|
||||||
|
@@ -266,27 +266,10 @@ const thesaurusService = services => {
|
|||||||
customWidth: 770,
|
customWidth: 770,
|
||||||
customHeight: 400,
|
customHeight: 400,
|
||||||
// title: localeService.t('add data'),
|
// title: localeService.t('add data'),
|
||||||
loading: true,
|
loading: true
|
||||||
},
|
},
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
// dlg.setContent("");
|
|
||||||
|
|
||||||
// let parms = {
|
|
||||||
// url: '/thesaurus/drop_records.php',
|
|
||||||
// data: {
|
|
||||||
// 'sbas_id': sbas_id,
|
|
||||||
// 'tx_term_id': tx_term_id,
|
|
||||||
// 'lst': lstRecords
|
|
||||||
// },
|
|
||||||
// async: true,
|
|
||||||
// cache: false,
|
|
||||||
// dataType: 'json',
|
|
||||||
// // timeout: 10 * 60 * 1000, // 10 minutes !
|
|
||||||
// success: function (result, textStatus) {
|
|
||||||
// dlg.setContent(result);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
$.get(
|
$.get(
|
||||||
`${url}prod/thesaurus/droprecords`,
|
`${url}prod/thesaurus/droprecords`,
|
||||||
|
@@ -4,10 +4,10 @@ namespace Alchemy\Phrasea\Twig;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Collection\CollectionHelper;
|
use Alchemy\Phrasea\Collection\CollectionHelper;
|
||||||
|
use Alchemy\Phrasea\Http\StaticFile\StaticMode;
|
||||||
use Alchemy\Phrasea\Model\Entities\ElasticsearchRecord;
|
use Alchemy\Phrasea\Model\Entities\ElasticsearchRecord;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
use Alchemy\Phrasea\Model\RecordInterface;
|
use Alchemy\Phrasea\Model\RecordInterface;
|
||||||
use Alchemy\Phrasea\Http\StaticFile\StaticMode;
|
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Flag;
|
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Flag;
|
||||||
|
|
||||||
class PhraseanetExtension extends \Twig_Extension
|
class PhraseanetExtension extends \Twig_Extension
|
||||||
@@ -59,7 +59,7 @@ class PhraseanetExtension extends \Twig_Extension
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// change this version when you change JS file to force the navigation to reload js file
|
// change this version when you change JS file to force the navigation to reload js file
|
||||||
'jsFileVersion' => 8
|
'jsFileVersion' => 9
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1128,7 +1128,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
public function setMetadatasByActions(stdClass $actions)
|
public function setMetadatasByActions(stdClass $actions)
|
||||||
{
|
{
|
||||||
// WIP crashes when trying to access an undefined stdClass property ? should return null ?
|
// WIP crashes when trying to access an undefined stdClass property ? should return null ?
|
||||||
// $this->apply_body($actions);
|
$this->apply_body($actions);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,20 +1141,19 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stdClass $b
|
* @param stdClass $b
|
||||||
* @param record_adapter $record
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function apply_body(stdClass $b)
|
private function apply_body(stdClass $b)
|
||||||
{
|
{
|
||||||
// do metadatas ops
|
// do metadatas ops
|
||||||
if (is_array($b->metadatas)) {
|
if (is_array(@$b->metadatas)) {
|
||||||
$this->do_metadatas($b->metadatas);
|
$this->do_metadatas($b->metadatas);
|
||||||
}
|
}
|
||||||
// do sb ops
|
// do sb ops
|
||||||
if (is_array($b->status)) {
|
if (is_array(@$b->status)) {
|
||||||
$this->do_status($b->status);
|
$this->do_status($b->status);
|
||||||
}
|
}
|
||||||
if(!is_null($b->base_id)) {
|
if(!is_null(@$b->base_id)) {
|
||||||
$this->do_collection($b->base_id);
|
$this->do_collection($b->base_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1176,8 +1175,10 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
/**
|
/**
|
||||||
* @param $metadatas
|
* @param $metadatas
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
*
|
||||||
|
* nb : use of "silent" @ operator on stdClass member access (equals null in not defined) is more simple than "iseet()" or "empty()"
|
||||||
*/
|
*/
|
||||||
private function do_metadatas($metadatas)
|
private function do_metadatas(array $metadatas)
|
||||||
{
|
{
|
||||||
/** @var databox_field[] $struct */
|
/** @var databox_field[] $struct */
|
||||||
$struct = $this->getDatabox()->get_meta_structure();
|
$struct = $this->getDatabox()->get_meta_structure();
|
||||||
@@ -1192,15 +1193,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$metadatas_ops = [];
|
$metadatas_ops = [];
|
||||||
|
/** @var stdClass $_m */
|
||||||
foreach ($metadatas as $_m) {
|
foreach ($metadatas as $_m) {
|
||||||
// sanity
|
// sanity
|
||||||
if($_m->meta_struct_id && $_m->field_name) { // WIP crashes if meta_struct_id is undefined
|
if(@$_m->meta_struct_id && @$_m->field_name) { // WIP crashes if meta_struct_id is undefined
|
||||||
throw new Exception("define meta_struct_id OR field_name, not both.");
|
throw new Exception("define meta_struct_id OR field_name, not both.");
|
||||||
}
|
}
|
||||||
// select fields that match meta_struct_id or field_name (can be arrays)
|
// select fields that match meta_struct_id or field_name (can be arrays)
|
||||||
$fields_list = null; // to filter caption_fields from record, default all
|
$fields_list = null; // to filter caption_fields from record, default all
|
||||||
$struct_fields = []; // struct fields that match meta_struct_id or field_name
|
$struct_fields = []; // struct fields that match meta_struct_id or field_name
|
||||||
$field_keys = $_m->meta_struct_id ? $_m->meta_struct_id : $_m->field_name; // can be null if none defined (=match all)
|
$field_keys = @$_m->meta_struct_id ?: @$_m->field_name; // can be null if none defined (=match all)
|
||||||
if($field_keys !== null) {
|
if($field_keys !== null) {
|
||||||
if (!is_array($field_keys)) {
|
if (!is_array($field_keys)) {
|
||||||
$field_keys = [$field_keys];
|
$field_keys = [$field_keys];
|
||||||
@@ -1222,9 +1224,9 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
$caption_fields = $this->get_caption()->get_fields($fields_list, true);
|
$caption_fields = $this->get_caption()->get_fields($fields_list, true);
|
||||||
|
|
||||||
$meta_id = is_null($_m->meta_id) ? null : (int)($_m->meta_id);
|
$meta_id = isset($_m->meta_id) ? (int)($_m->meta_id) : null;
|
||||||
|
|
||||||
if(!($match_method = (string)($_m->match_method))) {
|
if(!($match_method = (string)(@$_m->match_method))) {
|
||||||
$match_method = 'ignore_case';
|
$match_method = 'ignore_case';
|
||||||
}
|
}
|
||||||
if(!in_array($match_method, ['strict', 'ignore_case', 'regexp'])) {
|
if(!in_array($match_method, ['strict', 'ignore_case', 'regexp'])) {
|
||||||
@@ -1232,7 +1234,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
if(is_array($_m->value)) {
|
if(is_array(@$_m->value)) {
|
||||||
foreach ($_m->value as $v) {
|
foreach ($_m->value as $v) {
|
||||||
if(($v = trim((string)$v)) !== '') {
|
if(($v = trim((string)$v)) !== '') {
|
||||||
$values[] = $v;
|
$values[] = $v;
|
||||||
@@ -1240,16 +1242,16 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(($v = trim((string)($_m->value))) !== '') {
|
if(($v = trim((string)(@$_m->value))) !== '') {
|
||||||
$values[] = $v;
|
$values[] = $v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!($action = (string)($_m->action))) {
|
if(!($action = (string)(@$_m->action))) {
|
||||||
$action = 'set';
|
$action = 'set';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($_m->action) {
|
switch ($action) {
|
||||||
case 'set':
|
case 'set':
|
||||||
$ops = $this->metadata_set($struct_fields, $caption_fields, $meta_id, $values);
|
$ops = $this->metadata_set($struct_fields, $caption_fields, $meta_id, $values);
|
||||||
break;
|
break;
|
||||||
@@ -1260,6 +1262,9 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
$ops = $this->metadata_replace($caption_fields, $meta_id, $match_method, $values, null);
|
$ops = $this->metadata_replace($caption_fields, $meta_id, $match_method, $values, null);
|
||||||
break;
|
break;
|
||||||
case 'replace':
|
case 'replace':
|
||||||
|
if (!isset($_m->replace_with)) {
|
||||||
|
throw new Exception("missing mandatory \"replace_with\" for action \"replace\".");
|
||||||
|
}
|
||||||
if (!is_string($_m->replace_with) && !is_null($_m->replace_with)) {
|
if (!is_string($_m->replace_with) && !is_null($_m->replace_with)) {
|
||||||
throw new Exception("bad \"replace_with\" for action \"replace\".");
|
throw new Exception("bad \"replace_with\" for action \"replace\".");
|
||||||
}
|
}
|
||||||
@@ -1285,13 +1290,13 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
* @return array
|
* @return array
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function do_status($statuses)
|
private function do_status(array $statuses)
|
||||||
{
|
{
|
||||||
$datas = strrev($this->getStatus());
|
$datas = strrev($this->getStatus());
|
||||||
|
|
||||||
foreach ($statuses as $status) {
|
foreach ($statuses as $status) {
|
||||||
$n = (int)($status->bit);
|
$n = (int)(@$status->bit);
|
||||||
$value = (int)($status->state);
|
$value = (int)(@$status->state);
|
||||||
if ($n > 31 || $n < 4) {
|
if ($n > 31 || $n < 4) {
|
||||||
throw new Exception(sprintf("Invalid status bit number (%s).", $n));
|
throw new Exception(sprintf("Invalid status bit number (%s).", $n));
|
||||||
}
|
}
|
||||||
@@ -1327,7 +1332,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
|||||||
* @return array ops to execute
|
* @return array ops to execute
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function metadata_set(array $struct_fields, $caption_fields, $meta_id, $values): array
|
private function metadata_set(array $struct_fields, array $caption_fields, $meta_id, array $values): array
|
||||||
{
|
{
|
||||||
$ops = [];
|
$ops = [];
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
<option class="multi" value="add">add to</option>
|
<option class="multi" value="add">add to</option>
|
||||||
<option class="multi" value="replace">replace all</option>
|
<option class="multi" value="replace">replace all</option>
|
||||||
{# do NOT mix the following 2 options as one #}
|
{# do NOT mix the following 2 options as one #}
|
||||||
<option class="mono" value="delete">delete</option>
|
<option class="mono" value="delete">delete from</option>
|
||||||
<option class="multi" value="delete">remove from</option>
|
<option class="multi" value="delete">remove from</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@@ -78,8 +78,11 @@
|
|||||||
// let $container = $('#DroppedOnTH_form');
|
// let $container = $('#DroppedOnTH_form');
|
||||||
|
|
||||||
let dlg = dialog.get({{ dlg_level }});
|
let dlg = dialog.get({{ dlg_level }});
|
||||||
|
// todo : find dlg container by .widget() ?
|
||||||
let $container = dlg.getDomElement().parent(); // the whole dlg, including title & buttons
|
let $container = dlg.getDomElement().parent(); // the whole dlg, including title & buttons
|
||||||
|
|
||||||
|
// todo : fix black-dialog-wrap
|
||||||
|
// $container.addClass('black-dialog-wrap');
|
||||||
dlg.setOption("title", "editing {{ received_cnt }} record(s)");
|
dlg.setOption("title", "editing {{ received_cnt }} record(s)");
|
||||||
dlg.setOption("buttons",
|
dlg.setOption("buttons",
|
||||||
[
|
[
|
||||||
@@ -92,11 +95,22 @@
|
|||||||
let data = [];
|
let data = [];
|
||||||
$(' .fieldSelect').filter(function () { return $(this).prop('selectedIndex')>0;}).each(function () {
|
$(' .fieldSelect').filter(function () { return $(this).prop('selectedIndex')>0;}).each(function () {
|
||||||
let n = $(this).data('n');
|
let n = $(this).data('n');
|
||||||
data.push({
|
let action = $(' .actionSelect._'+n, $container).val();
|
||||||
'field_name': $(this).val(),
|
if(action === 'replace') {
|
||||||
'action' : $(' .actionSelect._'+n, $container).val(),
|
// replace ll multi-v needs a "replace_by" arg
|
||||||
'value' : $(' .synonym._'+n, $container).val()
|
data.push({
|
||||||
});
|
'field_name': $(this).val(),
|
||||||
|
'action': action,
|
||||||
|
'replace_with': $(' .synonym._' + n, $container).val()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data.push({
|
||||||
|
'field_name': $(this).val(),
|
||||||
|
'action': action,
|
||||||
|
'value': $(' .synonym._' + n, $container).val()
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
data = {
|
data = {
|
||||||
'records': {{ records|json_encode|raw }},
|
'records': {{ records|json_encode|raw }},
|
||||||
@@ -114,6 +128,7 @@
|
|||||||
data: JSON.stringify(data),
|
data: JSON.stringify(data),
|
||||||
success: function (data, textStatus) {
|
success: function (data, textStatus) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
dlg.close();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user