Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address permission support + enabled/disabled customer support #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions app/assets/stylesheets/components/_card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.card {
.card-disabled-message {
display: none;
}
&.card-disabled {
position: relative;
.card-disabled-message {
background-color: theme-color('danger');
border-radius: $border-radius;
color: $white;
display: block;
font-weight: bold;
font-size: .7rem;
left: 50%;
opacity: .7;
padding: .3rem;
padding-left: 1rem;
padding-right: 1rem;
position: absolute;
text-align: center;
text-transform: uppercase;
bottom: -.5rem;
transform: translate(-50%, -50%);
z-index: 11;
}
&:after {
$strip-color-1: transparentize(theme-color('danger'), .7);
$strip-color-2: transparentize(theme-color('danger'), .8);
background-image: repeating-linear-gradient(45deg, $strip-color-1, $strip-color-1 30px, $strip-color-2 30px, $strip-color-2 60px);
content: ' ';
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: 10;
}
}
}
56 changes: 38 additions & 18 deletions app/views/pages/account/account_address.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@ slug: addresses
<h1 class="h3">{{'account_address_lists' | translate }}</h1>
</div>
<div class="col-auto">
{% if store.customer.permission.address.create == true %}
<form action="{% path_to account_address_form %}" method="post">
<button type="submit" name="button" class="btn btn-outline-primary">
<i class="fa fa-plus"></i> {{'account_address_add' | translate}}
</button>
</form>
{% endif %}
</div>
<div class="col-12">
{% with_scope address_type: "address"%}
<div class="row">
{% for address in store.addresses%}
<div class="col-12 mt-3 mb-2">
<div class="card card-body">
{% for address in store.addresses %}
{% assign address_css = "" %}
{% if address.enabled != true %}
{% assign address_css = "card-disabled" %}
{% endif %}
<div class="col-12 mt-3 mb-2">
<div class="card card-body {{address_css}}">
{% if address.enabled != true %}
<div class="card-disabled-message">
{{ 'account_address_disabled' | translate }}
</div>
{% endif %}
<div class="row">
<div class="col-12 col-lg-4 border-right ">
<div class="row align-items-center">
Expand All @@ -39,21 +50,27 @@ slug: addresses
{{address.name}}
</div>
</div>
<div class="row small pt-3 pb-2">
<form action="{% path_to account_address_form %}" method="post" class="col-6">
<input type="hidden" name="item_id" value="{{address.id}}">
<button type="submit" name="update_{{address.id}}" class="btn btn-outline-primary btn-block">
<i class="fas fa-pencil-alt"></i> {{'cart_address_update' | translate }}
</button>
</form>
<form method="POST" action="/invader/addresses/{{address.id | round}}/delete" class="col-6">
<input type="hidden" name="invader_success_url" value="{% path_to page %}" />
<input type="hidden" name="invader_error_url" value="{% path_to page %}" />
<button type="submit" name="button" class="btn btn-outline-danger btn-block">
<i class="fas fa-trash"></i> {{'cart_address_delete' | translate }}
</button>
</form>
</div>
{% if address.enabled %}
<div class="row small pt-3 pb-2">
{% if address.access.update %}
<form action="{% path_to account_address_form %}" method="post" class="col-6">
<input type="hidden" name="item_id" value="{{address.id}}">
<button type="submit" name="update_{{address.id}}" class="btn btn-sm btn-outline-primary btn-block">
<i class="fas fa-pencil-alt"></i> {{'cart_address_update' | translate }}
</button>
</form>
{% endif %}
{% if address.access.delete %}
<form method="POST" action="/invader/addresses/{{address.id | round}}/delete" class="col-6">
<input type="hidden" name="invader_success_url" value="{% path_to page %}" />
<input type="hidden" name="invader_error_url" value="{% path_to page %}" />
<button type="submit" name="button" class="btn btn-sm btn-outline-danger btn-block">
<i class="fas fa-trash"></i> {{'cart_address_delete' | translate }}
</button>
</form>
{% endif %}
</div>
{% endif %}
</div>
<div class="col-12 col-lg-8">
<address>
Expand All @@ -69,6 +86,9 @@ slug: addresses
<div class="">
{{address.country.name}}
</div>
<div class="">
{{address.phone}}
</div>
</address>
</div>
</div>
Expand Down
69 changes: 56 additions & 13 deletions app/views/pages/account/account_address_form.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@ seo_title: Update my address | Shopinvader demo
{% extends 'layouts/account '%}

{% block 'body/content/tabcontent' %}
{% assign form_action = '/invader/addresses/create' %}

{% assign disabled = true %}
{% if params.item_id %}
{% with_scope id: params.item_id %}
{% assign item_id = params.item_id | round %}
{% with_scope id: item_id %}
{% assign address = store.addresses.first %}

