mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
PHRAS-1766 Add orderable checkbox for each subdef - Remove order option on groups
This commit is contained in:
@@ -149,12 +149,11 @@ class SubdefsController extends Controller
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$subdefs->set_subdef($group, $name, $class, false, $options, [], $preset);
|
$subdefs->set_subdef($group, $name, $class, false, $options, [], true, $preset);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$subdefs = $databox->get_subdef_structure();
|
$subdefs = $databox->get_subdef_structure();
|
||||||
$this->updateSubdefGroups($subdefs, $request);
|
|
||||||
|
|
||||||
foreach ($Parmsubdefs as $post_sub) {
|
foreach ($Parmsubdefs as $post_sub) {
|
||||||
$options = [];
|
$options = [];
|
||||||
@@ -193,7 +192,7 @@ class SubdefsController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$labels = $request->request->get($post_sub . '_label', []);
|
$labels = $request->request->get($post_sub . '_label', []);
|
||||||
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset, $orderable);
|
$subdefs->set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable, $preset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,35 +217,6 @@ class SubdefsController extends Controller
|
|||||||
return $mapping;
|
return $mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update Databox subdefsStructure DOM according to defined groups.
|
|
||||||
*
|
|
||||||
* @param \databox_subdefsStructure $subdefs
|
|
||||||
* @param Request $request
|
|
||||||
*/
|
|
||||||
protected function updateSubdefGroups(\databox_subdefsStructure $subdefs, Request $request)
|
|
||||||
{
|
|
||||||
$subdefsGroups = $request->request->get('subdefsgroups', []);
|
|
||||||
$changedGroups = [];
|
|
||||||
/** @var SubdefGroup $subdefsGroup */
|
|
||||||
foreach ($subdefs as $groupName => $subdefsGroup) {
|
|
||||||
$documentOrderable = isset($subdefsGroups[$groupName]['document_orderable'])
|
|
||||||
? \p4field::isyes($subdefsGroups[$groupName]['document_orderable'])
|
|
||||||
: false;
|
|
||||||
if ($subdefsGroup->isDocumentOrderable() !== $documentOrderable) {
|
|
||||||
if ($documentOrderable) {
|
|
||||||
$subdefsGroup->allowDocumentOrdering();
|
|
||||||
} else {
|
|
||||||
$subdefsGroup->disallowDocumentOrdering();
|
|
||||||
}
|
|
||||||
$changedGroups[] = $subdefsGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($changedGroups) {
|
|
||||||
$subdefs->updateSubdefGroups($changedGroups);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@@ -220,36 +220,19 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param SubdefGroup[] $groups
|
|
||||||
*/
|
|
||||||
public function updateSubdefGroups($groups)
|
|
||||||
{
|
|
||||||
Assertion::allIsInstanceOf($groups, SubdefGroup::class);
|
|
||||||
|
|
||||||
$dom_xp = $this->databox->get_xpath_structure();
|
|
||||||
|
|
||||||
foreach ($groups as $group) {
|
|
||||||
$nodes = $dom_xp->query('//record/subdefs/subdefgroup[@name="' . $group->getName() . '"]');
|
|
||||||
|
|
||||||
/** @var DOMElement $node */
|
|
||||||
foreach ($nodes as $node) {
|
|
||||||
$node->setAttribute('document_orderable', ($group->isDocumentOrderable() ? 'true' : 'false'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param string $group
|
* @param string $group
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $class
|
* @param string $class
|
||||||
* @param string $preset
|
|
||||||
* @param boolean $downloadable
|
* @param boolean $downloadable
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @param array $labels
|
* @param array $labels
|
||||||
|
* @param boolean $orderable
|
||||||
|
* @param string $preset
|
||||||
* @return databox_subdefsStructure
|
* @return databox_subdefsStructure
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $preset = "Custom")
|
public function set_subdef($group, $name, $class, $downloadable, $options, $labels, $orderable = true, $preset = "Custom")
|
||||||
{
|
{
|
||||||
$dom_struct = $this->databox->get_dom_structure();
|
$dom_struct = $this->databox->get_dom_structure();
|
||||||
|
|
||||||
@@ -257,6 +240,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
|||||||
$subdef->setAttribute('class', $class);
|
$subdef->setAttribute('class', $class);
|
||||||
$subdef->setAttribute('name', mb_strtolower($name));
|
$subdef->setAttribute('name', mb_strtolower($name));
|
||||||
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
$subdef->setAttribute('downloadable', ($downloadable ? 'true' : 'false'));
|
||||||
|
$subdef->setAttribute('orderable', ($orderable ? 'true' : 'false'));
|
||||||
$subdef->setAttribute('presets', $preset);
|
$subdef->setAttribute('presets', $preset);
|
||||||
|
|
||||||
foreach ($labels as $code => $label) {
|
foreach ($labels as $code => $label) {
|
||||||
|
@@ -373,24 +373,6 @@
|
|||||||
<button type="submit" disabled="disabled" class="btn btn-primary subviews-submit">{{ 'boutton::valider' | trans }}</button>
|
<button type="submit" disabled="disabled" class="btn btn-primary subviews-submit">{{ 'boutton::valider' | trans }}</button>
|
||||||
{% for subdefgroup, subdeflist in subdefs %}
|
{% for subdefgroup, subdeflist in subdefs %}
|
||||||
<div id="{{subdefgroup}}">
|
<div id="{{subdefgroup}}">
|
||||||
<div>
|
|
||||||
<table cellspacing="0" cellpadding="0" border="0" style="width:500px;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="width:120px;">
|
|
||||||
<h2>{{ 'subdef.document' | trans }}</h2>
|
|
||||||
</td>
|
|
||||||
<td style="width:250px;"></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>{{ 'subdef.orderable' | trans }}</td>
|
|
||||||
<td><input type="checkbox" name="subdefsgroups[{{ subdefgroup }}][document_orderable]" {% if subdeflist.isDocumentOrderable() %}checked="checked" {% endif %}value="1"/></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
{% for subdefname , subdef in subdeflist %}
|
{% for subdefname , subdef in subdeflist %}
|
||||||
<div>
|
<div>
|
||||||
<input type="hidden" name="subdefs[]" value="{{subdefgroup}}_{{subdefname}}"/>
|
<input type="hidden" name="subdefs[]" value="{{subdefgroup}}_{{subdefname}}"/>
|
||||||
@@ -404,6 +386,11 @@
|
|||||||
<td style="width:300px;"><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.isDownloadable() %}checked="checked"{% endif %} value="1" /></td>
|
<td style="width:300px;"><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_downloadable" {% if subdef.isDownloadable() %}checked="checked"{% endif %} value="1" /></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ 'subdef.orderable' | trans }}</td>
|
||||||
|
<td><input type="checkbox" name="{{subdefgroup}}_{{subdefname}}_orderable" {% if subdef.isOrderable() %}checked="checked"{% endif %} value="1" /></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
{{ 'classe' | trans }}
|
{{ 'classe' | trans }}
|
||||||
|
Reference in New Issue
Block a user