Skip to content

Commit

Permalink
Corrected some errors in Filter widget
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Mar 9, 2024
1 parent e4ae7cb commit 67a7924
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 77 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ E.g., if it was used in a menu and the menu is red, the circle would be red.
### **WORK IN PROGRESS**
-->
## Changelog
### 2.9.41 (2024-03-09)
### **WORK IN PROGRESS**
* (bluefox) Allowed limiting the view size only on desktop
* (bluefox) Change word "Filter" to "Search"

Expand Down
13 changes: 0 additions & 13 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
"name": "vis-2",
"version": "2.9.41",
"news": {
"2.9.41": {
"en": "Allowed limiting the view size only on desktop\nChange word \"Filter\" to \"Search\"",
"de": "Erlaubt, die Ansichtsgröße nur auf dem Desktop zu begrenzen\nWort \"Filter\" zu \"Search\" ändern",
"ru": "Разрешено ограничивать размер обзора только на настольном\nСменить слово \"Фильтер\" на \"Сеарх\"",
"pt": "Permite limitar o tamanho da vista apenas na área de trabalho\nAlterar palavra \"Filter\" para \"Search\"",
"nl": "Toegestaan om de weergavegrootte alleen op bureaublad te beperken\nWijzig woord \"Filter\" in \"Zoeken\"",
"fr": "Limiter la taille de la vue uniquement sur le bureau\nChanger le mot \"Filter\" en \"Rechercher\"",
"it": "Limitare la dimensione della vista solo sul desktop\nCambia la parola \"Filter\" a \"Search\"",
"es": "Permitido limitar el tamaño de la vista sólo en el escritorio\nCambiar la palabra \"Filter\" a \"Search\"",
"pl": "Dozwolone ograniczenie rozmiaru widoku tylko na pulpicie\nZmień słowo \"Filtr\" na \"Szukaj\"",
"uk": "Допускається обмеження розміру переглядів тільки на робочому столі\nЗміна слова \"Фільтр\" в \"Пошук\"",
"zh-cn": "只允许限制桌面上的视图大小\n\"Filter\"改为\"Search\""
},
"2.9.40": {
"en": "Migrated the filter widget to react\nMigrated the basic link widget to react",
"de": "Das Filter-Widget migriert\nDas grundlegende Link-Widget migriert",
Expand Down
2 changes: 1 addition & 1 deletion src/src/Attributes/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const View = props => {
{
name: 'Width',
field: 'bg-width',
type: 'type',
type: 'text',
hidden: '!data["bg-image"]',
notStyle: true,
},
Expand Down
2 changes: 1 addition & 1 deletion src/src/Attributes/Widget/WidgetBindingField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ class WidgetBindingField extends Component {
}
return <SelectID
key="selectDialog"
imagePrefix="../.."
imagePrefix="../"
selected={this.state.selectionValue}
onOk={async selected => {
// insert on cursor and replace selected text
Expand Down
2 changes: 1 addition & 1 deletion src/src/Attributes/Widget/WidgetField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ const WidgetField = props => {
{objectCache ? (typeof objectCache.common.name === 'object' ? objectCache.common.name[I18n.lang] : objectCache.common.name) : null}
</div>
{idDialog && !disabled ? <SelectID
imagePrefix="../.."
imagePrefix="../"
selected={value}
onOk={selected => change(selected)}
onClose={() => setIdDialog(false)}
Expand Down
2 changes: 1 addition & 1 deletion src/src/Toolbar/Projects.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Tools = props => {
/> : null}
{
objectsDialog ? <SelectID
imagePrefix="../.."
imagePrefix="../"
ready
onClose={() => setObjectsDialog(false)}
socket={props.socket}
Expand Down
11 changes: 6 additions & 5 deletions src/src/Vis/Widgets/Basic/BasicFilterDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ class BasicFilterDropdown extends VisRxWidget<RxData> {
/>,
default: '[]',
},
{
name: 'widgetTitle',
label: 'name',
},
{
name: 'type',
label: 'Type',
Expand All @@ -167,6 +163,11 @@ class BasicFilterDropdown extends VisRxWidget<RxData> {
],
default: 'horizontal_buttons',
},
{
name: 'widgetTitle',
label: 'name',
hidden: 'data.type !== "dropdown"',
},
{
name: 'autoFocus',
type: 'checkbox',
Expand Down Expand Up @@ -404,7 +405,7 @@ class BasicFilterDropdown extends VisRxWidget<RxData> {
startIcon={image ? <Icon src={image} alt={option.label} style={{ height: 24 }} /> : null}
style={{
flexGrow: 1,
color: viewsActiveFilter.includes(option.value) ? option.color : (option.activeColor || option.color),
color: viewsActiveFilter.includes(option.value) ? (option.activeColor || option.color) : option.color,
}}
>
{option.label}
Expand Down
17 changes: 13 additions & 4 deletions src/src/Vis/Widgets/Basic/FiltersEditorDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class FiltersEditorDialog extends Component<FiltersEditorDialogProps, FiltersEdi
return null;
}

let _value = this.state.items[this.state.selectImage as number].image || '';
let _value = this.state.items[this.state.selectImage].image || '';
if (_value.startsWith('../')) {
_value = _value.substring(3);
} else if (_value.startsWith('_PRJ_NAME/')) {
Expand Down Expand Up @@ -244,6 +244,15 @@ class FiltersEditorDialog extends Component<FiltersEditorDialogProps, FiltersEdi
}

renderTableRow(item: Item, index: number) {
let image = item.image;
if (image) {
if (image.startsWith('../')) {
image = image.substring(3);
} else if (image.startsWith('_PRJ_NAME/')) {
image = image.replace('_PRJ_NAME/', `../${this.props.context.adapterName}.${this.props.context.instance}/${this.props.context.projectName}/`);
}
}

return <Draggable key={item.id} draggableId={item.id || ''} index={index}>
{(dragProvided /* dragSnapshot */) => <TableRow
className={index % 2 ? this.props.classes.rowEven : ''}
Expand Down Expand Up @@ -346,12 +355,12 @@ class FiltersEditorDialog extends Component<FiltersEditorDialogProps, FiltersEdi
}}
/>
<Button
variant={item.image ? 'outlined' : undefined}
variant={image ? 'outlined' : undefined}
// @ts-expect-error grey is correct
color={item.image ? 'grey' : undefined}
color={image ? 'grey' : undefined}
onClick={() => this.setState({ selectImage: index })}
>
{item.image ? <Icon src={item.image} style={{ width: 36, height: 36 }} /> : '...'}
{image ? <Icon src={image} style={{ width: 36, height: 36 }} /> : '...'}
</Button>
</div>}
</TableCell>
Expand Down
23 changes: 22 additions & 1 deletion src/src/Vis/visContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ interface VisContextMenuProps {
setMarketplaceDialog: (data: { addPage: boolean; widget: { widget: (SingleWidget | GroupWidget)[]; image: string } }) => void;
}

interface VisMarketplaceProps {
language: ioBroker.Languages;
addPage?: boolean;
widget: { name: string; date: string; widget_id: string; image_id: string; };
installWidget: (widget: { name: string; date: string; widget_id: string; image_id: string; }) => Promise<void>;
installedWidgets?: {id: string}[];
themeName: string;
onAdded?: () => void;
}

declare global {
interface Window {
VisMarketplace?: {
api: {
apiGetWidgetRevision(widgetId: string, id: string): Promise<any>;
},
default: React.Component<VisMarketplaceProps>
};
}
}

const VisContextMenu = (props: VisContextMenuProps) => {
const [exportDialog, setExportDialog] = useState(false);
const [importDialog, setImportDialog] = useState(false);
Expand Down Expand Up @@ -149,7 +170,7 @@ const VisContextMenu = (props: VisContextMenuProps) => {
hide: props.selectedWidgets.length !== 1 ||
selectedWidget.tpl !== '_tplGroup',
},
(window as any).VisMarketplace ? {
window.VisMarketplace ? {
leftIcon: <img
src="./img/marketplace.png"
alt="widgeteria"
Expand Down
Loading

0 comments on commit 67a7924

Please sign in to comment.