Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-126945

Clearing auto-population of Web Content fields while adding translations

Details

    Description

      We are currently on LR DXP 7.2 with Service Pack 3 (SP3).

      While adding new data in web content, default translations is selected and data is saved, but when we change locale the same data gets auto-populated in other locales as well.

      Customer doesn't want this behavior as they will be manually entering the translations for all the fields rather than auto-population.

      We have tried a few customizations approaches, but it didn't work. A few of them are listed below:

      First Way
      ---------------
      1. Created fragment of edit_article.jsp file of journal-web Portlet.
      2. Add Liferay-Config-js file path in bnd.bnd
      3. Created a JournalTest.es.js file inside src>main>resources>META-INF>rsources>js folder.
      4. Then loaded the module using
      Loader.addModule(

      { dependencies: [], exports: 'JournalOverride', name: 'journal-override', path: MODULE_PATH + 'JournalTest.es.js' }

      );
      5. Try to replace the below piece of code in edit_article.jsp
      <liferay-frontend:component
      componentId='<%= liferayPortletResponse.getNamespace() + "JournalPortletComponent" %>'
      context="<%= journalEditArticleDisplayContext.getComponentContext() %>"
      module="js/JournalPortlet.es"
      servletContext="<%= application %>"
      />
      by below code
      <liferay-frontend:component
      componentId='<%= liferayPortletResponse.getNamespace() + "JournalPortletComponent" %>'
      context="<%= journalEditArticleDisplayContext.getComponentContext() %>"
      module="js/JournalTest.es"
      servletContext="<%= application %>"
      />
      Note:- It's giving error module not loaded.

      Second Way
      -------------------
      1. Below Script to empty the structure fields in web content on changing Locale.
      Event :- inputLocalized:localeChanged :::: this event get trigged when locale get change in edit_article.jsp
      let defaultLangId = Liferay.ThemeDisplay.getDefaultLanguageId;
      Liferay.after('inputLocalized:localeChanged',(event) => {
      let langId=event.details[0].item.getAttribute('data-value');
      if(defaultLangId != langId){
      //Below code not able to clear input field.
      $('.lfr-ddm-container').find('input').each(function(node)

      { $(node).val(''); }

      );
      }
      });

      Steps to reproduce:
      1- Navigate to Site -> Content & Data -> Web Content
      2- Add New Basic Web Content
      3- Enter Title and Content
      4- Change Language

      Actual Results:
      Default Locale contents are auto-populated

      Expected Results:
      Default Locale content should not be auto-populated

      Attachments

        Activity

          People

            Unassigned Unassigned
            ashish.singh Ashish Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Packages

                Version Package