onOffice-Web-Org / oo-wp-plugin

onOffice for WP-Websites
https://wp-plugin.onoffice.com
GNU General Public License v3.0
9 stars 9 forks source link

Allow custom labels for estate fields #396

Closed jmaas-onoffice closed 1 year ago

jmaas-onoffice commented 1 year ago

Discussed in https://github.com/onOffice-Web-Org/oo-wp-plugin/discussions/388

Originally posted by **jmaas-onoffice** December 1, 2022 ## Estate fields cannot be renamed easily Currently the fields for forms can get a custom label. However, estate fields cannot have custom labels. This is a problem for certain fields like "Type of commercialization" or "Available from (text)" which have default labels that are not suited for end users. (For example T#3381393.) At the moment we have to special case those fields in the template by modifying how they are output from inside the loop. ## Allow custom label for estate fields Instead, we want to add a custom label input to the estate fields just like for the forms. The templates are [using $pEstatesClone->getFieldLabel( $field ) to display the field label](https://github.com/onOffice-Web-Org/oo-wp-plugin/blob/dbfdfaf2a938003f5a1807377dfc5f26e62296fd/templates.dist/estate/default.php#L100). From this method, the custom label should be returned, if it exists, otherwise the default label like now. This should be backwards compatible, because the label stays the same unless the user enters a custom one. ## We do not yet want to refactore the translations Use the same translation mechanism as the forms currently do. It works by [listing the available languages](https://github.com/onOffice-Web-Org/oo-wp-plugin/blob/dbfdfaf2a938003f5a1807377dfc5f26e62296fd/plugin/WP/InstalledLanguageReader.php#L65), allowing users to enter a custom label for each of those, and storing that label in a [custom table](https://github.com/onOffice-Web-Org/oo-wp-plugin/blob/dbfdfaf2a938003f5a1807377dfc5f26e62296fd/plugin/Field/CustomLabel/CustomLabelRead.php#L108-L122). While there are some disadvantages to using this custom mechanism, fixing the translation would exceed our appetite for this problem. The translation mechanism should be refactored at a later point.
dai-eastgate commented 1 year ago

@jmaas-onoffice I have already added custom label for all estate fields, you can watch video and give me feedback.

https://user-images.githubusercontent.com/106214469/209925955-b685972c-5ca9-4ccc-80c4-5f4a14dd3d3f.mp4

jmaas-onoffice commented 1 year ago

Looks good, thanks! :)