Skip to content

Commit

Permalink
30852 Custom label doesn't work on first save in Similar Estate and D…
Browse files Browse the repository at this point in the history
…etail Estate (#457)

* fix custom label

* format code

* update custom label similar estate

* refactor code

* format code

* format code

* format code

* format code

* update custom label

* format code

* format code

* format code

* format code

* update unit test

* refactor code

* update view reference
  • Loading branch information
dai-eastgate authored Apr 4, 2023
1 parent c0a9f44 commit c4dbff4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion js/onoffice-custom-form-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ onOffice.custom_labels_input_converter = function () {
.querySelector('input[name*="oopluginfieldconfigformtranslatedlabels-value"].onoffice-input');
var fieldname = element.parentElement.parentElement.parentElement
.querySelector('span.menu-item-settings-name').textContent;
if (onOffice.custom_labels_inputs_converted.indexOf(fieldname) !== -1) {
if (onOffice.custom_labels_inputs_converted.indexOf(fieldname) !== -1 && fieldname !== 'dummy_key') {
return;
}
onOffice.custom_labels_inputs_converted.push(fieldname);
Expand Down
21 changes: 0 additions & 21 deletions plugin/EstateDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,25 +321,4 @@ public function getShowEstateMarketingStatus(): bool
return $this->getDataView()->getShowStatus();
}

/**
* @param string $field
* @return string
*/
public function getFieldLabel($field): string
{
$pContainerBuilder = new ContainerBuilder;
$pContainerBuilder->addDefinitions(ONOFFICE_DI_CONFIG_PATH);
$pContainer = $pContainerBuilder->build();
$pLanguage = $pContainer->get(Language::class)->getLocale();
$pDataDetailViewHandler = new DataDetailViewHandler();
$dataDetailView = $pDataDetailViewHandler->getDetailView();
$dataDetailCustomLabel = $dataDetailView->getCustomLabels();
if(!empty($dataDetailCustomLabel[$field][$pLanguage])){
$fieldNewName = $dataDetailCustomLabel[$field][$pLanguage];
}else {
$recordType = onOfficeSDK::MODULE_ESTATE;
$fieldNewName = $this->getEnvironment()->getFieldnames()->getFieldLabel($field, $recordType);
}
return $fieldNewName;
}
}
9 changes: 9 additions & 0 deletions plugin/EstateList.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ public function getFieldLabel($field): string
{
$recordType = onOfficeSDK::MODULE_ESTATE;
$pFieldsCollection = new FieldsCollection();
$pLanguage = $this->_pEnvironment->getContainer()->get( Language::class )->getLocale();
$pFieldBuilderShort = $this->_pEnvironment->getContainer()->get(FieldsCollectionBuilderShort::class);
$listType = method_exists($this->_pDataView, 'getListType') ? $this->_pDataView->getListType() : null;
$pFieldBuilderShort
Expand All @@ -518,6 +519,14 @@ public function getFieldLabel($field): string
->addCustomLabelFieldsEstateFrontend($pFieldsCollection, $this->_pDataView->getName(), $listType);

$label = $pFieldsCollection->getFieldByModuleAndName($recordType, $field)->getLabel();

if ( $this->_pDataView instanceof DataDetailView || $this->_pDataView instanceof DataViewSimilarEstates ) {
$dataView = $this->_pDataView->getCustomLabels();
if (!empty( $dataView[ $field ][ $pLanguage ])) {
$label = $dataView[ $field ][ $pLanguage ];
}
}

$fieldNewName = esc_html($label);
return $fieldNewName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ public function __construct(FieldModuleCollection $pFieldModuleCollection, $form
$this->_pFieldModuleCollection = $pFieldModuleCollection;
$this->_pContainer = $pContainer ?? $this->buildContainer();
$recordManagerReadForm = $this->_pContainer->get(RecordManagerReadListViewEstate::class);
$results = $recordManagerReadForm->getRowByName($formName, $typeList);
if($typeList === "reference"){
$results = $recordManagerReadForm->getRowByName($formName, null);
}else{
$results = $recordManagerReadForm->getRowByName($formName, $typeList);
}
if(empty($results['listview_id'])){
return;
}
$fieldsByFormIds = $recordManagerReadForm->getFieldconfigByListviewId(intval($results['listview_id']));

foreach ($fieldsByFormIds as $fieldsByFormId) {
Expand Down

0 comments on commit c4dbff4

Please sign in to comment.