1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-03 14:24:23 +01:00

Merge branch 'members-filters' into dev

This commit is contained in:
Sylvain 2020-01-07 10:44:55 +01:00
commit 1c4f144b8d
9 changed files with 52 additions and 7 deletions

View File

@ -146,7 +146,15 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
// currently displayed page of members // currently displayed page of members
page: 1, page: 1,
// true when all members where loaded // 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 // admins list
@ -261,6 +269,14 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
}, 300); }, 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 * Callback to alert the admin that the export request was acknowledged and is
* processing right now. * processing right now.
@ -317,6 +333,7 @@ Application.Controllers.controller('AdminMembersController', ['$scope', '$sce',
query: { query: {
search: $scope.member.searchText, search: $scope.member.searchText,
order_by: $scope.member.order, order_by: $scope.member.order,
filter: $scope.member.memberFilter,
page: $scope.member.page, page: $scope.member.page,
size: USERS_PER_PAGE size: USERS_PER_PAGE
} }

View File

@ -1,4 +1,6 @@
<div class="col-md-5 m-t-lg"> <div class="col-md-5 m-t-lg">
<div class="row">
<div class="col-lg-7">
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
<span class="input-group-addon"><i class="fa fa-filter"></i></span> <span class="input-group-addon"><i class="fa fa-filter"></i></span>
@ -6,6 +8,15 @@
</div> </div>
</div> </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>
<div class="col-md-12"> <div class="col-md-12">
<button type="button" class="btn btn-warning m-t m-b" ui-sref="app.admin.members_new" translate>{{ 'app.admin.members.add_a_new_member' }}</button> <button type="button" class="btn btn-warning m-t m-b" ui-sref="app.admin.members_new" translate>{{ 'app.admin.members.add_a_new_member' }}</button>
<div class="pull-right"> <div class="pull-right">
@ -21,7 +32,6 @@
<iframe name="export-frame" height="0" width="0" class="none"></iframe> <iframe name="export-frame" height="0" width="0" class="none"></iframe>
</div> </div>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>

View File

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

View File

@ -77,6 +77,8 @@ class User < ActiveRecord::Base
scope :active, -> { where(is_active: true) } scope :active, -> { where(is_active: true) }
scope :without_subscription, -> { includes(statistic_profile: [:subscriptions]).where(subscriptions: { statistic_profile_id: nil }) } scope :without_subscription, -> { includes(statistic_profile: [:subscriptions]).where(subscriptions: { statistic_profile_id: nil }) }
scope :with_subscription, -> { joins(statistic_profile: [:subscriptions]) } 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(*) def to_json(*)
ApplicationController.new.view_context.render( ApplicationController.new.view_context.render(

View File

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

View File

@ -646,6 +646,9 @@ en:
status_enabled: "Enabled" status_enabled: "Enabled"
status_disabled: "Disabled" status_disabled: "Disabled"
status_all: "All" status_all: "All"
member_filter_all: "All"
member_filter_not_confirmed: "Unconfirmed"
member_filter_inactive_for_3_years: "Inactive for 3 years"
members_new: members_new:
# add a member # add a member

View File

@ -591,6 +591,7 @@ es:
groups: "Grupos" groups: "Grupos"
tags: "Tags" tags: "Tags"
authentication: "Autenticación" authentication: "Autenticación"
confirmation_required: "Confirmation required"
confirm_delete_member: "¿Desea realmente eliminar este usario? Esto no se puede deshacer." confirm_delete_member: "¿Desea realmente eliminar este usario? Esto no se puede deshacer."
member_successfully_deleted: "Usario eliminado correctamente." member_successfully_deleted: "Usario eliminado correctamente."
unable_to_delete_the_member: "No se puede eliminar el usario." unable_to_delete_the_member: "No se puede eliminar el usario."
@ -645,6 +646,9 @@ es:
status_enabled: "Enabled" status_enabled: "Enabled"
status_disabled: "Disabled" status_disabled: "Disabled"
status_all: "All" status_all: "All"
member_filter_all: "All"
member_filter_not_confirmed: "Unconfirmed"
member_filter_inactive_for_3_years: "Inactive for 3 years"
members_new: members_new:
# add a member # add a member

View File

@ -646,6 +646,9 @@ fr:
status_enabled: "Activés" status_enabled: "Activés"
status_disabled: "Désactivés" status_disabled: "Désactivés"
status_all: "Tous" 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: members_new:
# ajouter un membre # ajouter un membre

View File

@ -646,6 +646,9 @@ pt:
status_enabled: "Ativos" status_enabled: "Ativos"
status_disabled: "Desabilitados" status_disabled: "Desabilitados"
status_all: "Todos" status_all: "Todos"
member_filter_all: "All"
member_filter_not_confirmed: "Unconfirmed"
member_filter_inactive_for_3_years: "Inactive for 3 years"
members_new: members_new:
# add a member # add a member