2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +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() {
return this.db?.schemaMap ?? {};
if (this.#isInitialized) {
return this.db?.schemaMap ?? getSchemas();
}
return getSchemas();
}
async createNewDatabase(dbPath: string, countryCode: string) {

View File

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

View File

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

View File

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