mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
(feat) machines reservable or not
This commit is contained in:
parent
f0d9537182
commit
7fc79d44e5
@ -1,6 +1,7 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Ability to group machines by categories
|
||||
- Ability to mark a machine as reservable or not
|
||||
- Private note on member's profile
|
||||
- Optional external identifier for users
|
||||
- Ability to disable generation of invoices at zero
|
||||
|
@ -49,7 +49,7 @@ class API::MachinesController < API::ApiController
|
||||
end
|
||||
|
||||
def machine_params
|
||||
params.require(:machine).permit(:name, :description, :spec, :disabled, :machine_category_id, :plan_ids,
|
||||
params.require(:machine).permit(:name, :description, :spec, :disabled, :machine_category_id, :plan_ids, :reservable,
|
||||
plan_ids: [], machine_image_attributes: [:attachment],
|
||||
machine_files_attributes: %i[id attachment _destroy],
|
||||
advanced_accounting_attributes: %i[code analytical_section])
|
||||
|
@ -55,13 +55,13 @@ const MachineCard: React.FC<MachineCardProps> = ({ user, machine, onShowMachine,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={`machine-card ${loading ? 'loading' : ''} ${machine.disabled ? 'disabled' : ''}`}>
|
||||
<div className={`machine-card ${loading ? 'loading' : ''} ${machine.disabled ? 'disabled' : ''} ${!machine.reservable ? 'unreservable' : ''}`}>
|
||||
{machinePicture()}
|
||||
<div className="machine-name">
|
||||
{machine.name}
|
||||
</div>
|
||||
<div className="machine-actions">
|
||||
{!machine.disabled && <ReserveButton currentUser={user}
|
||||
{!machine.disabled && machine.reservable && <ReserveButton currentUser={user}
|
||||
machineId={machine.id}
|
||||
onLoadingStart={() => setLoading(true)}
|
||||
onLoadingEnd={() => setLoading(false)}
|
||||
|
@ -110,6 +110,10 @@ export const MachineForm: React.FC<MachineFormProps> = ({ action, machine, onErr
|
||||
id="machine_files_attributes"
|
||||
className="machine-files" />
|
||||
|
||||
<FormSwitch control={control}
|
||||
id="reservable"
|
||||
label={t('app.admin.machine_form.reservable')}
|
||||
defaultValue={true} />
|
||||
<FormSwitch control={control}
|
||||
id="disabled"
|
||||
label={t('app.admin.machine_form.disable_machine')}
|
||||
|
@ -43,7 +43,7 @@ Application.Controllers.controller('AdminCalendarController', ['$scope', '$state
|
||||
$scope.trainings = trainingsPromise.filter(t => !t.disabled);
|
||||
|
||||
// list of the FabLab machines
|
||||
$scope.machines = machinesPromise;
|
||||
$scope.machines = machinesPromise.filter(m => !m.disabled && m.reservable);
|
||||
|
||||
// List of machine categories
|
||||
$scope.machineCategories = machineCategoriesPromise;
|
||||
@ -712,7 +712,7 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
|
||||
$scope.end = end;
|
||||
|
||||
// machines list
|
||||
$scope.machines = machinesPromise.filter(function (m) { return !m.disabled; });
|
||||
$scope.machines = machinesPromise.filter(function (m) { return !m.disabled && m.reservable; });
|
||||
|
||||
// trainings list
|
||||
$scope.trainings = trainingsPromise.filter(function (t) { return !t.disabled; });
|
||||
|
@ -18,6 +18,7 @@ export interface Machine {
|
||||
description?: string,
|
||||
spec?: string,
|
||||
disabled: boolean,
|
||||
reservable: boolean,
|
||||
slug: string,
|
||||
machine_image_attributes?: FileType,
|
||||
machine_files_attributes?: Array<FileType>,
|
||||
|
@ -113,7 +113,10 @@
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
&.disabled,
|
||||
&.unreservable {
|
||||
.machine-actions > span {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-4 b-t hide-b-md">
|
||||
<section class="heading-actions wrapper">
|
||||
<reserve-button ng-hide="machine.disabled"
|
||||
<reserve-button ng-hide="machine.disabled || !machine.reservable"
|
||||
class-name="'btn btn-lg btn-warning bg-white b-2x rounded m-t-xs'"
|
||||
current-user="currentUser"
|
||||
machine-id="machine.id"
|
||||
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.extract! machine, :id, :name, :slug, :disabled, :machine_category_id
|
||||
json.extract! machine, :id, :name, :slug, :disabled, :machine_category_id, :reservable
|
||||
|
||||
if machine.machine_image
|
||||
json.machine_image_attributes do
|
||||
|
@ -38,6 +38,7 @@ en:
|
||||
add_an_attachment: "Add an attachment"
|
||||
disable_machine: "Disable machine"
|
||||
disabled_help: "When disabled, the machine won't be reservable and won't appear by default in the machines list."
|
||||
reservable: "Can this machine be reserved?"
|
||||
ACTION_machine: "{ACTION, select, create{Create} other{Update}} the machine"
|
||||
create_success: "The machine was created successfully"
|
||||
update_success: "The machine was updated successfully"
|
||||
|
@ -536,3 +536,5 @@ en:
|
||||
spaces: "Spaces"
|
||||
events: "Events"
|
||||
externals: "Other calendars"
|
||||
machine:
|
||||
machine_uncategorized: "Uncategorized machines"
|
||||
|
8
db/migrate/20221227141529_add_reservable_to_machine.rb
Normal file
8
db/migrate/20221227141529_add_reservable_to_machine.rb
Normal file
@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# From this migration, the machines will be able to appear in the list, but without being reservable
|
||||
class AddReservableToMachine < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :machines, :reservable, :boolean, default: true
|
||||
end
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_12_20_105939) do
|
||||
ActiveRecord::Schema.define(version: 2022_12_27_141529) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "fuzzystrmatch"
|
||||
@ -397,6 +397,7 @@ ActiveRecord::Schema.define(version: 2022_12_20_105939) do
|
||||
t.boolean "disabled"
|
||||
t.datetime "deleted_at"
|
||||
t.bigint "machine_category_id"
|
||||
t.boolean "reservable", default: true
|
||||
t.index ["deleted_at"], name: "index_machines_on_deleted_at"
|
||||
t.index ["machine_category_id"], name: "index_machines_on_machine_category_id"
|
||||
t.index ["slug"], name: "index_machines_on_slug", unique: true
|
||||
|
Loading…
x
Reference in New Issue
Block a user