mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
minor fixes
This commit is contained in:
parent
1b42e46462
commit
cb446ba49f
@ -1,13 +1,23 @@
|
|||||||
const Modal = require('frappejs/client/ui/modal');
|
const Modal = require('frappejs/client/ui/modal');
|
||||||
const view = require('frappejs/client/view');
|
const view = require('frappejs/client/view');
|
||||||
const frappe = require('frappejs');
|
|
||||||
|
|
||||||
module.exports = class FormModal extends Modal {
|
module.exports = class FormModal extends Modal {
|
||||||
constructor(doctype, name) {
|
constructor(doctype, name) {
|
||||||
super({title: doctype});
|
super({title: doctype});
|
||||||
this.doctype = doctype;
|
this.doctype = doctype;
|
||||||
this.makeForm();
|
}
|
||||||
this.showWith(doctype, name);
|
|
||||||
|
async showWith(doctype, name) {
|
||||||
|
this.show();
|
||||||
|
await this.setDoc(doctype, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
async setDoc(doctype, name) {
|
||||||
|
if (!this.form) {
|
||||||
|
this.makeForm();
|
||||||
|
}
|
||||||
|
await this.form.setDoc(doctype, name);
|
||||||
|
this.modal.querySelector('input').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
makeForm() {
|
makeForm() {
|
||||||
@ -18,7 +28,8 @@ module.exports = class FormModal extends Modal {
|
|||||||
actions: ['submit']
|
actions: ['submit']
|
||||||
});
|
});
|
||||||
|
|
||||||
this.form.on('submit', () => {
|
this.form.on('submit', async () => {
|
||||||
|
await this.trigger('submit');
|
||||||
this.hide();
|
this.hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -31,9 +42,4 @@ module.exports = class FormModal extends Modal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async showWith(doctype, name) {
|
|
||||||
await this.form.setDoc(doctype, name);
|
|
||||||
this.show();
|
|
||||||
this.$modal.find('input:first').focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -17,6 +17,9 @@ module.exports = class FormPage extends Page {
|
|||||||
|
|
||||||
this.on('show', async (params) => {
|
this.on('show', async (params) => {
|
||||||
await this.showDoc(params.doctype, params.name);
|
await this.showDoc(params.doctype, params.name);
|
||||||
|
if (frappe.desk.center && !frappe.desk.center.activePage) {
|
||||||
|
frappe.desk.showListPage(doctype);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// if name is different after saving, change the route
|
// if name is different after saving, change the route
|
||||||
|
@ -69,8 +69,7 @@ module.exports = class Desk {
|
|||||||
})
|
})
|
||||||
|
|
||||||
frappe.router.add('list/:doctype', async (params) => {
|
frappe.router.add('list/:doctype', async (params) => {
|
||||||
let page = this.getListPage(params.doctype);
|
await this.showListPage(params.doctype);
|
||||||
await page.show(params);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.router.add('edit/:doctype/:name', async (params) => {
|
frappe.router.add('edit/:doctype/:name', async (params) => {
|
||||||
@ -92,10 +91,11 @@ module.exports = class Desk {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getListPage(doctype) {
|
async showListPage(doctype) {
|
||||||
if (!this.pages.lists[doctype]) {
|
if (!this.pages.lists[doctype]) {
|
||||||
this.pages.lists[doctype] = new ListPage(doctype);
|
this.pages.lists[doctype] = new ListPage(doctype);
|
||||||
}
|
}
|
||||||
|
await this.pages.lists[doctype].show(doctype);
|
||||||
return this.pages.lists[doctype];
|
return this.pages.lists[doctype];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,10 +108,9 @@ module.exports = class Desk {
|
|||||||
|
|
||||||
showFormModal(doctype, name) {
|
showFormModal(doctype, name) {
|
||||||
if (!this.pages.formModals[doctype]) {
|
if (!this.pages.formModals[doctype]) {
|
||||||
this.pages.formModals[doctype] = new FormModal(doctype, name);
|
this.pages.formModals[doctype] = new FormModal(doctype);
|
||||||
} else {
|
|
||||||
this.pages.formModals[doctype].showWith(doctype, name);
|
|
||||||
}
|
}
|
||||||
|
this.pages.formModals[doctype].showWith(doctype, name);
|
||||||
return this.pages.formModals[doctype];
|
return this.pages.formModals[doctype];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ html {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.page {
|
.page {
|
||||||
max-width: $page-width;
|
|
||||||
padding-bottom: $spacer-4;
|
padding-bottom: $spacer-4;
|
||||||
|
|
||||||
.page-head {
|
.page-head {
|
||||||
@ -62,7 +61,6 @@ html {
|
|||||||
|
|
||||||
.form-body {
|
.form-body {
|
||||||
padding: $spacer-3;
|
padding: $spacer-3;
|
||||||
max-width: $page-width;
|
|
||||||
|
|
||||||
.form-control.font-weight-bold {
|
.form-control.font-weight-bold {
|
||||||
background-color: lightyellow;
|
background-color: lightyellow;
|
||||||
|
@ -28,6 +28,7 @@ module.exports = class Modal extends Observable {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`).appendTo(document.body);
|
</div>`).appendTo(document.body);
|
||||||
|
this.modal = this.$modal.get(0);
|
||||||
|
|
||||||
if (this.primary) {
|
if (this.primary) {
|
||||||
this.addPrimary(this.primary.label, this.primary.action);
|
this.addPrimary(this.primary.label, this.primary.action);
|
||||||
@ -37,7 +38,9 @@ module.exports = class Modal extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.$modal.on('hidden.bs.modal', () => this.trigger('hide'));
|
this.$modal.on('hidden.bs.modal', () => this.trigger('hide'));
|
||||||
this.$modal.on('shown.bs.modal', () => this.trigger('show'));
|
this.$modal.on('shown.bs.modal', () => {
|
||||||
|
this.trigger('show');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getBodyHTML() {
|
getBodyHTML() {
|
||||||
|
@ -25,8 +25,6 @@ class LinkControl extends BaseControl {
|
|||||||
list.push({
|
list.push({
|
||||||
label:frappe._('+ New {0}', this.target),
|
label:frappe._('+ New {0}', this.target),
|
||||||
value: '__newItem',
|
value: '__newItem',
|
||||||
action: () => {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.awesomplete.list = list;
|
this.awesomplete.list = list;
|
||||||
@ -38,7 +36,7 @@ class LinkControl extends BaseControl {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const newDoc = await frappe.getNewDoc(this.target);
|
const newDoc = await frappe.getNewDoc(this.target);
|
||||||
const formModal = frappe.desk.showFormModal(this.target, newDoc.name);
|
const formModal = frappe.desk.showFormModal(this.target, newDoc.name);
|
||||||
formModal.form.once('submit', async () => {
|
formModal.once('submit', async () => {
|
||||||
await this.updateDocValue(formModal.form.doc.name);
|
await this.updateDocValue(formModal.form.doc.name);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ class TableControl extends BaseControl {
|
|||||||
|
|
||||||
setInputValue(value) {
|
setInputValue(value) {
|
||||||
this.datatable.refresh(this.getTableData(value));
|
this.datatable.refresh(this.getTableData(value));
|
||||||
|
this.datatable.setDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
getTableData(value) {
|
getTableData(value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user