Skip to content

Commit

Permalink
Merge pull request #25 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
razvanMiu authored Apr 26, 2023
2 parents fc5fb12 + 8dc3129 commit f67137f
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 3 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [5.1.1](https://github.com/eea/volto-object-widget/compare/5.1.0...5.1.1) - 26 April 2023

#### :rocket: New Features

- feat(package.json): add @eeacms/volto-widgets-view addon to dependencies [Miu Razvan - [`845046f`](https://github.com/eea/volto-object-widget/commit/845046f8254e0e03d2990cf7098bbcf3a11c42a0)]
- feat(package.json): add @eeacms/volto-widgets-view dependency [Miu Razvan - [`9046117`](https://github.com/eea/volto-object-widget/commit/904611758f00e8db5a3b73d9b08bcf3c83964d79)]

#### :house: Internal changes

- chore(package.json): update version from 5.1.0 to 5.2.0 [Miu Razvan - [`2ceff26`](https://github.com/eea/volto-object-widget/commit/2ceff2608147292ef427f32965ed96505deaad9f)]

#### :hammer_and_wrench: Others

- * version [andreiggr - [`052c684`](https://github.com/eea/volto-object-widget/commit/052c684180dd1f46af435e4cbc9e7e8641abebe7)]
- Revert changes on AttachedImageWidget [Miu Razvan - [`88eafeb`](https://github.com/eea/volto-object-widget/commit/88eafeb363f495faae7d915aa1f8867c86a5f1d6)]
- Revert fc658b5 [Miu Razvan - [`669d06f`](https://github.com/eea/volto-object-widget/commit/669d06f8b8856599feab29f96981eb67e21dc2b0)]
### [5.1.0](https://github.com/eea/volto-object-widget/compare/5.0.1...5.1.0) - 27 March 2023

#### :hammer_and_wrench: Others

- Release 5.1.0 [Alin Voinea - [`c09cdee`](https://github.com/eea/volto-object-widget/commit/c09cdeedfcec2f41c2b2a6e8862acf95729fd8db)]
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`33ab4d9`](https://github.com/eea/volto-object-widget/commit/33ab4d94a61939763e245c721acc9c300e8deba6)]
### [5.0.1](https://github.com/eea/volto-object-widget/compare/5.0.0...5.0.1) - 16 November 2022

Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
environment {
GIT_NAME = "volto-object-widget"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en"
SONARQUBE_TAGS = "volto.eea.europa.eu,forest.eea.europa.eu,biodiversity.europa.eu,www.eea.europa.eu-ims,climate-energy.eea.europa.eu,sustainability.eionet.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,water.europa.eu-marine,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-en"
DEPENDENCIES = ""
VOLTO = ""
}
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-object-widget",
"version": "5.1.0",
"version": "5.1.1",
"description": "volto-object-widget: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -23,6 +23,9 @@
"babel-plugin-transform-class-properties": "^6.24.1",
"md5": "^2.3.0"
},
"dependencies": {
"@eeacms/volto-resize-helper": "*"
},
"scripts": {
"release": "release-it",
"release-major-beta": "release-it major --preRelease=beta",
Expand Down
94 changes: 94 additions & 0 deletions src/Widget/ObjectTypesWidget.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import React from 'react';
import { Menu, Tab } from 'semantic-ui-react';
import { ObjectWidget } from '@plone/volto/components';
import { connect } from 'react-redux';

const getDeviceConfig = (width) => {
// semantic ui breakpoints
if (width < 320) {
return 'mobile';
} else if (width >= 320 && width < 768) {
return 'tablet';
} else if (width >= 768 && width < 992) {
return 'computer';
} else if (width >= 992 && width < 1280) {
return 'large';
} else if (width >= 1280) {
return 'widescreen';
}
};

export const ObjectTypesWidget = (props) => {
const {
schemas,
value = {},
onChange,
errors = {},
id,
block,
screen,
} = props;
const objectId = id;

const defaultActiveTab = 0;

const [activeTab, setActiveTab] = React.useState(
defaultActiveTab > -1 ? defaultActiveTab : 0,
);

const device = screen?.page?.width
? getDeviceConfig(screen?.page?.width)
: '';

const createTab = ({ schema, id, icon }, index) => {
return {
menuItem: () => (
<Menu.Item
onClick={() => setActiveTab(index)}
active={activeTab === index}
key={id}
>
<p style={{ fontSize: '14px', fontWeight: 'bold' }}>{schema.title}</p>
</Menu.Item>
),
render: () => {
return (
<Tab.Pane style={{ padding: '0' }}>
<ObjectWidget
schema={schema}
id={id}
block={block}
errors={errors}
value={value[id] || {}}
onChange={(schemaId, v) => {
onChange(objectId, { ...value, [schemaId]: v });
}}
/>
</Tab.Pane>
);
},
};
};

return (
<Tab
menu={{
vertical:
device === 'computer' || device === 'tablet' || device === 'mobile'
? false
: true,
tabular: true,
}}
panes={schemas.map(createTab)}
activeIndex={activeTab}
grid={{ paneWidth: 9, tabWidth: 3 }}
/>
);
};

export default connect(
(state, props) => ({
screen: state?.screen,
}),
{},
)(ObjectTypesWidget);
1 change: 1 addition & 0 deletions src/Widget/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export ObjectListWidget from './ObjectListWidget';
export ObjectListInlineWidget from './ObjectListInlineWidget';
export ObjectByTypeWidget from './ObjectByTypeWidget';
export MappingWidget from './MappingWidget';
export ObjectTypesWidget from './ObjectTypesWidget';
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import {
ObjectListInlineWidget,
ObjectByTypeWidget,
MappingWidget,
ObjectTypesWidget,
} from './Widget';

export {
ObjectListWidget,
ObjectListInlineWidget,
ObjectByTypeWidget,
MappingWidget,
ObjectTypesWidget,
} from './Widget';

export installDemo from './demo';
Expand All @@ -22,6 +24,7 @@ const applyConfig = (config) => {
config.widgets.widget.object_by_type = ObjectByTypeWidget;
config.widgets.widget.option_mapping = MappingWidget;
config.widgets.widget.attachedimage = AttachedImageWidget;
config.widgets.widget.object_types_widget = ObjectTypesWidget;
}

return config;
Expand Down

0 comments on commit f67137f

Please sign in to comment.