Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

fix(POPUP): merge tile defaults when passing newly created tile object #555

Merged
merged 1 commit into from
Nov 29, 2020

Conversation

rchl
Copy link
Collaborator

@rchl rchl commented Nov 29, 2020

We've overlooked the fact that user can pass a newly created tile object
to $scope.showPopup() in which case the tile defaults were not merged.

Explicitly merge defaults from the showPopup() call but avoid doing it
multiple times for tiles that have already had defaults merged by
checking a special cache key.

Fixes #553

We've overlooked the fact that user can pass a newly created tile object
to $scope.showPopup() in which case the tile defaults were not merged.

Explicitly merge defaults from the showPopup() call but avoid doing it
multiple times for tiles that have already had defaults merged by
checking a special cache key.

Fixes #553
@alphasixtyfive
Copy link
Contributor

It looks like openDoorEntry is actually broken now, although I do remember that it was calling openPopup internally. Unfortunately I don't have access to a PC to investigate.

@rchl
Copy link
Collaborator Author

rchl commented Mar 3, 2021

When calling it programmatically, you mean?

This test tile appears to work for me:

                  {
                     position: [0, 8],
                     width: 2, height: 2,
                     type: TYPES.DOOR_ENTRY,
                     id: {},
                     icon: 'mdi-phone',
                     title: 'DOOR_ENTRY',
                     state: false,
                     layout: {
                        camera: {
                           type: TYPES.CAMERA,
                           objFit: 'contain',  // https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit
                           id: 'camera.weather',
                           refresh: 5000,
                           bgSize: 'contain',
                           fullscreen: {
                              type: TYPES.CAMERA,
                              refresh: 15000, // can be number in milliseconds
                              bgSize: 'contain',
                           },
                        },
                        page: {},
                        tiles: [
                           {
                              position: [0, 0],
                              theme: ITEM_TRANSPARENT,
                              title: 'SCRIPT',
                              id: 'script.test_script',
                              type: TYPES.SCRIPT,
                              state: false,
                              variables: {
                                 value: 'value from script',
                              },
                           },
                        ],
                     },
                  },

And if I add:

                     secondaryAction(item, entity) {
                        this.$scope.openDoorEntry(item, entity)
                     },

then that also opens the popup on long-click.

@alphasixtyfive
Copy link
Contributor

I am calling it is a similar way, popup opens up but none of the tiles inside are clickable.

@rchl
Copy link
Collaborator Author

rchl commented Mar 3, 2021

I could probably envision some problems if the tiles are generated dynamically but otherwise not sure what might be the issue. I guess we can investigate when you have access to your code.

@alphasixtyfive
Copy link
Contributor

alphasixtyfive commented Mar 3, 2021

Ok, what I have is a CAMERA tile which has an action assigned to open the door entry:

 action: function() {
     this.$scope.openDoorEntry(TILES.DOOR_ENTRY_FRONT_GATE, {});
 }

For some reason it does look like defaults are not being merged as even item-clickable is not present but history does popup on long-press.

@rchl
Copy link
Collaborator Author

rchl commented Mar 3, 2021

I guess that's because TILES is not part of the initial tiles configuration. We are doing a sweep over registered tiles on load to extend them with default values but that won't extend tiles that are "outside".

Will have to think how to fix that.

@alphasixtyfive
Copy link
Contributor

For some reason this also does not work:

action: function(item, entity) {
    this.$scope.openDoorEntry({
        type: TYPES.DOOR_ENTRY,
        ...
    });
}

So I'm not too sure about TILES.

@rchl
Copy link
Collaborator Author

rchl commented Mar 3, 2021

Fixing in #664

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Popup when called as secondaryAction are not working properly.
3 participants