2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 03:29:00 +00:00

minor fixes

This commit is contained in:
Rushabh Mehta 2018-02-15 22:09:50 +05:30
parent 1b42e46462
commit cb446ba49f
7 changed files with 29 additions and 21 deletions

View File

@ -1,13 +1,23 @@
const Modal = require('frappejs/client/ui/modal');
const view = require('frappejs/client/view');
const frappe = require('frappejs');
module.exports = class FormModal extends Modal {
constructor(doctype, name) {
super({title: 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() {
@ -18,7 +28,8 @@ module.exports = class FormModal extends Modal {
actions: ['submit']
});
this.form.on('submit', () => {
this.form.on('submit', async () => {
await this.trigger('submit');
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();
}
}

View File

@ -17,6 +17,9 @@ module.exports = class FormPage extends Page {
this.on('show', async (params) => {
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

View File

@ -69,8 +69,7 @@ module.exports = class Desk {
})
frappe.router.add('list/:doctype', async (params) => {
let page = this.getListPage(params.doctype);
await page.show(params);
await this.showListPage(params.doctype);
});
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]) {
this.pages.lists[doctype] = new ListPage(doctype);
}
await this.pages.lists[doctype].show(doctype);
return this.pages.lists[doctype];
}
@ -108,10 +108,9 @@ module.exports = class Desk {
showFormModal(doctype, name) {
if (!this.pages.formModals[doctype]) {
this.pages.formModals[doctype] = new FormModal(doctype, name);
} else {
this.pages.formModals[doctype].showWith(doctype, name);
this.pages.formModals[doctype] = new FormModal(doctype);
}
this.pages.formModals[doctype].showWith(doctype, name);
return this.pages.formModals[doctype];
}

View File

@ -36,7 +36,6 @@ html {
}
.page {
max-width: $page-width;
padding-bottom: $spacer-4;
.page-head {
@ -62,7 +61,6 @@ html {
.form-body {
padding: $spacer-3;
max-width: $page-width;
.form-control.font-weight-bold {
background-color: lightyellow;

View File

@ -28,6 +28,7 @@ module.exports = class Modal extends Observable {
</div>
</div>
</div>`).appendTo(document.body);
this.modal = this.$modal.get(0);
if (this.primary) {
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('shown.bs.modal', () => this.trigger('show'));
this.$modal.on('shown.bs.modal', () => {
this.trigger('show');
});
}
getBodyHTML() {

View File

@ -25,8 +25,6 @@ class LinkControl extends BaseControl {
list.push({
label:frappe._('+ New {0}', this.target),
value: '__newItem',
action: () => {
}
});
this.awesomplete.list = list;
@ -38,7 +36,7 @@ class LinkControl extends BaseControl {
e.preventDefault();
const newDoc = await frappe.getNewDoc(this.target);
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);
})
}

View File

@ -55,6 +55,7 @@ class TableControl extends BaseControl {
setInputValue(value) {
this.datatable.refresh(this.getTableData(value));
this.datatable.setDimensions();
}
getTableData(value) {