Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mwpw 164318 edit flow lang #3396

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libs/blocks/locui-create/input-actions/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ function TranslateActions({ languageCount, handleActionSelect, handleWorkflowSel
</td>
<td>
<select
value=${entry.workflow || 'default'}
value=${entry.workflow || ''}
class="form-field-select"
onChange=${(e) => handleWorkflowSelect(e, entry)}
name="wf-type"
id="wf-type"
>
<option value="default">Default</option>
<option value="">Default</option>
<option value="HybridMT">HybridMT</option>
<option value="Standard">Standard</option>
</select>
Expand Down
3 changes: 2 additions & 1 deletion libs/blocks/locui-create/locui-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -40,6 +40,7 @@ function Create() {
type: 'info',
message: `Project ${project.value.name} fetched succesfully.`,
});
setSelectedLocalesAndRegions();
}
}
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions libs/blocks/locui-create/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
userToken = accessToken.value;
authenticated.value = true;
} catch {
console.error('Sharepoint login failed. Unable to get User-Token!');

Check warning on line 65 in libs/blocks/locui-create/store.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 Unexpected console statement. Raw Output: {"ruleId":"no-console","severity":1,"message":"Unexpected console statement.","line":65,"column":5,"nodeType":"MemberExpression","messageId":"unexpected","endLine":65,"endColumn":18}
authenticated.value = false;
}
loading.value = false;
Expand Down Expand Up @@ -96,7 +96,7 @@
locales.value = processedLocales;
localeRegion.value = processedLocaleRegion;
} catch (error) {
console.error('Error during fetchLocaleDetails:', error.message);

Check warning on line 99 in libs/blocks/locui-create/store.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 Unexpected console statement. Raw Output: {"ruleId":"no-console","severity":1,"message":"Unexpected console statement.","line":99,"column":5,"nodeType":"MemberExpression","messageId":"unexpected","endLine":99,"endColumn":18}
throw error;
}
}
Expand Down Expand Up @@ -206,6 +206,7 @@
editBehavior: resJson.settings?.regionalEditBehaviour,
urls: resJson.urls,
fragments: [],
languages: resJson?.languages ?? [],
});
projectInfo.value = {
...projectInfo.value,
Expand Down
33 changes: 32 additions & 1 deletion libs/blocks/locui-create/utils/utils.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 };
}
Loading