Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 45909 object browser limit #363

Merged
merged 6 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
<!--- -----------------------------------------------------------------
Esempio:
---------------------------------------------------------------------

## Versione 7.10.9 (12/09/2023)

### Migliorie

- Fissato il layout di stampa per pagine con Accordion

### Novità

- Nuovo blocco "Informazioni" [`Istruzioni`](https://docs.google.com/document/d/1SThuxa_ah0BuNXukWs564kKPfprK41WLQE8Mome-0xg/edit#heading=h.7ty110jumgmd)

### Fix

- il numero di telefono dentro card ufficio adesso è visibile anche senza indirizzo
-->

Expand All @@ -20,22 +27,31 @@
----------------------------------------------------------------------

## Versione X.X.X (dd/mm/yyyy)

### Migliorie

- ...

### Novità

- ... [`Istruzioni`](url della documentazione relativa alla novità)

### Fix

- ...
-->

## Versione X.X.X (dd/mm/yyyy)

### Migliorie

- Migliorato il comportamento alla selezione/deselezione degli elementi multipli nel componente Object Browser

### Fix

- Cambiato il colore del bordo dell'icona Ricerca nell'header dei sottositi per garantire il contrasto per accessibilità
- Non mostrare la fascia colorata del footer di un sottosito quando questo non è compilato
- Risolto un bug nel componente Object Browser che permetteva di selezionare più elementi di quelli consentiti

## Versione 8.7.8 (12/10/2023)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ class ObjectBrowserBody extends Component {
onSelectItem = (item) => {
const url = item['@id'];
const { block, data, mode, dataName, onChangeBlock } = this.props;

const updateState = (mode) => {
switch (mode) {
case 'image':
Expand Down Expand Up @@ -312,8 +311,18 @@ class ObjectBrowserBody extends Component {
};

isSelectable = (item) => {
return this.props.selectableTypes.length > 0
? this.props.selectableTypes.indexOf(item['@type']) >= 0
const { maximumSelectionSize, data, mode, selectableTypes } = this.props;
if (
maximumSelectionSize &&
data &&
mode === 'multiple' &&
maximumSelectionSize <= data.length
)
return data.some(
(d) => flattenToAppURL(d['@id']) === flattenToAppURL(item['@id']),
);
return selectableTypes.length > 0
? selectableTypes.indexOf(item['@type']) >= 0
: true;
};

Expand All @@ -331,16 +340,24 @@ class ObjectBrowserBody extends Component {
!this.props.maximumSelectionSize ||
this.props.mode === 'multiple' ||
!this.props.data ||
this.props.data.length < this.props.maximumSelectionSize
this.props.data.length <= this.props.maximumSelectionSize
) {
let isDeselecting;
if (this.props.mode === 'multiple' && Array.isArray(this.props.data))
isDeselecting = this.props.data.some(
(d) => flattenToAppURL(d['@id']) === flattenToAppURL(item['@id']),
);
this.onSelectItem(item);
let length = this.props.data ? this.props.data.length : 0;

let stopSelecting =
this.props.mode !== 'multiple' ||
(this.props.maximumSelectionSize > 0 &&
length + 1 >= this.props.maximumSelectionSize);

let stopSelecting = this.props.mode !== 'multiple';
if (isDeselecting && !stopSelecting)
stopSelecting =
this.props.maximumSelectionSize > 0 &&
length - 1 >= this.props.maximumSelectionSize;
else
stopSelecting =
this.props.maximumSelectionSize > 0 &&
length + 1 >= this.props.maximumSelectionSize;
if (stopSelecting) {
this.props.closeObjectBrowser();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,15 @@ export class ObjectBrowserWidgetComponent extends Component {
* @returns {string} Markup for the component.
*/
render() {
const { id, description, fieldSet, value, mode, onChange, isDisabled } =
this.props;
const {
id,
description,
fieldSet,
value,
mode,
onChange,
isDisabled,
} = this.props;

let items = compact(!isArray(value) && value ? [value] : value || []);

Expand Down