mirror of
https://github.com/frappe/books.git
synced 2025-01-23 23:28:24 +00:00
fix: dynamic ES6 import
- db selector hangup on file deletion
This commit is contained in:
parent
22dcaba66b
commit
459d334e08
@ -21,7 +21,17 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div
|
<div
|
||||||
@click="newDatabase"
|
@click="newDatabase"
|
||||||
class="w-1/2 border rounded-xl flex flex-col items-center py-8 px-5 cursor-pointer hover:shadow"
|
class="
|
||||||
|
w-1/2
|
||||||
|
border
|
||||||
|
rounded-xl
|
||||||
|
flex flex-col
|
||||||
|
items-center
|
||||||
|
py-8
|
||||||
|
px-5
|
||||||
|
cursor-pointer
|
||||||
|
hover:shadow
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="w-14 h-14 rounded-full bg-blue-200 relative flex-center"
|
class="w-14 h-14 rounded-full bg-blue-200 relative flex-center"
|
||||||
@ -48,7 +58,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
@click="existingDatabase"
|
@click="existingDatabase"
|
||||||
class="ml-6 w-1/2 border rounded-xl flex flex-col items-center py-8 px-5 cursor-pointer hover:shadow"
|
class="
|
||||||
|
ml-6
|
||||||
|
w-1/2
|
||||||
|
border
|
||||||
|
rounded-xl
|
||||||
|
flex flex-col
|
||||||
|
items-center
|
||||||
|
py-8
|
||||||
|
px-5
|
||||||
|
cursor-pointer
|
||||||
|
hover:shadow
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="w-14 h-14 rounded-full bg-green-200 relative flex-center"
|
class="w-14 h-14 rounded-full bg-green-200 relative flex-center"
|
||||||
@ -84,7 +105,17 @@
|
|||||||
<div v-if="showFiles">
|
<div v-if="showFiles">
|
||||||
<div class="px-12 mt-6">
|
<div class="px-12 mt-6">
|
||||||
<div
|
<div
|
||||||
class="py-2 px-4 text-sm flex justify-between items-center hover:bg-gray-100 cursor-pointer border-b"
|
class="
|
||||||
|
py-2
|
||||||
|
px-4
|
||||||
|
text-sm
|
||||||
|
flex
|
||||||
|
justify-between
|
||||||
|
items-center
|
||||||
|
hover:bg-gray-100
|
||||||
|
cursor-pointer
|
||||||
|
border-b
|
||||||
|
"
|
||||||
:class="{ 'border-t': i === 0 }"
|
:class="{ 'border-t': i === 0 }"
|
||||||
v-for="(file, i) in files"
|
v-for="(file, i) in files"
|
||||||
:key="file.filePath"
|
:key="file.filePath"
|
||||||
@ -125,7 +156,7 @@ import { DateTime } from 'luxon';
|
|||||||
import {
|
import {
|
||||||
createNewDatabase,
|
createNewDatabase,
|
||||||
loadExistingDatabase,
|
loadExistingDatabase,
|
||||||
connectToLocalDatabase
|
connectToLocalDatabase,
|
||||||
} from '@/utils';
|
} from '@/utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -135,14 +166,24 @@ export default {
|
|||||||
loadingDatabase: false,
|
loadingDatabase: false,
|
||||||
fileSelectedFrom: null,
|
fileSelectedFrom: null,
|
||||||
showFiles: false,
|
showFiles: false,
|
||||||
files: []
|
files: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.files = config.get('files', []).filter(({filePath}) => fs.existsSync(filePath));
|
this.setFiles();
|
||||||
this.showFiles = this.files.length > 0;
|
this.showFiles = this.files.length > 0;
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
showFiles() {
|
||||||
|
this.setFiles();
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setFiles() {
|
||||||
|
this.files = config
|
||||||
|
.get('files', [])
|
||||||
|
.filter(({ filePath }) => fs.existsSync(filePath));
|
||||||
|
},
|
||||||
async newDatabase() {
|
async newDatabase() {
|
||||||
this.fileSelectedFrom = 'New File';
|
this.fileSelectedFrom = 'New File';
|
||||||
let filePath = await createNewDatabase();
|
let filePath = await createNewDatabase();
|
||||||
@ -166,16 +207,18 @@ export default {
|
|||||||
const connectionSuccess = await connectToLocalDatabase(filePath);
|
const connectionSuccess = await connectToLocalDatabase(filePath);
|
||||||
this.loadingDatabase = false;
|
this.loadingDatabase = false;
|
||||||
|
|
||||||
if(connectionSuccess) {
|
if (connectionSuccess) {
|
||||||
this.$emit('database-connect');
|
this.$emit('database-connect');
|
||||||
} else {
|
} else {
|
||||||
alert(frappe._("Please select an existing database or create a new one."))
|
alert(
|
||||||
|
frappe._('Please select an existing database or create a new one.')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getFileLastModified(filePath) {
|
getFileLastModified(filePath) {
|
||||||
let stats = fs.statSync(filePath);
|
let stats = fs.statSync(filePath);
|
||||||
return DateTime.fromJSDate(stats.mtime).toRelative();
|
return DateTime.fromJSDate(stats.mtime).toRelative();
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -101,9 +101,9 @@ async function setupChartOfAccounts(bankName, country) {
|
|||||||
async function setupRegionalChanges(country) {
|
async function setupRegionalChanges(country) {
|
||||||
await generateTaxes(country);
|
await generateTaxes(country);
|
||||||
if (country === 'India') {
|
if (country === 'India') {
|
||||||
frappe.models.Party = await import(
|
frappe.models.Party = (
|
||||||
'../../../models/doctype/Party/RegionalChanges'
|
await import('../../../models/doctype/Party/RegionalChanges')
|
||||||
);
|
).default;
|
||||||
await frappe.db.migrate();
|
await frappe.db.migrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user