diff --git a/app/packs/src/apps/mydb/elements/details/vessels/VesselDetails.js b/app/packs/src/apps/mydb/elements/details/vessels/VesselDetails.js index dfc6b1d443..5b947a99b1 100644 --- a/app/packs/src/apps/mydb/elements/details/vessels/VesselDetails.js +++ b/app/packs/src/apps/mydb/elements/details/vessels/VesselDetails.js @@ -4,6 +4,7 @@ import ElementActions from 'src/stores/alt/actions/ElementActions'; import ElementCollectionLabels from 'src/apps/mydb/elements/labels/ElementCollectionLabels'; import { observer } from 'mobx-react'; import DetailActions from 'src/stores/alt/actions/DetailActions'; +import CollectionUtils from 'src/models/collection/CollectionUtils'; import PropTypes from 'prop-types'; import UIStore from 'src/stores/alt/stores/UIStore'; import UserStore from 'src/stores/alt/stores/UserStore'; @@ -12,16 +13,19 @@ import VesselProperties from 'src/apps/mydb/elements/details/vessels/propertiesT import VesselAttachmentsContainer from "src/apps/mydb/elements/details/vessels/attachmentsTab/VesselAttachmentsContainer"; function VesselDetails({ vesselItem, toggleFullScreen }) { - const isReadOnly = () => { const { currentCollection, isSync } = UIStore.getState(); const { currentUser } = UserStore.getState(); + return CollectionUtils.isReadOnly( + currentCollection, + currentUser.id, + isSync + ); }; const context = useContext(StoreContext); const [activeTab, setActiveTab] = useState('tab1'); const [readOnly, setReadOnly] = useState(isReadOnly()); - useEffect(() => { context.vesselDetailsStore.convertVesselToModel(vesselItem); setReadOnly(isReadOnly()); @@ -68,7 +72,6 @@ function VesselDetails({ vesselItem, toggleFullScreen }) { const { vesselDetailsStore } = context; const mobXItem = vesselDetailsStore.getVessel(vesselItem.id); const disabled = false; - // if (disabled) { return null; } const action = closeAfterClick ? () => { handleSubmit(vesselItem); DetailActions.close(vesselItem, true); } diff --git a/app/packs/src/apps/mydb/elements/details/vessels/attachmentsTab/AttachmentsModal.js b/app/packs/src/apps/mydb/elements/details/vessels/attachmentsTab/AttachmentsModal.js deleted file mode 100644 index 6898eddd4b..0000000000 --- a/app/packs/src/apps/mydb/elements/details/vessels/attachmentsTab/AttachmentsModal.js +++ /dev/null @@ -1,130 +0,0 @@ -/* eslint-disable react/function-component-definition */ -import React, { useState, useRef } from 'react'; -import PropTypes from 'prop-types'; -import { - Modal, Button, -} from 'react-bootstrap'; -import AttachmentsModalContent from 'src/apps/mydb/elements/details/vessels/attachmentsTab/AttachmentsModalContent'; - -const AttachmentsModal = ({ - show, onHide, onChange, readOnly = false, disabled = false, kind = null, datasetContainer, -}) => { - const datasetInput = useRef(null); - const [isNameEditing, setIsNameEditing] = useState(false); - const [localName, setLocalName] = useState(datasetContainer.name); - - const handleSave = () => { - if (datasetInput.current) { - datasetInput.current.handleSave(); - const updatedAttachments = datasetInput.current.getUpdatedAttachments(); - const updatedDatasetContainer = { - ...datasetContainer, - attachments: updatedAttachments, - name: localName, - }; - onChange(updatedDatasetContainer); - onHide(); - } - }; - - const handleModalClose = (event) => { - if (event && event.type === 'keydown' && event.key === 'Escape') { - handleSave(); - } else { - onHide(); - } - }; - - const handleNameChange = (newName) => { - setLocalName(newName); - }; - - const toggleNameEditing = () => { - setIsNameEditing((prev) => !prev); - }; - - if (show) { - return ( - (disabled ? onHide() : handleModalClose())} - > - - - {isNameEditing ? ( -
- { - if (event.key === 'Enter') { - handleNameChange(event.target.value); - toggleNameEditing(); - } - }} - onChange={(e) => { handleNameChange(e.target.value); }} - /> -
- ) : ( -
- {localName} - {!readOnly && ( -