2222 @click =" confirmAndCancel"
2323 />
2424 </template >
25+ <template
26+ v-if =" showLocalePicker "
27+ #localeDisplay
28+ >
29+ <AposDocLocalePicker
30+ :locale =" modalData.locale"
31+ :module-options =" moduleOptions"
32+ :is-modified =" false"
33+ :hide-localized =" true"
34+ @switch-locale =" switchLocale"
35+ />
36+ </template >
2537 <template #primaryControls >
2638 <AposUtilityOperations
2739 :module-options =" moduleOptions"
132144</template >
133145
134146<script >
135- import { mapState } from ' pinia' ;
147+ import { mapActions , mapState } from ' pinia' ;
136148import AposDocsManagerMixin from ' Modules/@apostrophecms/modal/mixins/AposDocsManagerMixin' ;
137149import AposModifiedMixin from ' Modules/@apostrophecms/ui/mixins/AposModifiedMixin' ;
138150import AposPublishMixin from ' Modules/@apostrophecms/ui/mixins/AposPublishMixin' ;
@@ -177,11 +189,12 @@ export default {
177189 allPiecesSelection: {
178190 isSelected: false ,
179191 total: 0
180- }
192+ },
193+ localeSwitched: this .modalData .hasContextLocale
181194 };
182195 },
183196 computed: {
184- ... mapState (useModalStore, [ ' activeModal' ]),
197+ ... mapState (useModalStore, [ ' activeModal' , ' updateModalData ' ]),
185198 moduleOptions () {
186199 return window .apos .modules [this .moduleName ];
187200 },
@@ -281,6 +294,7 @@ export default {
281294 apos .bus .$off (' command-menu-manager-close' , this .confirmAndCancel );
282295 },
283296 methods: {
297+ ... mapActions (useModalStore, [ ' updateModalData' ]),
284298 async create () {
285299 await this .edit (null );
286300 },
@@ -560,8 +574,8 @@ export default {
560574 }
561575 if (
562576 docIds ||
563- ! doc .aposLocale ||
564- doc .aposLocale .split (' :' )[0 ] === this .modalData .locale
577+ ! doc .aposLocale || // TODO: check localeSwitched?
578+ doc .aposLocale .split (' :' )[0 ] === this .modalData .locale // TODO: check localeSwitched?
565579 ) {
566580 await this .managePieces ();
567581 await this .manageAllPiecesTotal ();
@@ -570,6 +584,18 @@ export default {
570584 this .checked = this .checked .filter (checkedId => ! ids .includes (checkedId));
571585 }
572586 }
587+ },
588+ async switchLocale ({ locale, localized }) {
589+ this .updateModalData (this .modalData .id , { locale });
590+ this .localeSwitched = locale !== apos .i18n .locale ;
591+
592+ this .currentPage = 1 ;
593+
594+ await this .managePieces ();
595+ await this .manageAllPiecesTotal ();
596+ this .headers = this .computeHeaders ();
597+
598+ this .setCheckedDocs ([]);
573599 }
574600 }
575601};
0 commit comments