Skip to content

Commit

Permalink
Merge pull request frappe#16 from ssiyad/refactor/cleanup
Browse files Browse the repository at this point in the history
refactor/cleanup
  • Loading branch information
ssiyad authored Jan 4, 2023
2 parents 6359cde + f5c8a4f commit 076669a
Show file tree
Hide file tree
Showing 30 changed files with 172 additions and 115 deletions.
23 changes: 18 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
.DS_Store
*.pyc
**/__pycache__
*.egg-info
*.pyc
*.py~
*.swo
*.swp
*~
.DS_Store
.backportrc.json
.idea/
.vscode/
.wnf-lang-status
__pycache__
conf.py
dist/
webshop/docs/current
webshop/public/dist
latest_updates.json
locale
node_modules/
tags
node_modules
**/__pycache__
.vscode/
4 changes: 1 addition & 3 deletions webshop/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
app_license = "GNU General Public License (v3)"
app_version = _version

web_include_js = [
"override.bundle.js",
]
web_include_js = "web.bundle.js"

after_install = "webshop.setup.install.after_install"
on_logout = "webshop.webshop.shopping_cart.utils.clear_cart_count"
Expand Down
Binary file added webshop/public/images/cart-empty-state.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions webshop/public/js/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
if (!window.webshop) window.webshop = {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
erpnext.ProductGrid = class {
webshop.ProductGrid = class {
/* Options:
- items: Items
- settings: Webshop Settings
Expand Down Expand Up @@ -198,4 +198,4 @@ erpnext.ProductGrid = class {
return ``;
}
}
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
erpnext.ProductList = class {
webshop.ProductList = class {
/* Options:
- items: Items
- settings: Webshop Settings
Expand Down Expand Up @@ -201,4 +201,4 @@ erpnext.ProductList = class {
}
}

};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
erpnext.ProductSearch = class {
webshop.ProductSearch = class {
constructor(opts) {
/* Options: search_box_id (for custom search box) */
$.extend(this, opts);
Expand Down Expand Up @@ -48,7 +48,7 @@ erpnext.ProductSearch = class {
if (query.length < 3 || !query.length) return;

frappe.call({
method: "erpnext.templates.pages.product_search.search",
method: "webshop.templates.pages.product_search.search",
args: {
query: query
},
Expand Down Expand Up @@ -197,7 +197,7 @@ erpnext.ProductSearch = class {
let html = "";

product_results.forEach((res) => {
let thumbnail = res.thumbnail || '/assets/erpnext/images/ui-states/cart-empty-state.png';
let thumbnail = res.thumbnail || '/assets/webshop/images/cart-empty-state.png';
html += `
<div class="dropdown-item" style="display: flex;">
<img class="item-thumb col-2" src=${encodeURI(thumbnail)} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
erpnext.ProductView = class {
webshop.ProductView = class {
/* Options:
- View Type
- Products Section Wrapper,
Expand All @@ -24,7 +24,7 @@ erpnext.ProductView = class {
this.prepare_search();
this.prepare_view_toggler();

new erpnext.ProductSearch();
new webshop.ProductSearch();
}

prepare_view_toggler() {
Expand All @@ -45,7 +45,7 @@ erpnext.ProductView = class {
this.disable_view_toggler(true);

frappe.call({
method: "erpnext.webshop.api.get_product_filter_data",
method: "webshop.webshop.api.get_product_filter_data",
args: {
query_args: args
},
Expand Down Expand Up @@ -101,7 +101,7 @@ erpnext.ProductView = class {
let me = this;
this.prepare_product_area_wrapper("grid");

new erpnext.ProductGrid({
new webshop.ProductGrid({
items: items,
products_section: $("#products-grid-area"),
settings: settings,
Expand All @@ -113,7 +113,7 @@ erpnext.ProductView = class {
let me = this;
this.prepare_product_area_wrapper("list");

new erpnext.ProductList({
new webshop.ProductList({
items: items,
products_section: $("#products-list-area"),
settings: settings,
Expand Down Expand Up @@ -494,7 +494,7 @@ erpnext.ProductView = class {
let no_results_section = `
<div class="cart-empty frappe-card mt-4">
<div class="cart-empty-state">
<img src="/assets/erpnext/images/ui-states/cart-empty-state.png" alt="Empty Cart">
<img src="/assets/webshop/images/cart-empty-state.png" alt="Empty Cart">
</div>
<div class="cart-empty-message mt-4">${ __('No products found') }</p>
</div>
Expand Down Expand Up @@ -545,4 +545,4 @@ erpnext.ProductView = class {
}
return exists ? obj : undefined;
}
};
};
2 changes: 1 addition & 1 deletion webshop/public/js/wishlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ $.extend(wishlist, {
$(".page_content").append(`
<div class="cart-empty frappe-card">
<div class="cart-empty-state">
<img src="/assets/erpnext/images/ui-states/cart-empty-state.png" alt="Empty Cart">
<img src="/assets/webshop/images/cart-empty-state.png" alt="Empty Cart">
</div>
<div class="cart-empty-message mt-4">${ __('Wishlist is empty !') }</p>
</div>
Expand Down
9 changes: 9 additions & 0 deletions webshop/public/web.bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import './js/init'

import './js/customer_reviews'
import './js/product_ui/grid'
import './js/product_ui/list'
import './js/product_ui/search'
import './js/product_ui/views'
import './js/shopping_cart'
import './js/wishlist'
4 changes: 2 additions & 2 deletions webshop/templates/generators/item/item.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "templates/web.html" %}
{% from "erpnext/templates/includes/macros.html" import recommended_item_row %}
{% from "webshop/templates/includes/macros.html" import recommended_item_row %}

{% block title %} {{ title }} {% endblock %}

Expand All @@ -11,7 +11,7 @@

{% block page_content %}
<div class="product-container item-main">
{% from "erpnext/templates/includes/macros.html" import product_image %}
{% from "webshop/templates/includes/macros.html" import product_image %}
<div class="item-content">
<div class="product-page-content" itemscope itemtype="http://schema.org/Product">
<!-- Image, Description, Add to Cart -->
Expand Down
2 changes: 1 addition & 1 deletion webshop/templates/generators/item/item_reviews.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "erpnext/templates/includes/macros.html" import user_review, ratings_summary %}
{% from "webshop/templates/includes/macros.html" import user_review, ratings_summary %}

<div class="mt-4 ratings-reviews-section">
<!-- Title and Action -->
Expand Down
2 changes: 1 addition & 1 deletion webshop/templates/includes/cart/cart_address.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "erpnext/templates/includes/cart/cart_macros.html" import show_address %}
{% from "webshop/templates/includes/cart/cart_macros.html" import show_address %}

{% if addresses | length == 1%}
{% set select_address = True %}
Expand Down
2 changes: 1 addition & 1 deletion webshop/templates/includes/cart/cart_items.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "erpnext/templates/includes/macros.html" import product_image %}
{% from "webshop/templates/includes/macros.html" import product_image %}

{% macro item_subtotal(item) %}
<div>
Expand Down
2 changes: 1 addition & 1 deletion webshop/templates/includes/cart/cart_items_dropdown.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "erpnext/templates/includes/order/order_macros.html" import item_name_and_description_cart %}
{% from "webshop/templates/includes/order/order_macros.html" import item_name_and_description_cart %}

{% for d in doc.items %}
<div class="row cart-dropdown">
Expand Down
2 changes: 1 addition & 1 deletion webshop/templates/includes/order/order_macros.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% from "erpnext/templates/includes/macros.html" import product_image %}
{% from "webshop/templates/includes/macros.html" import product_image %}

{% macro item_name_and_description(d) %}
<div class="row item_name_and_description">
Expand Down
4 changes: 2 additions & 2 deletions webshop/templates/includes/product_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ frappe.ready(function() {
})

$("#item-add-to-cart button").on("click", function() {
frappe.provide('erpnext.shopping_cart');
frappe.provide('webshop.shopping_cart');

erpnext.shopping_cart.update_cart({
webshop.shopping_cart.update_cart({
item_code: get_item_code(),
qty: $("#item-spinner .cart-qty").val(),
callback: function(r) {
Expand Down
2 changes: 1 addition & 1 deletion webshop/templates/pages/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h5>{{ _("Terms and Conditions") }}</h5>
{% else %}
<div class="cart-empty frappe-card">
<div class="cart-empty-state">
<img src="/assets/erpnext/images/ui-states/cart-empty-state.png" alt="Empty State">
<img src="/assets/webshop/images/cart-empty-state.png" alt="Empty State">
</div>
<div class="cart-empty-message mt-4">{{ _('Your cart is Empty') }}</p>
{% if cart_settings.enable_checkout %}
Expand Down
4 changes: 2 additions & 2 deletions webshop/templates/pages/customer_reviews.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "templates/web.html" %}
{% from "erpnext/templates/includes/macros.html" import user_review, ratings_summary %}
{% from "webshop/templates/includes/macros.html" import user_review, ratings_summary %}

{% block title %} {{ _("Customer Reviews") }} {% endblock %}

Expand Down Expand Up @@ -64,4 +64,4 @@ <h3 class="text-muted mt-8">
<script type="text/javascript" src="/assets/js/control.min.js"></script>
<script type="text/javascript" src="/assets/js/dialog.min.js"></script>
<script type="text/javascript" src="/assets/js/bootstrap-4-web.min.js"></script>
{% endblock %}
{% endblock %}
6 changes: 3 additions & 3 deletions webshop/templates/pages/order.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "templates/web.html" %}
{% from "erpnext/templates/includes/order/order_macros.html" import item_name_and_description %}
{% from "webshop/templates/includes/order/order_macros.html" import item_name_and_description %}

{% block breadcrumbs %}
{% include "templates/includes/breadcrumbs.html" %}
Expand Down Expand Up @@ -123,7 +123,7 @@ <h3 class="m-0">{{ doc.name }}</h3>

<!-- taxes -->
<div class="">
{% include "erpnext/templates/includes/order/order_taxes.html" %}
{% include "webshop/templates/includes/order/order_taxes.html" %}
</div>
</div>
</div>
Expand Down Expand Up @@ -202,4 +202,4 @@ <h3 class="m-0">{{ doc.name }}</h3>
currency: '{{ doc.currency }}'
}
</script>
{% endblock %}
{% endblock %}
6 changes: 3 additions & 3 deletions webshop/templates/pages/wishlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="row">
<div class="col-md-12 item-card-group-section">
<div class="row products-list">
{% from "erpnext/templates/includes/macros.html" import wishlist_card %}
{% from "webshop/templates/includes/macros.html" import wishlist_card %}
{% for item in items %}
{{ wishlist_card(item, settings) }}
{% endfor %}
Expand All @@ -19,10 +19,10 @@
{% else %}
<div class="cart-empty frappe-card">
<div class="cart-empty-state">
<img src="/assets/erpnext/images/ui-states/cart-empty-state.png" alt="Empty Cart">
<img src="/assets/webshop/images/cart-empty-state.png" alt="Empty Cart">
</div>
<div class="cart-empty-message mt-4">{{ _('Wishlist is empty!') }}</p>
</div>
{% endif %}

{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion webshop/templates/pages/wishlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)
from webshop.webshop.shopping_cart.cart import _set_price_list
from erpnext.utilities.product import get_price
from webshop.shopping_cart.cart import get_party
from webshop.webshop.shopping_cart.cart import get_party


def get_context(context):
Expand Down
Loading

0 comments on commit 076669a

Please sign in to comment.