From 0a354fa5c1565871a6e1a098c33ba81f0a2f9c99 Mon Sep 17 00:00:00 2001 From: sahil28297 <37302950+sahil28297@users.noreply.github.com> Date: Fri, 7 Sep 2018 15:38:15 +0530 Subject: [PATCH 1/2] Displaying Links in correct sorted order (#84) --- common/router.js | 2 +- package.json | 2 +- server/index.js | 1 + test.db-journal | Bin 0 -> 4616 bytes ui/components/List/List.vue | 1 + ui/components/controls/Link.vue | 3 +++ ui/pages/Report/index.vue | 5 ++++- 7 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 test.db-journal diff --git a/common/router.js b/common/router.js index e2437d33..ce3ea8e7 100644 --- a/common/router.js +++ b/common/router.js @@ -136,4 +136,4 @@ module.exports = class Router extends Observable { } return route; } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 6635d115..27603255 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "express": "^4.16.2", "feather-icons": "^4.7.3", "flatpickr": "^4.3.2", - "frappe-datatable": "^1.1.2", + "frappe-datatable": "^1.3.1", "friendly-errors-webpack-plugin": "^1.7.0", "html-webpack-plugin": "^3.2.0", "jquery": "^3.3.1", diff --git a/server/index.js b/server/index.js index f1c841ef..7ff914d1 100644 --- a/server/index.js +++ b/server/index.js @@ -43,6 +43,7 @@ module.exports = { app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static(frappe.conf.distPath)); + app.use('/static', express.static(frappe.conf.staticPath)) app.use(morgan('tiny')); diff --git a/test.db-journal b/test.db-journal new file mode 100644 index 0000000000000000000000000000000000000000..aba14275ef9d58434282845f4f991a751b4dbcb4 GIT binary patch literal 4616 zcmeH~PfG$p6u@V6)e6)Og@-Oryd;Pa(mgE`X|pneJjv>gF}Ay7>zI1AK0;@qL!YG2 z5YacOTeJCZX*Ie=^I)0xm!0=}GlzM534Fj~;}s!nvN^ku3KrSWAr`i_)v9Yvm^&*6H+T9z#R zl7J*22}lBxfFvLZNCJ|8Bp?a=Z34qpe<+qn;JYf<>IONa1}ApGX5F?+RrbsIY$Xqs zY);LCD*)ST;1brehz*?dIY8;80;LO8g%p@fr%g)q+`t=a*hJ%$S>DLB${V>RgC4W> z&LkrKU}+{9Tc_pXakgBAqkMI~1=n80Q}Tc{DuebUf1U)%T_qSRCNQFwPWqi2Lp(ie zT9>mgyXI=Uw&OAa!z~<&#pC!MyAT#RF~>=c=34;J@qgp@`!=ZF2WoM0C3w$UNI_e( ziN(Fh#(ut_?P-k|kfD1Em$)0u(&^&4-D*a63Kt-m@daar_|H%s6jP>-?iY7z#kp6l H(PsJ+O2^-> literal 0 HcmV?d00001 diff --git a/ui/components/List/List.vue b/ui/components/List/List.vue index b844c1e2..9e99ba85 100644 --- a/ui/components/List/List.vue +++ b/ui/components/List/List.vue @@ -93,6 +93,7 @@ export default { }, async deleteCheckedItems() { await frappe.db.deleteMany(this.doctype, this.checkList); + this.$router.push(`/list/${this.doctype}`); this.checkList = []; }, toggleCheck(name) { diff --git a/ui/components/controls/Link.vue b/ui/components/controls/Link.vue index bcdc74df..b89ba602 100644 --- a/ui/components/controls/Link.vue +++ b/ui/components/controls/Link.vue @@ -101,6 +101,9 @@ export default { }, sort() { return (a, b) => { + a = a.toLowerCase(); + b = b.toLowerCase(); + if (a.value === '__newItem') { return 1; } diff --git a/ui/pages/Report/index.vue b/ui/pages/Report/index.vue index 35a3eb05..e921a8cf 100644 --- a/ui/pages/Report/index.vue +++ b/ui/pages/Report/index.vue @@ -2,7 +2,7 @@

{{ reportConfig.title }}

- +
@@ -22,6 +22,9 @@ export default { return utils.convertFieldsToDatatableColumns( this.reportConfig.getColumns() ); + }, + filtersExists() { + return (this.reportConfig.filterFields || []).length; } }, methods: { From dc7f7be4475b40f9e4286b47ddb674053f04ac8e Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 11 Sep 2018 23:45:18 +0530 Subject: [PATCH 2/2] Update documentation for new app (#86) --- docs/app.md | 139 ++++++++++++++++++++++------------------------------ 1 file changed, 59 insertions(+), 80 deletions(-) diff --git a/docs/app.md b/docs/app.md index c8b8c027..17689897 100644 --- a/docs/app.md +++ b/docs/app.md @@ -6,125 +6,104 @@ yarn add frappejs ``` -FrappeJS comes with built in rollup config for your files +FrappeJS comes with an Express Server on the backend, VueJS for the front-end and a CLI to run these things with built-in webpack configs. -## Build +## Config -There are 2 files that get built for the Desk single page application +FrappeJS requires a file named `frappe.conf.js` to be present in the root of your directory. Minimum configuration looks like: -- `/dist/js/bundle.js` -- `/dist/css/style.css` +``` +module.exports = { + staticPath: './static', // uploaded files are served from this directory + distPath: './dist', // bundled assets are built and served here + dev: { + // your client side entry files + entry: { + app: './src/main.js' + }, + outputDir: './dist', + assetsPublicPath: '/', + devServerPort: 8000, + env: { + PORT: process.env.PORT || 8000 + } + }, + node: { + paths: { + main: 'server/index.js' // your server entry file + } + }, + electron: { + // wip + } +} -Your `rollup.config.js` should look like: - -```js -module.exports = [ - require('frappejs/config/rollup.config.style.js'), - require('frappejs/config/rollup.config.app.js') -] ``` -## Create a basic app - -### index.html - -The UI for the single page app (desk) will be built inside the `body` element, so you just need to have an empty body element, and link your JS bundle in `index.html` - -Sample index.html +You also need an `index.html` located in the `src` directory. It can look like ```html - - - Document - + + + + My Awesome App - - +
``` -## For development setup -Clone frappejs in the same folder as your app, since you will be developing frappejs on the side. +### Server -### Link frappejs - -```sh -# make frappejs linkable -cd frappejs - -yarn link -yarn link frappejs - -# link frappejs in all -cd ../myapp -yarn link frappejs - -# install libs -yarn -``` - -### server.js - -Create your server file `server.js` +Assuming you have a `server/index.js` file, you can start the frappejs server in just a few lines of code. ```js const server = require('frappejs/server'); server.start({ backend: 'sqlite', - connection_params: {db_path: 'test.db'}, - static: './' + connection_params: { + db_path: 'test.db' + } }); ``` -### index.js +### Client -In your client file you will have to import all your controllers and init them. +In your client file you will have to initialize `frappe` and `models`. `frappejs/client` lib will initialize your server and user interface with the Desk. -Example starting point for a to-do app: +Example starting point for an app: ```js -const client = require('frappejs/client'); -const todo = require('frappejs/models/doctype/todo/todo.js'); -// start server -client.start({ - server: 'localhost:8000', -}).then(() => { - frappe.init_controller('todo', todo); +import frappe from 'frappejs'; +import io from 'socket.io-client'; +import HTTPClient from 'frappejs/backends/http'; +import common from 'frappejs/common'; +import coreModels from 'frappejs/models'; - frappe.desk.add_sidebar_item('Home', '#'); - frappe.desk.add_sidebar_item('New ToDo', '#new/todo'); +frappe.init(); +frappe.registerLibs(common); +frappe.registerModels(coreModels); + +const server = 'localhost:8000'; +frappe.fetch = window.fetch.bind(); +frappe.db = new HTTPClient({ server }); +const socket = io.connect(`http://${server}`); +frappe.db.bindSocketClient(socket); - frappe.router.default = '/list/todo'; - frappe.router.show(window.location.hash); -}); ``` ## Start -To start the app and build webpack simultaneously you can use a `Procfile` +To start the server and build webpack simultaneously you can use the cli command -```yml -server: nodemon server.js -watch: node_modules/.bin/rollup -c --watch -``` - -You can use any procfile handler like `node-foreman` to start the processes. - -``` -yarn global add foreman -``` - -Then - -``` -nf start +```bash +./node_modules/.bin/frappe start ```