-
Notifications
You must be signed in to change notification settings - Fork 615
Pro 8541 switch locale empty doc #5135
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
Open
ValJed
wants to merge
22
commits into
main
Choose a base branch
from
pro-8541-switch-locale-empty-doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
872a142
missing negative button interpolation in apos confirm modal
ValJed d772b4d
adds translation keys
ValJed ec69bdc
adds confirmation modal in AposDocLocalePicker to ask for doc localiz…
ValJed 49f523b
rename shouldLocalize toLocalize, passes entire locale (name, label) …
ValJed 54669ba
updaes AposDocEditor switchLocale method
ValJed df3ee5a
removes logs
ValJed b4e3fe3
passes isManager props in AposDocLocaleSwitcher to handle different b…
ValJed 0bd99b5
gets current locale from modalData in localize modal
ValJed e7e3d3d
emits modal result when localizing document if has been done or not
ValJed 6d6cd15
if toLocalize is null (the use closed the modal) just do nothing
ValJed 37fe79a
set currentId in instantiateExistingDoc method, no more slug conflict…
ValJed ee84a64
adds translation in all locales
ValJed a4fa926
adds changelog
ValJed 097f453
fixes translation key
ValJed 53960bf
fixes pages manager
ValJed 6ce2cec
do not ask to localize if doc doesn't exist in current locale
ValJed 3482501
removes duplicated updateModalData method instantiation
ValJed b82443d
uses saved doc to localize (if saved before to switch), passes module…
ValJed c155180
fixes sk translations
ValJed c03f0e3
feedback changelog
ValJed 439ed93
fixes locale switcher localize modal translation for pages
ValJed a981739
Merge remote-tracking branch 'origin/main' into pro-8541-switch-local…
ValJed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -533,7 +533,7 @@ export default { | |
| } | ||
| const canEdit = docData._edit || this.moduleOptions.canEdit; | ||
| this.readOnly = canEdit === false; | ||
| if (canEdit && !await this.lock(this.getOnePath, this.currentId)) { | ||
| if (canEdit && !await this.lock(this.getOnePath, docData._id)) { | ||
| this.lockNotAvailable(); | ||
| } | ||
| } catch { | ||
|
|
@@ -548,6 +548,7 @@ export default { | |
| if (docData.type !== this.docType) { | ||
| this.docType = docData.type; | ||
| } | ||
| this.currentId = docData._id; | ||
| this.original = klona(docData); | ||
| this.docFields.data = docData; | ||
| // TODO: Is this block even useful since published is fetched after | ||
|
|
@@ -860,10 +861,11 @@ export default { | |
| this.modal.showModal = false; | ||
| }, | ||
| async switchLocale({ | ||
| locale, localized, save | ||
| locale, save, localized, toLocalize | ||
| }) { | ||
| let saved; | ||
| if (save) { | ||
| const saved = await this.saveHandler('onSave', { | ||
| saved = await this.saveHandler('onSave', { | ||
| keepOpen: true, | ||
| andPublish: false | ||
| }); | ||
|
|
@@ -874,18 +876,38 @@ export default { | |
| this.referenceDocId = saved._id; | ||
| } | ||
| } | ||
| this.updateModalData(this.modalData.id, { locale }); | ||
| this.localeSwitched = locale !== apos.i18n.locale; | ||
| this.published = null; | ||
| if (localized) { | ||
| this.currentId = localized._id; | ||
| this.switchModalLocale(locale.name); | ||
| await this.instantiateExistingDoc(); | ||
| } else { | ||
| return; | ||
| } | ||
| if (!toLocalize) { | ||
| this.switchModalLocale(locale.name); | ||
| this.currentId = ''; | ||
| this.docType = this.moduleName; | ||
| await this.instantiateNewDoc(); | ||
| return; | ||
| } | ||
|
|
||
| const isLocalized = await apos.modal.execute('AposI18nLocalize', { | ||
| doc: saved || this.original, | ||
| locale, | ||
| moduleName: this.moduleName, | ||
| redirect: false | ||
| }); | ||
|
|
||
| if (isLocalized) { | ||
| this.switchModalLocale(locale.name); | ||
| await this.$nextTick(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why here only? |
||
| await this.instantiateExistingDoc(); | ||
| } | ||
| }, | ||
| switchModalLocale(locale) { | ||
| this.updateModalData(this.modalData.id, { locale }); | ||
| this.localeSwitched = locale !== apos.i18n.locale; | ||
| this.published = null; | ||
| }, | ||
| getRequestBody({ newInstance = false, update = false }) { | ||
| const body = newInstance | ||
| ? { _newInstance: true } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed