mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-28 09:24:24 +01:00
filter projects by date
This commit is contained in:
parent
97c652f785
commit
bc284e7813
@ -294,7 +294,9 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
|
||||
// Fab-manager's instance ID in the openLab network
|
||||
$scope.openlabAppId = settingsPromise.openlab_app_id;
|
||||
|
||||
// settings of optional filters
|
||||
$scope.memberFilterPresence = settingsPromise.projects_list_member_filter_presence !== 'false';
|
||||
$scope.dateFiltersPresence = settingsPromise.projects_list_date_filters_presence !== 'false';
|
||||
|
||||
// Is openLab enabled on the instance?
|
||||
$scope.openlab = {
|
||||
@ -306,6 +308,9 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
|
||||
$location.$$search.member_id = '';
|
||||
}
|
||||
|
||||
fromDate = $location.$$search.from_date ? new Date($location.$$search.from_date) : undefined;
|
||||
toDate = $location.$$search.to_date ? new Date($location.$$search.to_date) : undefined;
|
||||
|
||||
// default search parameters
|
||||
$scope.search = {
|
||||
q: ($location.$$search.q || ''),
|
||||
@ -314,7 +319,9 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
|
||||
component_id: (parseInt($location.$$search.component_id) || undefined),
|
||||
theme_id: (parseInt($location.$$search.theme_id) || undefined),
|
||||
status_id: (parseInt($location.$$search.status_id) || undefined),
|
||||
member_id: (parseInt($location.$$search.member_id) || undefined)
|
||||
member_id: (parseInt($location.$$search.member_id) || undefined),
|
||||
from_date: fromDate,
|
||||
to_date: toDate
|
||||
};
|
||||
|
||||
$scope.autoCompleteMemberName = function (nameLookup) {
|
||||
@ -385,6 +392,8 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
|
||||
$scope.search.theme_id = undefined;
|
||||
$scope.search.status_id = undefined;
|
||||
$scope.search.member_id = undefined;
|
||||
$scope.search.from_date = undefined;
|
||||
$scope.search.to_date = undefined;
|
||||
$scope.$apply();
|
||||
$scope.setUrlQueryParams($scope.search);
|
||||
$scope.triggerSearch();
|
||||
@ -413,7 +422,10 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
|
||||
} else {
|
||||
updateUrlParam('whole_network', 'f');
|
||||
$scope.projectsPagination = new paginationService.Instance(Project, currentPage, PROJECTS_PER_PAGE, null, { }, loadMoreCallback, 'search');
|
||||
Project.search({ search: $scope.search, page: currentPage, per_page: PROJECTS_PER_PAGE }, function (projectsPromise) {
|
||||
const fromDate = $scope.search.from_date ? $scope.search.from_date.toLocaleDateString() : undefined;
|
||||
const toDate = $scope.search.to_date ? $scope.search.to_date.toLocaleDateString() : undefined;
|
||||
const searchParams = Object.assign({}, $scope.search, { from_date: fromDate, to_date: toDate });
|
||||
Project.search({ search: searchParams, page: currentPage, per_page: PROJECTS_PER_PAGE }, function (projectsPromise) {
|
||||
$scope.projectsPagination.totalCount = projectsPromise.meta.total;
|
||||
$scope.projects = projectsPromise.projects;
|
||||
});
|
||||
@ -445,6 +457,10 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
|
||||
updateUrlParam('machine_id', search.machine_id);
|
||||
updateUrlParam('status_id', search.status_id);
|
||||
updateUrlParam('member_id', search.member_id);
|
||||
const fromDate = search.from_date ? search.from_date.toDateString() : undefined;
|
||||
updateUrlParam('from_date', fromDate);
|
||||
const toDate = search.to_date ? search.to_date.toDateString() : undefined;
|
||||
updateUrlParam('to_date', toDate);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
@ -199,7 +199,8 @@ export const projectsSettings = [
|
||||
'allowed_cad_extensions',
|
||||
'allowed_cad_mime_types',
|
||||
'disqus_shortname',
|
||||
'projects_list_member_filter_presence'
|
||||
'projects_list_member_filter_presence',
|
||||
'projects_list_date_filters_presence'
|
||||
] as const;
|
||||
|
||||
export const prepaidPacksSettings = [
|
||||
|
@ -301,7 +301,7 @@ angular.module('application.router', ['ui.router'])
|
||||
themesPromise: ['Theme', function (Theme) { return Theme.query().$promise; }],
|
||||
componentsPromise: ['Component', function (Component) { return Component.query().$promise; }],
|
||||
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
|
||||
settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['openlab_app_id', 'openlab_default', 'projects_list_member_filter_presence']" }).$promise; }],
|
||||
settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['openlab_app_id', 'openlab_default', 'projects_list_member_filter_presence', 'projects_list_date_filters_presence']" }).$promise; }],
|
||||
openLabActive: ['Setting', function (Setting) { return Setting.isPresent({ name: 'openlab_app_secret' }).$promise; }]
|
||||
}
|
||||
})
|
||||
|
@ -108,5 +108,12 @@
|
||||
on-error="onError"
|
||||
class-name="'m-l'"></boolean-setting>
|
||||
</div>
|
||||
<div class="row">
|
||||
<boolean-setting name="'projects_list_date_filters_presence'"
|
||||
label="'app.admin.settings.projects_list_date_filters_presence' | translate"
|
||||
on-success="onSuccess"
|
||||
on-error="onError"
|
||||
class-name="'m-l'"></boolean-setting>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -22,7 +22,7 @@
|
||||
<section class="projects">
|
||||
<div class="projects-filters">
|
||||
<header>
|
||||
<h3>Filter</h3>
|
||||
<h3 translate>{{ 'app.public.projects_list.filter' }}</h3>
|
||||
<a href="javascript:void(0);" class="fab-button is-black" name="button" ng-click="resetFiltersAndTriggerSearch()" ng-show="!openlab.searchOverWholeNetwork">{{ 'app.public.projects_list.reset_all_filters' | translate }}</a>
|
||||
</header>
|
||||
<span class="switch" ng-if="openlab.projectsActive" uib-tooltip="{{ 'app.public.projects_list.tooltip_openlab_projects_switch' | translate }}" tooltip-trigger="mouseenter">
|
||||
@ -74,6 +74,32 @@
|
||||
</ui-select-choices>
|
||||
</ui-select>
|
||||
|
||||
<label class="form-group m-n" ng-if="dateFiltersPresence">
|
||||
<div class="form-item-header">
|
||||
<p translate>{{ 'app.public.projects_list.created_from' }}</p>
|
||||
</div>
|
||||
<input class="form-control"
|
||||
ng-model="search.from_date"
|
||||
ng-model-options='{ debounce: 1000 }'
|
||||
ng-change="setUrlQueryParams(search) && triggerSearch()"
|
||||
type="date"
|
||||
min="2000-01-01"
|
||||
max="2060-01-01"/>
|
||||
</label>
|
||||
|
||||
<label class="form-group m-n" ng-if="dateFiltersPresence">
|
||||
<div class="form-item-header">
|
||||
<p translate>{{ 'app.public.projects_list.created_to' }}</p>
|
||||
</div>
|
||||
<input class="form-control"
|
||||
ng-model="search.to_date"
|
||||
ng-model-options='{ debounce: 1000 }'
|
||||
ng-change="setUrlQueryParams(search) && triggerSearch()"
|
||||
type="date"
|
||||
min="2000-01-01"
|
||||
max="2060-01-01"/>
|
||||
</label>
|
||||
|
||||
<status-filter on-filter-change="onStatusChange" current-status-index="search.status_id"/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -197,6 +197,7 @@ module SettingsHelper
|
||||
events_banner_cta_label
|
||||
events_banner_cta_url
|
||||
projects_list_member_filter_presence
|
||||
projects_list_date_filters_presence
|
||||
].freeze
|
||||
end
|
||||
# rubocop:enable Metrics/ModuleLength
|
||||
|
@ -46,7 +46,7 @@ class SettingPolicy < ApplicationPolicy
|
||||
external_id machines_banner_active machines_banner_text machines_banner_cta_active machines_banner_cta_label
|
||||
machines_banner_cta_url trainings_banner_active trainings_banner_text trainings_banner_cta_active trainings_banner_cta_label
|
||||
trainings_banner_cta_url events_banner_active events_banner_text events_banner_cta_active events_banner_cta_label
|
||||
events_banner_cta_url projects_list_member_filter_presence]
|
||||
events_banner_cta_url projects_list_member_filter_presence projects_list_date_filters_presence]
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -31,6 +31,12 @@ class ProjectService
|
||||
end
|
||||
end
|
||||
|
||||
created_from = Time.zone.parse(query_params['from_date']).beginning_of_day if query_params['from_date'].present?
|
||||
created_to = Time.zone.parse(query_params['to_date']).end_of_day if query_params['to_date'].present?
|
||||
if created_from || created_to
|
||||
records = records.where(created_at: created_from..created_to)
|
||||
end
|
||||
|
||||
records = if query_params['q'].present?
|
||||
records.search(query_params['q'])
|
||||
else
|
||||
|
@ -61,9 +61,6 @@
|
||||
buttons: <%= I18n.t('app.shared.buttons').to_json.html_safe %>,
|
||||
messages: <%= I18n.t('app.shared.messages').to_json.html_safe %>
|
||||
}
|
||||
},
|
||||
date: {
|
||||
month_names: <%= I18n.t('date.month_names').to_json.html_safe %>
|
||||
}
|
||||
};
|
||||
Fablab.weekStartingDay = <%= Date.parse(Rails.application.secrets.week_starting_day).strftime('%w') %>;
|
||||
|
@ -1775,6 +1775,7 @@ en:
|
||||
public_registrations: "Public registrations"
|
||||
show_username_in_admin_list: "Show the username in the list"
|
||||
projects_list_member_filter_presence: "Presence of member filter on projects list"
|
||||
projects_list_date_filters_presence: "Presence of date filters on projects list"
|
||||
overlapping_options:
|
||||
training_reservations: "Trainings"
|
||||
machine_reservations: "Machines"
|
||||
|
@ -1775,6 +1775,7 @@ fr:
|
||||
public_registrations: "Inscriptions publiques"
|
||||
show_username_in_admin_list: "Afficher le nom d'utilisateur dans la liste"
|
||||
projects_list_member_filter_presence: "Présence du filtre par membre dans la vue liste des projets"
|
||||
projects_list_date_filters_presence: "Présence des filtres par date dans la vue liste des projets"
|
||||
overlapping_options:
|
||||
training_reservations: "Formations"
|
||||
machine_reservations: "Machines"
|
||||
|
@ -167,6 +167,7 @@ en:
|
||||
full_price: "Full price: "
|
||||
#projects gallery
|
||||
projects_list:
|
||||
filter: Filter
|
||||
the_fablab_projects: "The projects"
|
||||
add_a_project: "Add a project"
|
||||
network_search: "Fab-manager network"
|
||||
@ -184,6 +185,8 @@ en:
|
||||
load_next_projects: "Load next projects"
|
||||
rough_draft: "Rough draft"
|
||||
filter_by_member: "Filter by member"
|
||||
created_from: Created from
|
||||
created_to: Created to
|
||||
status_filter:
|
||||
all_statuses: "All statuses"
|
||||
select_status: "Select a status"
|
||||
|
@ -167,6 +167,7 @@ fr:
|
||||
full_price: "Plein tarif : "
|
||||
#projects gallery
|
||||
projects_list:
|
||||
filter: Filtrer
|
||||
the_fablab_projects: "Les projets"
|
||||
add_a_project: "Ajouter un projet"
|
||||
network_search: "Réseau Fab-Manager"
|
||||
@ -184,6 +185,8 @@ fr:
|
||||
load_next_projects: "Charger les projets suivants"
|
||||
rough_draft: "Brouillon"
|
||||
filter_by_member: "Filter par membre"
|
||||
created_from: Créés à partir du
|
||||
created_to: Créés jusqu'au
|
||||
status_filter:
|
||||
all_statuses: "Tous les statuts"
|
||||
select_status: "Sélectionnez un statut"
|
||||
|
@ -698,6 +698,7 @@ en:
|
||||
trainings_invalidation_rule: "Trainings automatic invalidation"
|
||||
trainings_invalidation_rule_period: "Grace period before invalidating a training"
|
||||
projects_list_member_filter_presence: "Presence of member filter on projects list"
|
||||
projects_list_date_filters_presence: "Presence of dates filter on projects list"
|
||||
#statuses of projects
|
||||
statuses:
|
||||
new: "New"
|
||||
|
@ -698,6 +698,7 @@ fr:
|
||||
trainings_invalidation_rule: "Invalidation automatique des formations"
|
||||
trainings_invalidation_rule_period: "Période de grâce avant d'invalider une formation"
|
||||
projects_list_member_filter_presence: "Présence du filtre par membre dans la vue liste des projets"
|
||||
projects_list_date_filters_presence: "Présence des filtres par date dans la vue liste des projets"
|
||||
#statuses of projects
|
||||
statuses:
|
||||
new: "Nouveau"
|
||||
|
@ -730,3 +730,4 @@ Setting.set('accounting_Error_label', 'Erroneous invoices to refund') unless Set
|
||||
Setting.set('external_id', false) unless Setting.find_by(name: 'external_id').try(:value)
|
||||
|
||||
Setting.set('projects_list_member_filter_presence', false) unless Setting.find_by(name: 'projects_list_member_filter_presence')
|
||||
Setting.set('projects_list_date_filters_presence', false) unless Setting.find_by(name: 'projects_list_date_filters_presence')
|
||||
|
8
test/fixtures/history_values.yml
vendored
8
test/fixtures/history_values.yml
vendored
@ -858,4 +858,12 @@ history_value_103:
|
||||
value: 'false'
|
||||
created_at: 2023-04-05 09:16:08.000511500 Z
|
||||
updated_at: 2023-04-05 09:16:08.000511500 Z
|
||||
invoicing_profile_id: 1
|
||||
|
||||
history_value_104:
|
||||
id: 104
|
||||
setting_id: 103
|
||||
value: 'false'
|
||||
created_at: 2023-04-05 09:16:08.000511500 Z
|
||||
updated_at: 2023-04-05 09:16:08.000511500 Z
|
||||
invoicing_profile_id: 1
|
6
test/fixtures/settings.yml
vendored
6
test/fixtures/settings.yml
vendored
@ -592,3 +592,9 @@ setting_102:
|
||||
name: projects_list_member_filter_presence
|
||||
created_at: 2023-04-05 09:16:08.000511500 Z
|
||||
updated_at: 2023-04-05 09:16:08.000511500 Z
|
||||
|
||||
setting_103:
|
||||
id: 103
|
||||
name: projects_list_date_filters_presence
|
||||
created_at: 2023-04-05 09:16:08.000511500 Z
|
||||
updated_at: 2023-04-05 09:16:08.000511500 Z
|
||||
|
@ -831,6 +831,12 @@ export const settings: Array<Setting> = [
|
||||
value: 'false',
|
||||
last_update: '2022-12-23T14:39:12+0100',
|
||||
localized: 'Projects list member filter presence'
|
||||
},
|
||||
{
|
||||
name: 'projects_list_date_filters_presence',
|
||||
value: 'false',
|
||||
last_update: '2022-12-23T14:39:12+0100',
|
||||
localized: 'Projects list date filters presence'
|
||||
}
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user