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