[hub][init] add profile page
This commit is contained in:
		
							parent
							
								
									f26177bdbc
								
							
						
					
					
						commit
						d1224ca662
					
				| @ -34,9 +34,14 @@ def get_list(doctype, start=0, limit=20, fields=["*"], filters="{}", order_by=No | ||||
| #### LOCAL ITEMS | ||||
| @frappe.whitelist() | ||||
| def get_valid_items(search_value=''): | ||||
| 	items = frappe.get_list('Item', fields=["*"], filters={ | ||||
| 		'item_name': ['like', '%' + search_value + '%'] | ||||
| 	}) | ||||
| 	items = frappe.get_list( | ||||
| 		'Item', fields=["*"], | ||||
| 		filters={ | ||||
| 			'item_name': ['like', '%' + search_value + '%'], | ||||
| 			'publish_in_hub': 0 | ||||
| 		}, | ||||
| 		order_by="modified desc" | ||||
| 	) | ||||
| 
 | ||||
| 	valid_items = filter(lambda x: x.image and x.description, items) | ||||
| 
 | ||||
| @ -52,9 +57,6 @@ def publish_selected_items(items_to_publish, items_to_unpublish): | ||||
| 	for item_code in json.loads(items_to_publish): | ||||
| 		frappe.db.set_value('Item', item_code, 'publish_in_hub', 1) | ||||
| 
 | ||||
| 	for item_code in json.loads(items_to_unpublish): | ||||
| 		frappe.db.set_value('Item', item_code, 'publish_in_hub', 0) | ||||
| 
 | ||||
| 	hub_settings = frappe.get_doc('Hub Settings') | ||||
| 	hub_settings.sync() | ||||
| 
 | ||||
|  | ||||
| @ -137,11 +137,14 @@ erpnext.hub.Marketplace = class Marketplace { | ||||
| 			this.subpages.register = new erpnext.hub.Register(this.$body); | ||||
| 		} | ||||
| 
 | ||||
| 		if (route[1] === 'profile' && !this.subpages.profile) { | ||||
| 			this.subpages.profile = new erpnext.hub.Profile(this.$body, this.hub_settings); | ||||
| 		} | ||||
| 
 | ||||
| 		if (route[1] === 'publish' && !this.subpages.publish) { | ||||
| 			this.subpages.publish = new erpnext.hub.Publish(this.$body); | ||||
| 		} | ||||
| 
 | ||||
| 
 | ||||
| 		if (!Object.keys(this.subpages).includes(route[1])) { | ||||
| 			frappe.show_not_found(); | ||||
| 			return; | ||||
| @ -572,6 +575,51 @@ erpnext.hub.Register = class Register extends SubPage { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| erpnext.hub.Profile = class Profile extends SubPage { | ||||
| 	constructor(parent, profile_data) { | ||||
| 		super(parent); | ||||
| 		this.profile_data = profile_data; | ||||
| 	} | ||||
| 
 | ||||
| 	make_wrapper() { | ||||
| 		super.make_wrapper(); | ||||
| 		const profile_html = `<div class="hub-item-container">
 | ||||
| 			<div class="row visible-xs"> | ||||
| 				<div class="col-xs-12 margin-bottom"> | ||||
| 					<button class="btn btn-xs btn-default" data-route="marketplace/home">Back to home</button> | ||||
| 				</div> | ||||
| 			</div> | ||||
| 			<div class="row"> | ||||
| 				<div class="col-md-3"> | ||||
| 					<div class="hub-item-image"> | ||||
| 						<img src="${'gd'}"> | ||||
| 					</div> | ||||
| 				</div> | ||||
| 				<div class="col-md-6"> | ||||
| 					<h2>${'title'}</h2> | ||||
| 					<div class="text-muted"> | ||||
| 						<p>${'where'}${'dot_spacer'}${'when'}</p> | ||||
| 						<p>${'rating_html'}${'rating_count'}</p> | ||||
| 					</div> | ||||
| 					<hr> | ||||
| 					<div class="hub-item-description"> | ||||
| 					${'description' ? | ||||
| 						`<b>${__('Description')}</b>
 | ||||
| 						<p>${'description'}</p> | ||||
| 						` : __('No description')
 | ||||
| 					} | ||||
| 					</div> | ||||
| 				</div> | ||||
| 			</div> | ||||
| 		</div>`; | ||||
| 
 | ||||
| 		this.$wrapper.html(profile_html); | ||||
| 	} | ||||
| 
 | ||||
| 	refresh() {} | ||||
| 
 | ||||
| 	render() {} | ||||
| } | ||||
| erpnext.hub.Publish = class Publish extends SubPage { | ||||
| 	make_wrapper() { | ||||
| 		super.make_wrapper(); | ||||
| @ -604,9 +652,6 @@ erpnext.hub.Publish = class Publish extends SubPage { | ||||
| 			</div> | ||||
| 
 | ||||
| 			${search_html} | ||||
| 
 | ||||
| 			${select_all_button} | ||||
| 			${deselect_all_button} | ||||
| 		`);
 | ||||
| 
 | ||||
| 		this.$wrapper.append(subpage_header); | ||||
| @ -615,13 +660,13 @@ erpnext.hub.Publish = class Publish extends SubPage { | ||||
| 	} | ||||
| 
 | ||||
| 	setup_events() { | ||||
| 		this.$wrapper.find('.select-all').on('click', () => { | ||||
| 			this.$wrapper.find('.hub-card').addClass('active'); | ||||
| 		}); | ||||
| 		// this.$wrapper.find('.select-all').on('click', () => {
 | ||||
| 		// 	this.$wrapper.find('.hub-card').addClass('active');
 | ||||
| 		// });
 | ||||
| 
 | ||||
| 		this.$wrapper.find('.deselect-all').on('click', () => { | ||||
| 			this.$wrapper.find('.hub-card').removeClass('active'); | ||||
| 		}); | ||||
| 		// this.$wrapper.find('.deselect-all').on('click', () => {
 | ||||
| 		// 	this.$wrapper.find('.hub-card').removeClass('active');
 | ||||
| 		// });
 | ||||
| 
 | ||||
| 		this.$wrapper.find('.publish-items').on('click', () => { | ||||
| 			this.publish_selected_items() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user