mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
minor fixes
This commit is contained in:
parent
5446c2cc2e
commit
4e9eaa0fff
@ -195,7 +195,8 @@ module.exports = class Database extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
triggerChange(doctype, name) {
|
triggerChange(doctype, name) {
|
||||||
this.trigger(`change:${doctype}`, {name:name}, 1000);
|
this.trigger(`change:${doctype}`, {name:name}, 500);
|
||||||
|
this.trigger(`change`, {doctype:name, name:name}, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
async insert(doctype, doc) {
|
async insert(doctype, doc) {
|
||||||
@ -323,6 +324,10 @@ module.exports = class Database extends Observable {
|
|||||||
// datetime
|
// datetime
|
||||||
return value.toISOString();
|
return value.toISOString();
|
||||||
}
|
}
|
||||||
|
} else if (field.fieldtype === 'Link' && !value) {
|
||||||
|
// empty value must be null to satisfy
|
||||||
|
// foreign key constraint
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ module.exports = class sqliteDatabase extends Database {
|
|||||||
columns.push(def);
|
columns.push(def);
|
||||||
|
|
||||||
if (field.fieldtype==='Link' && field.target) {
|
if (field.fieldtype==='Link' && field.target) {
|
||||||
indexes.push(`FOREIGN KEY (${field.fieldname}) REFERENCES ${field.target} ON UPDATE RESTRICT ON DELETE RESTRICT`);
|
indexes.push(`FOREIGN KEY (${field.fieldname}) REFERENCES ${field.target} ON UPDATE CASCADE ON DELETE RESTRICT`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ module.exports = class FormPage extends Page {
|
|||||||
|
|
||||||
// if name is different after saving, change the route
|
// if name is different after saving, change the route
|
||||||
this.form.on('save', async (params) => {
|
this.form.on('save', async (params) => {
|
||||||
let route = frappe.router.get_route();
|
let route = frappe.router.getRoute();
|
||||||
if (this.form.doc.name && !(route && route[2] === this.form.doc.name)) {
|
if (this.form.doc.name && !(route && route[2] === this.form.doc.name)) {
|
||||||
await frappe.router.setRoute('edit', this.form.doc.doctype, this.form.doc.name);
|
await frappe.router.setRoute('edit', this.form.doc.doctype, this.form.doc.name);
|
||||||
frappe.ui.showAlert({message: 'Added', color: 'green'});
|
frappe.ui.showAlert({message: 'Added', color: 'green'});
|
||||||
|
@ -30,7 +30,9 @@ module.exports = class ListPage extends Page {
|
|||||||
async show(params) {
|
async show(params) {
|
||||||
super.show();
|
super.show();
|
||||||
this.setTitle(name===this.list.doctype ? (this.list.meta.label || this.list.meta.name) : name);
|
this.setTitle(name===this.list.doctype ? (this.list.meta.label || this.list.meta.name) : name);
|
||||||
frappe.desk.body.activePage.hide();
|
if (frappe.desk.body.activePage && frappe.router.getRoute()[0]==='list') {
|
||||||
|
frappe.desk.body.activePage.hide();
|
||||||
|
}
|
||||||
await this.list.refresh();
|
await this.list.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,13 +214,13 @@ mark {
|
|||||||
background-color: $gray-200 !important;
|
background-color: $gray-200 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-table-col .edit-cell {
|
.data-table-cell .edit-cell {
|
||||||
padding: 0px !important;
|
padding: 0px !important;
|
||||||
|
|
||||||
input, textarea {
|
input, textarea {
|
||||||
border-radius: none;
|
border-radius: none;
|
||||||
margin: none;
|
margin: none;
|
||||||
padding: $spacer-1;
|
padding: $spacer-2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.awesomplete > ul {
|
.awesomplete > ul {
|
||||||
|
@ -4,7 +4,8 @@ const controls = require('frappejs/client/view/controls');
|
|||||||
const Modal = require('frappejs/client/ui/modal');
|
const Modal = require('frappejs/client/ui/modal');
|
||||||
|
|
||||||
module.exports = class ModelTable {
|
module.exports = class ModelTable {
|
||||||
constructor({doctype, parent, layout='fixed', parentControl, getRowDoc, isDisabled}) {
|
constructor({doctype, parent, layout='fixed', parentControl, getRowDoc,
|
||||||
|
isDisabled, getTableData}) {
|
||||||
Object.assign(this, arguments[0]);
|
Object.assign(this, arguments[0]);
|
||||||
this.meta = frappe.getMeta(this.doctype);
|
this.meta = frappe.getMeta(this.doctype);
|
||||||
this.make();
|
this.make();
|
||||||
|
@ -11,7 +11,8 @@ class TableControl extends BaseControl {
|
|||||||
parentControl: this,
|
parentControl: this,
|
||||||
layout: this.layout || 'fixed',
|
layout: this.layout || 'fixed',
|
||||||
getRowDoc: (rowIndex) => this.doc[this.fieldname][rowIndex],
|
getRowDoc: (rowIndex) => this.doc[this.fieldname][rowIndex],
|
||||||
isDisabled: () => this.isDisabled()
|
isDisabled: () => this.isDisabled(),
|
||||||
|
getTableData: () => this.getTableData()
|
||||||
});
|
});
|
||||||
this.setupToolbar();
|
this.setupToolbar();
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ module.exports = class BaseForm extends Observable {
|
|||||||
this.container.setTitle(this.doc.name);
|
this.container.setTitle(this.doc.name);
|
||||||
}
|
}
|
||||||
if (this.doc.submitted) {
|
if (this.doc.submitted) {
|
||||||
this.container.addTitleBadge('✓', frappe._('Submitted'));
|
// this.container.addTitleBadge('✓', frappe._('Submitted'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ module.exports = class Router extends Observable {
|
|||||||
|
|
||||||
listen() {
|
listen() {
|
||||||
window.addEventListener('hashchange', (event) => {
|
window.addEventListener('hashchange', (event) => {
|
||||||
let route = this.get_route_string();
|
let route = this.getRoute_string();
|
||||||
if (this.last_route !== route) {
|
if (this.last_route !== route) {
|
||||||
this.show(route);
|
this.show(route);
|
||||||
}
|
}
|
||||||
@ -62,8 +62,8 @@ module.exports = class Router extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// split and get routes
|
// split and get routes
|
||||||
get_route() {
|
getRoute() {
|
||||||
let route = this.get_route_string();
|
let route = this.getRoute_string();
|
||||||
if (route) {
|
if (route) {
|
||||||
return route.split('/');
|
return route.split('/');
|
||||||
} else {
|
} else {
|
||||||
@ -129,7 +129,7 @@ module.exports = class Router extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get_route_string() {
|
getRoute_string() {
|
||||||
let route = window.location.hash;
|
let route = window.location.hash;
|
||||||
if (route && route[0]==='#') {
|
if (route && route[0]==='#') {
|
||||||
route = route.substr(1);
|
route = route.substr(1);
|
||||||
|
@ -9,6 +9,7 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
this.flags = {};
|
this.flags = {};
|
||||||
this.setup();
|
this.setup();
|
||||||
Object.assign(this, data);
|
Object.assign(this, data);
|
||||||
|
frappe.db.on('change', (params) => this.fetchValues[`${params.doctype}:${params.name}`] = {});
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@ -216,7 +217,6 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
|
|
||||||
async commit() {
|
async commit() {
|
||||||
// re-run triggers
|
// re-run triggers
|
||||||
await naming.setName(this);
|
|
||||||
this.setStandardValues();
|
this.setStandardValues();
|
||||||
this.setKeywords();
|
this.setKeywords();
|
||||||
this.setChildIdx();
|
this.setChildIdx();
|
||||||
@ -225,6 +225,7 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async insert() {
|
async insert() {
|
||||||
|
await naming.setName(this);
|
||||||
await this.commit();
|
await this.commit();
|
||||||
await this.trigger('beforeInsert');
|
await this.trigger('beforeInsert');
|
||||||
|
|
||||||
@ -291,10 +292,10 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
|
|
||||||
async getFrom(doctype, name, fieldname) {
|
async getFrom(doctype, name, fieldname) {
|
||||||
if (!name) return '';
|
if (!name) return '';
|
||||||
let key = `${doctype}:${name}:${fieldname}`;
|
let _values = this.fetchValues[`${doctype}:${name}`] || (this.fetchValues[`${doctype}:${name}`] = {});
|
||||||
if (!this.fetchValues[key]) {
|
if (!_values[fieldname]) {
|
||||||
this.fetchValues[key] = await frappe.db.getValue(doctype, name, fieldname);
|
_values[fieldname] = await frappe.db.getValue(doctype, name, fieldname);
|
||||||
}
|
}
|
||||||
return this.fetchValues[key];
|
return _values[fieldname];
|
||||||
}
|
}
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user