mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-03-15 12:29:16 +01:00
(bug) machine advanced accouting codes, files attachements, image
This commit is contained in:
parent
3c9c9f56a0
commit
ad8e95922f
@ -45,12 +45,12 @@ const MachineCard: React.FC<MachineCardProps> = ({ user, machine, onShowMachine,
|
||||
* Return the machine's picture or a placeholder
|
||||
*/
|
||||
const machinePicture = (): ReactNode => {
|
||||
if (!machine.machine_image) {
|
||||
if (!machine.machine_image_attributes?.attachment_url) {
|
||||
return <div className="machine-picture no-picture" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="machine-picture" style={{ backgroundImage: `url(${machine.machine_image}), url('/default-image.png')` }} onClick={handleShowMachine} />
|
||||
<div className="machine-picture" style={{ backgroundImage: `url(${machine.machine_image_attributes.attachment_url}), url('/default-image.png')` }} onClick={handleShowMachine} />
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -231,7 +231,7 @@
|
||||
if (ending == null) {
|
||||
ending = '...';
|
||||
}
|
||||
if (str.length > length) {
|
||||
if (str && str.length > length) {
|
||||
return str.substring(0, length - ending.length) + ending;
|
||||
} else {
|
||||
return str;
|
||||
|
@ -1,7 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.array!(@machines) do |machine|
|
||||
json.extract! machine, :id, :name, :slug, :disabled
|
||||
|
||||
json.machine_image machine.machine_image.attachment.medium.url if machine.machine_image
|
||||
json.partial! 'api/machines/machine', machine: machine
|
||||
end
|
||||
|
@ -1,11 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
json.extract! @machine, :id, :name, :description, :spec, :disabled, :slug
|
||||
json.machine_image @machine.machine_image.attachment.large.url if @machine.machine_image
|
||||
json.partial! 'api/machines/machine', machine: @machine
|
||||
json.extract! @machine, :description, :spec
|
||||
|
||||
json.machine_files_attributes @machine.machine_files do |f|
|
||||
json.id f.id
|
||||
json.attachment f.attachment_identifier
|
||||
json.attachment_name f.attachment_identifier
|
||||
json.attachment_url f.attachment_url
|
||||
end
|
||||
json.trainings @machine.trainings.each, :id, :name, :disabled
|
||||
|
Loading…
x
Reference in New Issue
Block a user