mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
paginate list of coupons
This commit is contained in:
parent
c223bd99ea
commit
9f8d24ec4f
@ -3,6 +3,7 @@
|
||||
- Asynchronously generate accounting archives
|
||||
- Improved end-user message when closing an accounting period
|
||||
- Improved date checks before closing an accounting period
|
||||
- Paginate list of coupons
|
||||
- Fix a bug: when VAT has changed during fab-manager's lifecycle, this may not be reflected in archives
|
||||
- Fix a bug: using a quote in event category's name results in angular $parse:syntax Error
|
||||
|
||||
|
@ -53,6 +53,7 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state',
|
||||
|
||||
// List of coupons
|
||||
$scope.coupons = couponsPromise;
|
||||
$scope.couponsPage = 0;
|
||||
|
||||
// List of spaces
|
||||
$scope.spaces = spacesPromise;
|
||||
@ -565,6 +566,13 @@ Application.Controllers.controller('EditPricingController', ['$scope', '$state',
|
||||
});
|
||||
};
|
||||
|
||||
$scope.loadMore = function() {
|
||||
$scope.couponsPage++;
|
||||
Coupon.query({ page: $scope.couponsPage }, function (data) {
|
||||
$scope.coupons = $scope.coupons.concat(data);
|
||||
});
|
||||
};
|
||||
|
||||
/* PRIVATE SCOPE */
|
||||
|
||||
/**
|
||||
|
@ -786,7 +786,7 @@ angular.module('application.router', ['ui.router'])
|
||||
machineCreditsPromise: ['Credit', function (Credit) { return Credit.query({ creditable_type: 'Machine' }).$promise; }],
|
||||
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
|
||||
trainingCreditsPromise: ['Credit', function (Credit) { return Credit.query({ creditable_type: 'Training' }).$promise; }],
|
||||
couponsPromise: ['Coupon', function (Coupon) { return Coupon.query().$promise; }],
|
||||
couponsPromise: ['Coupon', function (Coupon) { return Coupon.query({ page: 0 }).$promise; }],
|
||||
spacesPromise: ['Space', function (Space) { return Space.query().$promise; }],
|
||||
spacesPricesPromise: ['Price', function (Price) { return Price.query({ priceable_type: 'Space', plan_id: 'null' }).$promise; }],
|
||||
spacesCreditsPromise: ['Credit', function (Credit) { return Credit.query({ creditable_type: 'Space' }).$promise; }]
|
||||
|
@ -27,4 +27,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
||||
<div class="text-center">
|
||||
<button class="btn btn-warning" ng-click="loadMore()" ng-hide="coupons.length === 0 || coupons.length >= coupons[0].total"><i class="fa fa-search-plus" aria-hidden="true"></i> {{ 'pricing.display_more_coupons' | translate }}</button>
|
||||
</div>
|
||||
|
@ -6,8 +6,12 @@ class API::CouponsController < API::ApiController
|
||||
before_action :authenticate_user!
|
||||
before_action :set_coupon, only: %i[show update destroy]
|
||||
|
||||
# Number of notifications added to the page when the user clicks on 'load next notifications'
|
||||
COUPONS_PER_PAGE = 10
|
||||
|
||||
def index
|
||||
@coupons = Coupon.all
|
||||
@coupons = Coupon.page(params[:page]).per(COUPONS_PER_PAGE).order('created_at DESC')
|
||||
@total = Coupon.count
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
@ -1,3 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.array!(@coupons) do |coupon|
|
||||
json.partial! 'api/coupons/coupon', coupon: coupon
|
||||
json.total @total
|
||||
end
|
||||
|
@ -221,6 +221,7 @@ en:
|
||||
nb_of_usages: "Number of usages"
|
||||
status: "Status"
|
||||
add_a_new_coupon: "Add a new coupon"
|
||||
display_more_coupons: "Display the next coupons"
|
||||
disabled: "Disabled"
|
||||
expired: "Expired"
|
||||
sold_out: "Sold out"
|
||||
|
@ -221,6 +221,7 @@ es:
|
||||
nb_of_usages: "Número de usos"
|
||||
status: "Estado"
|
||||
add_a_new_coupon: "Añadir un nuevo cupón"
|
||||
display_more_coupons: "Display the next coupons" # translation_missing
|
||||
disabled: "Desactivado"
|
||||
expired: "Expirado"
|
||||
sold_out: "Agotado"
|
||||
|
@ -221,6 +221,7 @@ fr:
|
||||
nb_of_usages: "Nombre d'utilisations"
|
||||
status: "Statut"
|
||||
add_a_new_coupon: "Ajouter un code promotionnel"
|
||||
display_more_coupons: "Afficher les codes suivants"
|
||||
disabled: "Désactivé"
|
||||
expired: "Expiré"
|
||||
sold_out: "Épuisé"
|
||||
|
@ -221,6 +221,7 @@ pt:
|
||||
nb_of_usages: "Número de usos"
|
||||
status: "Status"
|
||||
add_a_new_coupon: "Adicionar novo cupom"
|
||||
display_more_coupons: "Display the next coupons" # translation_missing
|
||||
disabled: "Desabilitado"
|
||||
expired: "Expirado"
|
||||
sold_out: "Esgotado"
|
||||
|
Loading…
x
Reference in New Issue
Block a user