[skip ci]

PHRAS-3381_tx-as-classification-plan_MASTER
back controller for ok button
fix : PHRAS-3383
WIP
This commit is contained in:
jygaulier
2021-03-11 20:10:49 +01:00
parent 92df433af0
commit a76f64e892
10 changed files with 482 additions and 63 deletions

View File

@@ -1,3 +1,6 @@
<h3 style="color: red">POC/Experimental. The OK button will <u>NOT</u> edit records.</h3>
{% if error %}
{{ error }}
@@ -11,7 +14,7 @@
<form id="DroppedOnTH_form">
<table>
<tr>
<th>svalue</th>
<th>value</th>
<th><span class="fieldSelected" style="display: none">operation</span></th>
<th>to field</th>
</tr>
@@ -43,7 +46,9 @@
<option class="mono" value="set">set to</option>
<option class="multi" value="add">add to</option>
<option class="multi" value="replace">replace all</option>
<option class="mono multi" value="remove">remove from</option>
{# do NOT mix the following 2 options as one #}
<option class="mono" value="delete">delete</option>
<option class="multi" value="delete">remove from</option>
</select>
</td>
<td>
@@ -88,14 +93,30 @@
$(' .fieldSelect').filter(function () { return $(this).prop('selectedIndex')>0;}).each(function () {
let n = $(this).data('n');
data.push({
'field': $(this).val(),
'op' : $(' .actionSelect._'+n, $container).val(),
'value': $(' .synonym._'+n, $container).val()
'field_name': $(this).val(),
'action' : $(' .actionSelect._'+n, $container).val(),
'value' : $(' .synonym._'+n, $container).val()
});
});
data = {
'records': {{ records|json_encode|raw }},
'actions': {
'metadatas': data
}
};
console.log(data);
// $( this ).dialog( "close" );
$.ajax({
url: "{{ path('prod_edit_applyJSAction') }}",
type: "POST",
contentType: "application/json",
data: JSON.stringify(data),
success: function (data, textStatus) {
console.log(data);
}
},
);
}
},
{
@@ -115,18 +136,13 @@
let select = $(this);
let n = select.data('n');
if( $('option:eq(' + select.prop('selectedIndex') + ')', select).data('multi') ) {
// this select is on a multi-valued field
$(' .actionSelect._'+n+' OPTION.mono', $container).hide();
$(' .actionSelect._'+n+' OPTION.multi', $container).show();
$(' .actionSelect._'+n).prop('selectedIndex', 1); // add
}
else {
// this select is on a mono-valued field
$(' .actionSelect._'+n+' OPTION.multi', $container).hide();
$(' .actionSelect._'+n+' OPTION.mono', $container).show();
$(' .actionSelect._'+n).prop('selectedIndex', 0); // set
}
// show only possible actions, depending on field is mono/multi
let actionSelect = $(' .actionSelect._'+n, $container);
let multi = !!$('option:eq(' + select.prop('selectedIndex') + ')', select).data('multi');
$(' OPTION.mono', actionSelect).toggle(!multi);
$(' OPTION.multi', actionSelect).toggle(multi);
// set default action
actionSelect.prop('selectedIndex', multi ? 1 : 0); // 1=add : 0=set
// if at least one destination field is set, show some elements
let oneFieldSet = false;

View File

@@ -145,6 +145,7 @@
{% endif %}
</div>
{% if basket.getValidation() %}
<script type="text/javascript">
$( ".update-feed-validation" ).on( "submit", function( event ) {
@@ -197,5 +198,6 @@
</script>
{% endif %}

View File

@@ -183,32 +183,33 @@
<div id="retractableButton"><i class="fa fa-angle-double-left" aria-hidden="true"></i></div>
{% include 'prod/tab_headers.html.twig' %}
{% import 'prod/WorkZone/Macros.html.twig' as WorkZoneMacros %}
{% set expose_activate = app['conf'].get(['phraseanet-service', 'expose-service', 'activated']) %}
{% if expose_activate == 'true' %}
{% block tab_headers_wrapper %}
<div id="baskets_wrapper" class="PNB">
<div id="expose_tabs" class="tabs" aria-expanded="false">
<ul>
<li class="th_tab expose_li"><a href="#baskets"><span>{{ 'prod::basketTab:basket' | trans }}</span></a></li>
<li class="th_tab expose_li"><a href="#expose_tab"><span>{{ 'prod::basketTab:expose' | trans }}</span></a></li>
</ul>
<div class="ui-tabs-panels-container">
<div id="baskets" class="PNB">
{{WorkZoneMacros.make_bloc(app, WorkZone)}}
</div>
<div id="expose_tab">
{{ WorkZoneMacros.make_expose_bloc(app, WorkZone) }}
</div>
{% import 'prod/WorkZone/Macros.html.twig' as WorkZoneMacros %}
{% set expose_activate = app['conf'].get(['phraseanet-service', 'expose-service', 'activated']) %}
{% if expose_activate == 'true' %}
{% block tab_headers_wrapper %}
<div id="baskets_wrapper" class="PNB">
<div id="expose_tabs" class="tabs" aria-expanded="false">
<ul>
<li class="th_tab expose_li"><a href="#baskets"><span>{{ 'prod::basketTab:basket' | trans }}</span></a></li>
<li class="th_tab expose_li"><a href="#expose_tab"><span>{{ 'prod::basketTab:expose' | trans }}</span></a></li>
</ul>
<div class="ui-tabs-panels-container">
<div id="baskets" class="PNB">
{{WorkZoneMacros.make_bloc(app, WorkZone)}}
</div>
<div id="expose_tab">
{{ WorkZoneMacros.make_expose_bloc(app, WorkZone) }}
</div>
</div>
</div>
{% endblock %}
{% else %}
<div id="baskets" class="PNB">
{{WorkZoneMacros.make_bloc(app, WorkZone)}}
</div>
{% endif %}
</div>
{% endblock %}
{% else %}
<div id="baskets" class="PNB">
{{WorkZoneMacros.make_bloc(app, WorkZone)}}
</div>
{% endif %}
{% if GV_thesaurus %}
<div id="proposals" class="PNB thesaurus-from-facets-action">
@@ -268,6 +269,7 @@
</div>
{% include 'prod/tab_thesaurus.html.twig' with {has_access_to_module: app.getAclForUser(app.getAuthenticatedUser()).has_access_to_module('thesaurus')} %}
{% endif %}
{% endblock %}
{% if plugins.workzone is not empty %}
<div id="plugins" class="PNB {{ plugins.workzone|length > 1 ? 'multiple-plugin' : 'single-plugin' }}" style="top:52px;">

View File

@@ -17,7 +17,10 @@
</li>
{% endif %}
<li class="ui-corner-top baskets">
<a href="#baskets_wrapper" class="WZbasketTab WZtabs">
{% set expose_activate = app['conf'].get(['phraseanet-service', 'expose-service', 'activated']) %}
{% set hash = expose_activate ? '#baskets_wrapper' : '#baskets' %}
<a href="{{ hash }}" class="WZbasketTab WZtabs">
<img src="/assets/common/images/icons/workzone32.png" title="{{ 'phraseanet:: baskets' | trans }}"/>
<div id="basket_menu_trigger">&#9660;</div>
</a>