2
0
mirror of https://github.com/frappe/books.git synced 2025-01-03 07:12:21 +00:00

fix: init with schemas even if no db

- ux: show reload dialog on settings save
This commit is contained in:
18alantom 2023-05-11 10:23:07 +05:30 committed by Alan
parent ee29f8d564
commit afe04cccaf
4 changed files with 26 additions and 8 deletions

View File

@ -18,7 +18,11 @@ export class DatabaseManager extends DatabaseDemuxBase {
} }
getSchemaMap() { getSchemaMap() {
return this.db?.schemaMap ?? {}; if (this.#isInitialized) {
return this.db?.schemaMap ?? getSchemas();
}
return getSchemas();
} }
async createNewDatabase(dbPath: string, countryCode: string) { async createNewDatabase(dbPath: string, countryCode: string) {

View File

@ -167,7 +167,7 @@ export class Fyo {
} }
getField(schemaName: string, fieldname: string) { getField(schemaName: string, fieldname: string) {
return this.fieldMap[schemaName][fieldname]; return this.fieldMap[schemaName]?.[fieldname];
} }
async getValue( async getValue(

View File

@ -78,14 +78,14 @@ import FormHeader from 'src/components/FormHeader.vue';
import { handleErrorWithDialog } from 'src/errorHandling'; import { handleErrorWithDialog } from 'src/errorHandling';
import { getErrorMessage } from 'src/utils'; import { getErrorMessage } from 'src/utils';
import { evaluateHidden } from 'src/utils/doc'; import { evaluateHidden } from 'src/utils/doc';
import { showToast } from 'src/utils/interactive'; import { shortcutsKey } from 'src/utils/injectionKeys';
import { showDialog } from 'src/utils/interactive';
import { reloadWindow } from 'src/utils/ipcCalls'; import { reloadWindow } from 'src/utils/ipcCalls';
import { docsPathMap } from 'src/utils/misc'; import { docsPathMap } from 'src/utils/misc';
import { docsPathRef } from 'src/utils/refs'; import { docsPathRef } from 'src/utils/refs';
import { UIGroupedFields } from 'src/utils/types'; import { UIGroupedFields } from 'src/utils/types';
import { computed, defineComponent, inject } from 'vue'; import { computed, defineComponent, inject } from 'vue';
import CommonFormSection from '../CommonForm/CommonFormSection.vue'; import CommonFormSection from '../CommonForm/CommonFormSection.vue';
import { shortcutsKey } from 'src/utils/injectionKeys';
const COMPONENT_NAME = 'Settings'; const COMPONENT_NAME = 'Settings';
@ -165,11 +165,22 @@ export default defineComponent({
} }
this.update(); this.update();
await showToast({ showDialog({
message: this.t`Changes will be visible on reload`, title: this.t`Reload Frappe Books?`,
actionText: this.t`Reload App`, detail: this.t`Changes made to settings will be visible on reload.`,
type: 'info', type: 'info',
action: reloadWindow, buttons: [
{
label: this.t`Yes`,
isPrimary: true,
action: reloadWindow,
},
{
label: this.t`No`,
action() {},
isEscape: true,
},
],
}); });
}, },
async syncDoc(doc: Doc): Promise<void> { async syncDoc(doc: Doc): Promise<void> {

View File

@ -109,6 +109,9 @@ export default defineComponent({
}, },
async mounted() { async mounted() {
this.docOrNull = getSetupWizardDoc(); this.docOrNull = getSetupWizardDoc();
if (!this.fyo.db.isConnected) {
await this.fyo.db.init();
}
if (this.fyo.store.isDevelopment) { if (this.fyo.store.isDevelopment) {
// @ts-ignore // @ts-ignore