Skip to content

Commit

Permalink
💣 Added users changing buttons at /price page
Browse files Browse the repository at this point in the history
Signed-off-by: Vildan Safin <[email protected]>
  • Loading branch information
Enigma228322 committed May 10, 2020
1 parent e0b6343 commit bd008a3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 35 deletions.
6 changes: 6 additions & 0 deletions saas_apps/static/src/css/calculator.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
display: inline;
}

.users-qty-change-buttons{
max-width: 40px;
max-height: 40px;
opacity: 0.5;
}

.loader{
position: fixed;
z-index: 99;
Expand Down
Binary file added saas_apps/static/src/img/add-users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saas_apps/static/src/img/substr-users.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 22 additions & 5 deletions saas_apps/static/src/js/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ odoo.define('saas_apps.model', function (require){
calc_price_window_vals();
}
});
// Changing users qty buttons
$('#substr-users').click(function(){
check_users_input();
$('#users').val(parseInt($('#users').val(), 10) - 1);
calc_price_window_vals();
});
$('#add-users').click(function(){
check_users_input();
$('#users').val(parseInt($('#users').val(), 10) + 1);
calc_price_window_vals();
});

session.rpc('/check_currency', {
}).then(function (result) {
Expand Down Expand Up @@ -386,14 +397,18 @@ odoo.define('saas_apps.model', function (require){

function blink_anim(elems){
elems.forEach( (elem) =>{
elem.animate({opacity: "0"}, 200);
elem.animate({opacity: "1"}, 200);
elem.animate({opacity: "0"}, 250);
elem.animate({opacity: "1"}, 250);
});
}

function calc_price_window_vals(){
check_users_input();
// This method refreshes data in price window
price = Calc_Price();
// Adding blink animation
blink_anim([$('#apps-cost'), $('#users-cnt-cost'),
$('#apps-qty'), $('#price-users'), $('#users-qty'), $('#price')]);
var period = per_month ? "month" : "year";
$('#price').text(String(price) + ' ' + currency_symbol + ' / ');
$('#box-period').text(String(period));
Expand All @@ -403,9 +418,11 @@ odoo.define('saas_apps.model', function (require){
$('#apps-qty').text(String(apps_in_basket));
$('#users-cnt-cost').text(String(users_price_period * $('#users').val()));
$('#apps-cost').text(String(calc_apps_price()));
// Adding blink animation
blink_anim([$('#apps-cost'), $('#users-cnt-cost'),
$('#apps-qty'), $('#price-users'), $('#users-qty'), $('#price')]);
}

function check_users_input(){
if(parseInt($('#users').val(), 10) <= 0 || $('#users').val() === '')
$('#users').val(1);
}

function get_modules_to_install(){
Expand Down
13 changes: 4 additions & 9 deletions saas_apps/views/calculator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@
<div class="openerp_enterprise_pricing_step_head">
<h3 class="mt16 mb8">Choose the number of <b>Users</b></h3>
</div>
<div class="openerp_enterprise_pricing_step_body d-flex align-items-stretch form-inline">
<input class="openerp_enterprise_pricing_users form-control border text-right pr-2" id="users" name="num_users" type="number" style="max-width: 100px;" min="1" value="1"/>
<label class="px-2 mr-1 mb-0 bg-200 border-top border-right border-bottom">Users</label>
<label>
<b>
<span class="openerp_enterprise_pricing_user_amount_yearly">10,00</span><span class="openerp_enterprise_pricing_currency"><t t-esc="apps[0].currency_id.display_name"/></span><small class="fw_semibold">/user/month</small>
</b>
</label>
</div>
<img id="substr-users" src="/saas_apps/static/src/img/substr-users.png" alt="Decrease users qty" class="users-qty-change-buttons"/>
<input class="openerp_enterprise_pricing_users form-control border text-right pr-2"
id="users" name="num_users" type="text" value="1" style="max-width: 100px;display: inline;text-align: center !important;"/>
<img id="add-users" src="/saas_apps/static/src/img/add-users.png" alt="Increase users qty" class="users-qty-change-buttons"/>
</div>
<!-- App list -->
<div class="openerp_enterprise_pricing_step">
Expand Down
21 changes: 0 additions & 21 deletions saas_apps/views/manage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@
<!--Copyright 2020 Vildan Safin <https://www.it-projects.info/team/Enigma228322>
License AGPL-3.0 (https://www.gnu.org/licenses/agpl-3.0.html).-->
<odoo>
<template id="manage">
<t t-call="website.layout">
<title>Apps</title>
<div class="row container" style="margin-left: 25%">
<div class="col-sm-8">
<!-- App list -->
<div class="col-12 col-md-8 col-lg-9">
<h3 class="mt16 mb16">Choose your Apps</h3>
<h6 class="mt16 mb16">Choosen apps will be available in the store</h6>
<div class="openerp_enterprise_pricing_step_body mb24">
<div class="form-row">
<t t-foreach="apps" t-as="app">
<p id="application" class="col-12 col-sm-6 col-lg-4 shadow p-3 bg-white rounded price-window"><t t-esc="app.module_name"/></p>
</t>
</div>
</div>
</div>
</div>
</div>
</t>
</template>

<record id="view_manage_apps_search" model="ir.ui.view">
<field name="name">saas.line.search</field>
Expand Down

0 comments on commit bd008a3

Please sign in to comment.