mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 05:29:18 +00:00
feat(marketplace): edit item dialog
This commit is contained in:
45
erpnext/public/js/hub/components/edit_details_dialog.js
Normal file
45
erpnext/public/js/hub/components/edit_details_dialog.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
function EditDetailsDialog(primary_action, defaults) {
|
||||||
|
let dialog = new frappe.ui.Dialog({
|
||||||
|
title: __('Update Details'),
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
"label": "Item Name",
|
||||||
|
"fieldname": "item_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"default": defaults.item_name,
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Hub Category",
|
||||||
|
"fieldname": "hub_category",
|
||||||
|
"fieldtype": "Autocomplete",
|
||||||
|
"default": defaults.hub_category,
|
||||||
|
"options": [],
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Description",
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"default": defaults.description,
|
||||||
|
"options": [],
|
||||||
|
"reqd": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
primary_action_label: primary_action.label || __('Update Details'),
|
||||||
|
primary_action: primary_action.fn,
|
||||||
|
});
|
||||||
|
|
||||||
|
hub.call('get_categories')
|
||||||
|
.then(categories => {
|
||||||
|
categories = categories.map(d => d.name);
|
||||||
|
dialog.fields_dict.hub_category.df.options = categories;
|
||||||
|
dialog.fields_dict.hub_category.set_options();
|
||||||
|
});
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
EditDetailsDialog
|
||||||
|
};
|
||||||
@@ -35,6 +35,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import ReviewArea from '../components/ReviewArea.vue';
|
import ReviewArea from '../components/ReviewArea.vue';
|
||||||
import { get_rating_html } from '../components/reviews';
|
import { get_rating_html } from '../components/reviews';
|
||||||
|
import { EditDetailsDialog } from '../components/edit_details_dialog';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'item-page',
|
name: 'item-page',
|
||||||
@@ -200,6 +201,7 @@ export default {
|
|||||||
make_dialogs() {
|
make_dialogs() {
|
||||||
this.make_contact_seller_dialog();
|
this.make_contact_seller_dialog();
|
||||||
this.make_report_item_dialog();
|
this.make_report_item_dialog();
|
||||||
|
this.make_editing_dialog();
|
||||||
},
|
},
|
||||||
|
|
||||||
add_to_saved_items() {
|
add_to_saved_items() {
|
||||||
@@ -284,6 +286,36 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_editing_dialog() {
|
||||||
|
this.edit_details_dialog = EditDetailsDialog(
|
||||||
|
{
|
||||||
|
fn: (values) => {
|
||||||
|
this.update_details(values);
|
||||||
|
this.edit_details_dialog.hide();
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'item_name': this.item.item_name,
|
||||||
|
'hub_category': this.item.hub_category,
|
||||||
|
'description': this.item.description,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
update_details(values) {
|
||||||
|
frappe.call(
|
||||||
|
'erpnext.hub_node.api.update_item',
|
||||||
|
{
|
||||||
|
ref_doctype: 'Hub Item',
|
||||||
|
ref_doc: this.item.name,
|
||||||
|
data: values
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then((r) => {
|
||||||
|
this.get_item_details();
|
||||||
|
frappe.show_alert(__(`${this.item.item_name} Updated`));
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
contact_seller() {
|
contact_seller() {
|
||||||
this.contact_seller_dialog.show();
|
this.contact_seller_dialog.show();
|
||||||
},
|
},
|
||||||
@@ -296,7 +328,10 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
edit_details() {
|
edit_details() {
|
||||||
frappe.msgprint(__('This feature is under development...'));
|
if (!hub.is_seller_registered()) {
|
||||||
|
frappe.throw(__('Please login as a Marketplace User to edit this item.'));
|
||||||
|
}
|
||||||
|
this.edit_details_dialog.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
unpublish_item() {
|
unpublish_item() {
|
||||||
|
|||||||
Reference in New Issue
Block a user