{% assign form_action = '/invader/addresses/' | append: address.id | append: "/update" %}
{% if address.enabled and address.access.update %}
{% assign form_action = '/invader/addresses/' | append: address.id | append: "/update" %}
{% assign disabled = false %}
{% else %}
{% assign error_msg = 'account_address_no_update' | translate %}
{% endif %}
{% endwith_scope%}
{% else %}
{% if store.customer.permission.address.create == true%}
{% assign form_action = '/invader/addresses/create' %}
{% assign disabled = false %}
{% else %}
{% assign error_msg = 'account_address_no_create' | translate %}
{% endif %}
{% endif %}
<div class="pt-4">
<div class="card">
Expand All @@ -22,19 +35,49 @@ seo_title: Update my address | Shopinvader demo
{{'account_address_update' | translate }}
</h2>
<div class="card-body">
<form class="" action="{{form_action}}" method="post" data-autocomplete="address">
<input type="hidden" name="invader_success_url" value="{% path_to account_address %}" />
<input type="hidden" name="invader_error_url" value="{% path_to page %}{{form_params}}" />
{% include 'address_form' with address, with_require: true %}
{% if disabled == true %}
<div class="row">
<div class="col-6 text-left">
<a href="{% path_to account_address %}" class="btn btn-default " >{{'account_address_cancel' | translate}}</a>
<div class="col-12">
<div class="text-danger text-center">
<i class="fas fa-exclamation-triangle"></i>
{{error_msg}}
</div>
</div>
<div class="col-6 text-right">
<input type="submit" name="submit" class="btn btn-primary " value="{{'account_address_submit' | translate}}">
</div>
{% if address %}
{% include 'address_form' with
address,
disabled: true
%}
{% endif %}
<div class="row pt-2">
<div class="col-12 text-center">
<a href="{% path_to account_address %}" class="btn btn-dark ">
{{'btn_back' | translate}}
</a>
</div>
</div>
</form>
{% else %}
<form class="" action="{{form_action}}" method="post" data-autocomplete="address">
<input type="hidden" name="invader_success_url" value="{% path_to account_address %}" />
<input type="hidden" name="invader_error_url" value="{% path_to page %}{{form_params}}" />
{% include 'address_form' with
address,
with_require: true,
disabled: false
%}
<div class="row">
<div class="col-6 text-left">
<a href="{% path_to account_address %}" class="btn btn-outline-dark ">
{{'account_address_cancel' | translate}}
</a>
</div>
<div class="col-6 text-right">
<input type="submit" name="submit" class="btn btn-primary " value="{{'account_address_submit' | translate}}">
</div>
</div>
</form>
{% endif %}
</div>
</div>
</div>
Expand Down
31 changes: 27 additions & 4 deletions app/views/pages/account/account_profile.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,43 @@ seo_title: My account profile | Shopinvader demo
<div class="col-12 col-lg-7">
{% with_scope address_type: "profile"%}
{% assign profile = store.addresses.first %}
{% assign disabled = true %}
{% if profile.access.update %}
{% assign disabled = false %}
{% endif %}
<div class="card">
<h2 class="card-header bg-white">
<i class="far fa-user text-primary"></i>
{{'account_profil_title' | translate}}
</h2>
<div class="card-body">
{% if disabled == true %}
<div class="row">
<div class="col-12">
<div class="text-danger text-center">
<i class="fas fa-exclamation-triangle"></i>
{{ 'account_address_no_update' | translate }}
</div>
</div>
</div>
{% include 'address_form' with
address: profile,
disabled: true
%}
{% else %}
<form action="/invader/addresses/{{profile.id | round}}/update" method="post" data-autocomplete="address">
<input type="hidden" name="invader_success_url" value="{% path_to page %}" />
<input type="hidden" name="invader_error_url" value="{% path_to page %}" />
{% include 'address_form' with address: profile %}
<div class="text-right">
<input type="submit" name="submit" class="btn btn-primary " value="{{'account_address_submit' | translate}}">
</div>
{% include 'address_form' with
address: profile
%}
{% if profile.access.update %}
<div class="text-right">
<input type="submit" name="submit" class="btn btn-primary " value="{{'account_address_submit' | translate}}">
</div>
{% endif %}
</form>
{% endif %}
</div>
</div>
{% endwith_scope%}
Expand Down
26 changes: 26 additions & 0 deletions app/views/pages/account/account_user_disabled.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
handle: account_user_disabled
title: Account User disabled
listed: false
position: 200
published: true
seo_title: Your account is not enable yet | Shopinvader demo
slug: addresses-user-disabled
---
{% extends 'layouts/account '%}

{% block 'body/content/tabcontent' %}
<div class="text-center">
<p>
{{ 'account_user_disabled' | translate }}
</p>
<form method="post" action="{% path_to account %}">
<input type="hidden" name="auth_action" value="sign_out" />
<input type="hidden" name="auth_content_type" value="customers" />
<button type="submit" class="btn btn-outline-primary " >
<i class="fa fa-power-off"></i>
{{ 'account_signout' | translate }}
</button>
</form>
</div>
{% endblock %}
8 changes: 8 additions & 0 deletions app/views/pages/layouts/base.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ handle: base
title: Base layout
is_layout: false
---
{% if current_customer and page.handle != 'account_user_disabled' %}
{% if store.customer.enabled != true %}
{% action 'redirect to account_user_disabled' %}
redirectTo('account_user_disabled');
{% endaction %}
{% endif %}
{% endif %}

{% if locale != default_locale %}
{% assign url_base ="/" | append: locale %}
{% endif%}
Expand Down
Loading