diff --git a/libs/blocks/locui-create/input-actions/view.js b/libs/blocks/locui-create/input-actions/view.js
index c2a9ac48d8..ef08817a14 100644
--- a/libs/blocks/locui-create/input-actions/view.js
+++ b/libs/blocks/locui-create/input-actions/view.js
@@ -34,13 +34,13 @@ function TranslateActions({ languageCount, handleActionSelect, handleWorkflowSel
diff --git a/libs/blocks/locui-create/locui-create.js b/libs/blocks/locui-create/locui-create.js
index 5c0be26057..ae5e0d9133 100644
--- a/libs/blocks/locui-create/locui-create.js
+++ b/libs/blocks/locui-create/locui-create.js
@@ -15,7 +15,7 @@ import InputActions from './input-actions/view.js';
import Header from '../milostudio-header/milostudio-header.js';
import Sidenav from '../milostudio-sidenav/sidenav.js';
import { getConfig, loadStyle } from '../../utils/utils.js';
-import { getEnvQueryParam } from './utils/utils.js';
+import { getEnvQueryParam, setSelectedLocalesAndRegions } from './utils/utils.js';
import Toast from './components/toast.js';
function Create() {
@@ -40,6 +40,7 @@ function Create() {
type: 'info',
message: `Project ${project.value.name} fetched succesfully.`,
});
+ setSelectedLocalesAndRegions();
}
}
} catch (error) {
diff --git a/libs/blocks/locui-create/store.js b/libs/blocks/locui-create/store.js
index 9bc9ebb84e..47e9d2c87a 100644
--- a/libs/blocks/locui-create/store.js
+++ b/libs/blocks/locui-create/store.js
@@ -206,6 +206,7 @@ export async function fetchDraftProject(projectKey) {
editBehavior: resJson.settings?.regionalEditBehaviour,
urls: resJson.urls,
fragments: [],
+ languages: resJson?.languages ?? [],
});
projectInfo.value = {
...projectInfo.value,
diff --git a/libs/blocks/locui-create/utils/utils.js b/libs/blocks/locui-create/utils/utils.js
index 3513923bc4..46c4382304 100644
--- a/libs/blocks/locui-create/utils/utils.js
+++ b/libs/blocks/locui-create/utils/utils.js
@@ -1,6 +1,6 @@
import getServiceConfig from '../../../utils/service-config.js';
import { origin } from '../../locui/utils/franklin.js';
-import { env } from '../store.js';
+import { env, locSelected, locales as stLocales, project as stProject } from '../store.js';
export function getTenantName() {
try {
@@ -73,3 +73,34 @@ export function getEnvQueryParam() {
const urlSearchParams = new URLSearchParams(window.location.search);
return urlSearchParams.get('env') ?? 'local';
}
+
+export function setSelectedLocalesAndRegions() {
+ const { languages } = stProject.value;
+ const localeByLanguage = stLocales.value.reduce((acc, curr) => {
+ const { language } = curr;
+ acc[language] = curr;
+ return acc;
+ }, {});
+ const selectedLocale = [];
+ const activeLocales = {};
+ languages.forEach((loc) => {
+ const { language, locales } = loc;
+ const { livecopies } = localeByLanguage[language] || {};
+ const livecopiesArr = [];
+ if (livecopies) {
+ livecopiesArr.push(...livecopies.split(','));
+ }
+ if (locales.length > 0) {
+ locales.forEach((locale) => {
+ activeLocales[locale] = language;
+ });
+ } else {
+ livecopiesArr.forEach((liveCopy) => {
+ activeLocales[liveCopy] = language;
+ });
+ }
+ selectedLocale.push(...livecopiesArr);
+ });
+ selectedLocale.sort((a, b) => a.localeCompare(b));
+ locSelected.value = { selectedLocale, activeLocales };
+}
|