mirror of
https://github.com/frappe/books.git
synced 2024-11-14 09:24:04 +00:00
Format code
This commit is contained in:
parent
66c439d3d1
commit
349faf0695
@ -64,11 +64,12 @@ module.exports = () => {
|
|||||||
email: user.name,
|
email: user.name,
|
||||||
exp: timeInSecondsAfterHr(24)
|
exp: timeInSecondsAfterHr(24)
|
||||||
};
|
};
|
||||||
|
|
||||||
const token = jwt.encode(payload, jwtSecret);
|
const token = jwt.encode(payload, jwtSecret);
|
||||||
res.json({
|
res.json({
|
||||||
token: token
|
token: token
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
res.sendStatus(401);
|
res.sendStatus(401);
|
||||||
}
|
}
|
||||||
@ -100,7 +101,7 @@ module.exports = () => {
|
|||||||
res.json({
|
res.json({
|
||||||
user: user.email
|
user: user.email
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
res.status(500).send('Something went wrong!');
|
res.status(500).send('Something went wrong!');
|
||||||
}
|
}
|
||||||
@ -108,6 +109,6 @@ module.exports = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function timeInSecondsAfterHr(hour=1) {
|
function timeInSecondsAfterHr(hour = 1) {
|
||||||
return Math.floor(Date.now() / 1000) + (3600 * hour)
|
return Math.floor(Date.now() / 1000) + (3600 * hour)
|
||||||
}
|
}
|
@ -50,14 +50,14 @@ class todo_meta extends frappe.meta.Meta {
|
|||||||
|
|
||||||
Standard events on which you can bind handlers are
|
Standard events on which you can bind handlers are
|
||||||
|
|
||||||
- `before_insert`
|
- `beforeInsert`
|
||||||
- `before_update`
|
- `beforeUpdate`
|
||||||
- `validate` (called before any write)
|
- `validate` (called before any write)
|
||||||
- `after_insert`,
|
- `afterInsert`,
|
||||||
- `after_update` (called after any write)
|
- `afterUpdate` (called after any write)
|
||||||
- `before_submit`
|
- `beforeSubmit`
|
||||||
- `after_submit`
|
- `afterSubmit`
|
||||||
- `before_cancel`
|
- `beforeCancel`
|
||||||
- `after_cancel`
|
- `afterCancel`
|
||||||
- `before_delete`
|
- `beforeDelete`
|
||||||
- `after_delete`
|
- `afterDelete`
|
||||||
|
@ -274,9 +274,9 @@ module.exports = class BaseDocument extends Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async delete() {
|
async delete() {
|
||||||
await this.trigger('before_delete');
|
await this.trigger('beforeDelete');
|
||||||
await frappe.db.delete(this.doctype, this.name);
|
await frappe.db.delete(this.doctype, this.name);
|
||||||
await this.trigger('after_delete');
|
await this.trigger('afterDelete');
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
@ -6,10 +6,10 @@ const frappe = require('frappejs');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
format(value, field) {
|
format(value, field) {
|
||||||
if (typeof field === 'string') {
|
if (typeof field === 'string') {
|
||||||
field = {fieldtype: field};
|
field = { fieldtype: field };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.fieldtype==='Currency') {
|
if (field.fieldtype === 'Currency') {
|
||||||
value = number_format.format_number(value);
|
value = number_format.format_number(value);
|
||||||
|
|
||||||
} else if (field.fieldtype === 'Text') {
|
} else if (field.fieldtype === 'Text') {
|
||||||
@ -26,7 +26,7 @@ module.exports = {
|
|||||||
value = moment(value).format(dateFormat.toUpperCase());
|
value = moment(value).format(dateFormat.toUpperCase());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (value===null || value===undefined) {
|
if (value === null || value === undefined) {
|
||||||
value = '';
|
value = '';
|
||||||
} else {
|
} else {
|
||||||
value = value + '';
|
value = value + '';
|
||||||
|
Loading…
Reference in New Issue
Block a user