diff --git a/frontend/Makefile b/frontend/Makefile index 5c06df7..07d96cd 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -7,9 +7,9 @@ install : yarn install --force rollup : - yarn run dev --prefix $(SEMAPPS_PATH)/src/frontend/packages/archipelago-layout & - yarn run dev --prefix $(SEMAPPS_PATH)/src/frontend/packages/semantic-data-provider & - yarn run dev --prefix $(SEMAPPS_PATH)/src/frontend/packages/auth-provider + yarn --cwd $(SEMAPPS_PATH)/src/frontend/packages/archipelago-layout run dev & + yarn --cwd $(SEMAPPS_PATH)/src/frontend/packages/semantic-data-provider run dev & + yarn --cwd $(SEMAPPS_PATH)/src/frontend/packages/auth-provider run dev link: cd $(SEMAPPS_PATH)/src/frontend/packages/archipelago-layout && yarn link diff --git a/frontend/package.json b/frontend/package.json index 151c23d..81ce1d4 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -36,7 +36,7 @@ }, "scripts": { "start": "react-scripts start", - "startwithlink": "make link & sleep 5 && react-scripts start", + "startwithlink": "make link & make rollup & sleep 10 && react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject", diff --git a/frontend/src/components/CreateContextualButton.js b/frontend/src/components/CreateContextualButton.js new file mode 100644 index 0000000..6d4b70c --- /dev/null +++ b/frontend/src/components/CreateContextualButton.js @@ -0,0 +1,28 @@ +import React from 'react'; +import { + CreateButton, +} from 'react-admin'; +import { useLocation } from 'react-router'; +import { Link } from 'react-router-dom'; + +const CreateContextualButton = ({ record, parent, resource,reverseReference, children, ...otherProps }) => { + const location = useLocation(); + let filter = {}; + filter[reverseReference]=encodeURIComponent(parent?.id); + const search = `source=${JSON.stringify(filter)}&redirectUri=${encodeURIComponent(location.pathname)}` + const url=`../../${resource}/create` + + return ( + + + ); + +}; + + +export default CreateContextualButton; diff --git a/frontend/src/components/EditContextualButton.js b/frontend/src/components/EditContextualButton.js new file mode 100644 index 0000000..6d76f22 --- /dev/null +++ b/frontend/src/components/EditContextualButton.js @@ -0,0 +1,28 @@ +import React from 'react'; +import { + EditButton, +} from 'react-admin'; +import { useLocation } from 'react-router'; +import { Link } from 'react-router-dom'; + +const EditContextualButton = ({ record, parent, resource,reverseReference, children, ...otherProps }) => { + const location = useLocation(); + let filter = {}; + filter[reverseReference]=encodeURIComponent(parent?.id); + const search = `source=${JSON.stringify(filter)}&redirectUri=${encodeURIComponent(location.pathname)}` + const url=`../../${resource}/${encodeURIComponent(record?.id)}` + + return ( + + + ); + +}; + + +export default EditContextualButton; diff --git a/frontend/src/layout/Layout.js b/frontend/src/layout/Layout.js index dde23a8..b30623a 100644 --- a/frontend/src/layout/Layout.js +++ b/frontend/src/layout/Layout.js @@ -13,11 +13,11 @@ import SideMenu from './SideMenu'; import TreeMenu from './DefaultLayout/TreeMenu/TreeMenu'; const Layout = ({ logout, theme, children, title, menu }) => { - + const token = localStorage.getItem('token'); const payload = token && jwtDecode(token); const isConnected = payload && payload.webId !== ''; - + const menuItems = [ { link: '/About', name: 'Qui sommes-nous ?', admin: false }, { link: '/Map', name: 'Carte des tiers lieux', admin: false }, @@ -26,20 +26,20 @@ const Layout = ({ logout, theme, children, title, menu }) => { ]; const state = useSelector(state => state); - console.log('customState', state.customState); + // console.log('customState', state.customState); const [sidebarOpen, setSidebarOpen] = useState(false); - + return ( - + {/* */} {/* */} - + { isConnected && state.customState.isAdminContext - ? + ? @@ -48,7 +48,7 @@ const Layout = ({ logout, theme, children, title, menu }) => { {children} - : + : {children} diff --git a/frontend/src/resources/Equipment/EquipmentCreate.js b/frontend/src/resources/Equipment/EquipmentCreate.js new file mode 100644 index 0000000..4b3f9c2 --- /dev/null +++ b/frontend/src/resources/Equipment/EquipmentCreate.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { Create } from "@semapps/archipelago-layout"; +import { + SimpleForm, +} from 'react-admin'; +import EquipmentInputs from './EquipmentInputs'; +import EquipmentTitle from './EquipmentTitle'; +import { MarkdownInput } from '@semapps/markdown-components'; +import { useLocation } from 'react-router'; +import queryString from 'query-string'; + +export const EquipmentCreate = props =>{ + const location = useLocation(); + const query=queryString.parse(location.search); + return ( + } {...props} > + + + + + ) +}; + +export default EquipmentCreate; diff --git a/frontend/src/resources/Equipment/EquipmentEdit.js b/frontend/src/resources/Equipment/EquipmentEdit.js new file mode 100644 index 0000000..9aee317 --- /dev/null +++ b/frontend/src/resources/Equipment/EquipmentEdit.js @@ -0,0 +1,25 @@ +import React from 'react'; +import { Edit } from "@semapps/archipelago-layout"; +import EquipmentTitle from './EquipmentTitle'; +import EquipmentInputs from './EquipmentInputs'; +import { + SimpleForm, +} from 'react-admin'; +import { MarkdownInput } from '@semapps/markdown-components'; +import { useLocation } from 'react-router'; +import queryString from 'query-string'; + +export const EquipmentEdit = props =>{ + const location = useLocation(); + const query=queryString.parse(location.search); + + return ( + } {...props} > + + + + + ) +}; + +export default EquipmentEdit; diff --git a/frontend/src/resources/Equipment/EquipmentInputs.js b/frontend/src/resources/Equipment/EquipmentInputs.js new file mode 100644 index 0000000..f2c0e6f --- /dev/null +++ b/frontend/src/resources/Equipment/EquipmentInputs.js @@ -0,0 +1,48 @@ +import React from 'react'; +import { + TextInput, + NumberInput, + SelectInput, + ReferenceInput +} from 'react-admin'; +import { MarkdownInput } from '@semapps/markdown-components'; + +export const EquipmentInputs = props => ( + <> + + + + + + + + + + + + + + + + + +) + +export default EquipmentInputs; diff --git a/frontend/src/resources/Equipment/EquipmentShow.js b/frontend/src/resources/Equipment/EquipmentShow.js new file mode 100644 index 0000000..b272997 --- /dev/null +++ b/frontend/src/resources/Equipment/EquipmentShow.js @@ -0,0 +1,20 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { MainList, Show } from '@semapps/archipelago-layout'; +import { MarkdownField } from '@semapps/markdown-components'; + +const EquipmentShow = ({...props}) => { + + const state = useSelector(state => state); + const isAdminContext = state.customState.isAdminContext; + + return ( + + + + + + ); +}; + +export default EquipmentShow; diff --git a/frontend/src/resources/old/Resource/Equipment/EquipmentTitle.js b/frontend/src/resources/Equipment/EquipmentTitle.js similarity index 81% rename from frontend/src/resources/old/Resource/Equipment/EquipmentTitle.js rename to frontend/src/resources/Equipment/EquipmentTitle.js index 1257e9a..71ca100 100644 --- a/frontend/src/resources/old/Resource/Equipment/EquipmentTitle.js +++ b/frontend/src/resources/Equipment/EquipmentTitle.js @@ -4,4 +4,4 @@ const EquipmentTitle = ({ record }) => { return {record ? record['pair:label'] : ''}; }; -export default EquipmentTitle \ No newline at end of file +export default EquipmentTitle diff --git a/frontend/src/resources/Equipment/index.js b/frontend/src/resources/Equipment/index.js index ce9b460..49497c9 100644 --- a/frontend/src/resources/Equipment/index.js +++ b/frontend/src/resources/Equipment/index.js @@ -1,10 +1,20 @@ +import EquipmentEdit from './EquipmentEdit'; +import EquipmentShow from './EquipmentShow'; +import EquipmentCreate from './EquipmentCreate'; + export default { - config: {}, + config: { + show: EquipmentShow, + edit: EquipmentEdit, + create: EquipmentCreate, + options: { + label: 'Equipements' + }, + }, dataModel: { types: ['petr:Equipment'], containerUri: process.env.REACT_APP_MIDDLEWARE_URL + 'equipments', slugField: ['pair:label'], - forceArray: ['petr:equipmentOffers', 'petr:equipmentOfferedBy'] }, translations: {} }; diff --git a/frontend/src/resources/Organization/OrganizationEdit.js b/frontend/src/resources/Organization/OrganizationEdit.js index 679cfc2..36f2b85 100644 --- a/frontend/src/resources/Organization/OrganizationEdit.js +++ b/frontend/src/resources/Organization/OrganizationEdit.js @@ -1,176 +1,101 @@ -import React from 'react'; +import {default as React,useState,useCallback,useMemo} from 'react'; -import { makeStyles } from '@material-ui/core'; import { TextInput } from "ra-ui-materialui"; -import { +import { Dialog, DialogTitle, DialogContent, DialogActions, makeStyles } from '@material-ui/core'; +import { ArrayInput, BooleanInput, - FormTab, - ImageInput, - NumberInput, - SelectInput, - SimpleFormIterator, - TabbedForm, + FormTab, + ImageInput, + NumberInput, + SelectInput, + SimpleFormIterator, + TabbedForm, required, - useRecordContext + useRecordContext, + ListContextProvider, + useEditContext, + useList, + Datagrid, + TextField, + EditButton, + useEditController, + Button, + SimpleForm, + SaveButton, + useUpdate, + useCreate, + SaveContextProvider, + CreateContextProvider, + EditContextProvider, + FormWithRedirect, + useRefresh, + ReferenceInput, + ReferenceManyField, + DeleteButton } from 'react-admin'; +import {IconEvent, ContentCreate} from '@material-ui/icons/Event'; import { Edit } from "@semapps/archipelago-layout"; import { MapField } from '@semapps/geo-components'; import { MarkdownInput } from '@semapps/markdown-components' -import { ImageField, ReferenceInput, ReificationArrayInput } from '@semapps/semantic-data-provider'; +import { ImageField, ReificationArrayInput } from '@semapps/semantic-data-provider'; import { EquipmentsInput } from '../../pair'; import PairLocationInput from '../../components/PairLocationInput'; +import EditContextualButton from '../../components/EditContextualButton'; +import CreateContextualButton from '../../components/CreateContextualButton'; import Title from '../_Components/Title'; +import { Link } from 'react-router-dom'; +import { useLocation } from 'react-router'; + -const useStyles = makeStyles((theme) => ({ - resourceFormContainer: { - '& section' : { - flexDirection: 'column', - } - }, -})); export const OrganizationEdit = props => { - const classes = useStyles(); + const { + record, // record fetched via dataProvider.getOne() based on the id from the location + } = useEditController(props); + return ( - } {...props} > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {/* EQUIPMENTS */} - - - - - - - - - - - - {/* TODO */} - - - - - - {/* SPACES */} - - + } {...props} > + + - - - - - - - - - - {/* SERVICES */} - - - - + + + + + + + + + + + + + + + + + + + + + @@ -178,20 +103,98 @@ export const OrganizationEdit = props => { - + + + + + + + - {/* TODO */} - - - - - - + + {/* EQUIPMENTS */} + + + (true)}> + + + + + + + + {/* SPACES */} + + + + + + + + + + + + + + + {/* SERVICES */} + + + + + + + + + + + + + + + + + {/* TODO */} + + + + + + ); } + + export default OrganizationEdit; diff --git a/frontend/src/resources/Organization/index.js b/frontend/src/resources/Organization/index.js index 1576b69..9a06330 100644 --- a/frontend/src/resources/Organization/index.js +++ b/frontend/src/resources/Organization/index.js @@ -22,11 +22,8 @@ export default { slugField: 'pair:label', forceArray: [ 'petr:equipmentOffers', - 'petr:equipmentOfferedBy', 'petr:serviceOffers', - 'petr:serviceOfferedBy', 'petr:spaceOffers', - 'petr:spaceOfferedBy' ] }, translations: { @@ -48,4 +45,4 @@ export default { } } } -}; \ No newline at end of file +}; diff --git a/frontend/src/resources/old/Resource/Equipment/EquipmentEdit.js b/frontend/src/resources/old/Resource/Equipment/EquipmentEdit.js deleted file mode 100644 index b27612e..0000000 --- a/frontend/src/resources/old/Resource/Equipment/EquipmentEdit.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { SimpleForm } from "ra-ui-materialui"; -import { Edit } from "@semapps/archipelago-layout"; -import EquipmentForm from './EquipmentForm'; -import EquipmentTitle from './EquipmentTitle'; - -export const EquipmentEdit = props => ( - } {...props} > - - - - -); - -export default EquipmentEdit; diff --git a/frontend/src/resources/old/Resource/Equipment/EquipmentShow.js b/frontend/src/resources/old/Resource/Equipment/EquipmentShow.js deleted file mode 100644 index e62d326..0000000 --- a/frontend/src/resources/old/Resource/Equipment/EquipmentShow.js +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; -import { useSelector } from 'react-redux'; - -import EquipmentShowInAdmin from "./EquipmentShowInAdmin"; -import EquipmentShowInWebSite from "./EquipmentShowInWebSite"; - -const EquipmentShow = ({...props}) => { - - const state = useSelector(state => state); - const isAdminContext = state.customState.isAdminContext; - - return ( - isAdminContext - ? - : - ); -}; - -export default EquipmentShow; \ No newline at end of file diff --git a/middleware/.yalc/@semapps/inference/package.json b/middleware/.yalc/@semapps/inference/package.json index 340e36c..608455e 100644 --- a/middleware/.yalc/@semapps/inference/package.json +++ b/middleware/.yalc/@semapps/inference/package.json @@ -11,5 +11,5 @@ "publishConfig": { "access": "public" }, - "yalcSig": "b1fa29fece77c7668f7b3fed16afbcba" + "yalcSig": "97b4892beba6e391f8e3a70f07f9d18e" } diff --git a/middleware/.yalc/@semapps/inference/service.js b/middleware/.yalc/@semapps/inference/service.js index 59f1ecb..70e8fd9 100644 --- a/middleware/.yalc/@semapps/inference/service.js +++ b/middleware/.yalc/@semapps/inference/service.js @@ -15,7 +15,6 @@ module.exports = { for (let ontology of this.settings.ontologies) { if (ontology.owl) { const result = await this.findInverseRelations(ontology.owl); - console.log('RELATIONS',result); console.log(`Found ${Object.keys(result).length} inverse relations in ${ontology.owl}`); this.inverseRelations = { ...this.inverseRelations, ...result }; } diff --git a/middleware/.yalc/@semapps/inference/yalc.sig b/middleware/.yalc/@semapps/inference/yalc.sig index 3e9cc96..48868a3 100644 --- a/middleware/.yalc/@semapps/inference/yalc.sig +++ b/middleware/.yalc/@semapps/inference/yalc.sig @@ -1 +1 @@ -b1fa29fece77c7668f7b3fed16afbcba \ No newline at end of file +97b4892beba6e391f8e3a70f07f9d18e \ No newline at end of file diff --git a/middleware/.yalc/@semapps/ldp/package.json b/middleware/.yalc/@semapps/ldp/package.json index 3311817..01f37a3 100644 --- a/middleware/.yalc/@semapps/ldp/package.json +++ b/middleware/.yalc/@semapps/ldp/package.json @@ -20,5 +20,5 @@ "access": "public" }, "gitHead": "06cb2decdab424e8686a5d77cc3364fbf1912439", - "yalcSig": "f85055cb903c59b4fd2299843b74b074" + "yalcSig": "cee3ad6a5ca4374008dc9147edc09633" } diff --git a/middleware/.yalc/@semapps/ldp/services/resource/actions/put.js b/middleware/.yalc/@semapps/ldp/services/resource/actions/put.js index 298fa04..e7dadf7 100644 --- a/middleware/.yalc/@semapps/ldp/services/resource/actions/put.js +++ b/middleware/.yalc/@semapps/ldp/services/resource/actions/put.js @@ -39,7 +39,6 @@ module.exports = { disassembly: { type: 'array', optional: true } }, async handler(ctx) { - console.log('-------------------------------------'); let { resource, contentType } = ctx.params; let { webId } = ctx.params; webId = webId || ctx.meta.webId || 'anon'; @@ -51,7 +50,6 @@ module.exports = { ...ctx.params }; - console.log('-------------------------------------',disassembly, jsonContext ); // Save the current data, to be able to send it through the event // If the resource does not exist, it will throw a 404 error let oldData = await ctx.call('ldp.resource.get', { diff --git a/middleware/.yalc/@semapps/ldp/services/resource/methods.js b/middleware/.yalc/@semapps/ldp/services/resource/methods.js index f047c3d..a32aa03 100644 --- a/middleware/.yalc/@semapps/ldp/services/resource/methods.js +++ b/middleware/.yalc/@semapps/ldp/services/resource/methods.js @@ -135,11 +135,8 @@ module.exports = { newDisassemblyValue.some(t2 => (t1.id || t1['@id']) === (t2.id || t2['@id'])) ); - - if (resourcesToAdd) { for (let resource of resourcesToAdd) { - console.log('------------------------------------- ADD',disassemblyConfig,resource['@id'] || resource['id'] , resource); delete resource.id; const newResourceUri = await ctx.call('ldp.resource.post', { @@ -155,7 +152,7 @@ module.exports = { } } - if (method === 'PUT' || (method === 'PATCH' && newData[disassemblyConfig.path]!=undefined)) { + if (method === 'PUT') { if (resourcesToRemove) { for (let resource of resourcesToRemove) { await ctx.call('ldp.resource.delete', { @@ -167,22 +164,9 @@ module.exports = { } if (resourcesToKeep) { - for (let resource of resourcesToKeep) { - console.log('------------------------------------- UPDATE',resource['@id'] || resource['id'] , resource); - await ctx.call('ldp.resource.put', { - resourceUri: resource['@id'] || resource['id'] || resource, - resource: { - '@context': newData['@context'], - ...resource - }, - contentType: MIME_TYPES.JSON, - webId: 'system' - }); - uriRemoved.push({ '@id': resource['@id'] || resource['id'] || resource, '@type': '@id' }); - } uriKept = resourcesToKeep.map(r => ({ '@id': r['@id'] || r.id || r, '@type': '@id' })); } - } else if (method === 'PATCH' && newData[disassemblyConfig.path]==undefined) { + } else if (method === 'PATCH') { uriKept = oldDisassemblyValue.map(r => ({ '@id': r['@id'] || r.id || r, '@type': '@id' })); } else { throw new Error('Unknown method ' + method); diff --git a/middleware/.yalc/@semapps/ldp/yalc.sig b/middleware/.yalc/@semapps/ldp/yalc.sig index 533fd98..8abf82f 100644 --- a/middleware/.yalc/@semapps/ldp/yalc.sig +++ b/middleware/.yalc/@semapps/ldp/yalc.sig @@ -1 +1 @@ -f85055cb903c59b4fd2299843b74b074 \ No newline at end of file +cee3ad6a5ca4374008dc9147edc09633 \ No newline at end of file diff --git a/middleware/services/ldp.service.js b/middleware/services/ldp.service.js index a6c8084..0323b23 100644 --- a/middleware/services/ldp.service.js +++ b/middleware/services/ldp.service.js @@ -14,40 +14,30 @@ module.exports = { path: '/organizations', acceptedTypes: ['pair:Organization'], dereference: [ - 'pair:hasLocation/pair:hasPostalAddress', - 'petr:equipmentOffers', + 'pair:hasLocation/pair:hasPostalAddress', 'petr:serviceOffers', 'petr:spaceOffers', ], - disassembly: [{ - path: 'petr:equipmentOffers', - container: process.env.SEMAPPS_HOME_URL + 'equipments' - },{ - path: 'petr:spaceOffers', - container: process.env.SEMAPPS_HOME_URL + 'spaces' - },{ - path: 'petr:serviceOffers', - container: process.env.SEMAPPS_HOME_URL + 'services' + disassembly: [{ + path: 'petr:spaceOffers', + container: process.env.SEMAPPS_HOME_URL + 'spaces' + },{ + path: 'petr:serviceOffers', + container: process.env.SEMAPPS_HOME_URL + 'services' }, ] }, { path: '/equipments', acceptedTypes: ['petr:Equipment'], - dereference: ['petr:equipmentOfferedBy'], - disassembly: [{ path: 'petr:equipmentOfferedBy', container: process.env.SEMAPPS_HOME_URL + 'organizations' }] }, { path: '/services', acceptedTypes: ['petr:Service'], - dereference: ['petr:serviceOfferedBy'], - disassembly: [{ path: 'petr:serviceOfferedBy', container: process.env.SEMAPPS_HOME_URL + 'services' }] }, { path: '/spaces', acceptedTypes: ['petr:Space'], - dereference: ['petr:spaceOfferedBy'], - disassembly: [{ path: 'petr:spaceOfferedBy', container: process.env.SEMAPPS_HOME_URL + 'spaces' }] }, '/', '/audiences', @@ -59,7 +49,7 @@ module.exports = { '/networks', '/organizations', '/organization-types', - '/persons', + '/persons', '/rates', '/sectors', '/services', diff --git a/middleware/yalc.lock b/middleware/yalc.lock index 4160c83..8641978 100644 --- a/middleware/yalc.lock +++ b/middleware/yalc.lock @@ -5,7 +5,7 @@ "signature": "0a02690b85b00c1cb7e25a16cec50e11" }, "@semapps/inference": { - "signature": "b1fa29fece77c7668f7b3fed16afbcba" + "signature": "97b4892beba6e391f8e3a70f07f9d18e" }, "@semapps/auth": { "signature": "d44c71eead71b970dfc8c2835b4a8f63" @@ -14,7 +14,7 @@ "signature": "8ce40e7a74fb1c61a53dc71ad3ac587f" }, "@semapps/ldp": { - "signature": "f85055cb903c59b4fd2299843b74b074" + "signature": "cee3ad6a5ca4374008dc9147edc09633" }, "@semapps/middlewares": { "signature": "6f19a5233c3d505d3f03a3b82a87c83c"