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

(bug) fix display of banners and add unsaved form alert on events banner

This commit is contained in:
Karen 2023-02-03 13:09:13 +01:00 committed by Sylvain
parent c87d2b6364
commit 10de4fcf5e
10 changed files with 67 additions and 25 deletions

View File

@ -10,18 +10,21 @@ import { EditorialKeys, EditorialBlockForm } from '../editorial-block/editorial-
import SettingAPI from '../../api/setting';
import SettingLib from '../../lib/setting';
import { SettingName, SettingValue, eventsSettings } from '../../models/setting';
import { UnsavedFormAlert } from '../form/unsaved-form-alert';
import { UIRouter } from '@uirouter/angularjs';
declare const Application: IApplication;
interface EventsSettingsProps {
onError: (message: string) => void,
onSuccess: (message: string) => void
uiRouter: UIRouter
}
/**
* Events settings
*/
export const EventsSettings: React.FC<EventsSettingsProps> = ({ onError, onSuccess }) => {
export const EventsSettings: React.FC<EventsSettingsProps> = ({ onError, onSuccess, uiRouter }) => {
const { t } = useTranslation('admin');
const { register, control, formState, handleSubmit, reset } = useForm<Record<SettingName, SettingValue>>();
@ -57,6 +60,7 @@ export const EventsSettings: React.FC<EventsSettingsProps> = ({ onError, onSucce
<FabButton onClick={handleSubmit(onSubmit)} className='save-btn is-main'>{t('app.admin.events_settings.save')}</FabButton>
</header>
<form className="events-settings-content">
<UnsavedFormAlert uiRouter={uiRouter} formState={formState} />
<div className="settings-section">
<EditorialBlockForm register={register}
control={control}
@ -79,4 +83,4 @@ const EventsSettingsWrapper: React.FC<EventsSettingsProps> = (props) => {
);
};
Application.Components.component('eventsSettings', react2angular(EventsSettingsWrapper, ['onError', 'onSuccess']));
Application.Components.component('eventsSettings', react2angular(EventsSettingsWrapper, ['onError', 'onSuccess', 'uiRouter']));

View File

@ -14,10 +14,6 @@ import type { Machine } from '../../models/machine';
import TrainingAPI from '../../api/training';
import MachineAPI from '../../api/machine';
import { EditDestroyButtons } from '../base/edit-destroy-buttons';
import { EditorialBlock } from '../editorial-block/editorial-block';
import { SettingValue, trainingsSettings } from '../../models/setting';
import SettingAPI from '../../api/setting';
import SettingLib from '../../lib/setting';
declare const Application: IApplication;

View File

@ -51,8 +51,8 @@ class EventsController {
/**
* Controller used in the events listing page (admin view)
*/
Application.Controllers.controller('AdminEventsController', ['$scope', '$state', 'dialogs', '$uibModal', 'growl', 'AuthService', 'Event', 'Category', 'EventTheme', 'AgeRange', 'PriceCategory', 'eventsPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise', 'priceCategoriesPromise', '_t', 'Member', 'uiTourService', 'settingsPromise',
function ($scope, $state, dialogs, $uibModal, growl, AuthService, Event, Category, EventTheme, AgeRange, PriceCategory, eventsPromise, categoriesPromise, themesPromise, ageRangesPromise, priceCategoriesPromise, _t, Member, uiTourService, settingsPromise) {
Application.Controllers.controller('AdminEventsController', ['$scope', '$state', 'dialogs', '$uibModal', 'growl', 'AuthService', 'Event', 'Category', 'EventTheme', 'AgeRange', 'PriceCategory', 'eventsPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise', 'priceCategoriesPromise', '_t', 'Member', 'uiTourService', 'settingsPromise', '$uiRouter',
function ($scope, $state, dialogs, $uibModal, growl, AuthService, Event, Category, EventTheme, AgeRange, PriceCategory, eventsPromise, categoriesPromise, themesPromise, ageRangesPromise, priceCategoriesPromise, _t, Member, uiTourService, settingsPromise, $uiRouter) {
/* PUBLIC SCOPE */
/**
@ -62,6 +62,9 @@ Application.Controllers.controller('AdminEventsController', ['$scope', '$state',
growl.success(message);
};
// the following item is used by the UnsavedFormAlert component to detect a page change
$scope.uiRouter = $uiRouter;
/**
* Callback triggered by react components
*/

View File

@ -48,6 +48,7 @@
@import "modules/dashboard/reservations/reservations-dashboard";
@import "modules/dashboard/reservations/reservations-panel";
@import "modules/events/event";
@import "modules/events/events";
@import "modules/events/event-form";
@import "modules/events/update-recurrent-modal";
@import "modules/events/events-settings.scss";
@ -65,6 +66,7 @@
@import "modules/invoices/invoices-settings-panel";
@import "modules/invoices/vat-settings-modal";
@import "modules/layout/header-page";
@import "modules/machines/machines";
@import "modules/machines/machine-card";
@import "modules/machines/machine-categories";
@import "modules/machines/machine-form";

View File

@ -0,0 +1,7 @@
.events {
max-width: 1600px;
margin: 2rem;
padding-bottom: 6rem;
display: grid;
gap: 2.4rem;
}

View File

@ -0,0 +1,7 @@
.machines {
max-width: 1600px;
margin: 2rem;
padding-bottom: 6rem;
display: grid;
gap: 2.4rem;
}

View File

@ -29,7 +29,7 @@
<div class="col-md-12" ng-if="isAuthorized('admin')">
<uib-tabset justified="true" active="tabs.active">
<uib-tab heading="{{ 'app.admin.events.settings' | translate }}" index="0">
<events-settings on-error="onError" on-success="onSuccess"></events-settings>
<events-settings on-error="onError" on-success="onSuccess" ui-router="uiRouter"></events-settings>
</uib-tab>
<uib-tab heading="{{ 'app.admin.events.events_monitoring' | translate }}" index="1">

View File

@ -19,23 +19,23 @@
</div>
<section class="m-lg">
<section class="events">
<events-editorial-block on-error="onError"></events-editorial-block>
<div class="row m-b-md">
<div class="col-md-3 m-b" ng-show="categories.length > 0">
<div class="row">
<div class="col-md-3" ng-show="categories.length > 0">
<select ng-model="filters.category_id" ng-change="filterEvents()" class="form-control" ng-options="c.id as c.name for c in categories">
<option value="" translate>{{ 'app.public.events_list.all_categories' }}</option>
</select>
</div>
<div class="col-md-3 m-b" ng-show="themes.length > 0">
<div class="col-md-3" ng-show="themes.length > 0">
<select ng-model="filters.theme_id" ng-change="filterEvents()" class="form-control" ng-options="t.id as t.name for t in themes">
<option value="" translate>{{ 'app.public.events_list.all_themes' }}</option>
</select>
</div>
<div class="col-md-3 m-b" ng-show="ageRanges.length > 0">
<div class="col-md-3" ng-show="ageRanges.length > 0">
<select ng-model="filters.age_range_id" ng-change="filterEvents()" class="form-control" ng-options="a.id as a.name for a in ageRanges">
<option value="" translate>{{ 'app.public.events_list.for_all' }}</option>
</select>

View File

@ -13,7 +13,7 @@
</div>
</section>
<section class="m-lg"
<section class="machines"
ui-tour="machines"
ui-tour-backdrop="true"
ui-tour-template-url="'/shared/tour-step-template.html'"

View File

@ -19,8 +19,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
enable_extension "unaccent"
create_table "abuses", id: :serial, force: :cascade do |t|
t.integer "signaled_id"
t.string "signaled_type"
t.integer "signaled_id"
t.string "first_name"
t.string "last_name"
t.string "email"
@ -68,8 +68,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
t.string "locality"
t.string "country"
t.string "postal_code"
t.integer "placeable_id"
t.string "placeable_type"
t.integer "placeable_id"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -93,8 +93,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
end
create_table "assets", id: :serial, force: :cascade do |t|
t.integer "viewable_id"
t.string "viewable_type"
t.integer "viewable_id"
t.string "attachment"
t.string "type"
t.datetime "created_at"
@ -281,8 +281,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
end
create_table "credits", id: :serial, force: :cascade do |t|
t.integer "creditable_id"
t.string "creditable_type"
t.integer "creditable_id"
t.integer "plan_id"
t.integer "hours"
t.datetime "created_at"
@ -522,17 +522,37 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
t.bigint "machine_id", null: false
end
create_table "notification_preferences", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "notification_type_id", null: false
t.boolean "in_system", default: true
t.boolean "email", default: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["notification_type_id"], name: "index_notification_preferences_on_notification_type_id"
t.index ["user_id", "notification_type_id"], name: "index_notification_preferences_on_user_and_notification_type", unique: true
end
create_table "notification_types", force: :cascade do |t|
t.string "name", null: false
t.string "category", null: false
t.boolean "is_configurable", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["name"], name: "index_notification_types_on_name", unique: true
end
create_table "notifications", id: :serial, force: :cascade do |t|
t.integer "receiver_id"
t.integer "attached_object_id"
t.string "attached_object_type"
t.integer "attached_object_id"
t.integer "notification_type_id"
t.boolean "is_read", default: false
t.datetime "created_at"
t.datetime "updated_at"
t.string "receiver_type"
t.boolean "is_send", default: false
t.jsonb "meta_data", default: {}
t.jsonb "meta_data", default: "{}"
t.index ["notification_type_id"], name: "index_notifications_on_notification_type_id"
t.index ["receiver_id"], name: "index_notifications_on_receiver_id"
end
@ -772,8 +792,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
create_table "prices", id: :serial, force: :cascade do |t|
t.integer "group_id"
t.integer "plan_id"
t.integer "priceable_id"
t.string "priceable_type"
t.integer "priceable_id"
t.integer "amount"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@ -976,8 +996,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
t.text "message"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "reservable_id"
t.string "reservable_type"
t.integer "reservable_id"
t.integer "nb_reserve_places"
t.integer "statistic_profile_id"
t.index ["reservable_type", "reservable_id"], name: "index_reservations_on_reservable_type_and_reservable_id"
@ -986,8 +1006,8 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
create_table "roles", id: :serial, force: :cascade do |t|
t.string "name"
t.integer "resource_id"
t.string "resource_type"
t.integer "resource_id"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id"
@ -1199,7 +1219,7 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
t.text "description"
t.boolean "public_page", default: true
t.boolean "disabled"
t.boolean "auto_cancel"
t.boolean "auto_cancel", default: false
t.integer "auto_cancel_threshold"
t.integer "auto_cancel_deadline"
t.boolean "authorization"
@ -1377,6 +1397,9 @@ ActiveRecord::Schema.define(version: 2023_01_31_104958) do
add_foreign_key "invoices", "wallet_transactions"
add_foreign_key "invoicing_profiles", "users"
add_foreign_key "machines", "machine_categories"
add_foreign_key "notification_preferences", "notification_types"
add_foreign_key "notification_preferences", "users"
add_foreign_key "notifications", "notification_types"
add_foreign_key "order_activities", "invoicing_profiles", column: "operator_profile_id"
add_foreign_key "order_activities", "orders"
add_foreign_key "order_items", "orders"