Faris Ansari ad0be6aaa2 fix: Messages
- update messages according to new doctype
- sync logo in seller registration
- hub.is_seller_registered() and hub.is_user_registered() api
- Add Users dialog
2018-09-03 15:43:09 +05:30

70 lines
1.6 KiB
JavaScript

const ProfileDialog = (title = __('Edit Profile'), action={}) => {
const fields = [
{
fieldname: 'company_email',
label: __('Email'),
fieldtype: 'Read Only'
},
{
fieldtype: 'Link',
fieldname: 'company',
label: __('Company'),
options: 'Company',
onchange: () => {
const value = dialog.get_value('company');
if (value) {
frappe.db.get_doc('Company', value)
.then(company => {
console.log(company.company_logo);
dialog.set_values({
company_logo: company.company_logo,
company_description: company.company_description
});
});
}
}
},
{
label: __('About your company'),
fieldname: 'company_description',
fieldtype: 'Text'
}
];
let dialog = new frappe.ui.Dialog({
title: title,
fields: fields,
primary_action_label: action.label || __('Update'),
primary_action: () => {
const form_values = dialog.get_values();
let values_filled = true;
// TODO: Say "we notice that the company description and logo isn't set. Please set them in master."
// Only then allow to register
const mandatory_fields = ['company', 'company_description'];
mandatory_fields.forEach(field => {
const value = form_values[field];
if (!value) {
dialog.set_df_property(field, 'reqd', 1);
values_filled = false;
}
});
if (!values_filled) return;
action.on_submit(form_values);
}
});
// Post create
const default_company = frappe.defaults.get_default('company');
dialog.set_value('company', default_company);
dialog.set_value('email', frappe.session.user);
return dialog;
}
export {
ProfileDialog
}