2
0
mirror of https://github.com/frappe/books.git synced 2025-01-11 02:36:14 +00:00

Merge pull request #533 from zaqoutabed/rtl-mac-platform

fix: fix rtl in mac to prevent traffic lights overlapping
This commit is contained in:
Alan 2023-01-27 00:45:21 -08:00 committed by GitHub
commit 384bc28ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 12 deletions

View File

@ -54,7 +54,7 @@ import { initializeInstance } from './utils/initialization';
import { checkForUpdates } from './utils/ipcCalls'; import { checkForUpdates } from './utils/ipcCalls';
import { updateConfigFiles } from './utils/misc'; import { updateConfigFiles } from './utils/misc';
import { Search } from './utils/search'; import { Search } from './utils/search';
import { routeTo } from './utils/ui'; import { routeTo, systemLanguage } from './utils/ui';
import { Shortcuts, useKeys } from './utils/vueUtils'; import { Shortcuts, useKeys } from './utils/vueUtils';
export default { export default {
@ -69,8 +69,6 @@ export default {
companyName: '', companyName: '',
searcher: null, searcher: null,
shortcuts: null, shortcuts: null,
languageDirection: 'ltr',
language: '',
}; };
}, },
provide() { provide() {
@ -88,10 +86,6 @@ export default {
WindowsTitleBar, WindowsTitleBar,
}, },
async mounted() { async mounted() {
this.language = fyo.config.get('language');
this.languageDirection = RTL_LANGUAGES.includes(this.language)
? 'rtl'
: 'ltr';
this.shortcuts = new Shortcuts(this.keys); this.shortcuts = new Shortcuts(this.keys);
const lastSelectedFilePath = fyo.config.get( const lastSelectedFilePath = fyo.config.get(
ConfigKeys.LastSelectedFilePath, ConfigKeys.LastSelectedFilePath,
@ -109,6 +103,14 @@ export default {
await this.showDbSelector(); await this.showDbSelector();
} }
}, },
computed: {
language() {
return systemLanguage.value;
},
languageDirection() {
return RTL_LANGUAGES.includes(this.language) ? 'rtl' : 'ltr';
},
},
methods: { methods: {
async setDesk(filePath) { async setDesk(filePath) {
this.activeScreen = 'Desk'; this.activeScreen = 'Desk';

View File

@ -8,7 +8,7 @@
> >
<Transition name="spacer"> <Transition name="spacer">
<div <div
v-if="!sidebar && platform === 'Mac'" v-if="!sidebar && platform === 'Mac' && languageDirection !== 'rtl'"
class="h-full" class="h-full"
:class="sidebar ? '' : 'w-tl me-4 border-e'" :class="sidebar ? '' : 'w-tl me-4 border-e'"
/> />
@ -16,7 +16,10 @@
<h1 class="text-xl font-semibold select-none" v-if="title"> <h1 class="text-xl font-semibold select-none" v-if="title">
{{ title }} {{ title }}
</h1> </h1>
<div class="flex items-stretch window-no-drag gap-2 ms-auto"> <div
class="flex items-stretch window-no-drag gap-2 ms-auto"
:class="platform === 'Mac' && languageDirection === 'rtl' ? 'me-18' : ''"
>
<slot /> <slot />
<div class="border-e" v-if="showBorder" /> <div class="border-e" v-if="showBorder" />
<BackLink v-if="backLink" class="window-no-drag rtl-rotate-180" /> <BackLink v-if="backLink" class="window-no-drag rtl-rotate-180" />
@ -30,7 +33,7 @@ import BackLink from './BackLink.vue';
import SearchBar from './SearchBar.vue'; import SearchBar from './SearchBar.vue';
export default { export default {
inject: ['sidebar'], inject: ['sidebar', 'languageDirection'],
props: { props: {
title: { type: String, default: '' }, title: { type: String, default: '' },
backLink: { type: Boolean, default: true }, backLink: { type: Boolean, default: true },

View File

@ -9,7 +9,9 @@
<!-- Company name and DB Switcher --> <!-- Company name and DB Switcher -->
<div <div
class="px-4 flex flex-row items-center justify-between mb-4" class="px-4 flex flex-row items-center justify-between mb-4"
:class="platform === 'Mac' ? 'mt-10' : 'mt-2'" :class="
platform === 'Mac' && languageDirection === 'ltr' ? 'mt-10' : 'mt-2'
"
> >
<h6 <h6
class=" class="
@ -167,6 +169,7 @@ import Icon from './Icon.vue';
export default { export default {
components: [Button], components: [Button],
inject: ['languageDirection'],
emits: ['change-db-file', 'toggle-sidebar'], emits: ['change-db-file', 'toggle-sidebar'],
data() { data() {
return { return {

View File

@ -3,7 +3,7 @@ import { DEFAULT_LANGUAGE } from 'fyo/utils/consts';
import { setLanguageMapOnTranslationString } from 'fyo/utils/translation'; import { setLanguageMapOnTranslationString } from 'fyo/utils/translation';
import { fyo } from 'src/initFyo'; import { fyo } from 'src/initFyo';
import { IPC_ACTIONS, IPC_MESSAGES } from 'utils/messages'; import { IPC_ACTIONS, IPC_MESSAGES } from 'utils/messages';
import { showToast } from './ui'; import { showToast, systemLanguage } from './ui';
// Language: Language Code in books/translations // Language: Language Code in books/translations
export const languageCodeMap: Record<string, string> = { export const languageCodeMap: Record<string, string> = {
@ -42,6 +42,7 @@ export async function setLanguageMap(
if (success && !usingDefault) { if (success && !usingDefault) {
fyo.config.set('language', language); fyo.config.set('language', language);
systemLanguage.value = language;
} }
if (!dontReload && success && initLanguage !== oldLanguage) { if (!dontReload && success && initLanguage !== oldLanguage) {

View File

@ -24,6 +24,7 @@ import {
} from './types'; } from './types';
export const docsPath = ref(''); export const docsPath = ref('');
export const systemLanguage = ref('');
export async function openQuickEdit({ export async function openQuickEdit({
doc, doc,