mirror of
https://github.com/frappe/books.git
synced 2024-12-22 02:49:03 +00:00
chore: add lint workflow
- fix filter issue in List.vue - update readme with inspect notes - fix log_creds.txt path for dev
This commit is contained in:
parent
d42d0841aa
commit
b155d71170
@ -15,6 +15,7 @@ module.exports = {
|
||||
'vue/multi-word-component-names': 'off',
|
||||
'vue/no-useless-template-attributes': 'off',
|
||||
'vue/one-component-per-file': 'off',
|
||||
'vue/no-reserved-component-names': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
'@typescript-eslint/no-var-requires': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
@ -34,6 +35,7 @@ module.exports = {
|
||||
'plugin:vue/vue3-recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||
'plugin:prettier/recommended',
|
||||
],
|
||||
ignorePatterns: [
|
||||
'*.mjs',
|
||||
|
32
.github/workflows/lint.yml
vendored
Normal file
32
.github/workflows/lint.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
name: Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [$default-branch]
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
setup_and_lin:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16.14.0'
|
||||
|
||||
- name: Set yarn version
|
||||
run: yarn set version 1.22.18
|
||||
|
||||
- name: Checkout Books
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install Dependencies
|
||||
run: yarn
|
||||
|
||||
- name: Lint
|
||||
run: yarn lint
|
18
README.md
18
README.md
@ -90,6 +90,22 @@ To run Frappe Books in development mode (with hot reload, etc):
|
||||
yarn dev
|
||||
```
|
||||
|
||||
**Note: First Boot**
|
||||
|
||||
When you run `yarn dev` electron will run immediately but the UI will take a
|
||||
couple of seconds to render this because of how dev mode works. Each file is
|
||||
individually served by the dev server. And there are many files that have to be
|
||||
sent.
|
||||
|
||||
|
||||
**Note: Debug Electron Main Process**
|
||||
|
||||
When in dev mode electron runs with the `--inspect` flag which allows an
|
||||
external debugger to connect to port 5858. You can use chrome for this by
|
||||
visiting `chrome://inspect` while Frappe Books is running in dev mode.
|
||||
|
||||
See more [here](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process#external-debuggers).
|
||||
|
||||
#### Build
|
||||
|
||||
To build Frappe Books and create an installer:
|
||||
@ -99,7 +115,7 @@ To build Frappe Books and create an installer:
|
||||
yarn build
|
||||
```
|
||||
|
||||
**Note**
|
||||
**Note: Build Target**
|
||||
By default the above command will build for your computer's operating system and
|
||||
architecture. To build for other environments (example: for linux from a windows
|
||||
computer) check the _Building_ section at
|
||||
|
@ -53,6 +53,8 @@ const ctx = await esbuild.context({
|
||||
const fswatcher = chokidar.watch([
|
||||
path.join(root, 'main.ts'),
|
||||
path.join(root, 'main'),
|
||||
path.join(root, 'backend'),
|
||||
path.join(root, 'schemas'),
|
||||
]);
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ export function getUrlAndTokenString(): Creds {
|
||||
'../creds/log_creds.txt'
|
||||
);
|
||||
if (!fs.existsSync(errLogCredsPath)) {
|
||||
errLogCredsPath = path.join(__dirname, '../log_creds.txt');
|
||||
errLogCredsPath = path.join(__dirname, '..', '..', 'log_creds.txt');
|
||||
}
|
||||
|
||||
if (!fs.existsSync(errLogCredsPath)) {
|
||||
|
@ -14,7 +14,8 @@
|
||||
"postuninstall": "electron-rebuild",
|
||||
"script:translate": "scripts/runner.sh scripts/generateTranslations.ts",
|
||||
"script:profile": "scripts/profile.sh",
|
||||
"test": "scripts/test.sh"
|
||||
"test": "scripts/test.sh",
|
||||
"lint": "eslint . --ext ts,vue"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.4.2",
|
||||
|
@ -6,8 +6,6 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>Frappe Books</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Add a loading spinner or something -->
|
||||
</body>
|
||||
<body></body>
|
||||
<script type="module" src="./renderer.ts"></script>
|
||||
</html>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<p class="w-8 text-end me-4 text-gray-700">#</p>
|
||||
<Row
|
||||
class="flex-1 text-gray-700 h-row-mid"
|
||||
:columnCount="columns.length"
|
||||
:column-count="columns.length"
|
||||
gap="1rem"
|
||||
>
|
||||
<div
|
||||
@ -36,7 +36,7 @@
|
||||
<hr />
|
||||
|
||||
<!-- Data Rows -->
|
||||
<div class="overflow-y-auto custom-scroll" v-if="dataSlice.length !== 0">
|
||||
<div v-if="dataSlice.length !== 0" class="overflow-y-auto custom-scroll">
|
||||
<div v-for="(row, i) in dataSlice" :key="row.name">
|
||||
<!-- Row Content -->
|
||||
<div class="flex hover:bg-gray-50 items-center">
|
||||
@ -46,8 +46,8 @@
|
||||
<Row
|
||||
gap="1rem"
|
||||
class="cursor-pointer text-gray-900 flex-1 h-row-mid"
|
||||
:column-count="columns.length"
|
||||
@click="$emit('openDoc', row.name)"
|
||||
:columnCount="columns.length"
|
||||
>
|
||||
<ListCell
|
||||
v-for="(column, c) in columns"
|
||||
@ -66,12 +66,12 @@
|
||||
</div>
|
||||
|
||||
<!-- Pagination Footer -->
|
||||
<div class="mt-auto" v-if="data?.length">
|
||||
<div v-if="data?.length" class="mt-auto">
|
||||
<hr />
|
||||
<Paginator
|
||||
:item-count="data.length"
|
||||
@index-change="setPageIndices"
|
||||
class="px-4"
|
||||
@index-change="setPageIndices"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -82,42 +82,42 @@
|
||||
>
|
||||
<img src="../../assets/img/list-empty-state.svg" alt="" class="w-24" />
|
||||
<p class="my-3 text-gray-800">{{ t`No entries found` }}</p>
|
||||
<Button type="primary" class="text-white" @click="$emit('makeNewDoc')" v-if="canCreate">
|
||||
<Button
|
||||
v-if="canCreate"
|
||||
type="primary"
|
||||
class="text-white"
|
||||
@click="$emit('makeNewDoc')"
|
||||
>
|
||||
{{ t`Make Entry` }}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { clone } from 'lodash';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import Button from 'src/components/Button.vue';
|
||||
import Paginator from 'src/components/Paginator.vue';
|
||||
import Row from 'src/components/Row.vue';
|
||||
import { fyo } from 'src/initFyo';
|
||||
import { isNumeric } from 'src/utils';
|
||||
import { objectForEach } from 'utils/index';
|
||||
import { defineComponent, toRaw } from 'vue';
|
||||
import { defineComponent } from 'vue';
|
||||
import ListCell from './ListCell.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'List',
|
||||
props: { listConfig: Object, filters: Object, schemaName: String, canCreate: Boolean },
|
||||
emits: ['openDoc', 'makeNewDoc', 'updatedData'],
|
||||
components: {
|
||||
Row,
|
||||
ListCell,
|
||||
Button,
|
||||
Paginator,
|
||||
},
|
||||
watch: {
|
||||
schemaName(oldValue, newValue) {
|
||||
if (oldValue === newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
},
|
||||
props: {
|
||||
listConfig: Object,
|
||||
filters: Object,
|
||||
schemaName: String,
|
||||
canCreate: Boolean,
|
||||
},
|
||||
emits: ['openDoc', 'makeNewDoc', 'updatedData'],
|
||||
data() {
|
||||
return {
|
||||
data: [],
|
||||
@ -151,6 +151,15 @@ export default defineComponent({
|
||||
.filter(Boolean);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
schemaName(oldValue, newValue) {
|
||||
if (oldValue === newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateData();
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
await this.updateData();
|
||||
this.setUpdateListeners();
|
||||
@ -184,7 +193,8 @@ export default defineComponent({
|
||||
filters = { ...this.filters };
|
||||
}
|
||||
|
||||
filters = objectForEach(clone(filters), toRaw);
|
||||
// Unproxy the filters
|
||||
filters = cloneDeep(filters);
|
||||
|
||||
const orderBy = ['created'];
|
||||
if (fyo.db.fieldMap[this.schemaName]['date']) {
|
||||
|
@ -255,22 +255,6 @@ export function removeAtIndex<T>(array: T[], index: number): T[] {
|
||||
return [...array.slice(0, index), ...array.slice(index + 1)];
|
||||
}
|
||||
|
||||
export function objectForEach<T extends object | unknown>(
|
||||
obj: T,
|
||||
func: (arg: unknown) => unknown
|
||||
) {
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
return func(obj);
|
||||
}
|
||||
|
||||
const newObj: Record<string, unknown> = {};
|
||||
for (const key in obj) {
|
||||
newObj[key] = objectForEach(obj[key], func);
|
||||
}
|
||||
|
||||
return func(newObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that `value` is of type T. Use with care.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user