mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
order field mapping in expose
This commit is contained in:
@@ -10055,6 +10055,8 @@ var workzone = function workzone(services) {
|
||||
},
|
||||
success: function success(data) {
|
||||
(0, _jquery2.default)('#DIALOG-field-mapping .databox-field-list').empty().html(data);
|
||||
|
||||
(0, _jquery2.default)('.field-list').sortable().disableSelection();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -10055,6 +10055,8 @@ var workzone = function workzone(services) {
|
||||
},
|
||||
success: function success(data) {
|
||||
(0, _jquery2.default)('#DIALOG-field-mapping .databox-field-list').empty().html(data);
|
||||
|
||||
(0, _jquery2.default)('.field-list').sortable().disableSelection();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -145,6 +145,8 @@ const workzone = (services) => {
|
||||
},
|
||||
success: function (data) {
|
||||
$('#DIALOG-field-mapping .databox-field-list').empty().html(data);
|
||||
|
||||
$('.field-list').sortable().disableSelection();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -728,23 +728,21 @@ class PSExposeController extends Controller
|
||||
'message' => "Expose configuration not set!"
|
||||
]);
|
||||
}
|
||||
|
||||
$exposeMappingName = $this->getExposeMappingName();
|
||||
$clientAnnotationProfile = $this->getClientAnnotationProfile($exposeClient, $exposeName, $profile);
|
||||
|
||||
$fields = $this->getFields();
|
||||
$actualFieldsList = !empty($clientAnnotationProfile[$exposeMappingName]) ? $clientAnnotationProfile[$exposeMappingName] : [];
|
||||
$fields = $this->getFields($actualFieldsList);
|
||||
|
||||
return $this->render('prod/WorkZone/ExposeFieldList.html.twig', [
|
||||
'fields' => $fields,
|
||||
'actualFieldsList' => !empty($clientAnnotationProfile[$exposeMappingName]) ? $clientAnnotationProfile[$exposeMappingName] : []
|
||||
]);
|
||||
}
|
||||
|
||||
public function getFieldMappingAction(PhraseaApplication $app, Request $request)
|
||||
{
|
||||
$fields = $this->getFields();
|
||||
|
||||
return $this->render('prod/WorkZone/ExposeFieldMapping.html.twig', [
|
||||
'fields' => $fields,
|
||||
'exposeName' => $request->get('exposeName')
|
||||
]);
|
||||
}
|
||||
@@ -854,16 +852,32 @@ class PSExposeController extends Controller
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getFields()
|
||||
private function getFields($actualFieldsList)
|
||||
{
|
||||
$databoxes = $this->getApplicationBox()->get_databoxes();
|
||||
|
||||
$fields = [];
|
||||
$fieldFromProfile = [];
|
||||
foreach ($actualFieldsList as $value) {
|
||||
$t = explode('_', $value);
|
||||
$databox = $this->getApplicationBox()->get_databox($t[0]);
|
||||
$viewName = $databox->get_viewname();
|
||||
|
||||
$fieldFromProfile[$viewName][$t[1]]['id'] = $value;
|
||||
$fieldFromProfile[$viewName][$t[1]]['name'] = $databox->get_meta_structure()->get_element($t[1])->get_label($this->app['locale']);
|
||||
$fieldFromProfile[$viewName][$t[1]]['checked'] = true;
|
||||
}
|
||||
|
||||
$fields = $fieldFromProfile;
|
||||
foreach ($databoxes as $databox) {
|
||||
foreach ($databox->get_meta_structure() as $meta) {
|
||||
// get databoxID_metaID for the checkbox name
|
||||
if (!empty($fields[$databox->get_viewname()][$meta->get_id()]) && in_array($databox->get_sbas_id().'_'.$meta->get_id(), $fields[$databox->get_viewname()][$meta->get_id()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fields[$databox->get_viewname()][$meta->get_id()]['id'] = $databox->get_sbas_id().'_'.$meta->get_id();
|
||||
$fields[$databox->get_viewname()][$meta->get_id()]['name'] = $meta->get_label($this->app['locale']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -96,26 +96,32 @@ class ExposeUploadWorker implements WorkerInterface
|
||||
$record = $this->findDataboxById($payload['databoxId'])->get_record($payload['recordId']);
|
||||
|
||||
$helpers = new PhraseanetExtension($this->app);
|
||||
$canSeeBusiness = $helpers->isGrantedOnCollection($record->getBaseId(), [\ACL::CANMODIFRECORD]);
|
||||
|
||||
$captionsByfield = $record->getCaption($helpers->getCaptionFieldOrder($record, $canSeeBusiness));
|
||||
|
||||
// this is the unique reference for record in phraseanet and assets in expose
|
||||
// the identification of phraseanet instance in expose
|
||||
$phraseanetLocalId = $this->app['conf']->get(['phraseanet-service', 'phraseanet_local_id']);
|
||||
|
||||
$fieldListToUpload = $this->getFieldListToUpload($exposeClient, $payload['accessToken'], $payload['publicationId'], $phraseanetLocalId);
|
||||
|
||||
$description = "<dl>";
|
||||
|
||||
foreach ($captionsByfield as $name => $value) {
|
||||
$databoxId = $record->getDataboxId();
|
||||
$metaId = $record->get_caption()->get_field($name)->get_meta_struct_id();
|
||||
foreach ($fieldListToUpload as $value) {
|
||||
// value as databoxId_metaId
|
||||
$t = explode('_', $value);
|
||||
|
||||
if ($helpers->getCaptionFieldGuiVisible($record, $name) == 1 && in_array($databoxId . '_' . $metaId, $fieldListToUpload)) {
|
||||
$fieldType = $record->get_caption()->get_field($name)->get_databox_field()->get_type();
|
||||
$fieldLabel = $helpers->getCaptionFieldLabel($record, $name);
|
||||
// check if it is on the same databox
|
||||
if ($payload['databoxId'] == $t[0]) {
|
||||
$fieldName = $record->getDatabox()->get_meta_structure()->get_element($t[1])->get_name();
|
||||
if ($record->get_caption()->has_field($fieldName) && $helpers->getCaptionFieldGuiVisible($record, $fieldName) == 1) {
|
||||
// retrieve value for the corresponding field
|
||||
$captionField = $record->get_caption()->get_field($fieldName);
|
||||
$fieldValues = $captionField->get_values();
|
||||
|
||||
$description .= "<dt class='field-title field-type-". $fieldType ." field-name-". $fieldLabel ."' >" . $fieldLabel. "</dt>";
|
||||
$description .= "<dd class='field-value field-type-". $fieldType ." field-name-". $fieldLabel ."' >" . $helpers->getCaptionField($record, $name, $value). "</dd>";
|
||||
$fieldType = $captionField->get_databox_field()->get_type();
|
||||
$fieldLabel = $helpers->getCaptionFieldLabel($record, $fieldName);
|
||||
|
||||
$description .= "<dt class='field-title field-type-". $fieldType ." field-name-". $fieldLabel ."' >" . $fieldLabel. "</dt>";
|
||||
$description .= "<dd class='field-value field-type-". $fieldType ." field-name-". $fieldLabel ."' >" . $helpers->getCaptionField($record, $fieldName, $fieldValues). "</dd>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +147,7 @@ class ExposeUploadWorker implements WorkerInterface
|
||||
}
|
||||
}
|
||||
|
||||
// this is the unique reference for record in phraseanet and assets in expose
|
||||
// phraseanetLocalKey_basedID_record_id
|
||||
$assetId = $phraseanetLocalId.'_'.$record->getId();
|
||||
|
||||
|
@@ -1,11 +1,13 @@
|
||||
{% for dbName, field in fields %}
|
||||
<fieldset>
|
||||
<legend>{{ dbName }}</legend>
|
||||
{% for metaField in field %}
|
||||
<label class="checkbox" for="fields[{{ metaField.id }}]">
|
||||
<input type="checkbox" id="fields[{{ metaField.id }}]" name="fields[{{ metaField.id }}]" {% if metaField.id in actualFieldsList %} checked {% endif %} value="1">
|
||||
{{ metaField.name }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
<div class="field-list">
|
||||
{% for metaField in field %}
|
||||
<label class="checkbox" for="fields[{{ metaField.id }}]">
|
||||
<input type="checkbox" id="fields[{{ metaField.id }}]" name="fields[{{ metaField.id }}]" {% if metaField.checked %} checked {% endif %} value="1">
|
||||
{{ metaField.name }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
|
@@ -10,7 +10,6 @@
|
||||
</div>
|
||||
<hr>
|
||||
<div class="databox-field-list">
|
||||
{% include 'prod/WorkZone/ExposeFieldList.html.twig' with {'fields':fields} %}
|
||||
</div>
|
||||
|
||||
<div class="publication-btn-container submit-blockr">
|
||||
|
Reference in New Issue
Block a user