Complete add locale feature
This commit is contained in:
parent
a7a4352cad
commit
e7a128e04a
2 changed files with 11 additions and 15 deletions
|
@ -41,7 +41,6 @@
|
|||
import Modal from 'dashboard/components/Modal';
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import { required } from 'vuelidate/lib/validators';
|
||||
import { convertToPortalSlug } from 'dashboard/helper/commons.js';
|
||||
import allLocales from 'shared/constants/locales.js';
|
||||
export default {
|
||||
components: {
|
||||
|
@ -61,6 +60,7 @@ export default {
|
|||
data() {
|
||||
return {
|
||||
selectedLocale: '',
|
||||
isUpdating: false,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
|
@ -87,9 +87,6 @@ export default {
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
onNameChange() {
|
||||
this.slug = convertToPortalSlug(this.name);
|
||||
},
|
||||
async onCreate() {
|
||||
this.$v.$touch();
|
||||
if (this.$v.$invalid) {
|
||||
|
@ -100,23 +97,23 @@ export default {
|
|||
return allowedLocales[key].code;
|
||||
});
|
||||
addedLocales.push(this.selectedLocale);
|
||||
|
||||
this.isUpdating = true;
|
||||
try {
|
||||
await this.$store.dispatch('portals/update', {
|
||||
portalId: this.selectedPortalSlug,
|
||||
portalSlug: this.portal.slug,
|
||||
config: { allowed_locales: addedLocales },
|
||||
});
|
||||
this.alertMessage = this.$t(
|
||||
'HELP_CENTER.PORTAL.ADD_LOCALE.API.SUCCESS_MESSAGE'
|
||||
);
|
||||
this.onClose();
|
||||
} catch (error) {
|
||||
this.alertMessage =
|
||||
error?.message ||
|
||||
this.$t('HELP_CENTER.EDIT_ARTICLE.API.ERROR_MESSAGE');
|
||||
this.showAlert(this.alertMessage);
|
||||
this.$t('HELP_CENTER.PORTAL.ADD_LOCALE.API.ERROR_MESSAGE');
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
this.showAlert(this.alertMessage);
|
||||
this.isUpdating = false;
|
||||
this.isSaved = true;
|
||||
}, 1500);
|
||||
}
|
||||
},
|
||||
onClose() {
|
||||
|
|
|
@ -36,8 +36,7 @@ export const actions = {
|
|||
}
|
||||
},
|
||||
|
||||
update: async ({ commit }, { portalObj }) => {
|
||||
const portalSlug = portalObj.slug;
|
||||
update: async ({ commit }, { portalSlug, ...params }) => {
|
||||
commit(types.SET_HELP_PORTAL_UI_FLAG, {
|
||||
uiFlags: { isUpdating: true },
|
||||
portalSlug,
|
||||
|
@ -45,7 +44,7 @@ export const actions = {
|
|||
try {
|
||||
const { data } = await portalAPIs.updatePortal({
|
||||
portalSlug,
|
||||
portalObj,
|
||||
params,
|
||||
});
|
||||
commit(types.UPDATE_PORTAL_ENTRY, data);
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in a new issue