1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

members filters, translations for other languages are still needed

This commit is contained in:
Nicolas Florentin 2019-12-20 15:47:42 +01:00
parent 518511ab3b
commit 62c979cfc0
6 changed files with 42 additions and 7 deletions

View File

@ -146,7 +146,15 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
// currently displayed page of members
page: 1,
// true when all members where loaded
noMore: false
noMore: false,
// default filter for members
memberFilter: 'all',
// options for members filtering
memberFilters: [
'all',
'not_confirmed',
'inactive_for_3_years'
]
};
// admins list
@ -261,6 +269,14 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
}, 300);
};
/**
* Callback when the member filter changes: reload the search results
*/
$scope.updateMemberFilter = function () {
resetSearchMember();
memberSearch();
};
/**
* Callback to alert the admin that the export request was acknowledged and is
* processing right now.
@ -317,6 +333,7 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
query: {
search: $scope.member.searchText,
order_by: $scope.member.order,
filter: $scope.member.memberFilter,
page: $scope.member.page,
size: USERS_PER_PAGE
}

View File

@ -1,8 +1,19 @@
<div class="col-md-5 m-t-lg">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-filter"></i></span>
<input type="text" ng-model="member.searchText" class="form-control" placeholder="{{ 'app.admin.members.search_for_an_user' | translate }}" ng-change="updateTextSearch()">
<div class="row">
<div class="col-lg-7">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-filter"></i></span>
<input type="text" ng-model="member.searchText" class="form-control" placeholder="{{ 'app.admin.members.search_for_an_user' | translate }}" ng-change="updateTextSearch()">
</div>
</div>
</div>
<div class="col-lg-5">
<div class="form-group">
<select ng-model="member.memberFilter" ng-change="updateMemberFilter()" class="form-control">
<option ng-repeat="filter in member.memberFilters" value="{{filter}}" translate>{{ 'app.admin.members.group_form.member_filter_'+filter }}</option>
</select>
</div>
</div>
</div>
</div>
@ -21,7 +32,6 @@
<iframe name="export-frame" height="0" width="0" class="none"></iframe>
</div>
<table class="table">
<thead>
<tr>

View File

@ -231,6 +231,6 @@ class API::MembersController < API::ApiController
end
def query_params
params.require(:query).permit(:search, :order_by, :page, :size)
params.require(:query).permit(:search, :filter, :order_by, :page, :size)
end
end

View File

@ -77,6 +77,8 @@ class User < ActiveRecord::Base
scope :active, -> { where(is_active: true) }
scope :without_subscription, -> { includes(statistic_profile: [:subscriptions]).where(subscriptions: { statistic_profile_id: nil }) }
scope :with_subscription, -> { joins(statistic_profile: [:subscriptions]) }
scope :not_confirmed, -> { where(confirmed_at: nil) }
scope :inactive_for_3_years, -> { where("users.last_sign_in_at < ?", 3.years.ago) }
def to_json(*)
ApplicationController.new.view_context.render(

View File

@ -34,6 +34,9 @@ class Members::ListService
'plans.base_name ILIKE :search', search: "%#{params[:search]}%")
end
filter = params[:filter].presence_in(['inactive_for_3_years', 'not_confirmed']) || nil
@query = @query.send(filter) if filter
@query
end

View File

@ -646,6 +646,9 @@ fr:
status_enabled: "Activés"
status_disabled: "Désactivés"
status_all: "Tous"
member_filter_all: "Tous"
member_filter_not_confirmed: "Non confirmés"
member_filter_inactive_for_3_years: "Inactifs depuis 3 ans"
members_new:
# ajouter un membre